/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef TV_QTAPP_WINDOW_H #define TV_QTAPP_WINDOW_H #include "OdaCommon.h" #include "Tv.h" #include "TvDatabaseReceiver.h" #include "TvFactory.h" #include #include #include "OdVisualizeQtAppWidget.h" #include "TvDatabase.h" #include "Client.h" #include #include class OdTvMainWindow : public QMainWindow { Q_OBJECT public: class OdTvStreamingLimitManager : public OdTvLimitManager { public: OdTvStreamingLimitManager(); virtual ~OdTvStreamingLimitManager(); void setMemoryLimit( OdUInt64 nLimit ) { m_nMemoryLimit = nLimit; } OdUInt64 memoryLimit() const { return m_nMemoryLimit; } protected: OdUInt64 m_nMemoryLimit; }; OdTvMainWindow( QWidget* parent = Q_NULLPTR ); protected: void closeEvent( QCloseEvent* event ); public slots: void on_pushButton_clicked(); void onTimer(); void onRegen(); void onUpdate(); void askClient( int delay = 500 ); private: OdTvQtRenderingWidget* m_pWidget; OdTvDatabaseId m_dbId; OdTvStreamingClientPtr m_pClient; std::thread m_clientThread; class Reactor : public OdTvDatabaseReceiverReactor { OdTvMainWindow* m_pWindow = nullptr; OdString m_currentFile = OdString::kEmpty; public: Reactor( OdTvMainWindow* pWindow ); ~Reactor() {} virtual bool onServicePartReceived( bool bHasPartialIndex ); virtual void onRequest( OdUInt32 requestID, OdUInt32 nRecCount, const OdTvRequestRecord* pRecords ); virtual void onRequestResourceFile( OdUInt32 requestID, const OdString& fileName, OdUInt64 offset, OdUInt64 size ); virtual void onRequestResourceFile( OdUInt32 requestID, const OdString& fileName, OdUInt32 nRecCount, const OdTvRequestRecord* pRecords ); virtual void onRequestResponseParsed( OdUInt32 requestID ); virtual void onRequestAborted( OdUInt32 requestID ); void setCurrentFile( const OdString& str ) { m_currentFile = str; } const OdString& currentFile() const { return m_currentFile; } }; OdTvDatabaseReceiverPtr m_pDbReceiver; Reactor* m_pReceivingReactor; struct Command { OdString fileName = OdString::kEmpty; bool bPartial = false; OdUInt64 cmdID = (OdUInt64)( -1 ); OdUInt64 requestID = (OdUInt64)( -1 ); }; typedef std::shared_ptr< Command > CommandPtr; std::map< OdUInt64, CommandPtr > m_commands; OdVector< OdUInt64 > m_cmdToRemove; void cancelActiveCommands(); void reset( bool bResetDB = false ); bool requestFile( OdUInt64 requestID, const OdString& file, OdUInt32 nParts = 0, const OdTvMessage::FilePart* pParts = nullptr ); bool cancelRequest( OdUInt64 requestID ); bool cancelRequest( const OdString& file ); bool m_bTimerIsOn = false; OdTvStreamingLimitManager* m_pLimitManager = nullptr; class AssemblyReactor : public OdTvAssemblyCreationReactor { public: AssemblyReactor( OdTvMainWindow* pWindow ); ~AssemblyReactor() {} virtual bool onCreateAssembly( OdTvAssemblyTemplate& devices ) const override; virtual bool onFileParsed( const OdString& databasePath, OdVector& models ) const override; virtual void onAssemblyCreated( OdTvDatabaseId dbId ) const; private: OdTvMainWindow* m_pWindow = nullptr; }; AssemblyReactor* m_pAssemblyReactor = nullptr;; }; #endif