1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : Plot2d_AnalyticalCurveDlg.cxx
24 // Author : Roman NIKOLAEV, Open CASCADE S.A.S. (roman.nikolaev@opencascade.com)
28 // TODO : check what happens if invalid formula is given, e.g. x/0
29 // TODO : check what happens if curve formala is valid in general but some there are some problems with calculating (e.g. logarithmic formulas and negative x)
32 #include "Plot2d_AnalyticalCurveDlg.h"
33 #include "Plot2d_AnalyticalCurve.h"
34 #include "Plot2d_ViewFrame.h"
37 #include <QtxIntSpinBox.h>
38 #include <QtxColorButton.h>
41 #include <SUIT_MessageBox.h>
42 #include <SUIT_Session.h>
43 #include <SUIT_Application.h>
46 #include <QListWidget>
49 #include <QHBoxLayout>
54 #include <QPushButton>
60 const int MIN_NB_INTERVALS = 1;
61 const int MAX_NB_INTERVALS = 10000;
63 const int MIN_LINE_WIDTH = 0;
64 const int MAX_LINE_WIDTH = 10;
66 const char* PROP_TITLE = "title";
67 const char* PROP_VISIBLE = "visible";
68 const char* PROP_STATUS = "status";
69 const char* PROP_FORMULA = "formula";
70 const char* PROP_NBINTERVALS = "nb_intervals";
71 const char* PROP_AUTOASSIGN = "auto_assign";
72 const char* PROP_MARKERTYPE = "marker_type";
73 const char* PROP_LINETYPE = "line_type";
74 const char* PROP_LINEWIDTH = "line_width";
75 const char* PROP_COLOR = "color";
78 \class Plot2d_AnalyticalCurveDlg::UpdateLocker
79 \brief Update locker class
82 class Plot2d_AnalyticalCurveDlg::UpdateLocker
85 UpdateLocker( QObject* );
92 Plot2d_AnalyticalCurveDlg::UpdateLocker::UpdateLocker( QObject* object ) : myObject( object )
94 myLocked = myObject->blockSignals( true );
97 Plot2d_AnalyticalCurveDlg::UpdateLocker::~UpdateLocker()
99 myObject->blockSignals( myLocked );
103 \class Plot2d_AnalyticalCurveDlg::Updater
104 \brief Auxiliary class used for handle update requests from sub-widgets
108 Plot2d_AnalyticalCurveDlg::Updater::Updater( QWidget* parent ) : QObject( parent )
111 Plot2d_AnalyticalCurveDlg::Updater::~Updater()
117 Plot2d_AnalyticalCurveDlg::Plot2d_AnalyticalCurveDlg( Plot2d_CurveContainer* container, QWidget* parent )
118 : QDialog( parent ), myContainer( container )
121 setWindowTitle( tr( "ANALYTICAL_CURVE_TLT" ) );
122 setSizeGripEnabled( true );
124 // Curves list widget
125 myCurvesList = new QListWidget( this );
126 myCurvesList->setSelectionMode( QAbstractItemView::SingleSelection );
128 // Curve parameters group box
129 myCurveParams = new QGroupBox( tr( "AC_CURVE_PARAMS" ), this );
131 QLabel* formulaLabel = new QLabel( tr( "AC_FORMULA" ), myCurveParams );
132 myFormula = new QLineEdit( myCurveParams );
133 QLabel* nbIntervalsLabel = new QLabel( tr( "AC_NB_INTERVALS" ), myCurveParams );
134 myNbIntervals = new QtxIntSpinBox( MIN_NB_INTERVALS, MAX_NB_INTERVALS, STEP, myCurveParams );
136 QGridLayout* paramsLayout = new QGridLayout( myCurveParams );
137 paramsLayout->addWidget( formulaLabel, 0, 0 );
138 paramsLayout->addWidget( myFormula, 0, 1 );
139 paramsLayout->addWidget( nbIntervalsLabel, 1, 0 );
140 paramsLayout->addWidget( myNbIntervals, 1, 1 );
142 // Curve properties group box
143 myCurveProps = new QGroupBox( tr( "AC_CURVE_PROPS" ), this );
145 myAutoAssign = new QCheckBox( tr( "AC_AUTO_ASSIGN" ), myCurveProps );
146 myPropsGrp = new QWidget( myCurveProps );
147 QLabel* markerLabel = new QLabel( tr( "AC_MARKER_TYPE" ), myPropsGrp );
148 myMarkerType = new QComboBox( myPropsGrp );
149 QLabel* lineTypeLabel = new QLabel( tr( "AC_LINE_TYPE" ), myPropsGrp );
150 myLineType = new QComboBox( myPropsGrp );
151 QLabel* lineWidthLabel = new QLabel( tr( "AC_LINE_WIDTH" ), myPropsGrp );
152 myLineWidth = new QtxIntSpinBox( MIN_LINE_WIDTH, MAX_LINE_WIDTH, STEP, myPropsGrp );
153 QLabel* colorLabel = new QLabel( tr("AC_CURVE_COLOR"), myPropsGrp );
154 myColor = new QtxColorButton( myPropsGrp );
156 QGridLayout* propsGrpLayout = new QGridLayout( myPropsGrp );
157 propsGrpLayout->addWidget( markerLabel, 0, 0 );
158 propsGrpLayout->addWidget( myMarkerType, 0, 1 );
159 propsGrpLayout->addWidget( lineTypeLabel, 1, 0 );
160 propsGrpLayout->addWidget( myLineType, 1, 1 );
161 propsGrpLayout->addWidget( lineWidthLabel, 2, 0 );
162 propsGrpLayout->addWidget( myLineWidth, 2, 1 );
163 propsGrpLayout->addWidget( colorLabel, 3, 0 );
164 propsGrpLayout->addWidget( myColor, 3, 1 );
166 QVBoxLayout* propsLayout = new QVBoxLayout( myCurveProps );
167 propsLayout->addWidget( myAutoAssign );
168 propsLayout->addWidget( myPropsGrp );
170 // Add && Remove buttons
171 myAddButton = new QPushButton( tr("AC_ADD_BTN"), this );
172 myAddButton->setAutoDefault( true );
173 myRemoveButton = new QPushButton( tr("AC_REM_BTN"), this );
174 myRemoveButton->setAutoDefault( true );
176 // OK, Apply, Close, Help buttons
177 QPushButton* okButton = new QPushButton( tr( "AC_OK_BTN" ), this );
178 okButton->setDefault( true );
179 okButton->setAutoDefault( true );
181 QPushButton* applyButton = new QPushButton( tr( "AC_APPLY_BTN" ), this );
182 applyButton->setAutoDefault( true );
184 QPushButton* cancelButton = new QPushButton( tr( "AC_CLOSE_BTN" ), this );
185 cancelButton->setAutoDefault( true );
186 QPushButton* helpButton = new QPushButton( tr( "AC_HELP_BTN" ), this );
187 helpButton->setAutoDefault( true );
188 QHBoxLayout* btnLayout = new QHBoxLayout;
189 btnLayout->addWidget( okButton );
190 btnLayout->addWidget( applyButton );
191 btnLayout->addStretch();
192 btnLayout->addWidget( cancelButton );
193 btnLayout->addWidget( helpButton );
195 QGridLayout* mainLayout = new QGridLayout( this );
196 mainLayout->addWidget( myCurvesList, 0, 0, 3, 1 );
197 mainLayout->addWidget( myCurveParams, 0, 1, 1, 2 );
198 mainLayout->addWidget( myCurveProps, 1, 1, 1, 2 );
199 mainLayout->addWidget( myAddButton, 2, 1 );
200 mainLayout->addWidget( myRemoveButton, 2, 2 );
201 mainLayout->addLayout( btnLayout, 3, 0, 1, 3 );
204 QColor cl = myMarkerType->palette().color( QPalette::Text ); // color to draw markers
205 QSize sz = QSize( 16, 16 ); // size of the icons for markers
206 myMarkerType->setIconSize( sz );
208 myMarkerType->addItem( Plot2d::markerIcon( sz, cl, Plot2d::None ), tr( "NONE_MARKER_LBL" ) );
209 myMarkerType->addItem( Plot2d::markerIcon( sz, cl, Plot2d::Circle ), tr( "CIRCLE_MARKER_LBL" ) );
210 myMarkerType->addItem( Plot2d::markerIcon( sz, cl, Plot2d::Rectangle ), tr( "RECTANGLE_MARKER_LBL" ) );
211 myMarkerType->addItem( Plot2d::markerIcon( sz, cl, Plot2d::Diamond ), tr( "DIAMOND_MARKER_LBL" ) );
212 myMarkerType->addItem( Plot2d::markerIcon( sz, cl, Plot2d::DTriangle ), tr( "DTRIANGLE_MARKER_LBL" ) );
213 myMarkerType->addItem( Plot2d::markerIcon( sz, cl, Plot2d::UTriangle ), tr( "UTRIANGLE_MARKER_LBL" ) );
214 myMarkerType->addItem( Plot2d::markerIcon( sz, cl, Plot2d::LTriangle ), tr( "LTRIANGLE_MARKER_LBL" ) );
215 myMarkerType->addItem( Plot2d::markerIcon( sz, cl, Plot2d::RTriangle ), tr( "RTRIANGLE_MARKER_LBL" ) );
216 myMarkerType->addItem( Plot2d::markerIcon( sz, cl, Plot2d::Cross ), tr( "CROSS_MARKER_LBL" ) );
217 myMarkerType->addItem( Plot2d::markerIcon( sz, cl, Plot2d::XCross ), tr( "XCROSS_MARKER_LBL" ) );
219 cl = myLineType->palette().color( QPalette::Text ); // color to draw line types
220 sz = QSize( 40, 16 ); // size of the icons for line types
221 myLineType->setIconSize( sz );
223 myLineType->addItem( Plot2d::lineIcon( sz, cl, Plot2d::NoPen ), tr( "NONE_LINE_LBL" ) );
224 myLineType->addItem( Plot2d::lineIcon( sz, cl, Plot2d::Solid ), tr( "SOLID_LINE_LBL" ) );
225 myLineType->addItem( Plot2d::lineIcon( sz, cl, Plot2d::Dash ), tr( "DASH_LINE_LBL" ) );
226 myLineType->addItem( Plot2d::lineIcon( sz, cl, Plot2d::Dot ), tr( "DOT_LINE_LBL" ) );
227 myLineType->addItem( Plot2d::lineIcon( sz, cl, Plot2d::DashDot ), tr( "DASHDOT_LINE_LBL" ) );
228 myLineType->addItem( Plot2d::lineIcon( sz, cl, Plot2d::DashDotDot ), tr( "DAHSDOTDOT_LINE_LBL" ) );
231 myUpdater = new Updater( this );
232 connect( myUpdater, SIGNAL( update() ), this, SLOT( updateCurve() ) );
233 connect( myFormula, SIGNAL( textChanged( QString ) ), myUpdater, SIGNAL( update() ) );
234 connect( myNbIntervals, SIGNAL( valueChanged( int ) ), myUpdater, SIGNAL( update() ) );
235 connect( myAutoAssign, SIGNAL( stateChanged( int ) ), myUpdater, SIGNAL( update() ) );
236 connect( myMarkerType, SIGNAL( activated( int ) ), myUpdater, SIGNAL( update() ) );
237 connect( myLineType, SIGNAL( activated( int ) ), myUpdater, SIGNAL( update() ) );
238 connect( myLineWidth, SIGNAL( valueChanged( int ) ), myUpdater, SIGNAL( update() ) );
239 connect( myColor, SIGNAL( changed( QColor ) ), myUpdater, SIGNAL( update() ) );
240 connect( myCurvesList, SIGNAL( itemChanged( QListWidgetItem* ) ), myUpdater, SIGNAL( update() ) );
241 connect( myCurvesList, SIGNAL( itemSelectionChanged() ), this, SLOT( selectionChanged() ) );
242 connect( myAddButton, SIGNAL( clicked() ), this, SLOT( addCurve() ) );
243 connect( myRemoveButton, SIGNAL( clicked()), this, SLOT( removeCurve() ) );
244 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
245 connect( applyButton, SIGNAL( clicked() ), this, SLOT( apply() ) );
246 connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
247 connect( helpButton, SIGNAL( clicked() ), this, SLOT( help() ) );
249 // Initialize dialog box
256 Plot2d_AnalyticalCurveDlg::~Plot2d_AnalyticalCurveDlg()
260 void Plot2d_AnalyticalCurveDlg::init()
262 AnalyticalCurveList curves = myContainer->getAnalyticalCurves();
263 foreach ( Plot2d_AnalyticalCurve* curve, curves ) {
264 QListWidgetItem* item = new QListWidgetItem( curve->getName() );
265 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
266 item->setCheckState( curve->isActive() ? Qt::Checked : Qt::Unchecked );
267 initPropsFromCurve(curve);
269 var.setValue( (void*)curve );
270 item->setData( Qt::UserRole, var );
271 myCurvesList->addItem( item );
273 if ( !myCurvesList->currentItem() )
274 myCurvesList->setCurrentItem( item );
281 /brief Store curve properties in the local map.
283 void Plot2d_AnalyticalCurveDlg::initPropsFromCurve(Plot2d_AnalyticalCurve* curve) {
284 myProperties[ curve ][ PROP_TITLE ] = curve->getName();
285 myProperties[ curve ][ PROP_VISIBLE ] = curve->isActive();
286 myProperties[ curve ][ PROP_FORMULA ] = curve->getExpression();
287 myProperties[ curve ][ PROP_NBINTERVALS ] = (int)curve->getNbIntervals();
288 myProperties[ curve ][ PROP_AUTOASSIGN ] = curve->isAutoAssign();
289 myProperties[ curve ][ PROP_MARKERTYPE ] = curve->getMarker();
290 myProperties[ curve ][ PROP_LINETYPE ] = curve->getLine();
291 myProperties[ curve ][ PROP_LINEWIDTH ] = curve->getLineWidth();
292 myProperties[ curve ][ PROP_COLOR ] = curve->getColor();
293 myProperties[ curve ][ PROP_STATUS ] = ItemExisting;
296 QwtPlot* Plot2d_AnalyticalCurveDlg::getPlot() {
297 Plot2d_ViewFrame* frame = dynamic_cast<Plot2d_ViewFrame*>(myContainer);
299 return frame->getPlot();
304 /brief Store local copy on the curves properties into curves.
306 bool Plot2d_AnalyticalCurveDlg::processCurves() {
309 QwtPlot* plot = getPlot();
313 PropMap::Iterator it;
314 for ( it = myProperties.begin(); it != myProperties.end(); ++it ) {
315 Plot2d_AnalyticalCurve* curve = it.key();
316 if ( propStatus( curve ) == ItemRemoved ) {
317 myContainer->removeAnalyticalCurve( curve );
320 curve->setName( propTitle( curve ) );
321 curve->setActive( propVisible( curve ) );
322 curve->setExpression( propFormula( curve ) );
323 curve->setNbIntervals( propIntervals(curve) );
324 bool prevValue = curve->isAutoAssign();
325 curve->setAutoAssign( propAutoAssign( curve ) );
326 if ( !curve->isAutoAssign() ) {
327 curve->setMarker( propMarkerType( curve ) );
328 curve->setLine( propLineType( curve ) );
329 curve->setLineWidth( propLineWidth( curve ) );
330 curve->setColor( propColor( curve ) );
333 curve->autoFill(plot);
337 if (! curve->checkCurve(plot) ) {
338 QListWidgetItem* item = getItem(curve);
340 myCurvesList->setCurrentItem( item );
341 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "AC_CANT_CALCULATE" ) );
346 if ( propStatus( curve ) == ItemAdded ) {
347 myContainer->addAnalyticalCurve( curve );
348 myProperties[ curve ][ PROP_STATUS ] = ItemExisting;
355 \brief Private slot. Called when "Apply" button is clicked
357 void Plot2d_AnalyticalCurveDlg::apply() {
358 if(processCurves()) {
359 Plot2d_ViewFrame* f = dynamic_cast<Plot2d_ViewFrame*>(myContainer);
361 f->updateAnalyticalCurves();
363 AnalyticalCurveList curves = myContainer->getAnalyticalCurves();
364 foreach ( Plot2d_AnalyticalCurve* curve, curves ) {
365 initPropsFromCurve(curve);
372 \brief Private slot. Called when "Ok" button is clicked
374 void Plot2d_AnalyticalCurveDlg::accept()
381 \brief Private slot. Called when "Close" button is clicked
383 void Plot2d_AnalyticalCurveDlg::reject()
385 // clean-up curves just created
386 PropMap::Iterator it;
387 for ( it = myProperties.begin(); it != myProperties.end(); ++it ) {
388 Plot2d_AnalyticalCurve* curve = it.key();
389 if ( propStatus( curve ) == ItemAdded )
396 \brief Private slot. Called when "Add curve" button is clicked
398 void Plot2d_AnalyticalCurveDlg::addCurve()
400 Plot2d_AnalyticalCurve* curve = new Plot2d_AnalyticalCurve();
402 if(curve->isAutoAssign()) {
403 QwtPlot* plot = getPlot();
405 curve->autoFill(plot);
408 QListWidgetItem* item = new QListWidgetItem(curve->getName());
409 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
410 item->setCheckState( Qt::Checked );
412 var.setValue( (void*)curve );
413 item->setData( Qt::UserRole, var );
414 myCurvesList->addItem( item );
416 myProperties[ curve ][ PROP_STATUS ] = ItemAdded;
418 myCurvesList->setCurrentItem( item );
422 \brief Private slot. Called when "Remove curve" button is clicked
424 void Plot2d_AnalyticalCurveDlg::removeCurve()
426 QList<QListWidgetItem*> items = myCurvesList->selectedItems();
427 foreach( QListWidgetItem* item, items ) {
428 Plot2d_AnalyticalCurve* curve = (Plot2d_AnalyticalCurve*)( item->data( Qt::UserRole ).value<void*>() );
430 if ( propStatus( curve ) == ItemAdded ) {
431 myProperties.remove( curve );
435 myProperties[ curve ][ PROP_STATUS ] = ItemRemoved;
441 \brief Private slot. Called when any curve property is changed.
443 void Plot2d_AnalyticalCurveDlg::updateCurve()
445 UpdateLocker lock( myUpdater );
447 QListWidgetItem* item = selected();
448 Plot2d_AnalyticalCurve* curve = selectedCurve();
449 if ( item && curve ) {
450 myProperties[ curve ][ PROP_TITLE ] = item->text();
451 myProperties[ curve ][ PROP_VISIBLE ] = item->checkState() == Qt::Checked;
452 myProperties[ curve ][ PROP_FORMULA ] = myFormula->text();
453 myProperties[ curve ][ PROP_NBINTERVALS ] = myNbIntervals->value();
454 myProperties[ curve ][ PROP_AUTOASSIGN ] = myAutoAssign->isChecked();
455 myProperties[ curve ][ PROP_MARKERTYPE ] = myMarkerType->currentIndex();
456 myProperties[ curve ][ PROP_LINETYPE ] = myLineType->currentIndex();
457 myProperties[ curve ][ PROP_LINEWIDTH ] = myLineWidth->value();
458 myProperties[ curve ][ PROP_COLOR ] = myColor->color();
465 \brief Private slot. Update widgets state.
467 void Plot2d_AnalyticalCurveDlg::updateState()
469 myPropsGrp->setEnabled( !myAutoAssign->isChecked() );
470 myCurveParams->setEnabled( selectedCurve() != 0 );
471 myCurveProps->setEnabled( selectedCurve() != 0 );
472 myRemoveButton->setEnabled( selectedCurve() != 0 );
476 \brief Private slot. Called when selection in the curve list is changed.
478 void Plot2d_AnalyticalCurveDlg::selectionChanged()
480 UpdateLocker lock( myUpdater );
482 Plot2d_AnalyticalCurve* curve = selectedCurve();
484 myFormula->setText( propFormula( curve ) );
485 myNbIntervals->setValue( propIntervals( curve ) );
486 myMarkerType->setCurrentIndex( (int)propMarkerType( curve ) );
487 myLineType->setCurrentIndex( (int)propLineType( curve ) );
488 myLineWidth->setValue( propLineWidth( curve ) );
489 myColor->setColor( propColor( curve ) );
490 myAutoAssign->setChecked( propAutoAssign( curve ) );
496 \brief Show help page
498 void Plot2d_AnalyticalCurveDlg::help()
500 SUIT_Application* app = SUIT_Session::session()->activeApplication();
502 app->onHelpContextModule( "GUI", "plot2d_viewer.html", "analytical-curve" );
506 \brief Get currently selected list widget item
508 QListWidgetItem* Plot2d_AnalyticalCurveDlg::selected() const
510 QList<QListWidgetItem*> items = myCurvesList->selectedItems();
511 return items.count() > 0 ? items[0] : 0;
515 \brief Get widget item by the curve
517 QListWidgetItem* Plot2d_AnalyticalCurveDlg::getItem(Plot2d_AnalyticalCurve* theCurve) const
519 int nb = myCurvesList->count();
520 QListWidgetItem* item = 0;
521 for(int i = 0; i < nb ; i++) {
522 item = myCurvesList->item(i);
523 if(item->data( Qt::UserRole ).value<void*>() == theCurve)
530 \brief Get currently selected curve
532 Plot2d_AnalyticalCurve* Plot2d_AnalyticalCurveDlg::selectedCurve() const
534 return selected() ? (Plot2d_AnalyticalCurve*)( selected()->data( Qt::UserRole ).value<void*>() ) : 0;
538 \brief Get curve property: status
540 int Plot2d_AnalyticalCurveDlg::propStatus( Plot2d_AnalyticalCurve* curve, const int def )
544 if ( !myProperties.contains( curve ) )
545 myProperties[ curve ] = CurveProps();
546 if ( !myProperties[ curve ].contains( PROP_STATUS ) )
547 myProperties[ curve ][ PROP_STATUS ] = def;
548 QVariant v = myProperties[ curve ][ PROP_STATUS ];
549 if ( v.isValid() && v.type() == QVariant::Int ) val = v.toInt();
555 \brief Get curve property: title
557 QString Plot2d_AnalyticalCurveDlg::propTitle( Plot2d_AnalyticalCurve* curve, const QString& def )
561 if ( !myProperties.contains( curve ) )
562 myProperties[ curve ] = CurveProps();
563 if ( !myProperties[ curve ].contains( PROP_TITLE ) )
564 myProperties[ curve ][ PROP_TITLE ] = def;
565 QVariant v = myProperties[ curve ][ PROP_TITLE ];
566 if ( v.isValid() && v.type() == QVariant::String ) val = v.toString();
572 \brief Get curve property: visible flag
574 bool Plot2d_AnalyticalCurveDlg::propVisible( Plot2d_AnalyticalCurve* curve, bool def )
578 if ( !myProperties.contains( curve ) )
579 myProperties[ curve ] = CurveProps();
580 if ( !myProperties[ curve ].contains( PROP_VISIBLE ) )
581 myProperties[ curve ][ PROP_VISIBLE ] = def;
582 QVariant v = myProperties[ curve ][ PROP_VISIBLE ];
583 if ( v.isValid() && v.type() == QVariant::Bool ) val = v.toBool();
589 \brief Get curve property: formula
591 QString Plot2d_AnalyticalCurveDlg::propFormula( Plot2d_AnalyticalCurve* curve, const QString& def )
595 if ( !myProperties.contains( curve ) )
596 myProperties[ curve ] = CurveProps();
597 if ( !myProperties[ curve ].contains( PROP_FORMULA ) )
598 myProperties[ curve ][ PROP_FORMULA ] = def;
599 QVariant v = myProperties[ curve ][ PROP_FORMULA ];
600 if ( v.isValid() && v.type() == QVariant::String ) val = v.toString();
606 \brief Get curve property: nb intervals
608 int Plot2d_AnalyticalCurveDlg::propIntervals( Plot2d_AnalyticalCurve* curve, int def )
612 if ( !myProperties.contains( curve ) )
613 myProperties[ curve ] = CurveProps();
614 if ( !myProperties[ curve ].contains( PROP_NBINTERVALS ) )
615 myProperties[ curve ][ PROP_NBINTERVALS ] = def;
616 QVariant v = myProperties[ curve ][ PROP_NBINTERVALS ];
617 if ( v.isValid() && v.type() == QVariant::Int ) val = v.toInt();
623 \brief Get curve property: marker type
625 Plot2d::MarkerType Plot2d_AnalyticalCurveDlg::propMarkerType( Plot2d_AnalyticalCurve* curve, Plot2d::MarkerType def )
627 Plot2d::MarkerType val = def;
629 if ( !myProperties.contains( curve ) )
630 myProperties[ curve ] = CurveProps();
631 if ( !myProperties[ curve ].contains( PROP_MARKERTYPE ) )
632 myProperties[ curve ][ PROP_MARKERTYPE ] = def;
633 QVariant v = myProperties[ curve ][ PROP_MARKERTYPE ];
634 if ( v.isValid() && v.type() == QVariant::Int ) val = (Plot2d::MarkerType)( v.toInt() );
640 \brief Get curve property: line type
642 Plot2d::LineType Plot2d_AnalyticalCurveDlg::propLineType( Plot2d_AnalyticalCurve* curve, Plot2d::LineType def )
644 Plot2d::LineType val = def;
646 if ( !myProperties.contains( curve ) )
647 myProperties[ curve ] = CurveProps();
648 if ( !myProperties[ curve ].contains( PROP_LINETYPE ) )
649 myProperties[ curve ][ PROP_LINETYPE ] = def;
650 QVariant v = myProperties[ curve ][ PROP_LINETYPE ];
651 if ( v.isValid() && v.type() == QVariant::Int ) val = (Plot2d::LineType)( v.toInt() );
657 \brief Get curve property: line width
659 int Plot2d_AnalyticalCurveDlg::propLineWidth( Plot2d_AnalyticalCurve* curve, int def )
663 if ( !myProperties.contains( curve ) )
664 myProperties[ curve ] = CurveProps();
665 if ( !myProperties[ curve ].contains( PROP_LINEWIDTH ) )
666 myProperties[ curve ][ PROP_LINEWIDTH ] = def;
667 QVariant v = myProperties[ curve ][ PROP_LINEWIDTH ];
668 if ( v.isValid() && v.type() == QVariant::Int ) val = v.toInt();
674 \brief Get curve property: color
676 QColor Plot2d_AnalyticalCurveDlg::propColor( Plot2d_AnalyticalCurve* curve, const QColor& def )
680 if ( !myProperties.contains( curve ) )
681 myProperties[ curve ] = CurveProps();
682 if ( !myProperties[ curve ].contains( PROP_COLOR ) )
683 myProperties[ curve ][ PROP_COLOR ] = def;
684 QVariant v = myProperties[ curve ][ PROP_COLOR ];
685 if ( v.isValid() && v.type() == QVariant::Color ) val = v.value<QColor>();
691 \brief Get curve property: auto-assign flag
693 bool Plot2d_AnalyticalCurveDlg::propAutoAssign( Plot2d_AnalyticalCurve* curve, bool def )
697 if ( !myProperties.contains( curve ) )
698 myProperties[ curve ] = CurveProps();
699 if ( !myProperties[ curve ].contains( PROP_AUTOASSIGN ) )
700 myProperties[ curve ][ PROP_AUTOASSIGN ] = def;
701 QVariant v = myProperties[ curve ][ PROP_AUTOASSIGN ];
702 if ( v.isValid() && v.type() == QVariant::Bool ) val = v.toBool();