From: sln Date: Fri, 13 Apr 2007 12:16:49 +0000 (+0000) Subject: Protection from automatic generation of titles using curve’s titles is added. Before... X-Git-Tag: For_CTH_V1_2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cae17faab7a0a2eab02913ab5c1c7288d1db5e7d;p=modules%2Fgui.git Protection from automatic generation of titles using curve’s titles is added. Before this protection user could specify the titles manually using “Plot 2d View Settings” dialog box. There was situation when titles generated automatically in updateTitles method and user lost his changes. Now there are myTitleAutoGeneration, myXTitleAutoGeneration, myYTitleAutoGeneration fields. They are true by default but if user changes titles they becomes true and automatic generation is not performed. Also corresponding methods for setting/getting these fields are added. Signal titleChangedByUser( const int theObjectType ) added too. --- diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 6f43f3b0a..2ba1a51f0 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -149,6 +149,8 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title ) myBackground( white ), myTitleEnabled( true ), myXTitleEnabled( true ), myYTitleEnabled( true ), myY2TitleEnabled (true), + myTitleAutoGeneration( true ), myXTitleAutoGeneration( true ), + myYTitleAutoGeneration( true ), myXGridMajorEnabled( true ), myYGridMajorEnabled( true ), myY2GridMajorEnabled( true ), myXGridMinorEnabled( false ), myYGridMinorEnabled( false ), myY2GridMinorEnabled( false ), myXGridMaxMajor( 8 ), myYGridMaxMajor( 8 ), myY2GridMaxMajor( 8 ), @@ -996,14 +998,32 @@ void Plot2d_ViewFrame::onSettings() myY2GridMinorEnabled, myPlot->axisMaxMinor( QwtPlot::yRight ) ); if ( dlg->exec() == QDialog::Accepted ) { // horizontal axis title + bool isTileChanged = dlg->getXTitle() != myXTitle; setTitle( dlg->isXTitleEnabled(), dlg->getXTitle(), XTitle, false ); + if ( isTileChanged ) + { + myXTitleAutoGeneration = false; + emit titleChangedByUser( XTitle ); + } // vertical left axis title + isTileChanged = dlg->getYTitle() != myYTitle; setTitle( dlg->isYTitleEnabled(), dlg->getYTitle(), YTitle, false ); + if ( isTileChanged ) + { + myYTitleAutoGeneration = false; + emit titleChangedByUser( YTitle ); + } if (mySecondY) // vertical right axis title setTitle( dlg->isY2TitleEnabled(), dlg->getY2Title(), Y2Title, false ); // main title + isTileChanged = dlg->getMainTitle() != myTitle; setTitle( dlg->isMainTitleEnabled(), dlg->getMainTitle(), MainTitle, true ); + if ( isTileChanged ) + { + myTitleAutoGeneration = false; + emit titleChangedByUser( MainTitle ); + } // curve type if ( myCurveType != dlg->getCurveType() ) { setCurveType( dlg->getCurveType(), false ); @@ -2150,9 +2170,12 @@ void Plot2d_ViewFrame::updateTitles() if ( !yTitle.isEmpty() && !yUnits.isEmpty() ) yTitle += " "; - setTitle( myXTitleEnabled, xTitle + xUnits, XTitle, true ); - setTitle( myYTitleEnabled, yTitle + yUnits, YTitle, true ); - setTitle( true, aTables.join("; "), MainTitle, true ); + if ( myXTitleAutoGeneration ) + setTitle( myXTitleEnabled, xTitle + xUnits, XTitle, true ); + if ( myYTitleAutoGeneration ) + setTitle( myYTitleEnabled, yTitle + yUnits, YTitle, true ); + if ( myTitleAutoGeneration ) + setTitle( true, aTables.join("; "), MainTitle, true ); } /*! @@ -2330,3 +2353,66 @@ void Plot2d_ViewFrame::onZoomOut() { this->incrementalZoom( -INCREMENT_FOR_OP, -INCREMENT_FOR_OP ); } + +/*! + Specifies whether plot title must be generated automatically using curves titles +*/ +void Plot2d_ViewFrame::setTitleAutoGeneration( const bool toGenerate, const bool update ) +{ + setTitleAutoGeneration( toGenerate, MainTitle, update ); +} + +/*! + Verifies whether plot title must be generated automatically using curves titles +*/ +bool Plot2d_ViewFrame::getTitleAutoGeneration() const +{ + return myTitleAutoGeneration; +} + +/*! + Specifies whether plot title must be generated automatically using curves titles +*/ +void Plot2d_ViewFrame::setTitleAutoGeneration( const bool toGenerate, + const ObjectType type, + const bool update ) +{ + switch ( type ) + { + case MainTitle: + myTitleAutoGeneration = toGenerate; + break; + case XTitle: + myXTitleAutoGeneration = toGenerate; + break; + case YTitle: + myYTitleAutoGeneration = toGenerate; + break; + default: + return; + } + if ( update ) + updateTitles(); +} + +/*! + Verifies whether plot title must be generated automatically using curves titles +*/ +bool Plot2d_ViewFrame::getTitleAutoGeneration( const ObjectType type ) const +{ + switch ( type ) + { + case MainTitle: + return myTitleAutoGeneration; + case XTitle: + return myXTitleAutoGeneration; + case YTitle: + return myYTitleAutoGeneration; + default: + return false; + } +} + + + + diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index c30c4f56b..f4c4caf59 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -58,6 +58,8 @@ public: void updateTitles(); void setTitle( const QString& title ); QString getTitle() const { return myTitle; } + void setTitleAutoGeneration( const bool toGenerate, const bool update = true ); + bool getTitleAutoGeneration() const; void displayCurve( Plot2d_Curve* curve, bool update = false ); void displayCurves( const curveList& curves, bool update = false ); void eraseCurve ( Plot2d_Curve* curve, bool update = false ); @@ -99,6 +101,10 @@ public: bool y2MinorEnabled, const int y2MinorMax, bool update = true ); void setTitle( bool enabled, const QString& title, ObjectType type, bool update = true ); QString getTitle( ObjectType type ) const; + void setTitleAutoGeneration( const bool toGenerate, + const ObjectType type, + const bool update = true ); + bool getTitleAutoGeneration( const ObjectType type ) const; void setFont( const QFont& font, ObjectType type, bool update = true ); void setHorScaleMode( const int mode, bool update = true ); @@ -163,6 +169,8 @@ signals: void curveDisplayed( Plot2d_Curve* ); void curveErased( Plot2d_Curve* ); + void titleChangedByUser( const int theObjectType ); + protected: Plot2d_Plot2d* myPlot; int myOperation; @@ -176,6 +184,7 @@ protected: QColor myBackground; QString myTitle, myXTitle, myYTitle, myY2Title; bool myTitleEnabled, myXTitleEnabled, myYTitleEnabled, myY2TitleEnabled; + bool myTitleAutoGeneration, myXTitleAutoGeneration, myYTitleAutoGeneration; bool myXGridMajorEnabled, myYGridMajorEnabled, myY2GridMajorEnabled; bool myXGridMinorEnabled, myYGridMinorEnabled, myY2GridMinorEnabled; int myXGridMaxMajor, myYGridMaxMajor, myY2GridMaxMajor;