Improve modules handle in order to be compatible with new windows
This commit is contained in:
1 parent
769bcead86
commit
78d09e03af
7 files changed
+101
-79
No files matched your search
@@ -399,6 +399,8 @@ cv::Mat InputStream::getFrameCvMat()
|
||||
|
||||
Void InputStream::seekInput( UInt64 new_frame_num )
|
||||
{
|
||||
if( !m_pFile )
|
||||
return;
|
||||
if( new_frame_num < 0 || new_frame_num >= m_uiTotalFrameNum )
|
||||
return;
|
||||
#ifdef USE_FFMPEG
|
||||
|
||||
@@ -49,7 +49,7 @@ ModulesHandle::ModulesHandle( QWidget * parent )
|
||||
setParent( m_pcParent );
|
||||
m_uiModulesCount = 0;
|
||||
m_uiModuleSelected = -1;
|
||||
|
||||
m_bShowModulesNewWindow = false;
|
||||
ModulesList( true );
|
||||
}
|
||||
|
||||
@@ -68,42 +68,31 @@ void ModulesHandle::selectModule( int index )
|
||||
m_uiModuleSelected = index;
|
||||
}
|
||||
|
||||
PlaYUVerModuleIf* ModulesHandle::getSelectedModuleIf()
|
||||
{
|
||||
PlaYUVerModuleIf* currModuleIf = NULL;
|
||||
|
||||
if( m_uiModuleSelected >= 0 )
|
||||
//if( m_arrayModulesActions.at(m_uiModuleSelected)->isChecked() )
|
||||
currModuleIf = m_pcPlaYUVerModules.at( m_uiModuleSelected );
|
||||
|
||||
m_uiModuleSelected = -1;
|
||||
return currModuleIf;
|
||||
}
|
||||
|
||||
SubWindowHandle* ModulesHandle::toggleSelectedModuleIf( SubWindowHandle* pcSubWindow )
|
||||
{
|
||||
SubWindowHandle* interfaceChild = NULL;
|
||||
PlaYUVerModuleIf* currModuleIf = NULL;
|
||||
|
||||
if( m_uiModuleSelected >= 0 )
|
||||
//if( m_arrayModulesActions.at(m_uiModuleSelected)->isChecked() )
|
||||
currModuleIf = m_pcPlaYUVerModules.at( m_uiModuleSelected );
|
||||
m_uiModuleSelected = -1;
|
||||
|
||||
if( currModuleIf->m_pcAction->isChecked() )
|
||||
{
|
||||
if( currModuleIf->m_cModuleDef.m_bRequiresNewWindow )
|
||||
currModuleIf->m_pcDisplaySubWindow = NULL;
|
||||
if( currModuleIf->m_cModuleDef.m_bRequiresNewWindow || m_bShowModulesNewWindow )
|
||||
{
|
||||
QString windowName;
|
||||
interfaceChild = new SubWindowHandle( m_pcParent );
|
||||
//mdiArea->addSubWindow( interfaceChild );
|
||||
|
||||
pcSubWindow->setModuleSubWindow( interfaceChild );
|
||||
pcSubWindow->enableModule( currModuleIf );
|
||||
|
||||
interfaceChild->show();
|
||||
interfaceChild->zoomToFit();
|
||||
windowName.append( pcSubWindow->userFriendlyCurrentFile() );
|
||||
windowName.append( " - " );
|
||||
windowName.append( currModuleIf->m_cModuleDef.m_pchModuleName );
|
||||
interfaceChild->setWindowName( windowName );
|
||||
connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, PlaYUVerFrame *) ), this,
|
||||
SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) );
|
||||
currModuleIf->m_pcDisplaySubWindow = interfaceChild;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -114,11 +103,22 @@ SubWindowHandle* ModulesHandle::toggleSelectedModuleIf( SubWindowHandle* pcSubWi
|
||||
else
|
||||
{
|
||||
currModuleIf->m_pcSubWindow->disableModule();
|
||||
currModuleIf->m_pcSubWindow = NULL;
|
||||
}
|
||||
return interfaceChild;
|
||||
}
|
||||
|
||||
Void ModulesHandle::destroyModuleIf( PlaYUVerModuleIf* pcCurrModuleIf )
|
||||
{
|
||||
pcCurrModuleIf->m_pcAction->setChecked( false );
|
||||
if( pcCurrModuleIf->m_pcDisplaySubWindow )
|
||||
{
|
||||
pcCurrModuleIf->m_pcDisplaySubWindow->close();
|
||||
pcCurrModuleIf->m_pcDisplaySubWindow = NULL;
|
||||
}
|
||||
pcCurrModuleIf->m_pcSubWindow = NULL;
|
||||
pcCurrModuleIf->destroy();
|
||||
}
|
||||
|
||||
QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar )
|
||||
{
|
||||
PlaYUVerModuleIf* currModuleIf;
|
||||
|
||||
@@ -53,12 +53,13 @@ public:
|
||||
|
||||
QMenu* createMenus( QMenuBar *MainAppMenuBar );
|
||||
Void updateMenus( Bool hasSubWindow );
|
||||
PlaYUVerModuleIf* getSelectedModuleIf();
|
||||
SubWindowHandle* toggleSelectedModuleIf( SubWindowHandle* pcSubWindow );
|
||||
static Void destroyModuleIf( PlaYUVerModuleIf* pcCurrModuleIf );
|
||||
|
||||
private:
|
||||
QWidget *m_pcParent;
|
||||
|
||||
Bool m_bShowModulesNewWindow;
|
||||
UInt m_uiModulesCount;
|
||||
Int m_uiModuleSelected;
|
||||
QMenu* m_pcModulesMenu;
|
||||
|
||||
@@ -77,6 +77,12 @@ class SubWindowHandle;
|
||||
|
||||
class PlaYUVerModuleIf
|
||||
{
|
||||
friend class ModulesHandle;
|
||||
private:
|
||||
QAction* m_pcAction;
|
||||
SubWindowHandle* m_pcSubWindow;
|
||||
SubWindowHandle* m_pcDisplaySubWindow;
|
||||
|
||||
public:
|
||||
PlaYUVerModuleIf()
|
||||
{
|
||||
@@ -86,8 +92,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
QAction* m_pcAction;
|
||||
SubWindowHandle* m_pcSubWindow;
|
||||
PlaYUVerModuleDefinition m_cModuleDef;
|
||||
|
||||
virtual Void create() {};
|
||||
|
||||
@@ -52,8 +52,9 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) :
|
||||
m_cScrollArea->setWidget( m_cViewArea );
|
||||
m_cScrollArea->setWidgetResizable( true );
|
||||
|
||||
m_pCurrStream = NULL;
|
||||
m_pCurrStream = new InputStream;
|
||||
|
||||
m_pcCurrFrame = NULL;
|
||||
m_pcCurrentModule = NULL;
|
||||
m_pcModuleSubWindow = NULL;
|
||||
|
||||
@@ -64,15 +65,11 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) :
|
||||
|
||||
SubWindowHandle::~SubWindowHandle()
|
||||
{
|
||||
disableModule();
|
||||
delete m_cViewArea;
|
||||
delete m_cScrollArea;
|
||||
delete m_pCurrStream;
|
||||
if( m_pcCurrentModule )
|
||||
{
|
||||
m_pcCurrentModule->m_pcAction->setChecked( false );
|
||||
m_pcCurrentModule->destroy();
|
||||
m_pcCurrentModule = NULL;
|
||||
}
|
||||
if( m_pCurrStream )
|
||||
delete m_pCurrStream;
|
||||
}
|
||||
|
||||
Bool SubWindowHandle::loadFile( const QString &fileName )
|
||||
@@ -80,6 +77,9 @@ Bool SubWindowHandle::loadFile( const QString &fileName )
|
||||
UInt Width = 0, Height = 0, FrameRate = 30;
|
||||
Int InputFormat = -1;
|
||||
|
||||
if( !m_pCurrStream )
|
||||
m_pCurrStream = new InputStream;
|
||||
|
||||
m_pCurrStream->getFormat( Width, Height, InputFormat, FrameRate );
|
||||
|
||||
if( m_pCurrStream->guessFormat( fileName, Width, Height, InputFormat, FrameRate ) )
|
||||
@@ -102,7 +102,6 @@ Bool SubWindowHandle::loadFile( const QString &fileName )
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
refreshFrame();
|
||||
//normalSize();
|
||||
|
||||
m_cCurrFileName = fileName;
|
||||
m_cWindowName = m_pCurrStream->getStreamInformationString();
|
||||
@@ -116,11 +115,6 @@ Bool SubWindowHandle::loadFile( const QString &fileName )
|
||||
*/
|
||||
Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module )
|
||||
{
|
||||
if( m_pcCurrentModule == select_module )
|
||||
{
|
||||
disableModule();
|
||||
return;
|
||||
}
|
||||
m_pcCurrentModule = select_module;
|
||||
m_pcCurrentModule->create( m_pCurrStream->getCurrFrame() );
|
||||
refreshFrame();
|
||||
@@ -130,10 +124,9 @@ Void SubWindowHandle::disableModule()
|
||||
{
|
||||
if( !m_pcCurrentModule )
|
||||
return;
|
||||
|
||||
m_pcCurrentModule->m_pcAction->setChecked( false );
|
||||
m_pcCurrentModule->destroy();
|
||||
ModulesHandle::destroyModuleIf( m_pcCurrentModule );
|
||||
m_pcCurrentModule = NULL;
|
||||
m_pcModuleSubWindow = NULL;
|
||||
refreshFrame();
|
||||
}
|
||||
|
||||
@@ -268,7 +261,11 @@ Void SubWindowHandle::scaleView( Int width, Int height )
|
||||
|
||||
Void SubWindowHandle::scaleView( const QSize & size )
|
||||
{
|
||||
QSize imgViewSize( m_pCurrStream->getWidth(), m_pCurrStream->getHeight() );
|
||||
QSize imgViewSize;
|
||||
if( m_pcCurrFrame )
|
||||
imgViewSize = QSize( m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight() );
|
||||
else
|
||||
imgViewSize = QSize( m_pCurrStream->getWidth(), m_pCurrStream->getHeight() );
|
||||
QSize newSize = imgViewSize;
|
||||
newSize.scale( size, Qt::KeepAspectRatio );
|
||||
|
||||
@@ -361,7 +358,11 @@ QSize SubWindowHandle::sizeHint() const
|
||||
maxSize = p->size();
|
||||
}
|
||||
|
||||
QSize isize = QSize( m_pCurrStream->getWidth() + 50, m_pCurrStream->getHeight() + 50 );
|
||||
QSize isize;
|
||||
if( m_pcCurrFrame )
|
||||
isize = QSize( m_pcCurrFrame->getWidth() + 50, m_pcCurrFrame->getHeight() + 50 );
|
||||
else
|
||||
isize = QSize( m_pCurrStream->getWidth() + 50, m_pCurrStream->getHeight() + 50 );
|
||||
|
||||
// If the SubWindowHandle needs more space that the avaiable, we'll give
|
||||
// to the subwindow a reasonable size preserving the image aspect ratio.
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "TypeDef.h"
|
||||
#include "InputStream.h"
|
||||
#include "ViewArea.h"
|
||||
#include "PlaYUVerModuleIf.h"
|
||||
#include "ModulesHandle.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
@@ -94,6 +94,11 @@ public:
|
||||
return m_pCurrStream;
|
||||
}
|
||||
|
||||
PlaYUVerFrame* getCurrFrame()
|
||||
{
|
||||
return m_pcCurrFrame;
|
||||
}
|
||||
|
||||
ViewArea* getViewArea()
|
||||
{
|
||||
return m_cViewArea;
|
||||
@@ -146,6 +151,12 @@ public:
|
||||
|
||||
QSize sizeHint() const;
|
||||
|
||||
Void setWindowName( QString name )
|
||||
{
|
||||
m_cWindowName = name;
|
||||
setWindowTitle( m_cWindowName );
|
||||
}
|
||||
|
||||
QString userFriendlyCurrentFile()
|
||||
{
|
||||
return m_cWindowName;
|
||||
|
||||
+38
-35
@@ -224,6 +224,8 @@ void plaYUVerApp::selectModule( QAction *curr_action )
|
||||
if( interfaceChild )
|
||||
{
|
||||
mdiArea->addSubWindow( interfaceChild );
|
||||
interfaceChild->show();
|
||||
interfaceChild->zoomToFit();
|
||||
interfaceChild->getViewArea()->setTool( m_appTool );
|
||||
}
|
||||
return;
|
||||
@@ -247,7 +249,7 @@ Void plaYUVerApp::updateFrameProperties()
|
||||
{
|
||||
if( m_pcCurrentSubWindow )
|
||||
{
|
||||
m_pcFrameProperties->setData( m_pcCurrentSubWindow->getInputStream()->getCurrFrame() );
|
||||
m_pcFrameProperties->setData( m_pcCurrentSubWindow->getCurrFrame() );
|
||||
//m_pcFrameProperties->setSelection( m_pcCurrentSubWindow->getViewArea()->selectedArea() );
|
||||
}
|
||||
else
|
||||
@@ -297,47 +299,51 @@ Void plaYUVerApp::setTimerStatus()
|
||||
|
||||
void plaYUVerApp::play()
|
||||
{
|
||||
if( m_pcCurrentSubWindow )
|
||||
if( !m_pcCurrentSubWindow )
|
||||
return;
|
||||
|
||||
if( !m_pcCurrentSubWindow->getInputStream() )
|
||||
return;
|
||||
|
||||
if( actionVideoLock->isChecked() && m_acPlayingSubWindows.size() )
|
||||
{
|
||||
if( actionVideoLock->isChecked() && m_acPlayingSubWindows.size() )
|
||||
Bool bFind = false;
|
||||
for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
{
|
||||
Bool bFind = false;
|
||||
for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
if( m_acPlayingSubWindows.at( i ) == m_pcCurrentSubWindow )
|
||||
{
|
||||
if( m_acPlayingSubWindows.at( i ) == m_pcCurrentSubWindow )
|
||||
{
|
||||
bFind = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !bFind )
|
||||
{
|
||||
m_acPlayingSubWindows.append( m_pcCurrentSubWindow );
|
||||
m_pcCurrentSubWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() );
|
||||
m_pcCurrentSubWindow->play();
|
||||
m_pcFrameSlider->setMaximum( qMin( m_pcFrameSlider->maximum(), ( Int )m_pcCurrentSubWindow->getInputStream()->getFrameNum() - 1 ) );
|
||||
bFind = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
if( !bFind )
|
||||
{
|
||||
playingTimer->stop();
|
||||
m_acPlayingSubWindows.clear();
|
||||
m_acPlayingSubWindows.append( m_pcCurrentSubWindow );
|
||||
m_pcCurrentSubWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() );
|
||||
m_pcCurrentSubWindow->play();
|
||||
m_uiAveragePlayInterval = 0;
|
||||
m_bIsPlaying = false;
|
||||
}
|
||||
if( !m_bIsPlaying )
|
||||
{
|
||||
UInt frameRate = m_acPlayingSubWindows.at( 0 )->getInputStream()->getFrameRate();
|
||||
UInt timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 );
|
||||
qDebug( ) << "Desired frame rate: "
|
||||
<< QString::number( 1000 / timeInterval )
|
||||
<< " fps";
|
||||
playingTimer->start( timeInterval );
|
||||
m_cTimer.start();
|
||||
m_pcFrameSlider->setMaximum( qMin( m_pcFrameSlider->maximum(), ( Int )m_pcCurrentSubWindow->getInputStream()->getFrameNum() - 1 ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
playingTimer->stop();
|
||||
m_acPlayingSubWindows.clear();
|
||||
m_acPlayingSubWindows.append( m_pcCurrentSubWindow );
|
||||
m_pcCurrentSubWindow->play();
|
||||
m_uiAveragePlayInterval = 0;
|
||||
m_bIsPlaying = false;
|
||||
}
|
||||
if( !m_bIsPlaying )
|
||||
{
|
||||
UInt frameRate = m_acPlayingSubWindows.at( 0 )->getInputStream()->getFrameRate();
|
||||
UInt timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 );
|
||||
qDebug( ) << "Desired frame rate: "
|
||||
<< QString::number( 1000 / timeInterval )
|
||||
<< " fps";
|
||||
playingTimer->start( timeInterval );
|
||||
m_cTimer.start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void plaYUVerApp::pause()
|
||||
@@ -453,7 +459,6 @@ void plaYUVerApp::seekEvent( int direction )
|
||||
else
|
||||
{
|
||||
m_pcCurrentSubWindow->seekRelativeEvent( direction > 0 ? true : false );
|
||||
|
||||
}
|
||||
updateFrameProperties();
|
||||
updateCurrFrameNum();
|
||||
@@ -536,8 +541,6 @@ void plaYUVerApp::chageSubWindowSelection()
|
||||
if( activeSubWindow() )
|
||||
{
|
||||
m_pcCurrentSubWindow = new_window;
|
||||
m_pcStreamProperties->setData( m_pcCurrentSubWindow->getInputStream() );
|
||||
m_pcFrameProperties->setData( m_pcCurrentSubWindow->getInputStream()->getCurrFrame() );
|
||||
updateCurrFrameNum();
|
||||
updateTotalFrameNum();
|
||||
updateStreamProperties();
|
||||
|
||||
Reference in new issue
Block a user