diff --git a/app/FramePropertiesDock.cpp b/app/FramePropertiesDock.cpp index 091a397..7b4ec4f 100644 --- a/app/FramePropertiesDock.cpp +++ b/app/FramePropertiesDock.cpp @@ -32,12 +32,12 @@ namespace plaYUVer FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitch ) : QWidget( parent ), - pbMainPlaySwitch( pbMainPlaySwitch ) + m_pbIsPlaying( pbMainPlaySwitch ) { // -------------- Variables definition -------------- m_pcFrame = NULL; + m_pcSelectedFrame = NULL; m_iLastFrameType = -1; - m_pbIsPlaying = false; // Histogram area ----------------------------------------------------- @@ -259,110 +259,123 @@ QSize FramePropertiesDock::sizeHint() const return currSize; } -Void FramePropertiesDock::setData( PlaYUVerFrame* pcFrame, Bool isPlaying ) +Void FramePropertiesDock::reset() { - m_pbIsPlaying = isPlaying; - if( !pcFrame ) + m_pcFrame = NULL; + m_cSelectionArea = QRect(); + if( m_pcSelectedFrame ) { - m_pcFrame = NULL; - m_iLastFrameType = -1; - labelMeanValue->clear(); - labelPixelsValue->clear(); - labelStdDevValue->clear(); - labelCountValue->clear(); - labelMedianValue->clear(); - labelPercentileValue->clear(); - // Remove the histogram data from memory - histogramWidget->reset(); - setEnabled( false ); - return; + delete m_pcSelectedFrame; + m_pcSelectedFrame = NULL; } - else + + m_iLastFrameType = -1; + + labelMeanValue->clear(); + labelPixelsValue->clear(); + labelStdDevValue->clear(); + labelCountValue->clear(); + labelMedianValue->clear(); + labelPercentileValue->clear(); + + // Remove the histogram data from memory + histogramWidget->reset(); + + setEnabled( false ); +} + +Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame ) +{ + Int colorSpace = pcFrame->getColorSpace(); + if( m_iLastFrameType != colorSpace ) { - Int colorSpace = pcFrame->getColorSpace(); - if( m_iLastFrameType != colorSpace ) + m_iLastFrameType = colorSpace; + if( colorSpace == PlaYUVerFrame::COLOR_RGB || colorSpace == PlaYUVerFrame::COLOR_ARGB ) { - m_iLastFrameType = colorSpace; - if( colorSpace == PlaYUVerFrame::COLOR_RGB || colorSpace == PlaYUVerFrame::COLOR_ARGB ) + channelCB->clear(); + channelCB->clear(); + channelCB->insertItem( LuminosityChannel, QIcon( ":/images/channel-luma.png" ), "Luminance" ); + channelCB->insertItem( FirstChannel, QIcon( ":/images/channel-red.png" ), "Red" ); + channelCB->insertItem( SecondChannel, QIcon( ":/images/channel-green.png" ), "Green" ); + channelCB->insertItem( ThirdChannel, QIcon( ":/images/channel-blue.png" ), "Blue" ); + if( colorSpace == PlaYUVerFrame::COLOR_ARGB ) { - channelCB->clear(); - channelCB->clear(); - channelCB->insertItem( LuminosityChannel, QIcon( ":/images/channel-luma.png" ), "Luminance" ); - channelCB->insertItem( FirstChannel, QIcon( ":/images/channel-red.png" ), "Red" ); - channelCB->insertItem( SecondChannel, QIcon( ":/images/channel-green.png" ), "Green" ); - channelCB->insertItem( ThirdChannel, QIcon( ":/images/channel-blue.png" ), "Blue" ); - if( colorSpace == PlaYUVerFrame::COLOR_ARGB ) - { - channelCB->insertItem( AlphaChannel, QIcon( ":/images/channel-alpha.png" ), "Alpha" ); - } - channelCB->insertItem( ColorChannels, QIcon( ":/images/channel-all.png" ), "Colors" ); + channelCB->insertItem( AlphaChannel, QIcon( ":/images/channel-alpha.png" ), "Alpha" ); + } + channelCB->insertItem( ColorChannels, QIcon( ":/images/channel-all.png" ), "Colors" ); - colorsCB->clear(); - colorsCB->addItem( "Red" ); - colorsCB->addItem( "Green" ); - colorsCB->addItem( "Blue" ); - colorsCB->setEnabled( false ); - colorsCB->setWhatsThis( tr( "
Select here the main color displayed with Colors Channel mode:" - "
Red: Draw the Red image channel in the foreground.
" - "Green: Draw the Green image channel in the foreground.
" - "Blue: Draw the Blue image channel in the foreground.
" ) ); - colorsCB->show(); - colorsLabel->show(); - } - else if( colorSpace == PlaYUVerFrame::COLOR_YUV ) - { - channelCB->clear(); - channelCB->insertItem( FirstChannel, QIcon( ":/images/channel-luma.png" ), "Luminance" ); - channelCB->insertItem( SecondChannel, QIcon( ":/images/channel-red.png" ), "Chroma U" ); - channelCB->insertItem( ThirdChannel, QIcon( ":/images/channel-green.png" ), "Chroma V" ); - channelCB->insertItem( ColorChannels, QIcon( ":/images/channel-all.png" ), "All Channels" ); - - colorsCB->clear(); - colorsCB->addItem( "Luminance" ); - colorsCB->addItem( "Chroma U" ); - colorsCB->addItem( "Chroma V" ); - colorsCB->setEnabled( false ); - colorsCB->setWhatsThis( tr( "
Select here the main color displayed with Colors Channel mode:" - "
Luminance: Draw the Luminance channel in the foreground.
" - "Chroma U: Draw the Chroma U channel in the foreground.
" - "Chroma V: Draw the Chroma V channel in the foreground.
" ) ); - colorsCB->show(); - colorsLabel->show(); - } - else - { - channelCB->clear(); - channelCB->addItem( tr( "Luminance" ) ); - channelCB->setItemIcon( 0, QIcon( ":/images/channel-luma.png" ) ); - colorsCB->hide(); - colorsLabel->hide(); - } + colorsCB->clear(); + colorsCB->addItem( "Red" ); + colorsCB->addItem( "Green" ); + colorsCB->addItem( "Blue" ); + colorsCB->setEnabled( false ); + colorsCB->setWhatsThis( tr( "
Select here the main color displayed with Colors Channel mode:" + "
Red: Draw the Red image channel in the foreground.
" + "Green: Draw the Green image channel in the foreground.
" + "Blue: Draw the Blue image channel in the foreground.
" ) ); + colorsCB->show(); + colorsLabel->show(); } - setEnabled( true ); - if( m_pcFrame || !( *pbMainPlaySwitch ) ) + else if( colorSpace == PlaYUVerFrame::COLOR_YUV ) { - m_pcFrame = pcFrame; - updateDataHistogram(); + channelCB->clear(); + channelCB->insertItem( FirstChannel, QIcon( ":/images/channel-luma.png" ), "Luminance" ); + channelCB->insertItem( SecondChannel, QIcon( ":/images/channel-red.png" ), "Chroma U" ); + channelCB->insertItem( ThirdChannel, QIcon( ":/images/channel-green.png" ), "Chroma V" ); + channelCB->insertItem( ColorChannels, QIcon( ":/images/channel-all.png" ), "All Channels" ); + + colorsCB->clear(); + colorsCB->addItem( "Luminance" ); + colorsCB->addItem( "Chroma U" ); + colorsCB->addItem( "Chroma V" ); + colorsCB->setEnabled( false ); + colorsCB->setWhatsThis( tr( "
Select here the main color displayed with Colors Channel mode:" + "
Luminance: DraupdateDataw the Luminance channel in the foreground.
" + "Chroma U: Draw the Chroma U channel in the foreground.
" + "Chroma V: Draw the Chroma V channel in the foreground.
" ) ); + colorsCB->show(); + colorsLabel->show(); } + else + { + channelCB->clear(); + channelCB->addItem( tr( "Luminance" ) ); + channelCB->setItemIcon( 0, QIcon( ":/images/channel-luma.png" ) ); + colorsCB->hide(); + colorsLabel->hide(); + } + } + setEnabled( true ); + if( m_pcFrame || !( *m_pbIsPlaying ) ) + { + m_pcFrame = pcFrame; + updateDataHistogram(); } } Void FramePropertiesDock::setSelection( const QRect &selectionArea ) { - // This is necessary to stop computation because image.bits() is - // currently used by threaded histogram algorithm. - if( m_pcFrame ) { + Bool bSelectionChanged = !( selectionArea.size() == m_cSelectionArea.size() ); m_cSelectionArea = selectionArea; - if( selectionArea.isValid() ) { histogramWidget->stopHistogramComputation(); - histogramWidget->updateSelectionData( - new PlaYUVerFrame( m_pcFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(), selectionArea.height() ) ); - fullImageButton->show(); - selectionImageButton->show(); + + /* + * Allocate a new image for the selection + * or just copy information + */ + if( bSelectionChanged ) + { + if( m_pcSelectedFrame ) + { + delete m_pcSelectedFrame; + } + m_pcSelectedFrame = new PlaYUVerFrame( m_pcFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(), selectionArea.height() ); + } + updateDataHistogram(); selectionImageButton->click(); slotRenderingChanged( HistogramWidget::ImageSelectionHistogram ); } @@ -377,18 +390,22 @@ Void FramePropertiesDock::setSelection( const QRect &selectionArea ) Void FramePropertiesDock::updateDataHistogram() { - //if( m_pcFrame->isValid() && isVisible() ) if( m_pcFrame && isVisible() ) { - if( !( *pbMainPlaySwitch && m_pbIsPlaying ) ) + if( !*m_pbIsPlaying ) { - // If a selection area is done in Image Editor and if the current - // image is the same in Image Viewer, then compute too the histogram - // for this selection. - // New frame required to separate from the thread - histogramWidget->updateData( m_pcFrame, NULL ); - fullImageButton->hide(); - selectionImageButton->hide(); + if( m_pcSelectedFrame ) + { + m_pcSelectedFrame->copyFrom( m_pcFrame, m_cSelectionArea.x(), m_cSelectionArea.y() ); + fullImageButton->show(); + selectionImageButton->show(); + } + else + { + fullImageButton->hide(); + selectionImageButton->hide(); + } + histogramWidget->updateData( m_pcFrame, m_pcSelectedFrame ); } else { diff --git a/app/FramePropertiesDock.h b/app/FramePropertiesDock.h index dbb34ad..605fd5e 100644 --- a/app/FramePropertiesDock.h +++ b/app/FramePropertiesDock.h @@ -49,9 +49,9 @@ public: QSize sizeHint() const; - Void setData( PlaYUVerFrame* m_pcStream, Bool isPlaying ); + Void setFrame( PlaYUVerFrame* m_pcFrame ); Void setSelection( const QRect &selectionArea ); - + Void reset(); Void stopHistogram(); private: @@ -73,10 +73,10 @@ private: }; PlaYUVerFrame *m_pcFrame; + PlaYUVerFrame *m_pcSelectedFrame; Int m_iLastFrameType; - Bool* pbMainPlaySwitch; - Bool m_pbIsPlaying; + Bool* m_pbIsPlaying; QComboBox *channelCB; diff --git a/app/HistogramWidget.cpp b/app/HistogramWidget.cpp index 483d152..cd398f0 100644 --- a/app/HistogramWidget.cpp +++ b/app/HistogramWidget.cpp @@ -418,12 +418,6 @@ Void HistogramWidget::updateData( PlaYUVerFrame *pcFrame, PlaYUVerFrame *pcFrame } -Void HistogramWidget::updateSelectionData( PlaYUVerFrame *pcFrameSelection ) -{ - m_selectionImage = pcFrameSelection; - m_selectionWorker->setup( pcFrameSelection ); -} - //////////////////////////////////////////////////////////////////////////////// Void HistogramWidget::slotBlinkTimerDone() diff --git a/app/HistogramWidget.h b/app/HistogramWidget.h index ad941a5..dee1452 100644 --- a/app/HistogramWidget.h +++ b/app/HistogramWidget.h @@ -117,9 +117,6 @@ public : /** Update full image histogram data. */ Void updateData( PlaYUVerFrame *pcFrame, PlaYUVerFrame *pcFrameSelection ); - /** Update image selection histogram data.*/ - Void updateSelectionData( PlaYUVerFrame *pcFrameSelection ); - /** @see @p HistogramOption */ Void setOptions( HistogramOptions options = AllOptions ); Void setDataLoading(); diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index 7ff7f97..0109c17 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -65,7 +65,6 @@ VideoHandle::~VideoHandle() Void VideoHandle::createActions() { - m_arrayActions.resize( TOTAL_ACT ); m_arrayActions[PLAY_ACT] = new QAction( "Play", this ); m_arrayActions[PLAY_ACT]->setStatusTip( "Play/Pause" ); @@ -268,7 +267,7 @@ Void VideoHandle::update() m_pcResolutionLabel->setText( resolution ); } - m_pcFramePropertiesSideBar->setData( pcFrame, m_pcCurrentVideoSubWindow->isPlaying() ); + m_pcFramePropertiesSideBar->setFrame( pcFrame ); m_pcFrameNumInfo->setTotalFrameNum( total_frame_num ); m_pcFrameSlider->setMaximum( total_frame_num - 1 ); @@ -286,13 +285,12 @@ Void VideoHandle::update() m_arrayActions[PLAY_ACT]->setText( "Play" ); m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ); } - } else { m_pcVideoFormatLabel->setText( "" ); m_pcResolutionLabel->setText( "" ); - m_pcFramePropertiesSideBar->setData( NULL, false ); + m_pcFramePropertiesSideBar->reset(); m_pcFrameSlider->setValue( 0 ); m_pcFrameNumInfo->clear(); } @@ -615,7 +613,7 @@ Void VideoHandle::seekVideo() Void VideoHandle::seekSliderEvent( Int new_frame_num ) { - if( m_pcCurrentVideoSubWindow && !m_bIsPlaying ) // TODO: Fix this slot + if( m_pcCurrentVideoSubWindow && !m_bIsPlaying ) // TODO: Fix this slot { if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) ) {