From: rnv Date: Thu, 26 Jan 2012 07:34:31 +0000 (+0000) Subject: Implementation of the 0021407: [CEA 515] Plot2d Display error labels around the point... X-Git-Tag: V6_5_0a1~77 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=33b433a08f626a0930b9b9e38c7e7297ba95475d;p=modules%2Fgui.git Implementation of the 0021407: [CEA 515] Plot2d Display error labels around the point issue. --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 48d8aa5dd..bd14a61c9 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -2360,6 +2360,20 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "SelectionColor" ); + pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dGroup, + LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" ); + + int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dGroup, + LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" ); + pref->setItemProperty( "min", 1, deviationMarkerLw ); + pref->setItemProperty( "max", 5, deviationMarkerLw ); + + int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dGroup, + LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" ); + + pref->setItemProperty( "min", 1, deviationMarkerTs ); + pref->setItemProperty( "max", 5, deviationMarkerTs ); + int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat ); int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab ); diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index c7248f4f6..340517cbc 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -170,6 +170,9 @@ + + + diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 9ee4fcba3..5ff443a54 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -658,6 +658,18 @@ The changes will be applied on the next application session. PREF_GROUP_PLOT2DVIEWER Plot2d Viewer + + PREF_DEVIATION_COLOR + Deviation marker color + + + PREF_DEVIATION_MARKER_LW + Deviation marker line width + + + PREF_DEVIATION_MARKER_TS + Deviation marker tick size + MEN_DESK_MRU Most Recently Used diff --git a/src/Plot2d/Plot2d.cxx b/src/Plot2d/Plot2d.cxx index 721ab545a..b864720b9 100755 --- a/src/Plot2d/Plot2d.cxx +++ b/src/Plot2d/Plot2d.cxx @@ -39,7 +39,7 @@ const long COLOR_DISTANCE = 100; Constructor */ Plot2d_Point::Plot2d_Point() - : x( 0. ), y( 0. ) + : x( 0. ), y( 0. ), deviationPtr(0) { } @@ -47,10 +47,73 @@ Plot2d_Point::Plot2d_Point() Constructor */ Plot2d_Point::Plot2d_Point( double theX, double theY, const QString& theText ) - : x( theX ), y( theY ), text( theText ) + : x( theX ), y( theY ), text( theText ), deviationPtr(0) { } +/*! + Destructor. +*/ +Plot2d_Point::~Plot2d_Point() { + clearDeviation(); +} + +/*! + Free memory allocated for the deviation data. +*/ +void Plot2d_Point::clearDeviation() { + if(deviationPtr) + delete deviationPtr; + deviationPtr = 0; +} + +/*! + Return true in case if deviation data is assigned to the point. +*/ +bool Plot2d_Point::hasDeviation() const { + return !(deviationPtr == 0); +} + +/*! + Assign deviation data to the point. +*/ +void Plot2d_Point::setDeviation(double min, double max) { + clearDeviation(); + deviationPtr = new double[2]; + deviationPtr[0] = min;deviationPtr[1] = max; +} + +/*! + Return true in case if deviation data is assigned to the point + and store deviation data in the input parameters. +*/ +bool Plot2d_Point::deviation(double& min, double& max) const { + if(hasDeviation()) { + min = deviationPtr[0]; + max = deviationPtr[1]; + } + return false; +} + +/*! + Return minimal deviation value. +*/ +double Plot2d_Point::minDeviation() const { + if(hasDeviation()) + return deviationPtr[0]; + return 0.; +} + +/*! + Return minimal deviation value. +*/ +double Plot2d_Point::maxDeviation() const { + if(hasDeviation()) + return deviationPtr[1]; + return 0.; +} + + /*! \brief Convert Plot2d marker type to Qwt marker type. diff --git a/src/Plot2d/Plot2d.h b/src/Plot2d/Plot2d.h index b0e496fb9..648c81344 100755 --- a/src/Plot2d/Plot2d.h +++ b/src/Plot2d/Plot2d.h @@ -42,13 +42,26 @@ class QPainter; class QwtPlot; +// Properties on the deviation marker. +#define PLOT2D_DEVIATION_COLOR "DEVIATION_COLOR" +#define PLOT2D_DEVIATION_LW "DEVIATION_LW" +#define PLOT2D_DEVIATION_TS "DEVIATION_TS" + struct PLOT2D_EXPORT Plot2d_Point { double x; double y; + double* deviationPtr; QString text; Plot2d_Point(); - Plot2d_Point( double theX, double theY, const QString& theText = QString() ); + Plot2d_Point( double theX, double theY, const QString& theText = QString() ); + ~Plot2d_Point(); + bool deviation(double& min, double& max) const; + bool hasDeviation() const; + void setDeviation(double min, double max); + void clearDeviation(); + double minDeviation() const; + double maxDeviation() const; }; typedef QList pointList; diff --git a/src/Plot2d/Plot2d_Curve.cxx b/src/Plot2d/Plot2d_Curve.cxx index 8c96f8e4a..06e264b22 100755 --- a/src/Plot2d/Plot2d_Curve.cxx +++ b/src/Plot2d/Plot2d_Curve.cxx @@ -144,9 +144,22 @@ void Plot2d_Curve::updatePlotItem( QwtPlotItem* theItem ) QPen( getColor() ), QSize( getMarkerSize() , getMarkerSize() ))); - double *x, *y; + double *x, *y, *min, *max; long nb = getData( &x, &y ); - aCurve->setData( x, y, nb ); + if(nb > 0 && x && y) { + aCurve->setData( x, y, nb ); + delete x; + delete y; + QList idx; + getDeviationData(min, max, idx); + if(idx.size() > 0 && min && max) { + aCurve->setDeviationData(min,max,idx); + delete min; + delete max; + } else { + aCurve->clearDeviationData(); + } + } } /*! @@ -274,4 +287,75 @@ int Plot2d_Curve::getLineWidth() const { return myLineWidth; } +/*! + Sets deviation data on the curve. +*/ +void Plot2d_Curve::setDeviationData( const double* min, const double* max,const QList& idx) { + for( int i = 0; i < idx.size(); i++ ) { + if(idx[i] < myPoints.size()) { + myPoints[idx[i]].setDeviation(min[i], max[i]); + } + } +} + +/*! + Gets object's data +*/ +void Plot2d_Curve::getDeviationData( double*& theMin, double*& theMax, QList& idx) const +{ + int aNb = 0; + idx.clear(); + for (int i = 0; i < nbPoints(); i++) + if(myPoints[i].hasDeviation()) + aNb++; + if(aNb) { + double min, max; + theMin = new double[aNb]; + theMax = new double[aNb]; + for (int i = 0; i < nbPoints(); i++) + if(myPoints[i].hasDeviation()) { + myPoints[i].deviation(min,max); + theMin[i] = min; + theMax[i] = max; + idx.push_back(i); + } + } +} + +/*! + Clear deviation data on the curve. +*/ +void Plot2d_Curve::clearDeviationData() { + for( int i=0; i < myPoints.size(); i++ ) + myPoints[i].clearDeviation(); +} + +/*! + Gets object's minimal ordinate +*/ +double Plot2d_Curve::getMinY() const +{ + double aMinY = 1e150; + pointList::const_iterator aIt; + double coeff = 0.0; + for (aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) { + coeff = (*aIt).minDeviation(); + aMinY = qMin( aMinY, myScale * (*aIt).y - coeff ); + } + return aMinY; +} +/*! + Gets object's maximal ordinate +*/ +double Plot2d_Curve::getMaxY() const +{ + double aMaxY = -1e150; + pointList::const_iterator aIt; + double coeff = 0.0; + for (aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) { + coeff = (*aIt).maxDeviation(); + aMaxY = qMax( aMaxY, myScale * (*aIt).y + coeff ); + } + return aMaxY; +} \ No newline at end of file diff --git a/src/Plot2d/Plot2d_Curve.h b/src/Plot2d/Plot2d_Curve.h index 81640e936..6b6c67d09 100755 --- a/src/Plot2d/Plot2d_Curve.h +++ b/src/Plot2d/Plot2d_Curve.h @@ -50,7 +50,7 @@ public: void setMarker( Plot2d::MarkerType, const int ); void setMarker( Plot2d::MarkerType ); - void setMarkerStyle( QwtSymbol::Style style); + void setMarkerStyle( QwtSymbol::Style style); Plot2d::MarkerType getMarker() const; QwtSymbol::Style getMarkerStyle() const; void setMarkerSize( const int ); @@ -61,6 +61,13 @@ public: Plot2d::LineType getLine() const; void setLineWidth( const int ); int getLineWidth() const; + void setDeviationData( const double*, const double*, const QList&); + void getDeviationData( double*&, double*&, QList& ) const; + void clearDeviationData(); + + virtual double getMinY() const; + virtual double getMaxY() const; + protected: diff --git a/src/Plot2d/Plot2d_Object.h b/src/Plot2d/Plot2d_Object.h index 60b8cd010..248397d78 100755 --- a/src/Plot2d/Plot2d_Object.h +++ b/src/Plot2d/Plot2d_Object.h @@ -97,10 +97,10 @@ public: // Protection against QwtObject::drawLines() bug in Qwt 0.4.x: // it crashes if switched to X/Y logarithmic mode, when one or more points have // non-positive X/Y coordinate - double getMinX() const; - double getMaxX() const; - double getMinY() const; - double getMaxY() const; + virtual double getMinX() const; + virtual double getMaxX() const; + virtual double getMinY() const; + virtual double getMaxY() const; void setSelected(const bool); bool isSelected() const; diff --git a/src/Plot2d/Plot2d_PlotItems.cxx b/src/Plot2d/Plot2d_PlotItems.cxx index 5e23d88c4..5dc7725b3 100644 --- a/src/Plot2d/Plot2d_PlotItems.cxx +++ b/src/Plot2d/Plot2d_PlotItems.cxx @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include #include @@ -176,6 +178,37 @@ QColor Plot2d_QwtLegendItem::getColorFromPalette(QPalette::ColorRole role) { } return col; } +/* + * Internal class to store deviation data on the curve. + */ +class Plot2d_QwtPlotCurve::Plot2d_DeviationData { +public: + Plot2d_DeviationData::Plot2d_DeviationData(const double *min, const double *max,const QList& idx) + { + foreach(int index,idx) { + myMin[index] = min[index]; + myMax[index] = max[index]; + } + } + ~Plot2d_DeviationData(){} + + size_t size() const + { + return qwtMin(myMin.size(), myMax.size()); + } + bool values(size_t i, double &min, double &max) { + if(myMin.contains(i) && myMax.contains(i)) { + min = myMin[i]; + max = myMax[i]; + return true; + } + return false; + } +private: + QMap myMin; + QMap myMax; +}; + /*! Constructor of Plot2d_QwtPlotCurve @@ -185,8 +218,9 @@ Plot2d_QwtPlotCurve::Plot2d_QwtPlotCurve( const QString& title, Plot2d_SelectableItem(), QwtPlotCurve( title ), myYAxis( yAxis ), - myYAxisIdentifierEnabled( false ) -{ + myYAxisIdentifierEnabled( false ), + myDeviationData(0) +{ } /*! @@ -194,6 +228,7 @@ Plot2d_QwtPlotCurve::Plot2d_QwtPlotCurve( const QString& title, */ Plot2d_QwtPlotCurve::~Plot2d_QwtPlotCurve() { + clearDeviationData(); } /*! @@ -262,6 +297,111 @@ QWidget* Plot2d_QwtPlotCurve::legendItem() const { return new Plot2d_QwtLegendItem; } + +/*! + Redefined method, which draw a set of points of a curve. +*/ +void Plot2d_QwtPlotCurve::draw(QPainter *painter, + const QwtScaleMap &xMap, const QwtScaleMap &yMap, + int from, int to) const +{ + if (to < 0) + to = dataSize() - 1; + QwtPlotCurve::draw(painter, xMap, yMap, from, to); + + //draw deviation data + if(hasDeviationData()) { + painter->save(); + int lineW = deviationMarkerLineWidth(); + int tickSz = deviationMarkerTickSize() + qRound(lineW/2); + double min, max, xi, yi; + int xp, ytop, ybtm, tickl, tickr; + QColor c = isSelected() ? Plot2d_Object::selectionColor() : deviationMarkerColor(); + QPen p = QPen(c, lineW, Qt::SolidLine); + painter->setPen(p); + for (int i = from; i <= to; i++) { + if(!myDeviationData->values(i,min,max)) continue; + xi = x(i); + yi = y(i); + xp = xMap.transform(xi); + ytop = yMap.transform(yi + max); + ybtm = yMap.transform(yi - min); + tickl = xp - tickSz; + tickr = xp + tickSz; + painter->drawLine(tickl,ytop,tickr,ytop); + painter->drawLine(xp,ytop,xp,ybtm); + painter->drawLine(tickl,ybtm,tickr,ybtm); + } + painter->restore(); + } +} + +/*! + * Return color of the deviation marker. + */ +QColor Plot2d_QwtPlotCurve::deviationMarkerColor() const { + QColor c(0, 0, 127); + if(plot()) { + QVariant var = plot()->property(PLOT2D_DEVIATION_COLOR); + if(var.isValid()) + c = var.value(); + } + return c; +} +/*! + * Return line width of the deviation marker. + */ +int Plot2d_QwtPlotCurve::deviationMarkerLineWidth() const { + int lw = 1; + if(plot()) { + QVariant var = plot()->property(PLOT2D_DEVIATION_LW); + if(var.isValid()) + lw = var.toInt(); + } + return lw; +} + +/*! + * Return tick size of the deviation marker. + */ +int Plot2d_QwtPlotCurve::deviationMarkerTickSize() const { + int ts = 2; + if(plot()) { + QVariant var = plot()->property(PLOT2D_DEVIATION_TS); + if(var.isValid()) + ts = var.toInt(); + } + return ts; +} + +/*! + * Sets deviation data for the plot item. + */ +void Plot2d_QwtPlotCurve::setDeviationData(const double* min, const double* max,const QList &idx) { + clearDeviationData(); + myDeviationData = new Plot2d_DeviationData(min,max,idx); +} + +/*! + * Return true if deviation is assigned to the plot item, + false otherwise. + */ +bool Plot2d_QwtPlotCurve::hasDeviationData() const { + return myDeviationData != 0; +} + +/*! + * Remove deviation data from the plot item. + */ +void Plot2d_QwtPlotCurve::clearDeviationData() +{ + if(myDeviationData) + delete myDeviationData; + myDeviationData = 0; +} + + + /*! Constructor. */ @@ -790,4 +930,4 @@ int Plot2d_HistogramItem::getCrossedTop( const QRect& theRect ) const } } return aRes; -} +} \ No newline at end of file diff --git a/src/Plot2d/Plot2d_PlotItems.h b/src/Plot2d/Plot2d_PlotItems.h index 9ae278acc..8c71071ac 100644 --- a/src/Plot2d/Plot2d_PlotItems.h +++ b/src/Plot2d/Plot2d_PlotItems.h @@ -92,14 +92,30 @@ public: public: virtual void setYAxisIdentifierEnabled( const bool ); + virtual void draw(QPainter *p, + const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + int from, int to) const; + + void setDeviationData(const double* min, const double* max, const QList &idx); + bool hasDeviationData() const; + void clearDeviationData(); + protected: virtual void updateLegend( QwtLegend* ) const; virtual QWidget* legendItem() const; + QColor deviationMarkerColor() const; + int deviationMarkerLineWidth() const; + int deviationMarkerTickSize() const; + private: - QwtPlot::Axis myYAxis; - bool myYAxisIdentifierEnabled; + QwtPlot::Axis myYAxis; + bool myYAxisIdentifierEnabled; + + class Plot2d_DeviationData; + Plot2d_DeviationData* myDeviationData; }; class PLOT2D_EXPORT Plot2d_HistogramQwtItem: public QwtPlotItem diff --git a/src/Plot2d/Plot2d_SetupViewDlg.cxx b/src/Plot2d/Plot2d_SetupViewDlg.cxx index 07e143455..782ba4ff6 100755 --- a/src/Plot2d/Plot2d_SetupViewDlg.cxx +++ b/src/Plot2d/Plot2d_SetupViewDlg.cxx @@ -113,6 +113,37 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, QLabel* aBGLab = new QLabel( tr( "PLOT2D_BACKGROUND_COLOR_LBL" ), this ); myBackgroundBtn = new QtxColorButton( this ); + //Deviation marker parameters + QGroupBox* aDeviationGrp = new QGroupBox( tr( "PLOT2D_DEVIATION_MARKER_TLT" ), this ); + QHBoxLayout* aDeviationLayout = new QHBoxLayout(aDeviationGrp); + + //Deviation marker parameters : Line width + QLabel* aDeviationLwLbl = new QLabel( tr( "PLOT2D_DEVIATION_LW_LBL" ), aDeviationGrp ); + myDeviationLw = new QSpinBox( aDeviationGrp ); + myDeviationLw->setMinimum( 1 ); + myDeviationLw->setMaximum( 5 ); + myDeviationLw->setSingleStep( 1 ); + myDeviationLw->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + //Deviation marker parameters : Line width + QLabel* aDeviationTsLbl = new QLabel( tr( "PLOT2D_DEVIATION_TS_LBL" ), aDeviationGrp ); + myDeviationTs = new QSpinBox( aDeviationGrp ); + myDeviationTs->setMinimum( 1 ); + myDeviationTs->setMaximum( 5 ); + myDeviationTs->setSingleStep( 1 ); + myDeviationTs->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + //Deviation marker parameters : Color + QLabel* aDeviationClLbl = new QLabel( tr( "PLOT2D_DEVIATION_CL_LBL" ), aDeviationGrp ); + myDeviationCl = new QtxColorButton( aDeviationGrp ); + + aDeviationLayout->addWidget( aDeviationLwLbl ); + aDeviationLayout->addWidget( myDeviationLw ); + aDeviationLayout->addWidget( aDeviationTsLbl ); + aDeviationLayout->addWidget( myDeviationTs ); + aDeviationLayout->addWidget( aDeviationClLbl ); + aDeviationLayout->addWidget( myDeviationCl ); + // normalize mode QGroupBox* aNormalizeGrp = new QGroupBox( tr( "PLOT2D_NORMALIZE_TLT" ), this ); QGridLayout* aNormalizeLayout = new QGridLayout( aNormalizeGrp ); @@ -358,13 +389,14 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bgLayout->addWidget( myBackgroundBtn ); bgLayout->addStretch(); topLayout->addWidget( aBGLab, 3, 2 ); topLayout->addLayout( bgLayout, 3, 3 ); - topLayout->addWidget( aNormalizeGrp, 4, 0, 1, 4 ); - topLayout->addWidget( aScaleGrp, 5, 0, 1, 4 ); - topLayout->addWidget( aTabWidget, 6, 0, 1, 4 ); - topLayout->addWidget( myDefCheck, 7, 0, 1, 4 ); - topLayout->setRowStretch( 7, 5 ); - - topLayout->addLayout( btnLayout, 8, 0, 1, 4 ); + topLayout->addWidget( aDeviationGrp, 4, 0, 1, 4 ); + topLayout->addWidget( aNormalizeGrp, 5, 0, 1, 4 ); + topLayout->addWidget( aScaleGrp, 6, 0, 1, 4 ); + topLayout->addWidget( aTabWidget, 7, 0, 1, 4 ); + topLayout->addWidget( myDefCheck, 8, 0, 1, 4 ); + topLayout->setRowStretch( 9, 5 ); + + topLayout->addLayout( btnLayout, 10, 0, 1, 4 ); if ( !showDefCheck ) myDefCheck->hide(); @@ -732,6 +764,59 @@ int Plot2d_SetupViewDlg::getMarkerSize() { return myMarkerSpin->value(); } +/*! + \brief Set deviation marker line width. + \param width marker line width + \sa getDeviationMarkerLw() +*/ +void Plot2d_SetupViewDlg::setDeviationMarkerLw( const int width ){ + myDeviationLw->setValue(width); +} + +/*! + \brief Get deviation marker line width. + \return marker line width + \sa setMarkerSize() +*/ +int Plot2d_SetupViewDlg::getDeviationMarkerLw() const { + return myDeviationLw->value(); +} + +/*! + \brief Set deviation marker tick size. + \param size marker tick size + \sa getDeviationMarkerTs() +*/ +void Plot2d_SetupViewDlg::setDeviationMarkerTs( const int size) { + myDeviationTs->setValue(size); +} + +/*! + \brief Get deviation marker tick size. + \return marker tick size + \sa setDeviationMarkerTs() +*/ +int Plot2d_SetupViewDlg::getDeviationMarkerTs() const { + return myDeviationTs->value(); +} + +/*! + \brief Set color of the deviation marker. + \param color marker color + \sa getDeviationMarkerCl() +*/ +void Plot2d_SetupViewDlg::setDeviationMarkerCl( const QColor& col) { + myDeviationCl->setColor( col ); +} + +/*! + \brief Get color of the deviation marker. + \return marker color + \sa setDeviationMarkerCl() +*/ +QColor Plot2d_SetupViewDlg::getDeviationMarkerCl() const { + return myDeviationCl->color(); +} /*! \brief Set background color. diff --git a/src/Plot2d/Plot2d_SetupViewDlg.h b/src/Plot2d/Plot2d_SetupViewDlg.h index f109d1ba9..b339cb10e 100755 --- a/src/Plot2d/Plot2d_SetupViewDlg.h +++ b/src/Plot2d/Plot2d_SetupViewDlg.h @@ -94,6 +94,15 @@ public: int getXScaleMode(); int getYScaleMode(); + void setDeviationMarkerLw( const int); + int getDeviationMarkerLw() const; + + void setDeviationMarkerTs( const int); + int getDeviationMarkerTs() const; + + void setDeviationMarkerCl( const QColor&); + QColor getDeviationMarkerCl() const; + bool isSetAsDefault(); protected slots: @@ -153,6 +162,9 @@ private: QPushButton* myOkBtn; QPushButton* myCancelBtn; QPushButton* myHelpBtn; + QSpinBox* myDeviationLw; + QSpinBox* myDeviationTs; + QtxColorButton* myDeviationCl; bool mySecondAxisY; }; diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index effab0e22..fb196d7db 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -416,6 +416,13 @@ void Plot2d_ViewFrame::readPreferences() setNormLMaxMode( resMgr->booleanValue( "Plot2d", "VerNormLMaxMode", myNormLMax ) ); setNormRMinMode( resMgr->booleanValue( "Plot2d", "VerNormRMinMode", myNormRMin ) ); setNormRMaxMode( resMgr->booleanValue( "Plot2d", "VerNormRMaxMode", myNormRMax ) ); + QColor c = resMgr->colorValue( "Plot2d", "DeviationMarkerColor", QColor(0,0,255)); + myPlot->setProperty(PLOT2D_DEVIATION_COLOR, c); + myPlot->setProperty(PLOT2D_DEVIATION_LW, + resMgr->integerValue( "Plot2d", "DeviationMarkerLineWidth", 1)); + myPlot->setProperty(PLOT2D_DEVIATION_TS, + resMgr->integerValue( "Plot2d", "DeviationMarkerTickSize", 2)); + } /*! @@ -1524,6 +1531,20 @@ void Plot2d_ViewFrame::onSettings() dlg->setLMaxNormMode(myNormLMax); dlg->setRMinNormMode(myNormRMin); dlg->setRMaxNormMode(myNormRMax); + + QVariant v = myPlot->property(PLOT2D_DEVIATION_LW); + int lw = v.isValid() ? v.toInt() : 1; + + v = myPlot->property(PLOT2D_DEVIATION_TS); + int ts = v.isValid() ? v.toInt() : 2; + + v = myPlot->property(PLOT2D_DEVIATION_COLOR); + QColor cl = v.isValid() ? v.value() : QColor(0,0,255); + + dlg->setDeviationMarkerLw(lw); + dlg->setDeviationMarkerTs(ts); + dlg->setDeviationMarkerCl(cl); + // dlg->setMajorGrid( myXGridMajorEnabled, myPlot->axisMaxMajor( QwtPlot::xBottom ), myYGridMajorEnabled, myPlot->axisMaxMajor( QwtPlot::yLeft ), @@ -1600,6 +1621,14 @@ void Plot2d_ViewFrame::onSettings() setNormRMaxMode( dlg->getRMaxNormMode() ); } + myPlot->setProperty(PLOT2D_DEVIATION_COLOR, + dlg->getDeviationMarkerCl()); + myPlot->setProperty(PLOT2D_DEVIATION_LW, + dlg->getDeviationMarkerLw()); + myPlot->setProperty(PLOT2D_DEVIATION_TS, + dlg->getDeviationMarkerTs()); + + // update view myPlot->replot(); // update preferences diff --git a/src/Plot2d/resources/Plot2d_msg_en.ts b/src/Plot2d/resources/Plot2d_msg_en.ts index b363b48e8..de40b295b 100644 --- a/src/Plot2d/resources/Plot2d_msg_en.ts +++ b/src/Plot2d/resources/Plot2d_msg_en.ts @@ -331,6 +331,22 @@ PLOT2D_BACKGROUND_COLOR_LBL Background color: + + PLOT2D_DEVIATION_MARKER_TLT + Deviation marker + + + PLOT2D_DEVIATION_LW_LBL + Line width + + + PLOT2D_DEVIATION_TS_LBL + Tick size + + + PLOT2D_DEVIATION_CL_LBL + Color + WRN_XLOG_NOT_ALLOWED Some points with non-positive abscissa values have been detected.