-using namespace std;
-// File : SMESHGUI_Preferences_ColorDlg.cxx
-// Created : Mon Jun 17 19:11:27 2002
-// Author : Nicolas REJNERI
-
-// Project : SALOME
-// Module : SMESH
-// Copyright : Open CASCADE 2002
-// $Header$
-
+// Copyright (C) 2007-2011 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
+//
+// 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.
+//
+// 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
+//
+
+// SMESH SMESHGUI : GUI for SMESH component
+// File : SMESHGUI_Preferences_ColorDlg.cxx
+// Author : Nicolas REJNERI, Open CASCADE S.A.S.
+// SMESH includes
+//
#include "SMESHGUI_Preferences_ColorDlg.h"
+
#include "SMESHGUI.h"
+#include "SMESHGUI_SpinBox.h"
+#include "SMESHGUI_Utils.h"
+
+// SALOME GUI includes
+#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <QtxColorButton.h>
+#include <VTKViewer_MarkerWidget.h>
+#include <LightApp_Application.h>
+#include <SalomeApp_IntSpinBox.h>
+
+// Qt includes
+#include <QGroupBox>
+#include <QLabel>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QGridLayout>
+#include <QCheckBox>
+#include <QKeyEvent>
+
+#define SPACING 6
+#define MARGIN 11
-#include "utilities.h"
-
-#include <qbuttongroup.h>
-#include <qcheckbox.h>
-#include <qcombobox.h>
-#include <qframe.h>
-#include <qlabel.h>
-#include <qpixmap.h>
-#include <qpushbutton.h>
-#include <qlayout.h>
-#include <qcolordialog.h>
-#include <qspinbox.h>
-#include <qcolor.h>
-
-/*
- * Constructs a SMESHGUI_Preferences_ColorDlg which is a child of 'parent', with the
- * name 'name' and widget flags set to 'f'
- *
- * The dialog will by default be modeless, unless you set 'modal' to
- * TRUE to construct a modal dialog.
- */
-SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( QWidget* parent, const char* name )
- : QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+//=================================================================================
+// function : SMESHGUI_Preferences_ColorDlg()
+// purpose : Constructs a SMESHGUI_Preferences_ColorDlg which is a child
+// of 'parent', with the name 'name' and widget flags set to 'f'
+// The dialog will by default be modeless, unless you
+// set'modal' to true to construct a modal dialog.
+//=================================================================================
+SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( SMESHGUI* theModule )
+ : QDialog( SMESH::GetDesktop( theModule ) ),
+ mySMESHGUI( theModule )
{
- if ( !name )
- setName( "SMESHGUI_Preferences_ColorDlg" );
- setCaption( tr( "Preferences - Set Color" ) );
- setSizeGripEnabled( TRUE );
- QGridLayout* SMESHGUI_Preferences_ColorDlgLayout = new QGridLayout( this );
- SMESHGUI_Preferences_ColorDlgLayout->setSpacing( 6 );
- SMESHGUI_Preferences_ColorDlgLayout->setMargin( 11 );
-
- ButtonGroup1 = new QButtonGroup( tr( "Elements" ), this, "ButtonGroup1" );
- ButtonGroup1->setColumnLayout(0, Qt::Vertical );
- ButtonGroup1->layout()->setSpacing( 0 );
- ButtonGroup1->layout()->setMargin( 0 );
- QGridLayout* ButtonGroup1Layout = new QGridLayout( ButtonGroup1->layout() );
- ButtonGroup1Layout->setAlignment( Qt::AlignTop );
- ButtonGroup1Layout->setSpacing( 6 );
- ButtonGroup1Layout->setMargin( 11 );
-
- TextLabel_Fill = new QLabel( tr( "Fill" ), ButtonGroup1, "TextLabel_2D_Fill" );
- ButtonGroup1Layout->addWidget( TextLabel_Fill, 0, 0 );
-
- btnFillColor = new QPushButton( ButtonGroup1, "btnFillColor" );
- btnFillColor->setFixedSize( QSize( 25, 25 ) );
- ButtonGroup1Layout->addWidget( btnFillColor, 0, 1 );
-
- TextLabel_Outine = new QLabel( tr( "Outline" ), ButtonGroup1, "TextLabel_2D_Outine" );
- ButtonGroup1Layout->addWidget( TextLabel_Outine, 0, 2 );
-
- btnOutlineColor = new QPushButton( ButtonGroup1, "btnOutlineColor" );
- btnOutlineColor->setFixedSize( QSize( 25, 25 ) );
- ButtonGroup1Layout->addWidget( btnOutlineColor, 0, 3 );
-
- TextLabel_Width = new QLabel( tr( "Width" ), ButtonGroup1, "TextLabel_2D_Width" );
- ButtonGroup1Layout->addWidget( TextLabel_Width, 0, 4 );
-
- SpinBox_Width = new QSpinBox( 0, 5, 1, ButtonGroup1, "SpinBox_Width" );
- SpinBox_Width->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- SpinBox_Width->setWrapping( FALSE );
- SpinBox_Width->setButtonSymbols( QSpinBox::PlusMinus );
- ButtonGroup1Layout->addWidget( SpinBox_Width, 0, 5 );
-
- TextLabel_BackFace = new QLabel( tr( "Back Face" ), ButtonGroup1, "TextLabel_BackFace" );
- ButtonGroup1Layout->addWidget( TextLabel_BackFace, 1, 0 );
-
- btnBackFaceColor = new QPushButton( ButtonGroup1, "btnBackFaceColor" );
- btnBackFaceColor->setFixedSize( QSize( 25, 25 ) );
- ButtonGroup1Layout->addWidget( btnBackFaceColor, 1, 1 );
-
- TextLabel_ShrinkCoeff = new QLabel( tr( "Shrink coef." ), ButtonGroup1, "TextLabel_ShrinkCoeff" );
- ButtonGroup1Layout->addWidget( TextLabel_ShrinkCoeff, 2, 0 );
-
- SpinBox_Shrink = new QSpinBox( 20, 100, 1, ButtonGroup1, "SpinBox_Shrink" );
- SpinBox_Shrink->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- SpinBox_Shrink->setButtonSymbols( QSpinBox::PlusMinus );
- ButtonGroup1Layout->addMultiCellWidget( SpinBox_Shrink, 2, 2, 1, 5);
-
- SMESHGUI_Preferences_ColorDlgLayout->addWidget( ButtonGroup1, 0, 0 );
-
- ButtonGroup2 = new QButtonGroup( tr( "Nodes" ), this, "ButtonGroup2" );
- ButtonGroup2->setColumnLayout(0, Qt::Vertical );
- ButtonGroup2->layout()->setSpacing( 0 );
- ButtonGroup2->layout()->setMargin( 0 );
- QGridLayout* ButtonGroup2Layout = new QGridLayout( ButtonGroup2->layout() );
- ButtonGroup2Layout->setAlignment( Qt::AlignTop );
- ButtonGroup2Layout->setSpacing( 6 );
- ButtonGroup2Layout->setMargin( 11 );
-
- TextLabel_Nodes_Color = new QLabel( tr( "Color" ), ButtonGroup2, "TextLabel_Nodes_Color" );
- ButtonGroup2Layout->addWidget( TextLabel_Nodes_Color, 0, 0 );
-
- btnNodeColor = new QPushButton( ButtonGroup2, "btnNodeColor" );
- btnNodeColor->setFixedSize( QSize( 25, 25 ) );
- ButtonGroup2Layout->addWidget( btnNodeColor, 0, 1 );
-
- TextLabel_Nodes_Size = new QLabel( tr( "Size" ), ButtonGroup2, "TextLabel_Nodes_Size" );
- ButtonGroup2Layout->addWidget( TextLabel_Nodes_Size, 0, 2 );
-
- SpinBox_Nodes_Size = new QSpinBox( 0, 5, 1, ButtonGroup2, "SpinBox_Nodes_Size" );
- SpinBox_Nodes_Size->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- SpinBox_Nodes_Size->setWrapping( FALSE );
- SpinBox_Nodes_Size->setButtonSymbols( QSpinBox::PlusMinus );
- ButtonGroup2Layout->addWidget( SpinBox_Nodes_Size, 0, 3 );
-
- SMESHGUI_Preferences_ColorDlgLayout->addWidget( ButtonGroup2, 1, 0 );
-
- GroupButtons = new QButtonGroup( this, "GroupButtons" );
- GroupButtons->setColumnLayout(0, Qt::Vertical );
- GroupButtons->layout()->setSpacing( 0 );
- GroupButtons->layout()->setMargin( 0 );
- QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
- GroupButtonsLayout->setAlignment( Qt::AlignTop );
- GroupButtonsLayout->setSpacing( 6 );
- GroupButtonsLayout->setMargin( 11 );
-
- buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
- buttonOk->setAutoDefault( TRUE );
- buttonOk->setDefault( TRUE );
- GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
-
- GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
-
- buttonCancel = new QPushButton( tr( "&Cancel" ), GroupButtons, "buttonCancel" );
- buttonCancel->setAutoDefault( TRUE );
- GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
-
- SMESHGUI_Preferences_ColorDlgLayout->addWidget( GroupButtons, 2, 0 );
-
- Init();
+ setModal( true );
+ setWindowTitle( tr( "Properties (color, line width, shrink size, ...)" ) );
+ setSizeGripEnabled( true );
+
+ // -------------------------------
+ QVBoxLayout* topLayout = new QVBoxLayout( this );
+ topLayout->setSpacing( SPACING );
+ topLayout->setMargin( MARGIN );
+
+ // -------------------------------
+ QGroupBox* ButtonGroup1 = new QGroupBox( tr( "Elements" ), this );
+ QGridLayout* ButtonGroup1Layout = new QGridLayout( ButtonGroup1 );
+ ButtonGroup1Layout->setSpacing( SPACING );
+ ButtonGroup1Layout->setMargin( MARGIN );
+
+ QLabel* TextLabel_Fill = new QLabel( tr( "Surface color" ), ButtonGroup1 );
+
+ toolSurfColor = new QtxBiColorTool(ButtonGroup1);
+ toolSurfColor->setText( tr( "Back surface color" ));
+
+ 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 );
+
+ QLabel* TextLabel_0DElements_Size = new QLabel( tr( "Size of 0D elements" ), ButtonGroup1 );
+ SpinBox_0DElements_Size = new SalomeApp_IntSpinBox( ButtonGroup1 );
+ SpinBox_0DElements_Size->setAcceptNames( false ); // No Notebook variables allowed
+ SpinBox_0DElements_Size->setRange( 1, 10 );
+ SpinBox_0DElements_Size->setSingleStep( 1 );
+ SpinBox_0DElements_Size->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ SpinBox_0DElements_Size->setButtonSymbols( QSpinBox::PlusMinus );
+
+ 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( 1, 5 );
+ SpinBox_Width->setSingleStep( 1 );
+ SpinBox_Width->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ SpinBox_Width->setButtonSymbols( QSpinBox::PlusMinus );
+
+ QLabel* TextLabel_ShrinkCoeff = new QLabel( tr( "Shrink coef." ), ButtonGroup1 );
+ SpinBox_Shrink = new SalomeApp_IntSpinBox( ButtonGroup1 );
+ SpinBox_Shrink->setAcceptNames( false ); // No Notebook variables allowed
+ SpinBox_Shrink->setRange( 20, 100 );
+ SpinBox_Shrink->setSingleStep( 1 );
+ SpinBox_Shrink->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ SpinBox_Shrink->setButtonSymbols( QSpinBox::PlusMinus );
+
+ ButtonGroup1Layout->addWidget( TextLabel_Fill, 0, 0 );
+ ButtonGroup1Layout->addWidget( toolSurfColor, 0, 1, 1, 3 );
+
+ ButtonGroup1Layout->addWidget( TextLabel_Outline, 1, 0 );
+ ButtonGroup1Layout->addWidget( btnOutlineColor, 1, 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 );
+ ButtonGroup1Layout->addWidget( SpinBox_Shrink, 3, 3 );
+
+ // -------------------------------
+ QGroupBox* ButtonGroup2 = new QGroupBox( tr( "Nodes" ), this );
+ QGridLayout* ButtonGroup2Layout = new QGridLayout( ButtonGroup2 );
+ ButtonGroup2Layout->setSpacing( SPACING );
+ ButtonGroup2Layout->setMargin( MARGIN );
+
+ QLabel* TextLabel_Nodes_Color = new QLabel( tr( "Color" ), ButtonGroup2 );
+ btnNodeColor = new QtxColorButton( ButtonGroup2 );
+
+ QGroupBox* MarkerGroup = new QGroupBox( tr( "Marker" ), ButtonGroup2 );
+ QVBoxLayout* MarkerGroupLayout = new QVBoxLayout( MarkerGroup );
+ MarkerGroupLayout->setSpacing( 0 );
+ MarkerGroupLayout->setMargin( 0 );
+
+ MarkerWidget = new VTKViewer_MarkerWidget( MarkerGroup );
+
+ MarkerGroupLayout->addWidget( MarkerWidget );
+
+ ButtonGroup2Layout->addWidget( TextLabel_Nodes_Color, 0, 0 );
+ ButtonGroup2Layout->addWidget( btnNodeColor, 0, 1 );
+ ButtonGroup2Layout->addWidget( MarkerGroup, 1, 0, 1, 3 );
+ ButtonGroup2Layout->setColumnStretch( 2, 1 );
+
+ // -------------------------------
+ QGroupBox* ButtonGroup3 = new QGroupBox( tr( "Orientation of faces" ), this );
+ QGridLayout* ButtonGroup3Layout = new QGridLayout( ButtonGroup3 );
+ ButtonGroup3Layout->setSpacing( SPACING );
+ ButtonGroup3Layout->setMargin( MARGIN );
+
+ QLabel* TextLabel_Orientation_Color = new QLabel( tr( "Color" ), ButtonGroup3 );
+ btnOrientationColor = new QtxColorButton( ButtonGroup3 );
+
+ QLabel* TextLabel_Orientation_Scale = new QLabel( tr( "Scale" ), ButtonGroup3 );
+ SpinBox_Orientation_Scale = new SMESHGUI_SpinBox( ButtonGroup3 );
+ SpinBox_Orientation_Scale->setAcceptNames( false ); // No Notebook variables allowed
+ SpinBox_Orientation_Scale->RangeStepAndValidator( .05, .5, .05, "parametric_precision" );
+ SpinBox_Orientation_Scale->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ SpinBox_Orientation_Scale->setButtonSymbols( QSpinBox::PlusMinus );
+
+ CheckBox_Orientation_3DVectors = new QCheckBox( tr( "3D vectors" ), ButtonGroup3 );
+
+ ButtonGroup3Layout->addWidget( TextLabel_Orientation_Color, 0, 0 );
+ ButtonGroup3Layout->addWidget( btnOrientationColor, 0, 1 );
+ ButtonGroup3Layout->addWidget( TextLabel_Orientation_Scale, 0, 2 );
+ 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 );
+ GroupButtonsLayout->setSpacing( SPACING );
+ GroupButtonsLayout->setMargin( MARGIN );
+
+ QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
+ buttonOk->setAutoDefault( true );
+ buttonOk->setDefault( true );
+
+ QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ), GroupButtons );
+ buttonCancel->setAutoDefault( true );
+
+ QPushButton* buttonHelp = new QPushButton( tr( "&Help" ), GroupButtons );
+ buttonHelp->setAutoDefault( true );
+
+ GroupButtonsLayout->addWidget( buttonOk );
+ GroupButtonsLayout->addSpacing( 10 );
+ GroupButtonsLayout->addStretch();
+ GroupButtonsLayout->addWidget( buttonCancel );
+ GroupButtonsLayout->addWidget( buttonHelp );
+
+ // -------------------------------
+ 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 );
+
+ // -------------------------------
+ mySMESHGUI->SetActiveDialogBox( this );
+
+ myHelpFileName = "colors_size_page.html";
+
+ /* signals and slots connections */
+ connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+ connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
+ connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
+
+ connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ),
+ this, SLOT( DeactivateActiveDialog() ) );
+ /* to close dialog if study change */
+ connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ),
+ this, SLOT( ClickOnCancel() ) );
}
-/*
- * Destroys the object and frees any allocated resources
- */
+//=================================================================================
+// function : ~SMESHGUI_Preferences_ColorDlg()
+// purpose : Destructor
+//=================================================================================
SMESHGUI_Preferences_ColorDlg::~SMESHGUI_Preferences_ColorDlg()
{
- // no need to delete child widgets, Qt does it all for us
}
//=================================================================================
-// function : Init()
+// function : ClickOnOk()
// purpose :
//=================================================================================
-void SMESHGUI_Preferences_ColorDlg::Init()
-{
- mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
- mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
-
- /* signals and slots connections */
- connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
- connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
+void SMESHGUI_Preferences_ColorDlg::ClickOnOk()
+{
+ mySMESHGUI->ResetState();
+ accept();
+}
- connect( btnFillColor, SIGNAL( clicked() ), this, SLOT( SelectFillColor() ) ) ;
- connect( btnOutlineColor, SIGNAL( clicked() ), this, SLOT( SelectOutlineColor() ) ) ;
- connect( btnNodeColor, SIGNAL( clicked() ), this, SLOT( SelectNodeColor() ) ) ;
- connect( btnBackFaceColor, SIGNAL( clicked() ), this, SLOT( SelectBackFaceColor() ) ) ;
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void SMESHGUI_Preferences_ColorDlg::ClickOnCancel()
+{
+ mySMESHGUI->ResetState();
+ reject();
+}
- connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
- /* to close dialog if study change */
- connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
-
- /* Move widget on the botton right corner of main widget */
- int x, y ;
- mySMESHGUI->DefineDlgPosition( this, x, y ) ;
- this->move( x, y ) ;
+//=================================================================================
+// function : ClickOnHelp()
+// purpose :
+//=================================================================================
+void SMESHGUI_Preferences_ColorDlg::ClickOnHelp()
+{
+ LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app)
+ app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
+ else {
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
+ tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser",
+ platform)).
+ arg(myHelpFileName));
+ }
+}
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void SMESHGUI_Preferences_ColorDlg::DeactivateActiveDialog()
+{
+}
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void SMESHGUI_Preferences_ColorDlg::closeEvent( QCloseEvent* )
+{
+ ClickOnCancel(); /* same than click on cancel button */
+}
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void SMESHGUI_Preferences_ColorDlg::ActivateThisDialog()
+{
+ /* Emit a signal to deactivate any active dialog */
+ mySMESHGUI->EmitSignalDeactivateDialog();
}
//=================================================================================
-// function : SelectFillColor()
+// function : SetColor()
// purpose :
//=================================================================================
-void SMESHGUI_Preferences_ColorDlg::SelectFillColor()
+void SMESHGUI_Preferences_ColorDlg::SetColor( int type, const QColor& color )
{
- QColor color = btnFillColor->palette().active().button();
- color = QColorDialog::getColor( color );
- if ( color.isValid() ) {
- QPalette pal = btnFillColor->palette();
- pal.setColor(QColorGroup::Button, color);
- btnFillColor->setPalette(pal);
+ switch ( type ) {
+ 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;
}
}
//=================================================================================
-// function : SelectBackFaceColor()
+// function : GetColor()
// purpose :
//=================================================================================
-void SMESHGUI_Preferences_ColorDlg::SelectBackFaceColor()
+QColor SMESHGUI_Preferences_ColorDlg::GetColor( int type )
{
- QColor color = btnBackFaceColor->palette().active().button();
- color = QColorDialog::getColor( color );
- if ( color.isValid() ) {
- QPalette pal = btnBackFaceColor->palette();
- pal.setColor(QColorGroup::Button, color);
- btnBackFaceColor->setPalette(pal);
+ QColor color;
+ switch ( type ) {
+ 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;
}
//=================================================================================
-// function : SelectOutlineColor()
+// function : SetIntValue()
// purpose :
//=================================================================================
-void SMESHGUI_Preferences_ColorDlg::SelectOutlineColor()
+void SMESHGUI_Preferences_ColorDlg::SetIntValue( int type, int value )
{
- QColor color = btnOutlineColor->palette().active().button();
- color = QColorDialog::getColor( color );
- if ( color.isValid() ) {
- QPalette pal = btnOutlineColor->palette();
- pal.setColor(QColorGroup::Button, color);
- btnOutlineColor->setPalette(pal);
+ switch ( type ) {
+ case 1 : SpinBox_Width->setValue( value ); break; // width
+ case 2 : SpinBox_Shrink->setValue( value ); break; // shrink coeff
+ case 3 : SpinBox_0DElements_Size->setValue( value ); break; // 0d elements
+ default: break;
}
}
//=================================================================================
-// function : SelectNodeColor()
+// function : GetIntValue()
// purpose :
//=================================================================================
-void SMESHGUI_Preferences_ColorDlg::SelectNodeColor()
+int SMESHGUI_Preferences_ColorDlg::GetIntValue( int type )
{
- QColor color = btnNodeColor->palette().active().button();
- color = QColorDialog::getColor( color );
- if ( color.isValid() ) {
- QPalette pal = btnNodeColor->palette();
- pal.setColor(QColorGroup::Button, color);
- btnNodeColor->setPalette(pal);
+ int res = 0;
+ switch ( type ) {
+ case 1 : res = SpinBox_Width->value(); break; // width
+ case 2 : res = SpinBox_Shrink->value(); break; // shrink coeff
+ case 3 : res = SpinBox_0DElements_Size->value(); break; // 0d elements
+ default: break;
}
+ return res;
}
//=================================================================================
-// function : ClickOnOk()
+// function : SetDoubleValue()
// purpose :
//=================================================================================
-void SMESHGUI_Preferences_ColorDlg::ClickOnOk()
+void SMESHGUI_Preferences_ColorDlg::SetDoubleValue( int type, double value )
{
- mySMESHGUI->ResetState();
- accept();
+ switch ( type ) {
+ case 1 : SpinBox_Orientation_Scale->setValue( value ); break; // orientation scale
+ default: break;
+ }
}
//=================================================================================
-// function : ClickOnCancel()
+// function : GetDoubleValue()
// purpose :
//=================================================================================
-void SMESHGUI_Preferences_ColorDlg::ClickOnCancel()
+double SMESHGUI_Preferences_ColorDlg::GetDoubleValue( int type )
{
- mySMESHGUI->ResetState();
- reject() ;
+ double res = 0;
+ switch ( type ) {
+ case 1 : res = SpinBox_Orientation_Scale->value(); break; // orientation scale
+ default: break;
+ }
+ return res;
}
//=================================================================================
-// function : DeactivateActiveDialog()
+// function : SetBooleanValue()
// purpose :
//=================================================================================
-void SMESHGUI_Preferences_ColorDlg::DeactivateActiveDialog()
+void SMESHGUI_Preferences_ColorDlg::SetBooleanValue( int type, bool value )
{
- return ;
+ switch ( type ) {
+ case 1 : CheckBox_Orientation_3DVectors->setChecked( value ); break; // 3D vectors
+ default: break;
+ }
}
+//=================================================================================
+// function : GetBooleanValue()
+// purpose :
+//=================================================================================
+bool SMESHGUI_Preferences_ColorDlg::GetBooleanValue( int type )
+{
+ bool res = false;
+ switch ( type ) {
+ case 1 : res = CheckBox_Orientation_3DVectors->isChecked(); break; // 3D vectors
+ default: break;
+ }
+ return res;
+}
+//=================================================================================
+// function : setCustomMarkerMap()
+// purpose :
+//=================================================================================
+void SMESHGUI_Preferences_ColorDlg::setCustomMarkerMap( VTK::MarkerMap theMarkerMap )
+{
+ MarkerWidget->setCustomMarkerMap( theMarkerMap );
+}
//=================================================================================
-// function : closeEvent()
+// function : getCustomMarkerMap()
// purpose :
//=================================================================================
-void SMESHGUI_Preferences_ColorDlg::closeEvent( QCloseEvent* e )
+VTK::MarkerMap SMESHGUI_Preferences_ColorDlg::getCustomMarkerMap()
{
- this->ClickOnCancel() ; /* same than click on cancel button */
+ return MarkerWidget->getCustomMarkerMap();
}
//=================================================================================
-// function : ActivateThisDialog()
+// function : setStandardMarker()
// purpose :
//=================================================================================
-void SMESHGUI_Preferences_ColorDlg::ActivateThisDialog()
+void SMESHGUI_Preferences_ColorDlg::setStandardMarker( VTK::MarkerType theMarkerType,
+ VTK::MarkerScale theMarkerScale )
{
- /* Emit a signal to deactivate any active dialog */
- mySMESHGUI->EmitSignalDeactivateDialog() ;
+ MarkerWidget->setStandardMarker( theMarkerType, theMarkerScale );
+}
- return ;
+//=================================================================================
+// function : setCustomMarker()
+// purpose :
+//=================================================================================
+void SMESHGUI_Preferences_ColorDlg::setCustomMarker( int theId )
+{
+ MarkerWidget->setCustomMarker( theId );
}
//=================================================================================
-// function : SetColor()
+// function : getMarkerType()
// purpose :
//=================================================================================
-void SMESHGUI_Preferences_ColorDlg::SetColor(int type, QColor color)
+VTK::MarkerType SMESHGUI_Preferences_ColorDlg::getMarkerType() const
{
- switch (type) {
- case 1 : // fill
- {
- QPalette pal = btnFillColor->palette();
- pal.setColor(QColorGroup::Button, color);
- btnFillColor->setPalette(pal);
- break;
- }
- case 2 : // outline
- {
- QPalette pal = btnOutlineColor->palette();
- pal.setColor(QColorGroup::Button, color);
- btnOutlineColor->setPalette(pal);
- break;
- }
- case 3 : // node
- {
- QPalette pal = btnNodeColor->palette();
- pal.setColor(QColorGroup::Button, color);
- btnNodeColor->setPalette(pal);
- break;
- }
- case 4 : // back face
- {
- QPalette pal = btnBackFaceColor->palette();
- pal.setColor(QColorGroup::Button, color);
- btnBackFaceColor->setPalette(pal);
- break;
- }
- }
+ return MarkerWidget->getMarkerType();
}
//=================================================================================
-// function : GetColor()
+// function : getStandardMarkerScale()
// purpose :
//=================================================================================
-QColor SMESHGUI_Preferences_ColorDlg::GetColor(int type)
+VTK::MarkerScale SMESHGUI_Preferences_ColorDlg::getStandardMarkerScale() const
{
- QColor color;
- switch (type) {
- case 1 : color = btnFillColor->palette().active().button(); break; // fill
- case 2 : color = btnOutlineColor->palette().active().button(); break; // outline
- case 3 : color = btnNodeColor->palette().active().button(); break; // node
- case 4 : color = btnBackFaceColor->palette().active().button(); break; // back face
- }
- return color;
+ return MarkerWidget->getStandardMarkerScale();
}
//=================================================================================
-// function : SetIntValue()
-// purpose :
+// function : getCustomMarkerID()
+// purpose :
//=================================================================================
-void SMESHGUI_Preferences_ColorDlg::SetIntValue(int type, int value)
+int SMESHGUI_Preferences_ColorDlg::getCustomMarkerID() const
{
- switch (type) {
- case 1 : SpinBox_Width->setValue(value); break; // width
- case 2 : SpinBox_Nodes_Size->setValue(value); break; // nodes size = value; break;
- case 3 : SpinBox_Shrink->setValue(value); break; // shrink coeff
- }
+ return MarkerWidget->getCustomMarkerID();
}
//=================================================================================
-// function : GetIntValue()
-// purpose :
+// function : SetDeltaBrightness(int)
+// purpose :
//=================================================================================
-int SMESHGUI_Preferences_ColorDlg::GetIntValue(int type)
+void SMESHGUI_Preferences_ColorDlg::SetDeltaBrightness(int delta)
{
- int res = 0;
- switch (type) {
- case 1 : res = SpinBox_Width->value(); break; // width
- case 2 : res = SpinBox_Nodes_Size->value(); break; // nodes size
- case 3 : res = SpinBox_Shrink->value(); break; // shrink coeff
+ toolSurfColor->setDelta(delta);
+}
+//=================================================================================
+// function : GetDeltaBrightness()
+// purpose :
+//=================================================================================
+int SMESHGUI_Preferences_ColorDlg::GetDeltaBrightness()
+{
+ return toolSurfColor->delta();
+}
+
+//=================================================================================
+// function : keyPressEvent()
+// purpose :
+//=================================================================================
+void SMESHGUI_Preferences_ColorDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 ) {
+ e->accept();
+ ClickOnHelp();
}
- return res;
}