X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_Preferences_ColorDlg.cxx;h=85311c6b70492fef6f1ae5b7e6689c16260e7cde;hp=f8ed909ae6d49faf6ed288514874929219d87fca;hb=aa67cc96d730566d202d1014d97b7f0b3a4d71f4;hpb=64be032249f21ff884326a9b1d5e6b1a6eed93dc diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx index f8ed909ae..85311c6b7 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2010 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 @@ -19,6 +19,7 @@ // // 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. @@ -27,12 +28,14 @@ #include "SMESHGUI_Preferences_ColorDlg.h" #include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" #include "SMESHGUI_Utils.h" // SALOME GUI includes #include #include -#include +#include +#include // Qt includes #include @@ -41,7 +44,7 @@ #include #include #include -#include +#include #define SPACING 6 #define MARGIN 11 @@ -81,51 +84,94 @@ SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( SMESHGUI* theModul QLabel* TextLabel_Outine = new QLabel( tr( "Outline" ), ButtonGroup1 ); btnOutlineColor = 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( "Width" ), ButtonGroup1 ); - SpinBox_Width = new QSpinBox( ButtonGroup1 ); + SpinBox_Width = new SalomeApp_IntSpinBox( ButtonGroup1 ); + SpinBox_Width->setAcceptNames( false ); // No Notebook variables allowed SpinBox_Width->setRange( 0, 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 QtxIntSpinBox( 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( btnFillColor, 0, 1 ); - ButtonGroup1Layout->addWidget( TextLabel_BackFace, 0, 2 ); - ButtonGroup1Layout->addWidget( btnBackFaceColor, 0, 3 ); - ButtonGroup1Layout->addWidget( TextLabel_Outine, 1, 0 ); - ButtonGroup1Layout->addWidget( btnOutlineColor, 1, 1 ); - ButtonGroup1Layout->addWidget( TextLabel_Width, 1, 2 ); - ButtonGroup1Layout->addWidget( SpinBox_Width, 1, 3 ); - ButtonGroup1Layout->addWidget( TextLabel_ShrinkCoeff, 2, 0 ); - ButtonGroup1Layout->addWidget( SpinBox_Shrink, 2, 1, 1, 3 ); + 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( 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_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 ); - QHBoxLayout* ButtonGroup2Layout = new QHBoxLayout( ButtonGroup2 ); + QGridLayout* ButtonGroup2Layout = new QGridLayout( ButtonGroup2 ); ButtonGroup2Layout->setSpacing( SPACING ); ButtonGroup2Layout->setMargin( MARGIN ); QLabel* TextLabel_Nodes_Color = new QLabel( tr( "Color" ), ButtonGroup2 ); btnNodeColor = new QtxColorButton( ButtonGroup2 ); - QLabel* TextLabel_Nodes_Size = new QLabel( tr( "Size" ), ButtonGroup2 ); - SpinBox_Nodes_Size = new QSpinBox( ButtonGroup2 ); - SpinBox_Nodes_Size->setRange( 0, 5 ); - SpinBox_Nodes_Size->setSingleStep( 1 ); - SpinBox_Nodes_Size->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - SpinBox_Nodes_Size->setButtonSymbols( QSpinBox::PlusMinus ); + 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 ); - ButtonGroup2Layout->addWidget( TextLabel_Nodes_Color ); - ButtonGroup2Layout->addWidget( btnNodeColor ); - ButtonGroup2Layout->addWidget( TextLabel_Nodes_Size ); - ButtonGroup2Layout->addWidget( SpinBox_Nodes_Size ); + // ------------------------------- + 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* GroupButtons = new QGroupBox( this ); @@ -148,6 +194,7 @@ SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( SMESHGUI* theModul // ------------------------------- topLayout->addWidget( ButtonGroup1 ); topLayout->addWidget( ButtonGroup2 ); + topLayout->addWidget( ButtonGroup3 ); topLayout->addWidget( GroupButtons ); // ------------------------------- @@ -226,10 +273,12 @@ 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 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 default: break; } } @@ -242,10 +291,12 @@ 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 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 default: break; } return color; @@ -258,9 +309,9 @@ QColor SMESHGUI_Preferences_ColorDlg::GetColor( int type ) void SMESHGUI_Preferences_ColorDlg::SetIntValue( int type, int value ) { 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 + 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; } } @@ -273,10 +324,126 @@ int SMESHGUI_Preferences_ColorDlg::GetIntValue( int type ) { 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 + 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 : SetDoubleValue() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::SetDoubleValue( int type, double value ) +{ + switch ( type ) { + case 1 : SpinBox_Orientation_Scale->setValue( value ); break; // orientation scale + default: break; + } +} + +//================================================================================= +// function : GetDoubleValue() +// purpose : +//================================================================================= +double SMESHGUI_Preferences_ColorDlg::GetDoubleValue( int type ) +{ + double res = 0; + switch ( type ) { + case 1 : res = SpinBox_Orientation_Scale->value(); break; // orientation scale default: break; } return res; } + +//================================================================================= +// function : SetBooleanValue() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::SetBooleanValue( int type, bool value ) +{ + 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 : getCustomMarkerMap() +// purpose : +//================================================================================= +VTK::MarkerMap SMESHGUI_Preferences_ColorDlg::getCustomMarkerMap() +{ + return MarkerWidget->getCustomMarkerMap(); +} + +//================================================================================= +// function : setStandardMarker() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::setStandardMarker( VTK::MarkerType theMarkerType, + VTK::MarkerScale theMarkerScale ) +{ + MarkerWidget->setStandardMarker( theMarkerType, theMarkerScale ); +} + +//================================================================================= +// function : setCustomMarker() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::setCustomMarker( int theId ) +{ + MarkerWidget->setCustomMarker( theId ); +} + +//================================================================================= +// function : getMarkerType() +// purpose : +//================================================================================= +VTK::MarkerType SMESHGUI_Preferences_ColorDlg::getMarkerType() const +{ + return MarkerWidget->getMarkerType(); +} + +//================================================================================= +// function : getStandardMarkerScale() +// purpose : +//================================================================================= +VTK::MarkerScale SMESHGUI_Preferences_ColorDlg::getStandardMarkerScale() const +{ + return MarkerWidget->getStandardMarkerScale(); +} + +//================================================================================= +// function : getCustomMarkerID() +// purpose : +//================================================================================= +int SMESHGUI_Preferences_ColorDlg::getCustomMarkerID() const +{ + return MarkerWidget->getCustomMarkerID(); +}