Add new window classes for modules and streams

This commit is contained in:
jfmcarreira committed 2021-10-10 15:13:42 +01:00
1 parent 1c0321a705
commit be06ca656d
20 files changed
+1191 -945

No files matched your search

+63 -116
View File
@@ -28,6 +28,7 @@
#include <QDataStream>
#include <QFuture>
#include <QRect>
#include <QStaticText>
#include <QString>
#include <QVector>
@@ -45,69 +46,32 @@ class VideoSubWindow;
class ResourceHandle;
class CalypAppModuleIf;
typedef struct
/**
* \class VideoInformation
* \brief Shows information about video sub window
*/
class VideoInformation : public QWidget
{
QString m_cFilename;
unsigned int m_uiWidth;
unsigned int m_uiHeight;
int m_iPelFormat;
unsigned int m_uiBitsPelPixel;
unsigned int m_iEndianness;
unsigned int m_uiFrameRate;
unsigned long long int m_uiFileSize;
} CalypFileInfo;
typedef QVector<CalypFileInfo> CalypFileInfoVector;
public:
VideoInformation( QWidget* parent );
void setInformationTopLeft( const QStringList& textLines );
void setBusyWindow( bool bFlag );
QDataStream& operator<<( QDataStream& out, const CalypFileInfoVector& d );
QDataStream& operator>>( QDataStream& in, CalypFileInfoVector& d );
int findCalypStreamInfo( CalypFileInfoVector array, QString filename );
protected:
void paintEvent( QPaintEvent* event );
private:
QTimer* m_pcRefreshTimer;
QList<QStaticText> m_cTopLeftTextList;
QFont m_cTopLeftTextFont;
QFont m_cCenterTextFont;
bool m_bBusyWindow;
};
class VideoSubWindow : public SubWindowAbstract
{
Q_OBJECT
private:
ResourceHandle* m_pcResourceManager;
bool m_bWindowBusy;
QScrollArea* m_pcScrollArea;
QPoint m_cCurrScroll;
double m_dHorScroll;
double m_dVerScroll;
ViewArea* m_cViewArea;
VideoInformation* m_pcVideoInfo;
QString m_cFilename;
QString m_cStreamInformation;
CalypFileInfo m_sStreamInfo;
std::size_t m_uiResourceId;
CalypStream* m_pCurrStream;
std::shared_ptr<CalypFrame> m_pcCurrFrameAsset;
//CalypFrame* m_pcCurrFrame;
QRect m_cSelectedArea;
CalypAppModuleIf* m_pcCurrentDisplayModule{ nullptr };
std::vector<std::shared_ptr<CalypAppModuleIf>> m_associatedModules;
bool m_hasAssociatedModules;
VideoSubWindow* m_pcReferenceSubWindow;
// QString m_cWindowShortName;
QString m_cCurrFileName;
bool m_bIsPlaying;
QTimer* m_pcUpdateTimer;
/**
* Threads variables
* QtConcurrent
*/
QFuture<void> m_cRefreshResult;
QFuture<void> m_cReadResult;
public:
enum VideoSubWindowCategories
{
@@ -115,41 +79,26 @@ public:
MODULE_SUBWINDOW = SubWindowAbstract::MODULE_SUBWINDOW,
};
VideoSubWindow( enum VideoSubWindowCategories category, QWidget* parent = 0 );
VideoSubWindow( enum VideoSubWindowCategories category, CalypAppModuleIf* displayModule, QWidget* parent = 0 );
~VideoSubWindow();
void setResourceManaget( ResourceHandle* resourceManager ) { m_pcResourceManager = resourceManager; }
virtual void resetWindowName() = 0;
virtual void updateVideoWindowInfo() = 0;
void updateVideoWindowInfo();
virtual bool isPlaying() = 0;
virtual void stop() = 0;
virtual void advanceOneFrame() = 0;
virtual auto getFrameNum() -> std::uint64_t { return 1; };
bool loadFile( QString cFilename, bool bForceDialog = false );
bool loadFile( CalypFileInfo* streamInfo );
void loadAll();
QString getVideoInformation() { return m_cStreamInformation; }
bool save( QString filename );
bool saveStream( QString filename );
void refreshSubWindow();
void refreshFrame( bool bThreaded = false );
bool play();
void pause();
bool playEvent();
void stop();
void setPlaying( bool isPlaying );
bool isPlaying();
void seekAbsoluteEvent( unsigned int new_frame_num );
void seekRelativeEvent( bool bIsFoward );
void setCurrFrame( std::shared_ptr<CalypFrame> pcCurrFrame );
CalypFileInfo getStreamInfo() { return m_sStreamInfo; }
QString getStreamInformation() { return m_cStreamInformation; }
const CalypStream* getInputStream() { return m_pCurrStream; }
const CalypStream* getCurrStream() { return m_pCurrStream; }
CalypFrame* getCurrFrame() { return m_pcCurrFrameAsset.get(); }
std::shared_ptr<CalypFrame> getCurrFrameAsset();
ViewArea* getViewArea() { return m_cViewArea; }
auto getCurrFrame() -> CalypFrame* { return m_pcCurrFrameAsset.get(); }
auto getCurrFrameAsset() -> std::shared_ptr<CalypFrame> { return m_pcCurrFrameAsset; };
auto getViewArea() -> ViewArea* { return m_cViewArea; }
VideoSubWindow* getRefSubWindow() { return m_pcReferenceSubWindow; }
void setRefSubWindow( VideoSubWindow* subWindow )
{
m_pcReferenceSubWindow = NULL;
@@ -158,59 +107,37 @@ public:
m_pcReferenceSubWindow = subWindow;
}
VideoSubWindow* getRefSubWindow() { return m_pcReferenceSubWindow; }
/**
* Functions to enable a module in the
* current SubWindow
*/
//void enableModule( std::shared_ptr<CalypAppModuleIf> pcModule );
auto hasModules() -> bool { return m_associatedModules.size() > 0; }
bool hasAssociatedModule();
void setDisplayModule( CalypAppModuleIf* pcModule );
void associateModule( std::shared_ptr<CalypAppModuleIf> pcModule );
void disableModule( CalypAppModuleIf* pcModule );
bool disableAllModules();
CalypAppModuleIf* getDisplayModule() { return m_pcCurrentDisplayModule; }
QVector<CalypAppModuleIf*> getModuleArray()
{
QVector<CalypAppModuleIf*> apcModulesArray;
if( m_pcCurrentDisplayModule )
apcModulesArray.append( m_pcCurrentDisplayModule );
for( const auto& module : m_associatedModules )
{
apcModulesArray.append( module.get() );
}
return apcModulesArray;
}
CalypAppModuleIf* getDisplayModule() { return m_pcDisplayModule; }
/**
* Virtual functions from SubWindowAbstract
*/
void normalSize();
void zoomToFit();
void scaleView( double scale, QPoint center = QPoint() );
void zoomToFactor( double factor, QPoint center = QPoint() );
void normalSize() override;
void zoomToFit() override;
void scaleView( double scale, QPoint center = QPoint() ) override;
void zoomToFactor( double factor, QPoint center = QPoint() ) override;
double getScaleFactor() { return m_cViewArea->getZoomFactor(); }
double getScaleFactor() override { return m_cViewArea->getZoomFactor(); }
/**
* Size related functions
*/
QSize sizeHint() const;
QSize sizeHint( const QSize& ) const;
QSize sizeHint( const QSize& ) const override;
QString getCurrentFileName() { return m_cFilename; }
void clearWindowBusy() { m_bWindowBusy = false; }
void setFillWindow( bool bFlag );
void adjustScrollBarToRatio( const double& horRatio, const double& verRatio );
private:
void refreshFrameOperation();
bool goToNextFrame( bool bThreaded = false );
static bool guessFormat( QString filename, unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBitsPerPixel,
int& rEndianness, unsigned int& rFrameRate );
bool hasRunningModule();
/**
@@ -222,6 +149,8 @@ private:
QSize getScrollSize();
protected:
void refreshFrame();
void keyPressEvent( QKeyEvent* event ) override;
void resizeEvent( QResizeEvent* event ) override;
void closeEvent( QCloseEvent* event ) override;
@@ -233,9 +162,27 @@ public Q_SLOTS:
void updateScrollValues();
void updateSelectedArea( QRect area );
void updatePixelValueStatusBar( const QPoint& pos );
protected:
VideoInformation* m_pcVideoInfo;
QString m_cStreamInformation;
std::shared_ptr<CalypFrame> m_pcCurrFrameAsset;
//bool m_bWindowBusy;
//bool m_bIsPlaying;
std::vector<std::shared_ptr<CalypAppModuleIf>> m_associatedModules;
CalypAppModuleIf* m_pcDisplayModule{ nullptr };
//bool m_hasAssociatedModules;
private:
QScrollArea* m_pcScrollArea;
QPoint m_cCurrScroll;
double m_dHorScroll;
double m_dVerScroll;
ViewArea* m_cViewArea;
QRect m_cSelectedArea;
VideoSubWindow* m_pcReferenceSubWindow;
QTimer* m_pcUpdateTimer;
};
Q_DECLARE_METATYPE( CalypFileInfo ) // NOLINT
Q_DECLARE_METATYPE( CalypFileInfoVector ) // NOLINT
#endif // __VIDEOSUBWINDOW_H__