Salome HOME
Update copyright information
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Preferences_ColorDlg.cxx
index 7d03f277971f3154a7b0fa844f746c322e335fc9..f31c5312f124ecf44db60113ec4b9d6be3ddeea8 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  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.
+// 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.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 // SMESH SMESHGUI : GUI for SMESH component
@@ -66,7 +66,7 @@ SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( SMESHGUI* theModul
     mySMESHGUI( theModule )
 {
   setModal( true );
-  setWindowTitle( tr( "Preferences - Set Color" ) );
+  setWindowTitle( tr( "Properties (color, line width, shrink size, ...)" ) );
   setSizeGripEnabled( true );
 
   // -------------------------------
@@ -80,15 +80,17 @@ SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( SMESHGUI* theModul
   ButtonGroup1Layout->setSpacing( SPACING );
   ButtonGroup1Layout->setMargin( MARGIN );
 
-  QLabel* TextLabel_Fill = new QLabel( tr( "Fill" ), ButtonGroup1 );
-  btnFillColor = new QtxColorButton( ButtonGroup1 );
+  QLabel* TextLabel_Fill = new QLabel( tr( "Surface color" ), ButtonGroup1 );
 
-  QLabel* TextLabel_BackFace = new QLabel( tr( "Back Face" ), ButtonGroup1 );
-  btnBackFaceColor = new QtxColorButton( ButtonGroup1 );
+  toolSurfColor = new QtxBiColorTool(ButtonGroup1);
+  toolSurfColor->setText( tr( "Back surface color" ));
 
-  QLabel* TextLabel_Outine = new QLabel( tr( "Outline" ), ButtonGroup1 );
+  QLabel* TextLabel_Outline = new QLabel( tr( "Outline color" ), ButtonGroup1 );
   btnOutlineColor = new QtxColorButton( ButtonGroup1 );
 
+  QLabel* TextLabel_Wireframe = new QLabel( tr( "Wireframe color" ), ButtonGroup1 );
+  btnWireframeColor = new QtxColorButton( ButtonGroup1 );
+
   QLabel* TextLabel_0DElements_Color = new QLabel( tr( "0D elements" ), ButtonGroup1 );
   btn0DElementsColor = new QtxColorButton( ButtonGroup1 );
 
@@ -100,10 +102,10 @@ SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( SMESHGUI* theModul
   SpinBox_0DElements_Size->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
   SpinBox_0DElements_Size->setButtonSymbols( QSpinBox::PlusMinus );
 
-  QLabel* TextLabel_Width = new QLabel( tr( "Width" ), ButtonGroup1 );
+  QLabel* TextLabel_Width = new QLabel( tr( "Line width" ), ButtonGroup1 );
   SpinBox_Width = new SalomeApp_IntSpinBox( ButtonGroup1 );
   SpinBox_Width->setAcceptNames( false ); // No Notebook variables allowed
-  SpinBox_Width->setRange( 0, 5 );
+  SpinBox_Width->setRange( 1, 5 );
   SpinBox_Width->setSingleStep( 1 );
   SpinBox_Width->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
   SpinBox_Width->setButtonSymbols( QSpinBox::PlusMinus );
@@ -117,15 +119,19 @@ SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( SMESHGUI* theModul
   SpinBox_Shrink->setButtonSymbols( QSpinBox::PlusMinus );
 
   ButtonGroup1Layout->addWidget( TextLabel_Fill,             0, 0 );
-  ButtonGroup1Layout->addWidget( btnFillColor,               0, 1 );
-  ButtonGroup1Layout->addWidget( TextLabel_BackFace,         0, 2 );
-  ButtonGroup1Layout->addWidget( btnBackFaceColor,           0, 3 );
-  ButtonGroup1Layout->addWidget( TextLabel_Outine,           1, 0 );
+  ButtonGroup1Layout->addWidget( toolSurfColor,              0, 1, 1, 3 );
+
+  ButtonGroup1Layout->addWidget( TextLabel_Outline,          1, 0 );
   ButtonGroup1Layout->addWidget( btnOutlineColor,            1, 1 );
-  ButtonGroup1Layout->addWidget( TextLabel_0DElements_Color, 1, 2 );
-  ButtonGroup1Layout->addWidget( btn0DElementsColor,         1, 3 );
-  ButtonGroup1Layout->addWidget( TextLabel_0DElements_Size,  2, 0 );
-  ButtonGroup1Layout->addWidget( SpinBox_0DElements_Size,    2, 1 );
+  ButtonGroup1Layout->addWidget( TextLabel_Wireframe,        1, 2 );
+  ButtonGroup1Layout->addWidget( btnWireframeColor,         1, 3 );
+
+  ButtonGroup1Layout->addWidget( TextLabel_0DElements_Color, 2, 0 );
+  ButtonGroup1Layout->addWidget( btn0DElementsColor,         2, 1 );
+
+  ButtonGroup1Layout->addWidget( TextLabel_0DElements_Size,  2, 2 );
+  ButtonGroup1Layout->addWidget( SpinBox_0DElements_Size,    2, 3 );
+
   ButtonGroup1Layout->addWidget( TextLabel_Width,            3, 0 );
   ButtonGroup1Layout->addWidget( SpinBox_Width,              3, 1 );
   ButtonGroup1Layout->addWidget( TextLabel_ShrinkCoeff,      3, 2 );
@@ -178,6 +184,23 @@ SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( SMESHGUI* theModul
   ButtonGroup3Layout->addWidget( SpinBox_Orientation_Scale,      0, 3 );
   ButtonGroup3Layout->addWidget( CheckBox_Orientation_3DVectors, 1, 0, 1, 4 );
 
+  // -------------------------------
+  QGroupBox* ButtonGroup4 = new QGroupBox( tr( "Selection" ), this );
+  QGridLayout* ButtonGroup4Layout = new QGridLayout( ButtonGroup4 );
+  ButtonGroup3Layout->setSpacing( SPACING );
+  ButtonGroup3Layout->setMargin( MARGIN );
+  
+  QLabel* TextLabel_Selection_Color = new QLabel( tr( "Selection color" ), ButtonGroup4 );
+  btnSelectionColor = new QtxColorButton( ButtonGroup4 );
+  
+  QLabel* TextLabel_Preselection_Color = new QLabel( tr( "Pre-selection color" ), ButtonGroup4 );
+  btnPreselectionColor = new QtxColorButton( ButtonGroup4 );
+  
+  ButtonGroup4Layout->addWidget( TextLabel_Selection_Color,      0, 0 );
+  ButtonGroup4Layout->addWidget( btnSelectionColor,              0, 1 );
+  ButtonGroup4Layout->addWidget( TextLabel_Preselection_Color,   0, 2 );
+  ButtonGroup4Layout->addWidget( btnPreselectionColor,           0, 3 );
+
   // -------------------------------
   QGroupBox* GroupButtons = new QGroupBox( this );
   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
@@ -204,6 +227,9 @@ SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( SMESHGUI* theModul
   topLayout->addWidget( ButtonGroup1 );
   topLayout->addWidget( ButtonGroup2 );
   topLayout->addWidget( ButtonGroup3 );
+  //  rnv: Selection and preselection colors are defined only in the Preferences 
+  //  topLayout->addWidget( ButtonGroup4 );
+  ButtonGroup4->hide();
   topLayout->addWidget( GroupButtons );
 
   // -------------------------------
@@ -309,12 +335,14 @@ void SMESHGUI_Preferences_ColorDlg::ActivateThisDialog()
 void SMESHGUI_Preferences_ColorDlg::SetColor( int type, const QColor& color )
 {
   switch ( type ) {
-  case 1 : btnFillColor->setColor( color );        break; // fill
-  case 2 : btnOutlineColor->setColor( color );     break; // outline
-  case 3 : btnNodeColor->setColor( color );        break; // node
-  case 4 : btnBackFaceColor->setColor( color );    break; // back face
-  case 5 : btn0DElementsColor->setColor( color );  break; // 0d elements
-  case 6 : btnOrientationColor->setColor( color ); break; // orientation of faces
+  case 1 : toolSurfColor->setMainColor( color );     break; // fill
+  case 2 : btnWireframeColor->setColor( color );     break; // wireframe
+  case 3 : btnNodeColor->setColor( color );          break; // node
+  case 4 : btnOutlineColor->setColor( color );       break; // outline
+  case 5 : btn0DElementsColor->setColor( color );    break; // 0d elements
+  case 6 : btnOrientationColor->setColor( color );   break; // orientation of faces
+  case 7 : btnSelectionColor->setColor( color );     break; // selection color
+  case 8 : btnPreselectionColor->setColor( color );  break; // pre-selection color
   default: break;
   }
 }
@@ -327,12 +355,15 @@ QColor SMESHGUI_Preferences_ColorDlg::GetColor( int type )
 {
   QColor color;
   switch ( type ) {
-  case 1 : color = btnFillColor->color();        break; // fill
-  case 2 : color = btnOutlineColor->color();     break; // outline
-  case 3 : color = btnNodeColor->color();        break; // node
-  case 4 : color = btnBackFaceColor->color();    break; // back face
-  case 5 : color = btn0DElementsColor->color();  break; // 0d elements
-  case 6 : color = btnOrientationColor->color(); break; // orientation of faces
+  case 1 : color = toolSurfColor->mainColor();    break; // fill
+  case 2 : color = btnWireframeColor->color();    break; // outline
+  case 3 : color = btnNodeColor->color();         break; // node
+  case 4 : color = btnOutlineColor->color();      break; // node
+  case 5 : color = btn0DElementsColor->color();   break; // 0d elements
+  case 6 : color = btnOrientationColor->color();  break; // orientation of faces
+  case 7 : color = btnSelectionColor->color();    break; // selection color
+  case 8 : color = btnPreselectionColor->color(); break; // pre-selection color
+
   default: break;
   }
   return color;
@@ -484,6 +515,23 @@ int SMESHGUI_Preferences_ColorDlg::getCustomMarkerID() const
   return MarkerWidget->getCustomMarkerID();
 }
 
+//=================================================================================
+// function : SetDeltaBrightness(int)
+// purpose  :
+//=================================================================================
+void SMESHGUI_Preferences_ColorDlg::SetDeltaBrightness(int delta) 
+{
+  toolSurfColor->setDelta(delta);
+}
+//=================================================================================
+// function : GetDeltaBrightness()
+// purpose  :
+//=================================================================================
+int SMESHGUI_Preferences_ColorDlg::GetDeltaBrightness() 
+{
+  return toolSurfColor->delta();
+}
+
 //=================================================================================
 // function : keyPressEvent()
 // purpose  :