From: stv Date: Mon, 27 Jun 2005 11:29:58 +0000 (+0000) Subject: Prefernces. X-Git-Tag: T3_0_0_a4~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9a358116f4ee87b52d3d86752c4fb6b3f814a69f;p=modules%2Fsmesh.git Prefernces. --- diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index 7bea5e30b..667a80b6e 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -114,10 +114,10 @@ SMESH_ActorDef::SMESH_ActorDef() myIsShrinkable = false; myIsShrunk = false; - myControlsPrecision = (long)SMESH::GetFloat( "SMESH:ControlsPrecision", -1 ); + myControlsPrecision = (long)SMESH::GetFloat( "SMESH:controls_precision", -1 ); - float aPointSize = SMESH::GetFloat("SMESH:SettingsNodesSize",3); - float aLineWidth = SMESH::GetFloat("SMESH:SettingsWidth",1); + float aPointSize = SMESH::GetFloat("SMESH:node_size",3); + float aLineWidth = SMESH::GetFloat("SMESH:element_width",1); vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New(); VTKViewer_ExtractUnstructuredGrid* aFilter = NULL; @@ -126,16 +126,12 @@ SMESH_ActorDef::SMESH_ActorDef() //----------------------------------------- float anRGB[3] = {1,1,1}; mySurfaceProp = vtkProperty::New(); - anRGB[0] = SMESH::GetFloat("SMESH:SettingsFillColorRed", 0)/255.; - anRGB[1] = SMESH::GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; - anRGB[2] = SMESH::GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; - mySurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); + mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); myBackSurfaceProp = vtkProperty::New(); - anRGB[0] = SMESH::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; - anRGB[1] = SMESH::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; - anRGB[2] = SMESH::GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; - myBackSurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) ); + myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); my2DActor = SMESH_DeviceActor::New(); my2DActor->SetUserMatrix(aMatrix); @@ -170,9 +166,7 @@ SMESH_ActorDef::SMESH_ActorDef() myEdgeProp->SetAmbient(1.0); myEdgeProp->SetDiffuse(0.0); myEdgeProp->SetSpecular(0.0); - anRGB[0] = SMESH::GetFloat("SMESH:SettingsOutlineColorRed", 0)/255.; - anRGB[1] = SMESH::GetFloat("SMESH:SettingsOutlineColorGreen", 170)/255.; - anRGB[2] = SMESH::GetFloat("SMESH:SettingsOutlineColorBlue", 255)/255.; + SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myEdgeProp->SetLineWidth(aLineWidth); @@ -215,9 +209,7 @@ SMESH_ActorDef::SMESH_ActorDef() //Definition 0D divice of the actor //--------------------------------- myNodeProp = vtkProperty::New(); - anRGB[0] = SMESH::GetFloat("SMESH:SettingsNodeColorRed",255)/255.; - anRGB[1] = SMESH::GetFloat("SMESH:SettingsNodeColorGreen",0)/255.; - anRGB[2] = SMESH::GetFloat("SMESH:SettingsNodeColorBlue",0)/255.; + SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) ); myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myNodeProp->SetPointSize(aPointSize); @@ -246,9 +238,7 @@ SMESH_ActorDef::SMESH_ActorDef() myHighlightProp->SetAmbient(1.0); myHighlightProp->SetDiffuse(0.0); myHighlightProp->SetSpecular(0.0); - anRGB[0] = SMESH::GetFloat("SMESH:SettingsSelectColorRed", 255)/255.; // 1; - anRGB[1] = SMESH::GetFloat("SMESH:SettingsSelectColorGreen", 255)/255.; // 1; - anRGB[2] = SMESH::GetFloat("SMESH:SettingsSelectColorBlue", 255)/255.; // 1; + SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) ); myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myHighlightProp->SetPointSize(aPointSize); myHighlightProp->SetRepresentation(1); @@ -257,9 +247,7 @@ SMESH_ActorDef::SMESH_ActorDef() myPreselectProp->SetAmbient(1.0); myPreselectProp->SetDiffuse(0.0); myPreselectProp->SetSpecular(0.0); - anRGB[0] = SMESH::GetFloat("SMESH:SettingsPreSelectColorRed", 0)/255.; // 0; - anRGB[1] = SMESH::GetFloat("SMESH:SettingsPreSelectColorGreen", 255)/255.; // 1; - anRGB[2] = SMESH::GetFloat("SMESH:SettingsPreSelectColorBlue", 255)/255.; // 1; + SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) ); myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myPreselectProp->SetPointSize(aPointSize); myPreselectProp->SetRepresentation(1); @@ -269,7 +257,7 @@ SMESH_ActorDef::SMESH_ActorDef() myHighlitableActor->PickableOff(); myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe); - SetShrinkFactor(SMESH::GetFloat("SMESH:SettingsShrinkCoeff", 75)/100.); + SetShrinkFactor( SMESH::GetFloat( "SMESH", "shrink_coeff", 0.75 ) ); myName = ""; myIO = NULL; @@ -294,13 +282,14 @@ SMESH_ActorDef::SMESH_ActorDef() if( !mgr ) return; - QColor aTColor = mgr->colorValue( "ScalarBarTitleColor", "SMESH", QColor( 255, 255, 255 ) ); + QColor aTColor = mgr->colorValue( "SMESH", "ScalarBarTitleColor", QColor( 255, 255, 255 ) ); aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. ); aScalarBarTitleProp->SetFontFamilyToArial(); - if( mgr->hasValue( "ScalarBarTitleFont", "SMESH" ) ){ - QString str = mgr->stringValue( "ScalarBarTitleFont", "SMESH" ); + if ( mgr->hasValue( "SMESH", "ScalarBarTitleFont" ) ) + { + QString str = mgr->stringValue( "SMESH", "ScalarBarTitleFont" ); if ( str == "Arial" ) aScalarBarTitleProp->SetFontFamilyToArial(); else if ( str == "Courier" ) @@ -309,17 +298,17 @@ SMESH_ActorDef::SMESH_ActorDef() aScalarBarTitleProp->SetFontFamilyToTimes(); } - if ( mgr->stringValue( "ScalarBarTitleBold", "SMESH" ) == "true" ) + if ( mgr->booleanValue( "SMESH", "ScalarBarTitleBold" ) ) aScalarBarTitleProp->BoldOn(); else aScalarBarTitleProp->BoldOff(); - if ( mgr->stringValue( "ScalarBarTitleItalic", "SMESH" ) == "true" ) + if ( mgr->booleanValue( "SMESH", "ScalarBarTitleItalic" ) ) aScalarBarTitleProp->ItalicOn(); else aScalarBarTitleProp->ItalicOff(); - if ( mgr->stringValue( "ScalarBarTitleShadow", "SMESH" ) == "true" ) + if ( mgr->booleanValue( "SMESH", "ScalarBarTitleShadow" ) ) aScalarBarTitleProp->ShadowOn(); else aScalarBarTitleProp->ShadowOff(); @@ -329,13 +318,13 @@ SMESH_ActorDef::SMESH_ActorDef() vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New(); - aTColor = mgr->colorValue( "ScalarBarLabelColor", "SMESH", QColor( 255, 255, 255 ) ); + aTColor = mgr->colorValue( "SMESH", "ScalarBarLabelColor", QColor( 255, 255, 255 ) ); aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. ); aScalarBarLabelProp->SetFontFamilyToArial(); - if( mgr->hasValue( "ScalarBarLabelFont", "SMESH" ) ) + if( mgr->hasValue( "SMESH", "ScalarBarLabelFont" ) ) { - QString str = mgr->stringValue( "ScalarBarLabelFont", "SMESH" ); + QString str = mgr->stringValue( "SMESH", "ScalarBarLabelFont" ); if( str == "Arial" ) aScalarBarLabelProp->SetFontFamilyToArial(); else if( str == "Courier" ) @@ -344,17 +333,17 @@ SMESH_ActorDef::SMESH_ActorDef() aScalarBarLabelProp->SetFontFamilyToTimes(); } - if( mgr->stringValue( "ScalarBarLabelBold", "SMESH" ) == "true" ) + if ( mgr->booleanValue( "SMESH", "ScalarBarLabelBold" ) ) aScalarBarLabelProp->BoldOn(); else aScalarBarLabelProp->BoldOff(); - if ( mgr->stringValue( "ScalarBarLabelItalic", "SMESH" ) == "true" ) + if ( mgr->booleanValue( "SMESH", "ScalarBarLabelItalic" ) ) aScalarBarLabelProp->ItalicOn(); else aScalarBarLabelProp->ItalicOff(); - if( mgr->stringValue( "ScalarBarLabelShadow", "SMESH" ) == "true" ) + if( mgr->booleanValue( "SMESH", "ScalarBarLabelShadow" ) ) aScalarBarLabelProp->ShadowOn(); else aScalarBarLabelProp->ShadowOff(); @@ -362,37 +351,37 @@ SMESH_ActorDef::SMESH_ActorDef() myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp ); aScalarBarLabelProp->Delete(); - if( mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ) + if( mgr->stringValue( "SMESH", "ScalarBarOrientation" ) == "Horizontal" ) myScalarBarActor->SetOrientationToHorizontal(); else myScalarBarActor->SetOrientationToVertical(); - float aXVal = mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ? 0.20 : 0.01; - if( mgr->hasValue( "ScalarBarXPosition", "SMESH" ) ) - aXVal = mgr->doubleValue( "ScalarBarXPosition", "SMESH", aXVal ); - float aYVal = mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ? 0.01 : 0.1; - if( mgr->hasValue( "ScalarBarYPosition", "SMESH" ) ) - aYVal = mgr->doubleValue( "ScalarBarYPosition", "SMESH", aYVal ); + float aXVal = mgr->stringValue( "SMESH", "ScalarBarOrientation" ) == "Horizontal" ? 0.20 : 0.01; + if( mgr->hasValue( "SMESH", "ScalarBarXPosition" ) ) + aXVal = mgr->doubleValue( "SMESH", "ScalarBarXPosition", aXVal ); + float aYVal = mgr->stringValue( "SMESH", "ScalarBarOrientation" ) == "Horizontal" ? 0.01 : 0.1; + if( mgr->hasValue( "SMESH", "ScalarBarYPosition" ) ) + aYVal = mgr->doubleValue( "SMESH", "ScalarBarYPosition", aYVal ); myScalarBarActor->SetPosition( aXVal, aYVal ); - float aWVal = mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ? 0.60 : 0.10; - if( mgr->hasValue( "ScalarBarWidth", "SMESH" ) ) - aWVal = mgr->doubleValue( "ScalarBarWidth", "SMESH", aWVal ); + float aWVal = mgr->stringValue( "SMESH", "ScalarBarOrientation" ) == "Horizontal" ? 0.60 : 0.10; + if( mgr->hasValue( "SMESH", "ScalarBarWidth" ) ) + aWVal = mgr->doubleValue( "SMESH", "ScalarBarWidth", aWVal ); myScalarBarActor->SetWidth( aWVal ); - float aHVal = mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ? 0.12 : 0.80; - if( mgr->hasValue( "ScalarBarHeight", "SMESH" ) ) - aHVal = mgr->doubleValue( "ScalarBarHeight", "SMESH", aHVal ); + float aHVal = mgr->stringValue( "SMESH", "ScalarBarOrientation" ) == "Horizontal" ? 0.12 : 0.80; + if( mgr->hasValue( "SMESH", "ScalarBarHeight" ) ) + aHVal = mgr->doubleValue( "SMESH", "ScalarBarHeight", aHVal ); myScalarBarActor->SetHeight( aHVal ); int anIntVal = 5; - if( mgr->hasValue( "ScalarBarNbOfLabels", "SMESH" ) ) - anIntVal = mgr->integerValue( "ScalarBarNbOfLabels", "SMESH", anIntVal ); + if( mgr->hasValue( "SMESH", "ScalarBarNbOfLabels" ) ) + anIntVal = mgr->integerValue( "SMESH", "ScalarBarNbOfLabels", anIntVal ); myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal ); anIntVal = 64; - if( mgr->hasValue( "ScalarBarNbOfColors", "SMESH" ) ) - anIntVal = mgr->integerValue( "ScalarBarNbOfColors", "SMESH", anIntVal ); + if( mgr->hasValue( "SMESH", "ScalarBarNbOfColors" ) ) + anIntVal = mgr->integerValue( "SMESH", "ScalarBarNbOfColors", anIntVal ); myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal ); @@ -625,7 +614,7 @@ SetControlMode(eControl theMode, return; myControlMode = eNone; - theCheckEntityMode &= mgr->stringValue( "DispayEntity", "SMESH" ) == "true"; + theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false ); my1DActor->GetMapper()->SetScalarVisibility(false); my2DActor->GetMapper()->SetScalarVisibility(false); diff --git a/src/OBJECT/SMESH_ActorUtils.cxx b/src/OBJECT/SMESH_ActorUtils.cxx index 05aa47c59..feee143db 100644 --- a/src/OBJECT/SMESH_ActorUtils.cxx +++ b/src/OBJECT/SMESH_ActorUtils.cxx @@ -20,8 +20,9 @@ #include "SMESH_ActorUtils.h" -#include "SUIT_ResourceMgr.h" +#include "SUIT_Tools.h" #include "SUIT_Session.h" +#include "SUIT_ResourceMgr.h" #include "utilities.h" @@ -42,10 +43,10 @@ namespace SMESH{ float val = theDefault; if( pos>=0 ) { - QString val = theValue.right( theValue.length()-pos-1 ), + QString name = theValue.right( theValue.length()-pos-1 ), sect = theValue.left( pos ); - if( !val.isEmpty() && !sect.isEmpty() ) - val = GetFloat( val, sect, theDefault ); + if( !name.isEmpty() && !sect.isEmpty() ) + val = GetFloat( name, sect, theDefault ); } return val; } @@ -70,4 +71,31 @@ namespace SMESH{ aWriter->Delete(); } + QColor GetColor( const QString& theSect, const QString& theName, const QColor& def ) + { + QColor c = def; + SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr(); + if ( mgr ) + c = mgr->colorValue( theSect, theName, def ); + return c; + } + + void GetColor( const QString& theSect, const QString& theName, int& r, int& g, int& b, const QColor& def ) + { + QColor c = def; + SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr(); + if ( mgr ) + c = mgr->colorValue( theSect, theName, def ); + + SUIT_Tools::rgbSet( SUIT_Tools::rgbSet( c ), r, g, b ); + } + + void GetColor( const QString& theSect, const QString& theName, float& r, float& g, float& b, const QColor& def ) + { + int ir( 0 ), ig( 0 ), ib( 0 ); + GetColor( theSect, theName, ir, ig, ib, def ); + r = ir / 255.; + g = ig / 255.; + b = ib / 255.; + } } diff --git a/src/OBJECT/SMESH_ActorUtils.h b/src/OBJECT/SMESH_ActorUtils.h index b4f8194c5..f28e8d6c9 100644 --- a/src/OBJECT/SMESH_ActorUtils.h +++ b/src/OBJECT/SMESH_ActorUtils.h @@ -20,6 +20,7 @@ #ifndef SMESH_ACTORUTILS_H #define SMESH_ACTORUTILS_H +#include #include class vtkUnstructuredGrid; @@ -29,6 +30,10 @@ namespace SMESH{ float GetFloat( const QString& theValue, float theDefault = 0 ); float GetFloat( const QString& theName, const QString& theSection, float theDefault = 0 ); + QColor GetColor( const QString& theSect, const QString& theName, const QColor&t = QColor() ); + void GetColor( const QString& theSect, const QString& theName, int&, int&, int&, const QColor&t = QColor() ); + void GetColor( const QString& theSect, const QString& theName, float&, float&, float&, const QColor&t = QColor() ); + void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName); } diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 511b6f1cf..29840349b 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -92,14 +92,16 @@ #include "QtxPopupMgr.h" -#include "SalomeApp_Application.h" -#include "SalomeApp_NameDlg.h" -#include "SalomeApp_DataOwner.h" -#include "SalomeApp_ImportOperation.h" #include "SalomeApp_Tools.h" #include "SalomeApp_Study.h" +#include "SalomeApp_NameDlg.h" +#include "SalomeApp_DataOwner.h" +#include "SalomeApp_Application.h" +#include "SalomeApp_Preferences.h" #include "SalomeApp_VTKSelector.h" +#include "SalomeApp_ImportOperation.h" + #include #include @@ -845,7 +847,6 @@ SalomeApp_Module( "SMESH" ) myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp ); } - myAutomaticUpdate = false; myActiveDialogBox = 0 ; myState = -1 ; @@ -880,6 +881,15 @@ SalomeApp_SelectionMgr* SMESHGUI::selectionMgr() return 0; } +bool SMESHGUI::automaticUpdate() +{ + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + if ( !resMgr ) + return false; + + return resMgr->booleanValue( "SMESH", "auto_update", false ); +} + //============================================================================= /*! * @@ -1326,8 +1336,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) } CORBA::Long anId = aStudy->StudyId(); TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry()); - cout<<"myAutomaticUpdate - "<Update(); SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry()); if(!anActor){ @@ -1765,14 +1774,14 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 1001: // AUTOMATIC UPDATE PREFERENCES { - if (act->isOn()) { - mgr->setValue( "SMESH", "AutomaticUpdate", true ); - myAutomaticUpdate = true; - } - else { - mgr->setValue( "SMESH", "AutomaticUpdate", false ); - myAutomaticUpdate = false; - } +// if (act->isOn()) { +// mgr->setValue( "SMESH", "AutomaticUpdate", true ); +// myAutomaticUpdate = true; +// } +// else { +// mgr->setValue( "SMESH", "AutomaticUpdate", false ); +// myAutomaticUpdate = false; +// } break; } @@ -2377,14 +2386,14 @@ bool SMESHGUI::SetSettings(SUIT_Desktop* parent) action( 10003 )->setOn( Shrink ); // Automatic Update - if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) { - action( 1001 )->setOn( true ); - myAutomaticUpdate = true; - } - else { - action( 1001 )->setOn( false ); - myAutomaticUpdate = false; - } +// if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) { +// action( 1001 )->setOn( true ); +// myAutomaticUpdate = true; +// } +// else { +// action( 1001 )->setOn( false ); +// myAutomaticUpdate = false; +// } if ( mgr->booleanValue( "SMESH","DispayEntity", false ) ) action( 10071 )->setOn( true ); @@ -2481,10 +2490,10 @@ void SMESHGUI::initialize( CAM_Application* app ) { SalomeApp_Module::initialize( app ); - SUIT_ResourceMgr* mgr = app->resourceMgr(); - if ( mgr ) +// SUIT_ResourceMgr* mgr = app->resourceMgr(); +// if ( mgr ) /* Automatic Update flag */ - myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate ); +// myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate ); // ----- create actions -------------- @@ -3128,6 +3137,77 @@ void SMESHGUI::viewManagers( QStringList& list ) const void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr ) { - if( dynamic_cast( mgr ) ) + if ( dynamic_cast( mgr ) ) SMESH::UpdateSelectionProp( this ); } + +void SMESHGUI::createPreferences() +{ + int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) ); + + int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab ); + addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "display_entity" ); + addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "auto_update" ); + + int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab ); + setPreferenceProperty( precGroup, "columns", 1 ); + + addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool ); + int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" ); + + setPreferenceProperty( prec, "min", 0 ); + setPreferenceProperty( prec, "max", 16 ); + + int meshTab = addPreference( tr( "PREF_TAB_MESH" ) ); + int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab ); + + addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" ); + int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" ); + + setPreferenceProperty( nodeSz, "min", 1 ); + setPreferenceProperty( nodeSz, "max", 5 ); + + int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab ); + + addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" ); + addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" ); + addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" ); + addPreference( "", elemGroup, SalomeApp_Preferences::Space ); + + int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" ); + int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" ); + + setPreferenceProperty( elemW, "min", 1 ); + setPreferenceProperty( elemW, "max", 5 ); + + setPreferenceProperty( shrink, "min", 0 ); + setPreferenceProperty( shrink, "max", 100 ); + + int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) ); + + int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab ); + + addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" ); + addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" ); + int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" ); + + setPreferenceProperty( selW, "min", 1 ); + setPreferenceProperty( selW, "max", 5 ); + + int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab ); + + addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" ); + int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" ); + + setPreferenceProperty( preW, "min", 1 ); + setPreferenceProperty( preW, "max", 5 ); + + int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab ); + + addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" ); + addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" ); +} + +void SMESHGUI::preferencesChanged( const QString&, const QString& ) +{ +} diff --git a/src/SMESHGUI/SMESHGUI.h b/src/SMESHGUI/SMESHGUI.h index ec883cab7..396de4b86 100644 --- a/src/SMESHGUI/SMESHGUI.h +++ b/src/SMESHGUI/SMESHGUI.h @@ -68,6 +68,8 @@ public : static SalomeApp_Study* activeStudy(); bool isActiveStudyLocked(); + static bool automaticUpdate(); + virtual QString engineIOR() const; virtual void initialize( CAM_Application* ); virtual void windows( QMap& ) const; @@ -96,6 +98,9 @@ public : void EmitSignalStudyFrameChanged() ; void EmitSignalCloseAllDialogs() ; + virtual void createPreferences(); + virtual void preferencesChanged( const QString&, const QString& ); + public slots: virtual bool deactivateModule( SUIT_Study* ); virtual bool activateModule( SUIT_Study* ); @@ -119,9 +124,7 @@ private : static SMESH::SMESH_Gen_var myComponentSMESH; QDialog* myActiveDialogBox; int myState; - bool myAutomaticUpdate; QMap myRules; }; - #endif diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx index 263758674..c9a559b38 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx @@ -118,21 +118,17 @@ namespace SMESH { myPreviewActor->VisibilityOff(); myPreviewActor->SetMapper(myMapper); - vtkProperty* aProp = vtkProperty::New(); float anRGB[3]; - anRGB[0] = GetFloat("SMESH:SettingsFillColorRed", 0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; - anRGB[2] = GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; - aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - myPreviewActor->SetProperty(aProp); + vtkProperty* aProp = vtkProperty::New(); + GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); + aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); + myPreviewActor->SetProperty( aProp ); aProp->Delete(); vtkProperty* aBackProp = vtkProperty::New(); - anRGB[0] = GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; - anRGB[2] = GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; - aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - myPreviewActor->SetBackfaceProperty(aBackProp); + GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) ); + aBackProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); + myPreviewActor->SetBackfaceProperty( aBackProp ); aBackProp->Delete(); myVTKViewWindow->AddActor(myPreviewActor); diff --git a/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx b/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx index f415162d5..bdc7b83af 100644 --- a/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx @@ -157,20 +157,16 @@ protected: myActor->SetInfinitive(true); myActor->SetMapper(myMapper); - vtkProperty* aProp = vtkProperty::New(); float anRGB[3]; - anRGB[0] = SMESH::GetFloat("SMESH:SettingsFillColorRed", 0)/255.; - anRGB[1] = SMESH::GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; - anRGB[2] = SMESH::GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; + vtkProperty* aProp = vtkProperty::New(); + SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); aProp->SetOpacity(0.75); myActor->SetProperty(aProp); aProp->Delete(); vtkProperty* aBackProp = vtkProperty::New(); - anRGB[0] = SMESH::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; - anRGB[1] = SMESH::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; - anRGB[2] = SMESH::GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; + SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) ); aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); aBackProp->SetOpacity(0.75); myActor->SetBackfaceProperty(aBackProp); diff --git a/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx b/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx index abf447e17..b84c11b10 100644 --- a/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx @@ -112,19 +112,15 @@ class TPolySimulation{ myPreviewActor->VisibilityOff(); myPreviewActor->SetMapper( myMapper ); - vtkProperty* aProp = vtkProperty::New(); float anRGB[3]; - anRGB[0] = GetFloat("SMESH:SettingsFillColorRed", 0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; - anRGB[2] = GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; + vtkProperty* aProp = vtkProperty::New(); + GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myPreviewActor->SetProperty( aProp ); aProp->Delete(); vtkProperty* aBackProp = vtkProperty::New(); - anRGB[0] = GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; - anRGB[2] = GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; + GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) ); aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myPreviewActor->SetBackfaceProperty( aBackProp ); aBackProp->Delete(); diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx index b2e9627b8..f1b72a35e 100755 --- a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx @@ -2192,13 +2192,8 @@ bool SMESHGUI_FilterDlg::createFilter (const int theType) long aPrecision = -1; SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); - if (mgr && mgr->hasValue("SMESH", "ControlsPrecision")) { - QString aStr = mgr->stringValue("SMESH", "ControlsPrecision"); - bool isOk = false; - int aVal = aStr.toInt(&isOk); - if (isOk) - aPrecision = aVal; - } + if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) ) + aPrecision = mgr->integerValue( "SMESH", "controls_precision", aPrecision ); for (CORBA::ULong i = 0; i < n; i++) { SMESH::Filter::Criterion aCriterion = createCriterion(); diff --git a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx index e896c4e6c..ecd3c522a 100755 --- a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx @@ -415,9 +415,7 @@ bool SMESHGUI_MeshPatternDlg::onApply() if ( myPattern->MakeMesh( myMesh, toCreatePolygons, toCreatePolyedrs ) ) { mySelectionMgr->clearSelected(); SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); - bool autoUpdate = false; - if (mgr && mgr->stringValue("SMESH", "AutomaticUpdate").compare("true") == 0) - autoUpdate = true; + bool autoUpdate = SMESHGUI::automaticUpdate(); if (!isRefine() && autoUpdate) { _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in()); SMESH_Actor* anActor = SMESH::FindActorByEntry(aSO->GetID().c_str()); @@ -855,7 +853,7 @@ void SMESHGUI_MeshPatternDlg::displayPreview() aProp->SetRepresentationToWireframe(); aProp->SetColor(250, 0, 250); if (SMESH::FindActorByObject(myMesh)) - aProp->SetLineWidth(SMESH::GetFloat("SMESH:SettingsWidth", 1) +1); + aProp->SetLineWidth( SMESH::GetFloat( "SMESH:element_width", 1 ) + 1 ); else aProp->SetLineWidth(1); myPreviewActor->SetProperty(aProp); diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx index 3237ae793..47e8f82c2 100644 --- a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx @@ -178,15 +178,13 @@ namespace SMESH { aProp->SetRepresentationToPoints(); float anRGB[3]; - anRGB[0] = GetFloat("SMESH:SettingsNodeColorRed",0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsNodeColorGreen",255)/255.; - anRGB[2] = GetFloat("SMESH:SettingsNodeColorBlue",0)/255.; - aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) ); + aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); - float aPointSize = GetFloat("SMESH:SettingsNodesSize",3); - aProp->SetPointSize(aPointSize); + float aPointSize = GetFloat( "SMESH:node_size", 3 ); + aProp->SetPointSize( aPointSize ); - myPreviewActor->SetProperty(aProp); + myPreviewActor->SetProperty( aProp ); aProp->Delete(); myViewWindow->AddActor(myPreviewActor); diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index 924450bb9..cc4ccdcaf 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -435,15 +435,15 @@ namespace SMESH{ return; } - QColor aHiColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white ), - aSelColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow ), - aPreColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan ); + QColor aHiColor = mgr->colorValue( "SMESH", "selection_object_color", Qt::white ), + aSelColor = mgr->colorValue( "SMESH", "selection_element_color", Qt::yellow ), + aPreColor = mgr->colorValue( "SMESH", "highlight_color", Qt::cyan ); - int SW = mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ), - PW = mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ); + int SW = mgr->integerValue( "SMESH", "selection_width", 5 ), + PW = mgr->integerValue( "SMESH", "highlight_width", 5 ); - double SP1 = mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ), - SP2 = mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ); + double SP1 = mgr->doubleValue( "SMESH", "selection_precision_node", 0.025 ), + SP2 = mgr->doubleValue( "SMESH", "selection_precision_element", 0.001 ); for ( int i=0, n=views.count(); i\n" "Content-Type: text/plain; charset=iso-8859-1\n" - #------------------------------------------------------------------------- # BUTTON #------------------------------------------------------------------------- @@ -1455,6 +1454,7 @@ msgid "SMESHGUI_SmoothingDlg::IS_PARAMETRIC" msgstr "in parametric space" #---------------SMESHGUI_SewingDlg----------- + msgid "SMESHGUI_SewingDlg::CREATE_POLYGONS_INSTEAD_SPLITTING" msgstr "Create polygons instead of splitting" @@ -1536,8 +1536,8 @@ msgstr "Nodes on the side 1 are either not linked or not laying on the element s msgid "SMESHGUI_SewingDlg::ERROR_9" msgstr "Nodes on the side 2 are either not linked or not laying on the element set boundary" - #---------------------------------------------------- + msgid "SMESHGUI_ExtrusionDlg::EXTRUSION_ALONG_LINE" msgstr "Extrusion along a line" @@ -1611,84 +1611,6 @@ msgstr "Revolution of 1D elements" msgid "SMESHGUI_RevolutionDlg::REVOLUTION_2D" msgstr "Revolution of 2D elements" -#---------------------------------------------------- - -msgid "SMESHGUI_SewingDlg::MERGE_EQUAL_ELEMENTS" -msgstr "Merge equal elements" - -msgid "SMESHGUI_SewingDlg::SEW_FREE_BORDERS" -msgstr "Sew Free Borders" - -msgid "SMESHGUI_SewingDlg::BORDER" -msgstr "Border" - -msgid "SMESHGUI_SewingDlg::BORDER_1" -msgstr "Border 1" - -msgid "SMESHGUI_SewingDlg::BORDER_2" -msgstr "Border 2" - -msgid "SMESHGUI_SewingDlg::SEW_CONFORM_FREE_BORDERS" -msgstr "Sew Conform Free Borders" - -msgid "SMESHGUI_SewingDlg::SEW_BORDER_TO_SIDE" -msgstr "Sew Border To Side" - -msgid "SMESHGUI_SewingDlg::SIDE" -msgstr "Side" - -msgid "SMESHGUI_SewingDlg::SEW_SIDE_ELEMENTS" -msgstr "Sew Side Elements" - -msgid "SMESHGUI_SewingDlg::SIDE_1" -msgstr "Side 1" - -msgid "SMESHGUI_SewingDlg::SIDE_2" -msgstr "Side 2" - -msgid "SMESHGUI_SewingDlg::NODE1_TO_MERGE" -msgstr "Node 1 To Merge" - -msgid "SMESHGUI_SewingDlg::NODE2_TO_MERGE" -msgstr "Node 2 To Merge" - -msgid "SMESHGUI_SewingDlg::FIRST_NODE_ID" -msgstr "First Node ID" - -msgid "SMESHGUI_SewingDlg::SECOND_NODE_ID" -msgstr "Second Node ID" - -msgid "SMESHGUI_SewingDlg::LAST_NODE_ID" -msgstr "Last Node ID" - -msgid "SMESHGUI_SewingDlg::ERROR_1" -msgstr "Free Border1 not found by the selected nodes" - -msgid "SMESHGUI_SewingDlg::ERROR_2" -msgstr "Free Border2 not found by the selected nodes" - -msgid "SMESHGUI_SewingDlg::ERROR_3" -msgstr "Free Border1 and Border2 not found by the selected nodes" - -msgid "SMESHGUI_SewingDlg::ERROR_4" -msgstr "No path from the first side node to the last side node have been found" - -msgid "SMESHGUI_SewingDlg::ERROR_5" -msgstr "Not allowed to splite volumes on the side!" - -msgid "SMESHGUI_SewingDlg::ERROR_6" -msgstr "Different number of elements selected on the sides" - -msgid "SMESHGUI_SewingDlg::ERROR_7" -msgstr "Element sets are topologically different or given nodes are inconvenient" - -msgid "SMESHGUI_SewingDlg::ERROR_8" -msgstr "Nodes on the side 1 are either not linked or not laying on the element set boundary" - -msgid "SMESHGUI_SewingDlg::ERROR_9" -msgstr "Nodes on the side 2 are either not linked or not laying on the element set boundary" - - #---------------------------------------------------- #Coincident nodes @@ -2800,3 +2722,81 @@ msgstr "Modification Toolbar" msgid "TB_DISP_MODE" msgstr "Display Mode Toolbar" +#------------------------------------------------------------------------- +# PREFEERENCES +#------------------------------------------------------------------------- + +msgid "SMESHGUI::PREF_TAB_GENERAL" +msgstr "General" + +msgid "SMESHGUI::PREF_GROUP_QUALITY" +msgstr "Quality controls" + +msgid "SMESHGUI::PREF_DISPLAY_ENTITY" +msgstr "Display entity" + +msgid "SMESHGUI::PREF_AUTO_UPDATE" +msgstr "Automatic update" + +msgid "SMESHGUI::PREF_PRECISION_USE" +msgstr "Use precision" + +msgid "SMESHGUI::PREF_PRECISION_VALUE" +msgstr "Number of digits after point" + +msgid "SMESHGUI::PREF_GROUP_PRECISION" +msgstr "Precision" + +msgid "SMESHGUI::PREF_TAB_MESH" +msgstr "Mesh" + +msgid "SMESHGUI::PREF_GROUP_NODES" +msgstr "Nodes" + +msgid "SMESHGUI::PREF_GROUP_ELEMENTS" +msgstr "Elements" + +msgid "SMESHGUI::PREF_COLOR" +msgstr "Color" + +msgid "SMESHGUI::PREF_SIZE" +msgstr "Size" + +msgid "SMESHGUI::PREF_WIDTH" +msgstr "Width" + +msgid "SMESHGUI::PREF_FILL" +msgstr "Fill" + +msgid "SMESHGUI::PREF_OUTLINE" +msgstr "Outline" + +msgid "SMESHGUI::PREF_BACKFACE" +msgstr "Back face" + +msgid "SMESHGUI::PREF_SHRINK_COEFF" +msgstr "Shrink coef." + +msgid "SMESHGUI::PREF_TAB_SELECTION" +msgstr "Selection" + +msgid "SMESHGUI::PREF_GROUP_SELECTION" +msgstr "Selection" + +msgid "SMESHGUI::PREF_GROUP_PRESELECTION" +msgstr "Preselection" + +msgid "SMESHGUI::PREF_OBJECT_COLOR" +msgstr "Object color" + +msgid "SMESHGUI::PREF_ELEMENT_COLOR" +msgstr "Element color" + +msgid "SMESHGUI::PREF_HIGHLIGHT_COLOR" +msgstr "Highlight color" + +msgid "SMESHGUI::PREF_NODES" +msgstr "Nodes" + +msgid "SMESHGUI::PREF_ELEMENTS" +msgstr "Elements"