From: adv Date: Wed, 4 Apr 2012 08:21:26 +0000 (+0000) Subject: Automatically replot the plot2d if selection is changed. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=04d6c35a701817775b229df8b52e78b2d5d48caa;p=modules%2Fgui.git Automatically replot the plot2d if selection is changed. --- diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index e5100107e..b82e05d16 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -173,7 +173,8 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title ) myXGridMaxMinor( 5 ), myYGridMaxMinor( 5 ), myY2GridMaxMinor( 5 ), myXMode( 0 ), myYMode( 0 ), mySecondY( false ), myTitleAutoUpdate( true ), myXTitleAutoUpdate( true ), myYTitleAutoUpdate( true ), - myTitleChangedByUser( false ), myXTitleChangedByUser( false ), myYTitleChangedByUser( false ) + myTitleChangedByUser( false ), myXTitleChangedByUser( false ), myYTitleChangedByUser( false ), + myShowAutoReplot( true ), myAutoReplot( false ) { setObjectName( title ); /* Plot 2d View */ @@ -411,6 +412,9 @@ void Plot2d_ViewFrame::readPreferences() myTitle = myPrefTitle; myXTitle = myPrefXTitle; myYTitle = myPrefYTitle; + + if( myShowAutoReplot ) + myAutoReplot = resMgr->integerValue( "Plot2d", "AutoReplot", myAutoReplot ); } /*! @@ -469,6 +473,11 @@ void Plot2d_ViewFrame::writePreferences() myPrefYTitle = myYTitle; myYPrefTitleChangedByUser = true; } + + if( myShowAutoReplot ) + { + resMgr->setValue( "Plot2d", "AutoReplot", myAutoReplot ); + } } /*! @@ -2243,6 +2252,8 @@ void Plot2d_ViewFrame::copyPreferences( Plot2d_ViewFrame* vf ) myYMode = vf->myYMode; mySecondY = vf->mySecondY; + myAutoReplot = vf->myAutoReplot; + // special fields for automatic update of viewer titles myTitleAutoUpdate = vf->myTitleAutoUpdate; myXTitleAutoUpdate = vf->myXTitleAutoUpdate; @@ -2640,3 +2651,23 @@ void Plot2d_ViewFrame::updateSymbols() } } } + +/*! + Sets flag for show\hide of automatic replotting of view in accordance + with current selection. You should call setShowAutoReplot( false ) + if your application doesn't support this functionality. + By default flag is true. +*/ +void Plot2d_ViewFrame::setShowAutoReplot( const bool show ) +{ + myShowAutoReplot = show; +} + +/*! + Sets flag for automatic replotting of view in accordance with current selection. + By default flag is false. +*/ +void Plot2d_ViewFrame::setAutoReplot( const bool replot ) +{ + myAutoReplot = replot; +} diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 3d585bbfa..59877ce9b 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -143,6 +143,12 @@ public: void updateSymbols(); + void setShowAutoReplot( const bool show ); + bool isShowAutoReplot() const { return myShowAutoReplot; } + + void setAutoReplot( const bool replot ); + bool isAutoReplot() const { return myAutoReplot; } + protected: int testOperation( const QMouseEvent& ); void readPreferences(); @@ -214,6 +220,8 @@ protected: bool myTitleAutoUpdate, myXTitleAutoUpdate, myYTitleAutoUpdate; bool myTitleChangedByUser, myXTitleChangedByUser, myYTitleChangedByUser; + bool myShowAutoReplot, myAutoReplot; + static QString myPrefTitle; static QString myPrefXTitle; static QString myPrefYTitle; diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index 9c7b9e224..f2694a32e 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -146,6 +146,18 @@ void Plot2d_ViewWindow::contextMenuPopup( QMenu* thePopup ) // settings thePopup->addAction( mgr->action( CurvSettingsId ) ); thePopup->addAction( mgr->action( CurvesSettingsId ) ); + + if ( myViewFrame->isShowAutoReplot() ) + { + // automatically update + QAction* aAutoReplot = new QAction( tr( "TOT_PLOT2D_AUTOREPLOT" ), this ); + aAutoReplot->setCheckable( true ); + aAutoReplot->setChecked( myViewFrame->isAutoReplot() ); + connect( aAutoReplot, SIGNAL( triggered() ), this, SLOT( onAutoReplot() ) ); + + thePopup->addSeparator(); + thePopup->addAction( aAutoReplot ); + } } /*! @@ -614,6 +626,17 @@ void Plot2d_ViewWindow::onPrintView() myViewFrame->updateSymbols(); } +/*! + \brief Called when the "Automatically update" action is activated. +*/ +void Plot2d_ViewWindow::onAutoReplot() +{ + QAction* anAct = ::qobject_cast( sender() ); + if( !myViewFrame || !anAct ) + return; + myViewFrame->setAutoReplot( anAct->isChecked() ); +} + /*! \brief Dump the contents of the view window to the image. \return image, containing all scene rendered in the window diff --git a/src/Plot2d/Plot2d_ViewWindow.h b/src/Plot2d/Plot2d_ViewWindow.h index b0a1f0835..a1b6ecf32 100755 --- a/src/Plot2d/Plot2d_ViewWindow.h +++ b/src/Plot2d/Plot2d_ViewWindow.h @@ -93,6 +93,8 @@ public slots: void onDumpView(); void onPrintView(); + void onAutoReplot(); + protected: virtual QImage dumpView(); virtual bool dumpViewToFormat( const QImage&, diff --git a/src/Plot2d/resources/Plot2d_msg_en.ts b/src/Plot2d/resources/Plot2d_msg_en.ts index d9dcdd395..91d36f5f4 100644 --- a/src/Plot2d/resources/Plot2d_msg_en.ts +++ b/src/Plot2d/resources/Plot2d_msg_en.ts @@ -475,6 +475,10 @@ Logarithmic scale for ordinate axis is not allowed. MEN_PLOT2D_CURVES_LINES Draw lines + + TOT_PLOT2D_AUTOREPLOT + Update automatically + Plot2d_FitDataDlg diff --git a/src/Plot2d/resources/Plot2d_msg_fr.ts b/src/Plot2d/resources/Plot2d_msg_fr.ts index 76436a3b3..c285259e4 100755 --- a/src/Plot2d/resources/Plot2d_msg_fr.ts +++ b/src/Plot2d/resources/Plot2d_msg_fr.ts @@ -477,6 +477,10 @@ L'échelle logarithmique de l'ordonnée n'est pas permise.MEN_PLOT2D_CURVES_LINES Dessiner les Lignes + + TOT_PLOT2D_AUTOREPLOT + Mettre à jour automatiquement + Plot2d_FitDataDlg