From 577906c7b0205411b4cb816d1cefaf7d62a01d4c Mon Sep 17 00:00:00 2001 From: vsr Date: Sat, 29 Dec 2012 11:45:10 +0000 Subject: [PATCH] Imp: numbering font preferences --- resources/SalomeApp.xml.in | 12 +---- src/OBJECT/SMESH_Actor.cxx | 40 ++++++++++++---- src/SMESHGUI/SMESHGUI.cxx | 42 ++++------------ src/SMESHGUI/SMESHGUI.h | 7 +-- src/SMESHGUI/SMESHGUI_VTKUtils.cxx | 77 +++++++++++++++++++----------- src/SMESHGUI/SMESH_msg_en.ts | 28 ----------- src/SMESHGUI/SMESH_msg_fr.ts | 16 +++++++ 7 files changed, 112 insertions(+), 110 deletions(-) diff --git a/resources/SalomeApp.xml.in b/resources/SalomeApp.xml.in index b40da74b5..efad182db 100644 --- a/resources/SalomeApp.xml.in +++ b/resources/SalomeApp.xml.in @@ -95,17 +95,9 @@ - - - - - + - - - - - + diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index f1bb13d16..933f34c56 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -152,19 +152,39 @@ SMESH_ActorDef::SMESH_ActorDef() vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1); vtkFloatingPointType aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1); - int aSizeNd = mgr->integerValue( "SMESH", "numbering_node_size", 10 ); - SMESH::LabelFont aFamilyNd = (SMESH::LabelFont)( mgr->integerValue( "SMESH", "numbering_node_font", 2 ) ); - bool aBoldNd = mgr->booleanValue( "SMESH", "numbering_node_bold", true ); - bool anItalicNd = mgr->booleanValue( "SMESH", "numbering_node_italic", false ); - bool aShadowNd = mgr->booleanValue( "SMESH", "numbering_node_shadow", false ); + SMESH::LabelFont aFamilyNd = SMESH::FntTimes; + bool aBoldNd = true; + bool anItalicNd = false; + bool aShadowNd = false; + int aSizeNd = 10; + if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) { + QFont f = mgr->fontValue( "SMESH", "numbering_node_font" ); + if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial; + else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier; + else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes; + aBoldNd = f.bold(); + anItalicNd = f.italic(); + aShadowNd = f.overline(); + aSizeNd = f.pointSize(); + } vtkFloatingPointType anRGBNd[3] = {1,1,1}; SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) ); - int aSizeEl = mgr->integerValue( "SMESH", "numbering_elem_size", 12 ); - SMESH::LabelFont aFamilyEl = (SMESH::LabelFont)( mgr->integerValue( "SMESH", "numbering_elem_font", 2 ) ); - bool aBoldEl = mgr->booleanValue( "SMESH", "numbering_elem_bold", true ); - bool anItalicEl = mgr->booleanValue( "SMESH", "numbering_elem_italic", false ); - bool aShadowEl = mgr->booleanValue( "SMESH", "numbering_elem_shadow", false ); + SMESH::LabelFont aFamilyEl = SMESH::FntTimes; + bool aBoldEl = true; + bool anItalicEl = false; + bool aShadowEl = false; + int aSizeEl = 12; + if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) { + QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" ); + if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial; + else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier; + else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes; + aBoldEl = f.bold(); + anItalicEl = f.italic(); + aShadowEl = f.overline(); + aSizeEl = f.pointSize(); + } vtkFloatingPointType anRGBEl[3] = {0,1,0}; SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) ); diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index b252b541c..b509f6ac1 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -4885,32 +4885,13 @@ void SMESHGUI::createPreferences() setPreferenceProperty( shrink, "max", 100 ); int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab ); - setPreferenceProperty( numGroup, "columns", 6 ); - QStringList fonts; - fonts << tr( "SMESH_ARIAL" ) << tr( "SMESH_COURIER" ) << tr( "SMESH_TIMES" ); - indices.clear(); indices << 0 << 1 << 2; - // ... + setPreferenceProperty( numGroup, "columns", 2 ); + addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" ); - int NumNodeSize = addPreference( tr( "PREF_NUMBERING_SIZE" ), numGroup, LightApp_Preferences::IntSpin, "SMESH", "numbering_node_size" ); - setPreferenceProperty( NumNodeSize, "min", 1 ); - setPreferenceProperty( NumNodeSize, "max", 100 ); - int NumFontNode = addPreference( tr( "PREF_NUMBERING_FONT" ), numGroup, LightApp_Preferences::Selector, "SMESH", "numbering_node_font" ); - setPreferenceProperty( NumFontNode, "strings", fonts ); - setPreferenceProperty( NumFontNode, "indexes", indices ); - addPreference( tr( "PREF_NUMBERING_BOLD" ), numGroup, LightApp_Preferences::Bool, "SMESH", "numbering_node_bold" ); - addPreference( tr( "PREF_NUMBERING_ITALIC" ), numGroup, LightApp_Preferences::Bool, "SMESH", "numbering_node_italic" ); - addPreference( tr( "PREF_NUMBERING_SHADOW" ), numGroup, LightApp_Preferences::Bool, "SMESH", "numbering_node_shadow" ); - // ... + addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true ); + addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" ); - int NumElemSize = addPreference( tr( "PREF_NUMBERING_SIZE" ), numGroup, LightApp_Preferences::IntSpin, "SMESH", "numbering_elem_size" ); - setPreferenceProperty( NumElemSize, "min", 1 ); - setPreferenceProperty( NumElemSize, "max", 100 ); - int NumFontElem = addPreference( tr( "PREF_NUMBERING_FONT" ), numGroup, LightApp_Preferences::Selector, "SMESH", "numbering_elem_font" ); - setPreferenceProperty( NumFontElem, "strings", fonts ); - setPreferenceProperty( NumFontElem, "indexes", indices ); - addPreference( tr( "PREF_NUMBERING_BOLD" ), numGroup, LightApp_Preferences::Bool, "SMESH", "numbering_elem_bold" ); - addPreference( tr( "PREF_NUMBERING_ITALIC" ), numGroup, LightApp_Preferences::Bool, "SMESH", "numbering_elem_italic" ); - addPreference( tr( "PREF_NUMBERING_SHADOW" ), numGroup, LightApp_Preferences::Bool, "SMESH", "numbering_elem_shadow" ); + addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true ); int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab ); setPreferenceProperty( orientGroup, "columns", 1 ); @@ -5098,14 +5079,10 @@ void SMESHGUI::preferencesChanged( const QString& sect, const QString& name ) QString val = aResourceMgr->stringValue( "SMESH", name ); myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() ); } - else if(name == QString("numbering_node_color") || name == QString("numbering_node_size") || - name == QString("numbering_node_font") || name == QString("numbering_node_bold") || - name == QString("numbering_node_italic") || name == QString("numbering_node_shadow") ) { - SMESH::UpdateFontProp( this ); + else if ( name == QString( "numbering_node_color" ) || name == QString( "numbering_node_font" ) ) { + SMESH::UpdateFontProp( this ); } - else if(name == QString("numbering_elem_color") || name == QString("numbering_elem_size") || - name == QString("numbering_elem_font") || name == QString("numbering_elem_bold") || - name == QString("numbering_elem_italic") || name == QString("numbering_elem_shadow") ) { + else if ( name == QString( "numbering_elem_color" ) || name == QString( "numbering_elem_font" ) ) { SMESH::UpdateFontProp( this ); } @@ -6375,7 +6352,7 @@ void SMESHGUI::restoreVisualParameters (int savePoint) \param param parameter \return identifier of preferences */ -int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param ) +int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize ) { int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param ); @@ -6389,6 +6366,7 @@ int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString setPreferenceProperty( tfont, "fonts", fam ); int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow; + if ( needSize ) f = f | QtxFontEdit::Size; setPreferenceProperty( tfont, "features", f ); return tfont; diff --git a/src/SMESHGUI/SMESHGUI.h b/src/SMESHGUI/SMESHGUI.h index 6f5237ce3..f45cfbfb5 100644 --- a/src/SMESHGUI/SMESHGUI.h +++ b/src/SMESHGUI/SMESHGUI.h @@ -200,9 +200,10 @@ protected: private: void OnEditDelete(); - int addVtkFontPref( const QString& label, - const int pId, - const QString& param ); + int addVtkFontPref( const QString&, + const int, + const QString&, + const bool = false); void connectView( const SUIT_ViewWindow* ); diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index dcc093c07..229d7f809 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -963,42 +963,65 @@ namespace SMESH // vtkFloatingPointType anRGBNd[3] = {1,1,1}; SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) ); - int aSizeNd = mgr->integerValue( "SMESH", "numbering_node_size", 10 ); - SMESH::LabelFont aFamilyNd = (SMESH::LabelFont)( mgr->integerValue( "SMESH", "numbering_node_font", 2 ) ); - bool aBoldNd = mgr->booleanValue( "SMESH", "numbering_node_bold", true ); - bool anItalicNd = mgr->booleanValue( "SMESH", "numbering_node_italic", false ); - bool aShadowNd = mgr->booleanValue( "SMESH", "numbering_node_shadow", false ); + int aSizeNd = 10; + SMESH::LabelFont aFamilyNd = SMESH::FntTimes; + bool aBoldNd = true; + bool anItalicNd = false; + bool aShadowNd = false; + + if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) { + QFont f = mgr->fontValue( "SMESH", "numbering_node_font" ); + if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial; + else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier; + else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes; + aBoldNd = f.bold(); + anItalicNd = f.italic(); + aShadowNd = f.overline(); + aSizeNd = f.pointSize(); + } // vtkFloatingPointType anRGBEl[3] = {0,1,0}; SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) ); - int aSizeEl = mgr->integerValue( "SMESH", "numbering_elem_size", 12 ); - SMESH::LabelFont aFamilyEl = (SMESH::LabelFont)( mgr->integerValue( "SMESH", "numbering_elem_font", 2 ) ); - bool aBoldEl = mgr->booleanValue( "SMESH", "numbering_elem_bold", true ); - bool anItalicEl = mgr->booleanValue( "SMESH", "numbering_elem_italic", false ); - bool aShadowEl = mgr->booleanValue( "SMESH", "numbering_elem_shadow", false ); + int aSizeEl = 12; + SMESH::LabelFont aFamilyEl = SMESH::FntTimes; + bool aBoldEl = true; + bool anItalicEl = false; + bool aShadowEl = false; + + if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) { + QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" ); + + if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial; + else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier; + else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes; + aBoldEl = f.bold(); + anItalicEl = f.italic(); + aShadowEl = f.overline(); + aSizeEl = f.pointSize(); + } // ViewManagerList vmList; app->viewManagers( SVTK_Viewer::Type(), vmList ); foreach ( SUIT_ViewManager* vm, vmList ) { QVector views = vm->getViews(); foreach ( SUIT_ViewWindow* vw, views ) { - // update VTK viewer properties - if ( SVTK_ViewWindow* aVtkView = GetVtkViewWindow( vw ) ) { - // update actors - vtkRenderer* aRenderer = aVtkView->getRenderer(); - VTK::ActorCollectionCopy aCopy( aRenderer->GetActors() ); - vtkActorCollection* aCollection = aCopy.GetActors(); - aCollection->InitTraversal(); - while ( vtkActor* anAct = aCollection->GetNextActor() ) { - if ( SMESH_NodeLabelActor* anActor = dynamic_cast< SMESH_NodeLabelActor* >( anAct ) ) { - anActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] ); - } - else if ( SMESH_CellLabelActor* anActor = dynamic_cast< SMESH_CellLabelActor* >( anAct ) ) { - anActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] ); - } - } - aVtkView->Repaint( false ); - } + // update VTK viewer properties + if ( SVTK_ViewWindow* aVtkView = GetVtkViewWindow( vw ) ) { + // update actors + vtkRenderer* aRenderer = aVtkView->getRenderer(); + VTK::ActorCollectionCopy aCopy( aRenderer->GetActors() ); + vtkActorCollection* aCollection = aCopy.GetActors(); + aCollection->InitTraversal(); + while ( vtkActor* anAct = aCollection->GetNextActor() ) { + if ( SMESH_NodeLabelActor* anActor = dynamic_cast< SMESH_NodeLabelActor* >( anAct ) ) { + anActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] ); + } + else if ( SMESH_CellLabelActor* anActor = dynamic_cast< SMESH_CellLabelActor* >( anAct ) ) { + anActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] ); + } + } + aVtkView->Repaint( false ); + } } } } diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 78680c95f..c0f36aa9f 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -2232,38 +2232,10 @@ Check algorithm documentation for supported geometry PREF_NUMBERING_ELEM Edges: Color - - PREF_NUMBERING_SIZE - Size - PREF_NUMBERING_FONT Font - - SMESH_ARIAL - Arial - - - SMESH_COURIER - Courier - - - SMESH_TIMES - Times - - - PREF_NUMBERING_BOLD - Bold - - - PREF_NUMBERING_ITALIC - Italic - - - PREF_NUMBERING_SHADOW - Shadow - SMESH_PREFERENCES_SCALARBAR Scalar Bar Preferences diff --git a/src/SMESHGUI/SMESH_msg_fr.ts b/src/SMESHGUI/SMESH_msg_fr.ts index 845d6a4c7..74dbb0125 100755 --- a/src/SMESHGUI/SMESH_msg_fr.ts +++ b/src/SMESHGUI/SMESH_msg_fr.ts @@ -2192,6 +2192,22 @@ Référez-vous à la documentation sur l'algorithme et la géométrie suppo SMESH_PRECISION Précision + + PREF_GROUP_NUMBERING + Numbering + + + PREF_NUMBERING_NODE + Nodes: Color + + + PREF_NUMBERING_ELEM + Edges: Color + + + PREF_NUMBERING_FONT + Police + SMESH_PREFERENCES_SCALARBAR Préférences de la barre d'échelle -- 2.39.2