From cae17faab7a0a2eab02913ab5c1c7288d1db5e7d Mon Sep 17 00:00:00 2001 From: sln Date: Fri, 13 Apr 2007 12:16:49 +0000 Subject: [PATCH] =?utf8?q?Protection=20from=20automatic=20generation=20of?= =?utf8?q?=20titles=20using=20curve=C2=92s=20titles=20is=20added.=20Before?= =?utf8?q?=20this=20protection=20user=20could=20specify=20the=20titles=20m?= =?utf8?q?anually=20using=20=C2=93Plot=202d=20View=20Settings=C2=94=20dial?= =?utf8?q?og=20box.=20There=20was=20situation=20when=20titles=20generated?= =?utf8?q?=20automatically=20in=20updateTitles=20method=20and=20user=20los?= =?utf8?q?t=20his=20changes.=20Now=20there=20are=20myTitleAutoGeneration,?= =?utf8?q?=20myXTitleAutoGeneration,=20myYTitleAutoGeneration=20fields.=20?= =?utf8?q?They=20are=20true=20by=20default=20but=20if=20user=20changes=20t?= =?utf8?q?itles=20they=20becomes=20true=20and=20automatic=20generation=20i?= =?utf8?q?s=20not=20performed.=20Also=20corresponding=20methods=20for=20se?= =?utf8?q?tting/getting=20these=20fields=20are=20added.=20Signal=20titleCh?= =?utf8?q?angedByUser(=20const=20int=20theObjectType=20)=20added=20too.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/Plot2d/Plot2d_ViewFrame.cxx | 92 +++++++++++++++++++++++++++++++-- src/Plot2d/Plot2d_ViewFrame.h | 9 ++++ 2 files changed, 98 insertions(+), 3 deletions(-) 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; -- 2.39.2