Salome HOME
Redesign SALOME documentation
[modules/gui.git] / src / Plot2d / Plot2d_SetupViewDlg.cxx
index c15c7390cef5291e8ff5067cef42d45cefa0be92..d3275cc370c606f553bdb67ea659d49f7df75508 100755 (executable)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 //
 #include "Plot2d_SetupViewDlg.h"
 
+#ifndef NO_SUIT
 #include <SUIT_Session.h>
 #include <SUIT_Application.h>
+#endif
 #include <QtxColorButton.h>
 #include <QtxFontEdit.h>
 
@@ -58,20 +60,20 @@ const int MIN_SPIN_WIDTH  = 70;
   \param showDefCheck if \c true, show "Set settings as default" check box
   \param secondAxisY if \c true, show widgets for the second (right) vertical axis
 */
-Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, 
-                                          bool showDefCheck, 
+Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
+                                          bool showDefCheck,
                                           bool secondAxisY )
-: QDialog( parent ), 
+: QDialog( parent ),
   mySecondAxisY( secondAxisY )
 {
   setModal( true );
   setWindowTitle( tr("TLT_SETUP_PLOT2D_VIEW") );
-  setSizeGripEnabled( TRUE );
+  setSizeGripEnabled( true );
 
-  QGridLayout* topLayout = new QGridLayout( this ); 
+  QGridLayout* topLayout = new QGridLayout( this );
   topLayout->setSpacing( SPACING_SIZE );
   topLayout->setMargin( MARGIN_SIZE );
-  
+
   // main title
   myTitleCheck = new QCheckBox( tr( "PLOT2D_ENABLE_MAIN_TITLE" ), this );
   myTitleEdit  = new QLineEdit( this );
@@ -87,19 +89,6 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
   myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_LINES" ) );
   myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_SPLINE" ) );
 
-  // legend
-  myLegendCheck = new QCheckBox( tr( "PLOT2D_ENABLE_LEGEND" ), this );
-  myLegendCombo = new QComboBox( this );
-  myLegendFont = new QtxFontEdit( this );
-  myLegendColor = new QtxColorButton( this );
-  QLabel* aLegendFontLab = new QLabel( tr( "PLOT2D_LEGEND_FONT" ), this );
-  myLegendCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-  myLegendCombo->setMinimumWidth( MIN_COMBO_WIDTH );
-  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_LEFT" ) );
-  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_RIGHT" ) );
-  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_TOP" ) );
-  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_BOTTOM" ) );
-
   // marker size
   QLabel* aMarkerLab  = new QLabel( tr( "PLOT2D_MARKER_SIZE_LBL" ), this );
   myMarkerSpin = new QSpinBox( this );
@@ -113,6 +102,68 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
   QLabel* aBGLab  = new QLabel( tr( "PLOT2D_BACKGROUND_COLOR_LBL" ), this );
   myBackgroundBtn = new QtxColorButton( this );
 
+  // selection color
+  QLabel* aSelectionLab  = new QLabel( tr( "PLOT2D_SELECTION_COLOR_LBL" ), this );
+  mySelectionBtn = new QtxColorButton( this );
+
+  QHBoxLayout* ViewerColorLayout = new QHBoxLayout;
+  ViewerColorLayout->addWidget( aBGLab );
+  ViewerColorLayout->addWidget( myBackgroundBtn );
+  ViewerColorLayout->addStretch();
+  ViewerColorLayout->addWidget( aSelectionLab );
+  ViewerColorLayout->addWidget( mySelectionBtn );
+  ViewerColorLayout->addStretch();
+
+  // legend
+  QGroupBox* aLegendGrp = new QGroupBox( tr( "PLOT2D_LEGEND_GROUP" ), this );
+  QGridLayout* aLegendLayout = new QGridLayout( aLegendGrp );
+  aLegendLayout->setMargin( MARGIN_SIZE ); aLegendLayout->setSpacing( SPACING_SIZE );
+  aLegendGrp->setLayout( aLegendLayout );
+
+  myLegendCheck = new QCheckBox( tr( "PLOT2D_ENABLE_LEGEND" ), this );
+
+  QLabel* aLegendPosition = new QLabel( tr( "PLOT2D_LEGEND_POSITION" ), this );
+  myLegendCombo = new QComboBox( this );
+  myLegendCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myLegendCombo->setMinimumWidth( MIN_COMBO_WIDTH );
+  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_LEFT" ) );
+  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_RIGHT" ) );
+  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_TOP" ) );
+  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_BOTTOM" ) );
+
+  QLabel* aLegendSymbolType = new QLabel( tr( "PLOT2D_LEGEND_SYMBOL_TYPE" ), this );
+  myLegendSymbolType = new QComboBox( this );
+  myLegendSymbolType->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myLegendSymbolType->setMinimumWidth( MIN_COMBO_WIDTH );
+  myLegendSymbolType->addItem( tr( "PLOT2D_MARKER_ON_LINE" ) );
+  myLegendSymbolType->addItem( tr( "PLOT2D_MARKER_ABOVE_LINE" ) );
+
+  QLabel* aLegendFontLab = new QLabel( tr( "PLOT2D_LEGEND_FONT" ), this );
+  myLegendFont = new QtxFontEdit( this );
+
+  QLabel* aLegendFontColor = new QLabel( tr( "PLOT2D_LEGEND_FONT_COLOR" ), this );
+  myLegendFontColor = new QtxColorButton( this );
+
+  QLabel* aSelectLegendFontColor = new QLabel( tr( "PLOT2D_SELECTED_LEGEND_FONT_COLOR" ), this );
+  mySelectedLegendFontColor = new QtxColorButton( this );
+
+  QHBoxLayout* FontLayout = new QHBoxLayout;
+  FontLayout->addWidget( aLegendFontColor );
+  FontLayout->addWidget( myLegendFontColor );
+  FontLayout->addStretch();
+  FontLayout->addWidget( aSelectLegendFontColor );
+  FontLayout->addWidget( mySelectedLegendFontColor );
+  FontLayout->addStretch();
+
+  aLegendLayout->addWidget( myLegendCheck,      0, 0 );
+  aLegendLayout->addWidget( aLegendPosition,    1, 0 );
+  aLegendLayout->addWidget( myLegendCombo,      1, 1 );
+  aLegendLayout->addWidget( aLegendSymbolType,  2, 0 );
+  aLegendLayout->addWidget( myLegendSymbolType, 2, 1 );
+  aLegendLayout->addWidget( aLegendFontLab,     3, 0 );
+  aLegendLayout->addWidget( myLegendFont,       3, 1 );
+  aLegendLayout->addLayout( FontLayout,         4, 0, 1, 2 );
+
   //Deviation marker parameters
   QGroupBox* aDeviationGrp = new QGroupBox( tr( "PLOT2D_DEVIATION_MARKER_TLT" ), this );
   QHBoxLayout* aDeviationLayout = new QHBoxLayout(aDeviationGrp);
@@ -188,12 +239,12 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
   aScaleLayout->addWidget( yScaleLab,    0, 2 );
   aScaleLayout->addWidget( myYModeCombo, 0, 3 );
 
-  // tab widget for choose properties of axis 
+  // tab widget for choose properties of axis
   QTabWidget* aTabWidget = new QTabWidget( this );
 
   // widget for parameters on Ox
   QWidget* aXWidget = new QWidget(aTabWidget);
-  QGridLayout* aXLayout = new QGridLayout( aXWidget ); 
+  QGridLayout* aXLayout = new QGridLayout( aXWidget );
   aXLayout->setSpacing( SPACING_SIZE );
   aXLayout->setMargin( MARGIN_SIZE );
 
@@ -208,7 +259,7 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
   // grid
   QGroupBox* aGridGrpX = new QGroupBox( tr( "PLOT2D_GRID_TLT" ), aXWidget );
   QGridLayout* aGridLayoutX = new QGridLayout( aGridGrpX );
-  aGridLayoutX->setMargin( MARGIN_SIZE ); 
+  aGridLayoutX->setMargin( MARGIN_SIZE );
   aGridLayoutX->setSpacing( SPACING_SIZE );
 
   myXGridCheck      = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_HOR_MAJOR" ), aGridGrpX );
@@ -220,9 +271,9 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
   myXGridSpin->setSingleStep( 1 );
   myXGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
   myXGridSpin->setMinimumWidth( MIN_SPIN_WIDTH );
-  
+
   myXMinGridCheck      = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_HOR_MINOR" ), aGridGrpX );
-  
+
   QLabel* aXMinLbl     = new QLabel( tr( "PLOT2D_MAX_INTERVALS" ), aGridGrpX);
   myXMinGridSpin       = new QSpinBox( aGridGrpX );
   myXMinGridSpin->setMinimum( 1 );
@@ -243,7 +294,7 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
 
   // widget for parameters on Oy
   QWidget* aYWidget = new QWidget(aTabWidget);
-  QGridLayout* aYLayout = new QGridLayout( aYWidget ); 
+  QGridLayout* aYLayout = new QGridLayout( aYWidget );
   aYLayout->setSpacing( SPACING_SIZE );
   aYLayout->setMargin( MARGIN_SIZE );
 
@@ -360,44 +411,35 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
 
   /* OK/Cancel buttons */
   myOkBtn = new QPushButton( tr( "BUT_OK" ), this );
-  myOkBtn->setAutoDefault( TRUE );
-  myOkBtn->setDefault( TRUE );
+  myOkBtn->setAutoDefault( true );
+  myOkBtn->setDefault( true );
   myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this );
-  myCancelBtn->setAutoDefault( TRUE );
+  myCancelBtn->setAutoDefault( true );
   myHelpBtn = new QPushButton( tr( "BUT_HELP" ), this );
-  myHelpBtn->setAutoDefault( TRUE );
+  myHelpBtn->setAutoDefault( true );
   QHBoxLayout* btnLayout = new QHBoxLayout;
   btnLayout->addWidget( myOkBtn );
   btnLayout->addStretch();
   btnLayout->addWidget( myCancelBtn );
   btnLayout->addWidget( myHelpBtn );
-  
+
   // layout widgets
-  topLayout->addWidget( myTitleCheck,  0,    0    );
-  topLayout->addWidget( myTitleEdit,   0, 1, 1, 3 );
-  topLayout->addWidget( myLegendCheck, 1,    0    );
-  topLayout->addWidget( myLegendCombo, 1,    1    );
-  topLayout->addWidget( aCurveLab,  1,    2    );
-  topLayout->addWidget( myCurveCombo,  1,     3    );
-  topLayout->addWidget( aLegendFontLab,2,    0    );
-  topLayout->addWidget( myLegendFont,     2,    1    );
-  topLayout->addWidget( myLegendColor,  2,    2    );
-
-  topLayout->addWidget( aMarkerLab,    3,    0    );
-  topLayout->addWidget( myMarkerSpin,  3,    1    );
-  QHBoxLayout* bgLayout = new QHBoxLayout;
-  bgLayout->addWidget( myBackgroundBtn ); bgLayout->addStretch();
-  topLayout->addWidget( aBGLab,        3,    2    );
-  topLayout->addLayout( bgLayout,      3,    3    );
-  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 );
-  
+  topLayout->addWidget( myTitleCheck,      0, 0       );
+  topLayout->addWidget( myTitleEdit,       0, 1, 1, 3 );
+  topLayout->addWidget( aCurveLab,         1, 0       );
+  topLayout->addWidget( myCurveCombo,      1, 1       );
+  topLayout->addWidget( aMarkerLab,        2, 0       );
+  topLayout->addWidget( myMarkerSpin,      2, 1       );
+  topLayout->addLayout( ViewerColorLayout, 3, 0, 1, 4 );
+  topLayout->addWidget( aLegendGrp,        4, 0, 1, 4 );
+  topLayout->addWidget( aDeviationGrp,     5, 0, 1, 4 );
+  topLayout->addWidget( aNormalizeGrp,     6, 0, 1, 4 );
+  topLayout->addWidget( aScaleGrp,         7, 0, 1, 4 );
+  topLayout->addWidget( aTabWidget,        8, 0, 1, 4 );
+  topLayout->addWidget( myDefCheck,        9, 0, 1, 4 );
+  topLayout->setRowStretch( 10, 5 );
+  topLayout->addLayout( btnLayout,         11, 0, 1, 4 );
+
   if ( !showDefCheck )
     myDefCheck->hide();
 
@@ -418,7 +460,7 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
   connect( myOkBtn,         SIGNAL( clicked() ), this, SLOT( accept() ) );
   connect( myCancelBtn,     SIGNAL( clicked() ), this, SLOT( reject() ) );
   connect( myHelpBtn,       SIGNAL( clicked() ), this, SLOT( onHelp() ) );
-  
+
   if ( mySecondAxisY ) {
     connect( myTitleY2Check,   SIGNAL( clicked() ), this, SLOT( onY2TitleChecked() ) );
     connect( myY2GridCheck,    SIGNAL( clicked() ), this, SLOT( onY2GridMajorChecked() ) );
@@ -696,12 +738,15 @@ bool Plot2d_SetupViewDlg::getRMinNormMode()
   \param col legend font color
   \sa isLegendEnabled(), getLegendPos(), getLegendFont()
 */
-void Plot2d_SetupViewDlg::setLegend( bool enable, int pos, const QFont& fnt, const QColor& col )
+void Plot2d_SetupViewDlg::setLegend( bool enable, int pos, int symbolType,
+                                     const QFont& fnt, const QColor& fontColor, const QColor& selFontColor )
 {
   myLegendCheck->setChecked( enable );
   myLegendCombo->setCurrentIndex( pos );
+  myLegendSymbolType->setCurrentIndex( symbolType );
   myLegendFont->setCurrentFont( fnt );
-  myLegendColor->setColor( col );
+  myLegendFontColor->setColor( fontColor );
+  mySelectedLegendFontColor->setColor( selFontColor );
   onLegendChecked();
 }
 
@@ -725,6 +770,16 @@ int Plot2d_SetupViewDlg::getLegendPos()
   return myLegendCombo->currentIndex();
 }
 
+/*!
+  \brief Get legend symbol type.
+  \return legend symbol type: 0 (marker on line), 1 (marker above line)
+  \sa setLegend()
+*/
+int Plot2d_SetupViewDlg::getLegendSymbolType()
+{
+  return myLegendSymbolType->currentIndex();
+}
+
 /*!
   \brief Get legend font.
   \return legend font
@@ -742,7 +797,17 @@ QFont Plot2d_SetupViewDlg::getLegendFont()
 */
 QColor Plot2d_SetupViewDlg::getLegendColor()
 {
-  return myLegendColor->color();
+  return myLegendFontColor->color();
+}
+
+/*!
+  \brief Get selected legend font color.
+  \return selected legend font color
+  \sa setLegend()
+*/
+QColor Plot2d_SetupViewDlg::getSelectedLegendColor()
+{
+  return mySelectedLegendFontColor->color();
 }
 
 /*!
@@ -838,6 +903,26 @@ QColor Plot2d_SetupViewDlg::getBackgroundColor()
   return myBackgroundBtn->color();
 }
 
+/*!
+  \brief Set selection color.
+  \param color selection color
+  \sa getSelectionColor()
+*/
+void Plot2d_SetupViewDlg::setSelectionColor( const QColor& color )
+{
+  mySelectionBtn->setColor( color );
+}
+
+/*!
+  \brief Get selection color.
+  \return selection color
+  \sa setSelectionColor()
+*/
+QColor Plot2d_SetupViewDlg::getSelectionColor()
+{
+  return mySelectionBtn->color();
+}
+
 /*!
   \brief Set major grid parameters.
   \param enableX if \c true, horizontal major grid is enabled
@@ -1107,7 +1192,9 @@ bool Plot2d_SetupViewDlg::isSetAsDefault()
 */
 void Plot2d_SetupViewDlg::onHelp()
 {
+#ifndef NO_SUIT
   SUIT_Application* app = SUIT_Session::session()->activeApplication();
   if ( app )
-    app->onHelpContextModule( "GUI", "plot2d_viewer_page.html", "settings" );
+    app->onHelpContextModule( "GUI", "plot2d_viewer.html", "settings" );
+#endif
 }