//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
#include "Plot2d_ViewFrame.h"
#include "Plot2d_Prs.h"
#include "SUIT_ResourceMgr.h"
#include "SUIT_Application.h"
-#include "qapplication.h"
+#include <qapplication.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qcursor.h>
#define DEFAULT_MARKER_SIZE 9 // default marker size
#define MIN_RECT_SIZE 11 // min sensibility area size
-#define X11_COORD_MIN -16384\r
-#define X11_COORD_MAX 16384\r
+#define X11_COORD_MIN -16384
+
+#define X11_COORD_MAX 16384
const char* imageZoomCursor[] = {
"32 32 3 1",
QString Plot2d_ViewFrame::myPrefXTitle = "";
QString Plot2d_ViewFrame::myPrefYTitle = "";
-bool Plot2d_ViewFrame::myTitleAutoGeneration = true;
-bool Plot2d_ViewFrame::myXTitleAutoGeneration = true;
-bool Plot2d_ViewFrame::myYTitleAutoGeneration = true;
-
+bool Plot2d_ViewFrame::myPrefTitleChangedByUser = false;
+bool Plot2d_ViewFrame::myXPrefTitleChangedByUser = false;
+bool Plot2d_ViewFrame::myYPrefTitleChangedByUser = false;
/*!
Constructor
myXGridMinorEnabled( false ), myYGridMinorEnabled( false ), myY2GridMinorEnabled( false ),
myXGridMaxMajor( 8 ), myYGridMaxMajor( 8 ), myY2GridMaxMajor( 8 ),
myXGridMaxMinor( 5 ), myYGridMaxMinor( 5 ), myY2GridMaxMinor( 5 ),
- myXMode( 0 ), myYMode( 0 ), mySecondY( false )
+ myXMode( 0 ), myYMode( 0 ), mySecondY( false ),
+ myTitleAutoUpdate( true ), myXTitleAutoUpdate( true ), myYTitleAutoUpdate( true ),
+ myTitleChangedByUser( false ), myXTitleChangedByUser( false ), myYTitleChangedByUser( false )
{
/* Plot 2d View */
QVBoxLayout* aLayout = new QVBoxLayout( this );
resMgr->setValue( "Plot2d", "VerScaleMode", myYMode );
- if ( !myTitleAutoGeneration )
+ if ( myTitleChangedByUser )
+ {
myPrefTitle = myTitle;
- if ( !myXTitleAutoGeneration )
+ myPrefTitleChangedByUser = true;
+ }
+ if ( myXTitleChangedByUser )
+ {
myPrefXTitle = myXTitle;
- if ( !myYTitleAutoGeneration )
+ myXPrefTitleChangedByUser = true;
+ }
+ if ( myYTitleChangedByUser )
+ {
myPrefYTitle = myYTitle;
+ myYPrefTitleChangedByUser = true;
+ }
}
/*!
bool isTileChanged = dlg->getXTitle() != myXTitle;
setTitle( dlg->isXTitleEnabled(), dlg->getXTitle(), XTitle, false );
if ( isTileChanged )
- {
- myXTitleAutoGeneration = false;
- emit titleChangedByUser( XTitle );
- }
+ myXTitleChangedByUser = true;
+
// vertical left axis title
isTileChanged = dlg->getYTitle() != myYTitle;
setTitle( dlg->isYTitleEnabled(), dlg->getYTitle(), YTitle, false );
if ( isTileChanged )
- {
- myYTitleAutoGeneration = false;
- emit titleChangedByUser( YTitle );
- }
+ myYTitleChangedByUser = true;
+
if (mySecondY) // vertical right axis title
setTitle( dlg->isY2TitleEnabled(), dlg->getY2Title(), Y2Title, false );
isTileChanged = dlg->getMainTitle() != myTitle;
setTitle( dlg->isMainTitleEnabled(), dlg->getMainTitle(), MainTitle, true );
if ( isTileChanged )
- {
- myTitleAutoGeneration = false;
- emit titleChangedByUser( MainTitle );
- }
+ myTitleChangedByUser = true;
+
// curve type
if ( myCurveType != dlg->getCurveType() ) {
setCurveType( dlg->getCurveType(), false );
if ( !yTitle.isEmpty() && !yUnits.isEmpty() )
yTitle += " ";
- if ( myXTitleAutoGeneration )
+ if ( !isTitleChangedByUser( XTitle ) && myXTitleAutoUpdate )
setTitle( myXTitleEnabled, xTitle + xUnits, XTitle, true );
- if ( myYTitleAutoGeneration )
+ if ( !isTitleChangedByUser( YTitle ) && myYTitleAutoUpdate )
setTitle( myYTitleEnabled, yTitle + yUnits, YTitle, true );
- if ( myTitleAutoGeneration )
+ if ( !isTitleChangedByUser( MainTitle ) && myTitleAutoUpdate )
setTitle( true, aTables.join("; "), MainTitle, true );
}
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()
+bool Plot2d_ViewFrame::isTitleChangedByUser( const ObjectType type )
{
- return myTitleAutoGeneration;
+ switch ( type )
+ {
+ case MainTitle:
+ return myPrefTitleChangedByUser || myTitleChangedByUser;
+ case XTitle:
+ return myXPrefTitleChangedByUser || myXTitleChangedByUser;
+ case YTitle:
+ return myYPrefTitleChangedByUser || myYTitleChangedByUser;
+ default:
+ return false;
+ }
}
/*!
- Specifies whether plot title must be generated automatically using curves titles
+ Sets flag for automatic updates of titles in accordance with current set of curves
+ ( updateTitles method). You should call setAutoUpdateTitle( ObjType, false )
+ if your application set titles itself and they can not be updated automatically.
+ By default titles are updated automatically.
*/
-void Plot2d_ViewFrame::setTitleAutoGeneration( const bool toGenerate,
- const ObjectType type,
- const bool update )
+
+void Plot2d_ViewFrame::setAutoUpdateTitle( const ObjectType type, const bool upd )
{
- switch ( type )
+ switch ( type )
{
case MainTitle:
- myTitleAutoGeneration = toGenerate;
- break;
+ myTitleAutoUpdate = upd;
case XTitle:
- myXTitleAutoGeneration = toGenerate;
- break;
+ myXTitleAutoUpdate = upd;
case YTitle:
- myYTitleAutoGeneration = toGenerate;
- break;
+ myYTitleAutoUpdate = upd;
default:
- return;
+ break;
}
- if ( update )
- updateTitles();
}
/*!
- Verifies whether plot title must be generated automatically using curves titles
+ Gets flag for automatic updates of titles in accordance with current set of curves
+ ( updateTitles method)
*/
-bool Plot2d_ViewFrame::getTitleAutoGeneration( const ObjectType type )
+bool Plot2d_ViewFrame::getAutoUpdateTitle( const ObjectType type ) const
{
- switch ( type )
+ switch ( type )
{
case MainTitle:
- return myTitleAutoGeneration;
+ return myTitleAutoUpdate;
case XTitle:
- return myXTitleAutoGeneration;
+ return myXTitleAutoUpdate;
case YTitle:
- return myYTitleAutoGeneration;
+ return myYTitleAutoUpdate;
default:
- return false;
+ return true;
}
}
void updateTitles();
void setTitle( const QString& title );
QString getTitle() const { return myTitle; }
- void setTitleAutoGeneration( const bool toGenerate, const bool update = true );
- bool getTitleAutoGeneration();
void displayCurve( Plot2d_Curve* curve, bool update = false );
void displayCurves( const curveList& curves, bool update = false );
void eraseCurve ( Plot2d_Curve* curve, bool update = false );
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 );
- static bool getTitleAutoGeneration( const ObjectType type );
+
+ bool isTitleChangedByUser( const ObjectType type );
void setFont( const QFont& font, ObjectType type, bool update = true );
void setHorScaleMode( const int mode, bool update = true );
void incrementalPan ( const int incrX, const int incrY );
void incrementalZoom( const int incrX, const int incrY );
+ void setAutoUpdateTitle( const ObjectType type, const bool upd );
+ bool getAutoUpdateTitle( const ObjectType type ) const;
+
protected:
int testOperation( const QMouseEvent& );
void readPreferences();
void curveDisplayed( Plot2d_Curve* );
void curveErased( Plot2d_Curve* );
- void titleChangedByUser( const int theObjectType );
-
protected:
Plot2d_Plot2d* myPlot;
int myOperation;
int myXMode, myYMode;
double myXDistance, myYDistance, myYDistance2;
bool mySecondY;
+
+ bool myTitleAutoUpdate, myXTitleAutoUpdate, myYTitleAutoUpdate;
+ bool myTitleChangedByUser, myXTitleChangedByUser, myYTitleChangedByUser;
static QString myPrefTitle;
static QString myPrefXTitle;
static QString myPrefYTitle;
- static bool myTitleAutoGeneration;
- static bool myXTitleAutoGeneration;
- static bool myYTitleAutoGeneration;
+ static bool myPrefTitleChangedByUser;
+ static bool myXPrefTitleChangedByUser;
+ static bool myYPrefTitleChangedByUser;
};
class Plot2d_Plot2d : public QwtPlot