Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/gui.git] / src / Plot2d / Plot2d_SetupViewDlg.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : Plot2d_SetupViewDlg.cxx
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
24 //
25 #include "Plot2d_SetupViewDlg.h"
26
27 #include <SUIT_Session.h>
28 #include <SUIT_Application.h>
29 #include <QtxColorButton.h>
30
31 #include <QCheckBox>
32 #include <QLineEdit>
33 #include <QComboBox>
34 #include <QSpinBox>
35 #include <QGridLayout>
36 #include <QHBoxLayout>
37 #include <QGroupBox>
38 #include <QLabel>
39 #include <QPushButton>
40 #include <QTabWidget>
41
42 const int MARGIN_SIZE     = 11;
43 const int SPACING_SIZE    = 6;
44 const int MIN_EDIT_WIDTH  = 200;
45 const int MIN_COMBO_WIDTH = 100;
46 const int MIN_SPIN_WIDTH  = 70;
47
48 /*!
49   \class Plot2d_SetupViewDlg
50   \brief Dialog box to setup Plot2d view window.
51 */
52
53 /*!
54   \brief Constructor.
55   \param parent parent widget
56   \param showDefCheck if \c true, show "Set settings as default" check box
57   \param secondAxisY if \c true, show widgets for the second (right) vertical axis
58 */
59 Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, 
60                                           bool showDefCheck, 
61                                           bool secondAxisY )
62 : QDialog( parent ), 
63   mySecondAxisY( secondAxisY )
64 {
65   setModal( true );
66   setWindowTitle( tr("TLT_SETUP_PLOT2D_VIEW") );
67   setSizeGripEnabled( TRUE );
68
69   QGridLayout* topLayout = new QGridLayout( this ); 
70   topLayout->setSpacing( SPACING_SIZE );
71   topLayout->setMargin( MARGIN_SIZE );
72   
73   // main title
74   myTitleCheck = new QCheckBox( tr( "PLOT2D_ENABLE_MAIN_TITLE" ), this );
75   myTitleEdit  = new QLineEdit( this );
76   myTitleEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
77   myTitleEdit->setMinimumWidth( MIN_EDIT_WIDTH );
78
79   // curve type : points, lines, spline
80   QLabel* aCurveLab = new QLabel( tr( "PLOT2D_CURVE_TYPE_LBL" ), this );
81   myCurveCombo      = new QComboBox( this );
82   myCurveCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
83   myCurveCombo->setMinimumWidth( MIN_COMBO_WIDTH );
84   myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_POINTS" ) );
85   myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_LINES" ) );
86   myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_SPLINE" ) );
87
88   // legend
89   myLegendCheck = new QCheckBox( tr( "PLOT2D_ENABLE_LEGEND" ), this );
90   myLegendCombo = new QComboBox( this );
91   myLegendCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
92   myLegendCombo->setMinimumWidth( MIN_COMBO_WIDTH );
93   myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_LEFT" ) );
94   myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_RIGHT" ) );
95   myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_TOP" ) );
96   myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_BOTTOM" ) );
97
98   // marker size
99   QLabel* aMarkerLab  = new QLabel( tr( "PLOT2D_MARKER_SIZE_LBL" ), this );
100   myMarkerSpin = new QSpinBox( this );
101   myMarkerSpin->setMinimum( 0 );
102   myMarkerSpin->setMaximum( 100 );
103   myMarkerSpin->setSingleStep( 1 );
104   myMarkerSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
105   myMarkerSpin->setMinimumWidth( MIN_SPIN_WIDTH );
106
107   // background color
108   QLabel* aBGLab  = new QLabel( tr( "PLOT2D_BACKGROUND_COLOR_LBL" ), this );
109   myBackgroundBtn = new QtxColorButton( this );
110
111   // scale mode
112   QGroupBox* aScaleGrp = new QGroupBox( tr( "PLOT2D_SCALE_TLT" ), this );
113   QGridLayout* aScaleLayout = new QGridLayout( aScaleGrp );
114   aScaleLayout->setMargin( MARGIN_SIZE ); aScaleLayout->setSpacing( SPACING_SIZE );
115   aScaleGrp->setLayout( aScaleLayout );
116
117   QLabel* xScaleLab = new QLabel( tr( "PLOT2D_SCALE_MODE_HOR" ), aScaleGrp );
118   myXModeCombo = new QComboBox( aScaleGrp );
119   myXModeCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
120   myXModeCombo->setMinimumWidth( MIN_COMBO_WIDTH );
121   myXModeCombo->addItem( tr( "PLOT2D_SCALE_MODE_LINEAR" ) );
122   myXModeCombo->addItem( tr( "PLOT2D_SCALE_MODE_LOGARITHMIC" ) );
123
124   QLabel* yScaleLab = new QLabel( tr( "PLOT2D_SCALE_MODE_VER" ), aScaleGrp );
125   myYModeCombo = new QComboBox( aScaleGrp );
126   myYModeCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
127   myYModeCombo->setMinimumWidth( MIN_COMBO_WIDTH );
128   myYModeCombo->addItem( tr( "PLOT2D_SCALE_MODE_LINEAR" ) );
129   myYModeCombo->addItem( tr( "PLOT2D_SCALE_MODE_LOGARITHMIC" ) );
130
131   aScaleLayout->addWidget( xScaleLab,    0, 0 );
132   aScaleLayout->addWidget( myXModeCombo, 0, 1 );
133   aScaleLayout->addWidget( yScaleLab,    0, 2 );
134   aScaleLayout->addWidget( myYModeCombo, 0, 3 );
135
136   // tab widget for choose properties of axis 
137   QTabWidget* aTabWidget = new QTabWidget( this );
138
139   // widget for parameters on Ox
140   QWidget* aXWidget = new QWidget(aTabWidget);
141   QGridLayout* aXLayout = new QGridLayout( aXWidget ); 
142   aXLayout->setSpacing( SPACING_SIZE );
143   aXLayout->setMargin( MARGIN_SIZE );
144
145   // axis title
146   myTitleXCheck = new QCheckBox( tr( "PLOT2D_ENABLE_HOR_TITLE" ), aXWidget );
147   myTitleXEdit  = new QLineEdit( aXWidget );
148   myTitleXEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
149   myTitleXEdit->setMinimumWidth( MIN_EDIT_WIDTH );
150   aXLayout->addWidget( myTitleXCheck,1,    0    );
151   aXLayout->addWidget( myTitleXEdit, 1, 1, 1, 3 );
152
153   // grid
154   QGroupBox* aGridGrpX = new QGroupBox( tr( "PLOT2D_GRID_TLT" ), aXWidget );
155   QGridLayout* aGridLayoutX = new QGridLayout( aGridGrpX );
156   aGridLayoutX->setMargin( MARGIN_SIZE ); 
157   aGridLayoutX->setSpacing( SPACING_SIZE );
158
159   myXGridCheck      = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_HOR_MAJOR" ), aGridGrpX );
160
161   QLabel* aXMajLbl  = new QLabel( tr( "PLOT2D_MAX_INTERVALS" ), aGridGrpX);
162   myXGridSpin       = new QSpinBox( aGridGrpX );
163   myXGridSpin->setMinimum( 1 );
164   myXGridSpin->setMaximum( 100 );
165   myXGridSpin->setSingleStep( 1 );
166   myXGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
167   myXGridSpin->setMinimumWidth( MIN_SPIN_WIDTH );
168   
169   myXMinGridCheck      = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_HOR_MINOR" ), aGridGrpX );
170   
171   QLabel* aXMinLbl     = new QLabel( tr( "PLOT2D_MAX_INTERVALS" ), aGridGrpX);
172   myXMinGridSpin       = new QSpinBox( aGridGrpX );
173   myXMinGridSpin->setMinimum( 1 );
174   myXMinGridSpin->setMaximum( 100 );
175   myXMinGridSpin->setSingleStep( 1 );
176   myXMinGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
177   myXMinGridSpin->setMinimumWidth( MIN_SPIN_WIDTH );
178
179   aGridLayoutX->addWidget( myXGridCheck,    0, 0 );
180   aGridLayoutX->addWidget( aXMajLbl,        0, 1 );
181   aGridLayoutX->addWidget( myXGridSpin,     0, 2 );
182   aGridLayoutX->addWidget( myXMinGridCheck, 1, 0 );
183   aGridLayoutX->addWidget( aXMinLbl,        1, 1 );
184   aGridLayoutX->addWidget( myXMinGridSpin,  1, 2 );
185   aXLayout->addWidget( aGridGrpX, 3, 0, 1, 4 );
186
187   aTabWidget->addTab( aXWidget, tr( "INF_AXES_X" ) );
188
189   // widget for parameters on Oy
190   QWidget* aYWidget = new QWidget(aTabWidget);
191   QGridLayout* aYLayout = new QGridLayout( aYWidget ); 
192   aYLayout->setSpacing( SPACING_SIZE );
193   aYLayout->setMargin( MARGIN_SIZE );
194
195   // axis title
196   myTitleYCheck = new QCheckBox( tr( "PLOT2D_ENABLE_VER_TITLE" ), aYWidget );
197   myTitleYEdit  = new QLineEdit( aYWidget );
198   myTitleYEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
199   myTitleYEdit->setMinimumWidth( MIN_EDIT_WIDTH );
200   aYLayout->addWidget( myTitleYCheck,1,    0    );
201   aYLayout->addWidget( myTitleYEdit, 1, 1, 1, 3 );
202
203   // grid
204   QGroupBox* aGridGrpY = new QGroupBox( tr( "PLOT2D_GRID_TLT" ), aYWidget );
205   QGridLayout* aGridLayoutY = new QGridLayout( aGridGrpY );
206   aGridGrpY->setLayout( aGridLayoutY );
207   aGridLayoutY->setMargin( MARGIN_SIZE ); aGridLayoutY->setSpacing( SPACING_SIZE );
208
209   myYGridCheck      = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_VER_MAJOR" ), aGridGrpY );
210
211   QLabel* aYMajLbl  = new QLabel( tr( "PLOT2D_MAX_INTERVALS" ), aGridGrpY);
212   myYGridSpin       = new QSpinBox( aGridGrpY );
213   myYGridSpin->setMinimum( 1 );
214   myYGridSpin->setMaximum( 100 );
215   myYGridSpin->setSingleStep( 1 );
216   myYGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
217   myYGridSpin->setMinimumWidth( MIN_SPIN_WIDTH );
218
219   myYMinGridCheck      = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_VER_MINOR" ), aGridGrpY );
220
221   QLabel* aYMinLbl     = new QLabel( tr( "PLOT2D_MAX_INTERVALS" ), aGridGrpY);
222   myYMinGridSpin       = new QSpinBox( aGridGrpY );
223   myYMinGridSpin->setMinimum( 1 );
224   myYMinGridSpin->setMaximum( 100 );
225   myYMinGridSpin->setSingleStep( 1 );
226   myYMinGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
227   myYMinGridSpin->setMinimumWidth( MIN_SPIN_WIDTH );
228
229   aGridLayoutY->addWidget( myYGridCheck,    0, 0 );
230   aGridLayoutY->addWidget( aYMajLbl,        0, 1 );
231   aGridLayoutY->addWidget( myYGridSpin,     0, 2 );
232   aGridLayoutY->addWidget( myYMinGridCheck, 1, 0 );
233   aGridLayoutY->addWidget( aYMinLbl,        1, 1 );
234   aGridLayoutY->addWidget( myYMinGridSpin,  1, 2 );
235   aYLayout->addWidget( aGridGrpY, 3, 0, 1, 4 );
236
237   aTabWidget->addTab( aYWidget, tr( "INF_AXES_Y_LEFT" ) );
238
239   // if exist second axis Oy, addition new tab widget for right axis
240   if ( mySecondAxisY ) {
241     // widget for parameters on Oy
242     QWidget* aYWidget2 = new QWidget( aTabWidget );
243     QGridLayout* aYLayout2 = new QGridLayout( aYWidget2 );
244     aYLayout2->setSpacing( SPACING_SIZE );
245     aYLayout2->setMargin( MARGIN_SIZE );
246
247     // axis title
248     myTitleY2Check = new QCheckBox( tr( "PLOT2D_ENABLE_VER_TITLE" ), aYWidget2 );
249     myTitleY2Edit  = new QLineEdit( aYWidget2 );
250     myTitleY2Edit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
251     myTitleY2Edit->setMinimumWidth( MIN_EDIT_WIDTH );
252     aYLayout2->addWidget( myTitleY2Check,1,    0    );
253     aYLayout2->addWidget( myTitleY2Edit, 1, 1, 1, 3 );
254
255     // grid
256     QGroupBox* aGridGrpY2 = new QGroupBox( tr( "PLOT2D_GRID_TLT" ), aYWidget2 );
257     QGridLayout* aGridLayoutY2 = new QGridLayout( aGridGrpY2 );
258     aGridGrpY2->setLayout( aGridLayoutY2 );
259     aGridLayoutY2->setMargin( MARGIN_SIZE ); aGridLayoutY2->setSpacing( SPACING_SIZE );
260
261     myY2GridCheck      = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_VER_MAJOR" ), aGridGrpY2 );
262
263     QLabel* aY2MajLbl  = new QLabel( tr( "PLOT2D_MAX_INTERVALS" ), aGridGrpY2);
264     myY2GridSpin       = new QSpinBox( aGridGrpY2 );
265     myY2GridSpin->setMinimum( 1 );
266     myY2GridSpin->setMaximum( 100 );
267     myY2GridSpin->setSingleStep( 1 );
268     myY2GridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
269     myY2GridSpin->setMinimumWidth( MIN_SPIN_WIDTH );
270
271     myY2MinGridCheck      = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_VER_MINOR" ), aGridGrpY2 );
272
273     QLabel* aY2MinLbl     = new QLabel( tr( "PLOT2D_MAX_INTERVALS" ), aGridGrpY2);
274     myY2MinGridSpin       = new QSpinBox( aGridGrpY2 );
275     myY2MinGridSpin->setMinimum( 1 );
276     myY2MinGridSpin->setMaximum( 100 );
277     myY2MinGridSpin->setSingleStep( 1 );
278     myY2MinGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
279     myY2MinGridSpin->setMinimumWidth( MIN_SPIN_WIDTH );
280
281     aGridLayoutY2->addWidget( myY2GridCheck,    0, 0 );
282     aGridLayoutY2->addWidget( aY2MajLbl,        0, 1 );
283     aGridLayoutY2->addWidget( myY2GridSpin,     0, 2 );
284     aGridLayoutY2->addWidget( myY2MinGridCheck, 1, 0 );
285     aGridLayoutY2->addWidget( aY2MinLbl,        1, 1 );
286     aGridLayoutY2->addWidget( myY2MinGridSpin,  1, 2 );
287     aYLayout2->addWidget( aGridGrpY2, 3, 0, 1, 4 );
288
289     aTabWidget->addTab( aYWidget2, tr( "INF_AXES_Y_RIGHT" ) );
290   }
291   else {
292     myTitleY2Check   = 0;
293     myTitleY2Edit    = 0;
294     myY2GridCheck    = 0;
295     myY2GridSpin     = 0;
296     myY2MinGridCheck = 0;
297     myY2MinGridSpin  = 0;
298     myY2ModeCombo    = 0;
299   }
300
301   aTabWidget->setCurrentIndex( 0 );
302   /* "Set as default" check box */
303
304   myDefCheck = new QCheckBox( tr( "PLOT2D_SET_AS_DEFAULT_CHECK" ), this );
305
306   /* OK/Cancel buttons */
307   myOkBtn = new QPushButton( tr( "BUT_OK" ), this );
308   myOkBtn->setAutoDefault( TRUE );
309   myOkBtn->setDefault( TRUE );
310   myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this );
311   myCancelBtn->setAutoDefault( TRUE );
312   myHelpBtn = new QPushButton( tr( "BUT_HELP" ), this );
313   myHelpBtn->setAutoDefault( TRUE );
314   QHBoxLayout* btnLayout = new QHBoxLayout;
315   btnLayout->addWidget( myOkBtn );
316   btnLayout->addStretch();
317   btnLayout->addWidget( myCancelBtn );
318   btnLayout->addWidget( myHelpBtn );
319   
320   // layout widgets
321   topLayout->addWidget( myTitleCheck,  0,    0    );
322   topLayout->addWidget( myTitleEdit,   0, 1, 1, 3 );
323   topLayout->addWidget( aCurveLab,     1,    0    );
324   topLayout->addWidget( myCurveCombo,  1,    1    );
325   topLayout->addWidget( myLegendCheck, 1,    2    );
326   topLayout->addWidget( myLegendCombo, 1,    3    );
327   topLayout->addWidget( aMarkerLab,    2,    0    );
328   topLayout->addWidget( myMarkerSpin,  2,    1    );
329   QHBoxLayout* bgLayout = new QHBoxLayout;
330   bgLayout->addWidget( myBackgroundBtn ); bgLayout->addStretch();
331   topLayout->addWidget( aBGLab,        2,    2    );
332   topLayout->addLayout( bgLayout,      2,    3    );
333   topLayout->addWidget( aScaleGrp,     3, 0, 1, 4 );
334   topLayout->addWidget( aTabWidget,    4, 0, 1, 4 );
335   topLayout->addWidget( myDefCheck,    5, 0, 1, 4 );
336   topLayout->setRowStretch( 5, 5 );
337
338   topLayout->addLayout( btnLayout,     6, 0, 1, 4 );
339   
340   if ( !showDefCheck )
341     myDefCheck->hide();
342
343   connect( myTitleCheck,    SIGNAL( clicked() ), this, SLOT( onMainTitleChecked() ) );
344   connect( myTitleXCheck,   SIGNAL( clicked() ), this, SLOT( onXTitleChecked() ) );
345   connect( myTitleYCheck,   SIGNAL( clicked() ), this, SLOT( onYTitleChecked() ) );
346   connect( myLegendCheck,   SIGNAL( clicked() ), this, SLOT( onLegendChecked() ) );
347   connect( myXGridCheck,    SIGNAL( clicked() ), this, SLOT( onXGridMajorChecked() ) );
348   connect( myYGridCheck,    SIGNAL( clicked() ), this, SLOT( onYGridMajorChecked() ) );
349   connect( myXMinGridCheck, SIGNAL( clicked() ), this, SLOT( onXGridMinorChecked() ) );
350   connect( myYMinGridCheck, SIGNAL( clicked() ), this, SLOT( onYGridMinorChecked() ) );
351
352   connect( myOkBtn,         SIGNAL( clicked() ), this, SLOT( accept() ) );
353   connect( myCancelBtn,     SIGNAL( clicked() ), this, SLOT( reject() ) );
354   connect( myHelpBtn,       SIGNAL( clicked() ), this, SLOT( onHelp() ) );
355   
356   if ( mySecondAxisY ) {
357     connect( myTitleY2Check,   SIGNAL( clicked() ), this, SLOT( onY2TitleChecked() ) );
358     connect( myY2GridCheck,    SIGNAL( clicked() ), this, SLOT( onY2GridMajorChecked() ) );
359     connect( myY2MinGridCheck, SIGNAL( clicked() ), this, SLOT( onY2GridMinorChecked() ) );
360   }
361
362   // init fields
363   setBackgroundColor( Qt::gray );
364   onMainTitleChecked();
365   onXTitleChecked();
366   onYTitleChecked();
367   onLegendChecked();
368   onXGridMajorChecked();
369   onYGridMajorChecked();
370   onXGridMinorChecked();
371   if ( mySecondAxisY ) {
372     onY2TitleChecked();
373     onY2GridMajorChecked();
374     onY2GridMinorChecked();
375   }
376 }
377
378 /*!
379   \brief Destructor.
380 */
381 Plot2d_SetupViewDlg::~Plot2d_SetupViewDlg()
382 {
383 }
384
385 /*!
386   \brief Set main title attributes.
387   \param enable if \c true main title is enabled
388   \param title main title
389   \sa isMainTitleEnabled(), getMainTitle()
390 */
391 void Plot2d_SetupViewDlg::setMainTitle( bool enable, const QString& title )
392 {
393   myTitleCheck->setChecked( enable );
394   if ( !title.isNull() )
395     myTitleEdit->setText( title );
396   onMainTitleChecked();
397 }
398
399 /*!
400   \brief Check if main title is enabled.
401   \return \c true if main title is enabled
402   \sa setMainTitle()
403 */
404 bool Plot2d_SetupViewDlg::isMainTitleEnabled()
405 {
406   return myTitleCheck->isChecked();
407 }
408
409 /*!
410   \brief Get main title.
411   \return main title
412   \sa setMainTitle()
413 */
414 QString Plot2d_SetupViewDlg::getMainTitle()
415 {
416   return myTitleEdit->text();
417 }
418
419 /*!
420   \brief Set horizontal axis title attributes.
421   \param enable if \c true horizontal axis title is enabled
422   \param title horizontal axis title
423   \sa isXTitleEnabled(), getXTitle()
424 */
425 void Plot2d_SetupViewDlg::setXTitle( bool enable, const QString& title )
426 {
427   myTitleXCheck->setChecked( enable );
428   if ( !title.isNull() )
429     myTitleXEdit->setText( title );
430   onXTitleChecked();
431 }
432
433 /*!
434   \brief Check if main title is enabled.
435   \return \c true if horizontal axis title is enabled
436   \sa setXTitle()
437 */
438 bool Plot2d_SetupViewDlg::isXTitleEnabled()
439 {
440   return myTitleXCheck->isChecked();
441 }
442
443 /*!
444   \brief Get horizontal axis title.
445   \return horizontal axis title
446   \sa setXTitle()
447 */
448 QString Plot2d_SetupViewDlg::getXTitle()
449 {
450   return myTitleXEdit->text();
451 }
452
453 /*!
454   \brief Set left vertical axis title attributes.
455   \param enable if \c true left vertical axis title is enabled
456   \param title left vertical axis title
457   \sa setY2Title(), isYTitleEnabled(), getYTitle()
458 */
459 void Plot2d_SetupViewDlg::setYTitle( bool enable, const QString& title )
460 {
461   myTitleYCheck->setChecked( enable );
462   if ( !title.isNull() )
463     myTitleYEdit->setText( title );
464   onYTitleChecked();
465 }
466
467 /*!
468   \brief Set right vertical axis title attributes.
469   \param enable if \c true right vertical axis title is enabled
470   \param title right vertical axis title
471   \sa setYTitle(), isY2TitleEnabled(), getY2Title()
472 */
473 void Plot2d_SetupViewDlg::setY2Title( bool enable, const QString& title )
474 {
475   myTitleY2Check->setChecked( enable );
476   if ( !title.isNull() )
477     myTitleY2Edit->setText( title );
478   onY2TitleChecked();
479 }
480
481 /*!
482   \brief Check if left vertical axis title is enabled.
483   \return \c true if right vertical axis title is enabled
484   \sa setYTitle()
485 */
486 bool Plot2d_SetupViewDlg::isYTitleEnabled()
487 {
488   return myTitleYCheck->isChecked();
489 }
490
491 /*!
492   \brief Check if right vertical axis title is enabled.
493   \return \c true if right vertical axis title is enabled
494   \sa setY2Title()
495 */
496 bool Plot2d_SetupViewDlg::isY2TitleEnabled()
497 {
498   return myTitleY2Check->isChecked();
499 }
500
501 /*!
502   \brief Get left vertical axis title.
503   \return left vertical axis title
504   \sa setYTitle()
505 */
506 QString Plot2d_SetupViewDlg::getYTitle()
507 {
508   return myTitleYEdit->text();
509 }
510
511 /*!
512   \brief Get right vertical axis title.
513   \return right vertical axis title
514   \sa setY2Title()
515 */
516 QString Plot2d_SetupViewDlg::getY2Title()
517 {
518   return myTitleY2Edit->text();
519 }
520
521 /*!
522   \brief Set curve type.
523   \param type curve type: 0 (points), 1 (lines) or 2 (splines)
524   \sa getCurveType()
525 */
526 void Plot2d_SetupViewDlg::setCurveType( const int type )
527 {
528   myCurveCombo->setCurrentIndex( type );
529 }
530
531 /*!
532   \brief Get curve type.
533   \return curve type: 0 (points), 1 (lines) or 2 (splines)
534   \sa setCurveType()
535 */
536 int Plot2d_SetupViewDlg::getCurveType()
537 {
538   return myCurveCombo->currentIndex();
539 }
540
541 /*!
542   \brief Set legend attribute.
543   \param if \c true legend is shown
544   \param pos legend position: 0 (left), 1 (right), 2 (top), 3 (bottom)
545   \sa isLegendEnabled(), getLegendPos()
546 */
547 void Plot2d_SetupViewDlg::setLegend( bool enable, int pos )
548 {
549   myLegendCheck->setChecked( enable );
550   myLegendCombo->setCurrentIndex( pos );
551   onLegendChecked();
552 }
553
554 /*!
555   \brief Check if legend is enabled.
556   \return \c true if legend is enabled
557   \sa setLegend()
558 */
559 bool Plot2d_SetupViewDlg::isLegendEnabled()
560 {
561   return myLegendCheck->isChecked();
562 }
563
564 /*!
565   \brief Get legend position.
566   \return legend position: 0 (left), 1 (right), 2 (top), 3 (bottom)
567   \sa setLegend()
568 */
569 int Plot2d_SetupViewDlg::getLegendPos()
570 {
571   return myLegendCombo->currentIndex();
572 }
573
574 /*!
575   \brief Set marker size.
576   \param size marker size
577   \sa getMarkerSize()
578 */
579 void Plot2d_SetupViewDlg::setMarkerSize( const int size )
580 {
581   myMarkerSpin->setValue( size );
582 }
583
584 /*!
585   \brief Get marker size.
586   \return marker size
587   \sa setMarkerSize()
588 */
589 int Plot2d_SetupViewDlg::getMarkerSize()
590 {
591   return myMarkerSpin->value();
592 }
593
594 /*!
595   \brief Set background color.
596   \param color background color
597   \sa getBackgroundColor()
598 */
599 void Plot2d_SetupViewDlg::setBackgroundColor( const QColor& color )
600 {
601   myBackgroundBtn->setColor( color );
602 }
603
604 /*!
605   \brief Get background color.
606   \return background color
607   \sa setBackgroundColor()
608 */
609 QColor Plot2d_SetupViewDlg::getBackgroundColor()
610 {
611   return myBackgroundBtn->color();
612 }
613
614 /*!
615   \brief Set major grid parameters.
616   \param enableX if \c true, horizontal major grid is enabled
617   \param divX maximum number of ticks for horizontal major grid
618   \param enableY if \c true, left vertical major grid is enabled
619   \param divY maximum number of ticks for left vertical major grid
620   \param enableY2 if \c true, right vertical major grid is enabled
621   \param divY2 maximum number of ticks for right vertical major grid
622   \sa getMajorGrid()
623 */
624 void Plot2d_SetupViewDlg::setMajorGrid( bool enableX, const int divX,
625                                         bool enableY, const int divY,
626                                         bool enableY2, const int divY2 )
627 {
628   myXGridCheck->setChecked( enableX );
629   myXGridSpin->setValue( divX );
630   myYGridCheck->setChecked( enableY );
631   myYGridSpin->setValue( divY );
632   onXGridMajorChecked();
633   onYGridMajorChecked();
634   if (mySecondAxisY) {
635     myY2GridCheck->setChecked( enableY2 );
636     myY2GridSpin->setValue( divY2 );
637     onY2GridMajorChecked();
638   }
639 }
640
641 /*!
642   \brief Get major grid parameters.
643   \param enableX \c true if horizontal major grid is enabled
644   \param divX maximum number of ticks for horizontal major grid
645   \param enableY \c true if left vertical major grid is enabled
646   \param divY maximum number of ticks for left vertical major grid
647   \param enableY2 \c true if right vertical major grid is enabled
648   \param divY2 maximum number of ticks for right vertical major grid
649   \sa setMajorGrid()
650 */
651 void Plot2d_SetupViewDlg::getMajorGrid( bool& enableX, int& divX,
652                                         bool& enableY, int& divY,
653                                         bool& enableY2, int& divY2 )
654 {
655   enableX  = myXGridCheck->isChecked();
656   divX     = myXGridSpin->value();
657   enableY  = myYGridCheck->isChecked();
658   divY     = myYGridSpin->value();
659   if (mySecondAxisY) {
660     enableY2 = myY2GridCheck->isChecked();
661     divY2    = myY2GridSpin->value();
662   }
663   else {
664     enableY2 = false;
665     divY2    = 1;
666   }
667 }
668
669 /*!
670   \brief Set minor grid parameters.
671   \param enableX if \c true, horizontal minor grid is enabled
672   \param divX maximum number of ticks for horizontal minor grid
673   \param enableY if \c true, left vertical minor grid is enabled
674   \param divY maximum number of ticks for left vertical minor grid
675   \param enableY2 if \c true, right vertical minor grid is enabled
676   \param divY2 maximum number of ticks for right vertical minor grid
677   \sa getMinorGrid()
678 */
679 void Plot2d_SetupViewDlg::setMinorGrid( bool enableX, const int divX,
680                                         bool enableY, const int divY,
681                                         bool enableY2, const int divY2 )
682 {
683   myXMinGridCheck->setChecked( enableX );
684   myXMinGridSpin->setValue( divX );
685   myYMinGridCheck->setChecked( enableY );
686   myYMinGridSpin->setValue( divY );
687   onXGridMinorChecked();
688   onYGridMinorChecked();
689   if (mySecondAxisY) {
690     myY2MinGridCheck->setChecked( enableY2 );
691     myY2MinGridSpin->setValue( divY2 );
692     onY2GridMinorChecked();
693   }
694 }
695
696 /*!
697   \brief Get minor grid parameters.
698   \param enableX \c true if horizontal minor grid is enabled
699   \param divX maximum number of ticks for horizontal minor grid
700   \param enableY \c true if left vertical minor grid is enabled
701   \param divY maximum number of ticks for left vertical minor grid
702   \param enableY2 \c true if right vertical minor grid is enabled
703   \param divY2 maximum number of ticks for right vertical minor grid
704   \sa setMinorGrid()
705 */
706 void Plot2d_SetupViewDlg::getMinorGrid( bool& enableX, int& divX,
707                                         bool& enableY, int& divY,
708                                         bool& enableY2, int& divY2 )
709 {
710   enableX  = myXMinGridCheck->isChecked();
711   divX     = myXMinGridSpin->value();
712   enableY  = myYMinGridCheck->isChecked();
713   divY     = myYMinGridSpin->value();
714   if ( mySecondAxisY ) {
715     enableY2 = myY2MinGridCheck->isChecked();
716     divY2    = myY2MinGridSpin->value();
717   }
718   else {
719     enableY2 = false;
720     divY2    = 1;
721   }
722 }
723
724 /*!
725   \brief Set scale mode for horizontal and vertical axes.
726   \param xMode horizontal axis scale mode: 0 (linear), 1 (logarithmic)
727   \param yMode vertical axis scale mode: 0 (linear), 1 (logarithmic)
728   \sa getXScaleMode(), getYScaleMode()
729 */
730 void Plot2d_SetupViewDlg::setScaleMode( const int xMode, const int yMode )
731 {
732   myXModeCombo->setCurrentIndex( xMode );
733   myYModeCombo->setCurrentIndex( yMode );
734 }
735
736 /*!
737   \brief Get scale mode for horizontal axis.
738   \return horizontal axis scale mode: 0 (linear), 1 (logarithmic)
739   \sa setScaleMode()
740 */
741 int Plot2d_SetupViewDlg::getXScaleMode()
742 {
743   return myXModeCombo->currentIndex();
744 }
745
746 /*!
747   \brief Get scale mode for vertical axis.
748   \return vertical axis scale mode: 0 (linear), 1 (logarithmic)
749   \sa setScaleMode()
750 */
751 int  Plot2d_SetupViewDlg::getYScaleMode()
752 {
753   return myYModeCombo->currentIndex();
754 }
755
756 /*!
757   \brief Called when user clicks "Show main title" check box.
758 */
759 void Plot2d_SetupViewDlg::onMainTitleChecked()
760 {
761   myTitleEdit->setEnabled( myTitleCheck->isChecked() );
762 }
763
764 /*!
765   \brief Called when user clicks "Show horizontal axis title" check box.
766 */
767 void Plot2d_SetupViewDlg::onXTitleChecked()
768 {
769   myTitleXEdit->setEnabled( myTitleXCheck->isChecked() );
770 }
771
772 /*!
773   \brief Called when user clicks "Show vertical left axis title" check box.
774 */
775 void Plot2d_SetupViewDlg::onYTitleChecked()
776 {
777   myTitleYEdit->setEnabled( myTitleYCheck->isChecked() );
778 }
779
780 /*!
781   \brief Called when user clicks "Show vertical right axis title" check box.
782 */
783 void Plot2d_SetupViewDlg::onY2TitleChecked()
784 {
785   myTitleY2Edit->setEnabled( myTitleY2Check->isChecked() );
786 }
787
788 /*!
789   \brief Called when user clicks "Show Legend" check box.
790 */
791 void Plot2d_SetupViewDlg::onLegendChecked()
792 {
793   myLegendCombo->setEnabled( myLegendCheck->isChecked() );
794 }
795
796 /*!
797   \brief Called when user clicks "Enable horizontal major grid" check box.
798 */
799 void Plot2d_SetupViewDlg::onXGridMajorChecked()
800 {
801   myXMinGridCheck->setEnabled( myXGridCheck->isChecked() );
802 }
803
804 /*!
805   \brief Called when user clicks "Enable left vertical major grid" check box.
806 */
807 void Plot2d_SetupViewDlg::onYGridMajorChecked()
808 {
809   myYMinGridCheck->setEnabled( myYGridCheck->isChecked() );
810 }
811
812 /*!
813   \brief Called when user clicks "Enable right vertical major grid" check box.
814 */
815 void Plot2d_SetupViewDlg::onY2GridMajorChecked()
816 {
817   myY2MinGridCheck->setEnabled( myY2GridCheck->isChecked() );
818 }
819
820 /*!
821   \brief Called when user clicks "Enable horizontal minor grid" check box.
822 */
823 void Plot2d_SetupViewDlg::onXGridMinorChecked()
824 {
825 }
826
827 /*!
828   \brief Called when user clicks "Enable left vertical minor grid" check box.
829 */
830 void Plot2d_SetupViewDlg::onYGridMinorChecked()
831 {
832 }
833
834 /*!
835   \brief Called when user clicks "Enable right vertical minor grid" check box.
836 */
837 void Plot2d_SetupViewDlg::onY2GridMinorChecked()
838 {
839 }
840
841 /*!
842   \brief Get "Set settings as default" check box value.
843   \return \c true if "Set settings as default" check box is on
844 */
845 bool Plot2d_SetupViewDlg::isSetAsDefault()
846 {
847   return myDefCheck->isChecked();
848 }
849
850 /*!
851   Slot, called when user clicks "Help" button
852 */
853 void Plot2d_SetupViewDlg::onHelp()
854 {
855   SUIT_Application* app = SUIT_Session::session()->activeApplication();
856   if ( app )
857     app->onHelpContextModule( "GUI", "plot2d_viewer_page.html", "settings" );
858 }