From f42e2228e6f3cb43d0142d024f95fc40e29250d3 Mon Sep 17 00:00:00 2001 From: sln Date: Tue, 9 Dec 2008 12:28:09 +0000 Subject: [PATCH] 0013557: field values display Now you can display values applied to the cells or nodes of 3D presentation intended for visualization of calculation data. VisuGUI is updated corresponding actions and slots for this. Also problems with preferences of VTK font is solved. --- src/VISUGUI/Makefile.am | 9 +- src/VISUGUI/VisuGUI.cxx | 158 +++++++++++++++++++++++++++---- src/VISUGUI/VisuGUI.h | 4 + src/VISUGUI/VisuGUI_ActionsDef.h | 4 + 4 files changed, 156 insertions(+), 19 deletions(-) diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index 6abacc7d..959e972e 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -71,7 +71,8 @@ salomeinclude_HEADERS= \ VisuGUI_Slider.h \ VisuGUI_InputPane.h \ VisuGUI_CacheDlg.h \ - VisuGUI_FieldFilter.h + VisuGUI_FieldFilter.h \ + VisuGUI_ValuesLabelingDlg.h dist_libVISU_la_SOURCES= \ VisuGUI.cxx \ @@ -121,7 +122,8 @@ dist_libVISU_la_SOURCES= \ VisuGUI_FieldFilter.cxx \ VisuGUI_ClippingPanel.cxx \ VisuGUI_ClippingPlaneDlg.cxx \ - VisuGUI_FilterScalarsDlg.cxx + VisuGUI_FilterScalarsDlg.cxx \ + VisuGUI_ValuesLabelingDlg.cxx MOC_FILES= \ VisuGUI_moc.cxx \ @@ -164,7 +166,8 @@ MOC_FILES= \ VisuGUI_FileInfoDlg_moc.cxx \ VisuGUI_ClippingPanel_moc.cxx \ VisuGUI_ClippingPlaneDlg_moc.cxx \ - VisuGUI_FilterScalarsDlg_moc.cxx + VisuGUI_FilterScalarsDlg_moc.cxx \ + VisuGUI_ValuesLabelingDlg_moc.cxx nodist_libVISU_la_SOURCES=$(MOC_FILES) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index ebe2c5c3..815df26d 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -161,7 +161,9 @@ #include "VisuGUI_Slider.h" #include "VisuGUI_Sweep.h" - +#include +#include +#include using namespace VISU; @@ -2558,6 +2560,15 @@ VisuGUI createAction( VISU_FILTERSCALARS, tr("MEN_FILTER_SCALARS"), QIcon(), tr("MEN_FILTER_SCALARS"), "", 0, aParent, false, this, SLOT(OnFilterScalars())); + + createAction( VISU_VALUES_LABELING, tr("MEN_VALUES_LABELING"), QIcon(), + tr("MEN_VALUES_LABELING"), "", 0, aParent, true, + this, SLOT(OnValuesLabeling())); + + createAction( VISU_VALUES_LABELING_PARAMS, tr("VISU_VALUES_LABELING_PARAMS"), QIcon(), + tr("VISU_VALUES_LABELING_PARAMS"), "", 0, aParent, false, + this, SLOT(OnValuesLabelingParams())); + } void @@ -2684,6 +2695,12 @@ VisuGUI // delete mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 ); + + // labeling + mgr->insert( separator(), -1, -1, -1 ); + mgr->insert( action( VISU_VALUES_LABELING ), -1, -1, -1 ); + mgr->insert( action( VISU_VALUES_LABELING_PARAMS ), -1, -1, -1 ); + mgr->insert( separator(), -1, -1, -1 ); // table commands mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table @@ -2811,6 +2828,13 @@ VisuGUI aRule = "selcount=1 and $type in { " + aSimplePrsAll + "}"; mgr->setRule( action( VISU_FILTERSCALARS ), aRule ); + + // labeling + + aRule = "hasActor=1 and selcount=1 and $type in { 'VISU::TGAUSSPOINTS'" + aPrsAll + " }"; + mgr->setRule( action( VISU_VALUES_LABELING ), aRule, QtxPopupMgr::VisibleRule ); + mgr->setRule( action( VISU_VALUES_LABELING ), "{true} in $isValuesLabeled", QtxPopupMgr::ToggleRule ); + mgr->setRule( action( VISU_VALUES_LABELING_PARAMS ), aRule, QtxPopupMgr::VisibleRule ); // view parameters aRule = "selcount=1 and type='VISU::TVIEW3D' and activeView='VTKViewer'"; @@ -3319,23 +3343,11 @@ void VisuGUI::createPreferences() int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab ); setPreferenceProperty( fontGr, "columns", 2 ); - int tfont = addPreference( tr( "VISU_TITLE" ), fontGr, LightApp_Preferences::Font, "VISU", "scalar_bar_title_font" ); + addVtkFontPref( tr( "VISU_TITLE" ), fontGr, "scalar_bar_title_font", false ); addPreference( tr( "VISU_TITLE" ), fontGr, LightApp_Preferences::Color, "VISU", "scalar_bar_title_color" ); - int lfont = addPreference( tr( "VISU_LABELS" ), fontGr, LightApp_Preferences::Font, "VISU", "scalar_bar_label_font" ); - addPreference( tr( "VISU_LABELS" ), fontGr, LightApp_Preferences::Color, "VISU", "scalar_bar_label_color" ); - QStringList fam; - fam.append( tr( "VISU_FONT_ARIAL" ) ); - fam.append( tr( "VISU_FONT_COURIER" ) ); - fam.append( tr( "VISU_FONT_TIMES" ) ); - int wflag = ( QtxFontEdit::All & ( ~( QtxFontEdit::Size | QtxFontEdit::UserSize ) ) ); - - setPreferenceProperty( tfont, "families", fam ); - setPreferenceProperty( tfont, "system", false ); - setPreferenceProperty( tfont, "widget_flags", wflag ); - setPreferenceProperty( lfont, "families", fam ); - setPreferenceProperty( lfont, "system", false ); - setPreferenceProperty( lfont, "widget_flags", wflag ); + addVtkFontPref( tr( "VISU_LABELS" ), fontGr, "scalar_bar_label_font", false ); + addPreference( tr( "VISU_LABELS" ), fontGr, LightApp_Preferences::Color, "VISU", "scalar_bar_label_color" ); // group: "Colors & Labels" int colorsLabelsGr = addPreference( tr( "VISU_COLORS_AND_LABELS" ), sbarTab ); @@ -3735,6 +3747,22 @@ void VisuGUI::createPreferences() addPreference( tr( "VISU_SHOW_MANIFOLD_EDGES" ), featureEdgesGr, LightApp_Preferences::Bool, "VISU", "show_manifold_edges" ); addPreference( tr( "VISU_SHOW_NON_MANIFOLD_EDGES" ), featureEdgesGr, LightApp_Preferences::Bool, "VISU", "show_non_manifold_edges" ); //addPreference( tr( "VISU_FEATURE_EDGES_COLORING" ), featureEdgesGr, LightApp_Preferences::Bool, "VISU", "feature_edges_coloring" ); + + // TAB: "Values labels" + + int valLblTab = addPreference( tr( "VALUES_LABELING" ) ); + + // "Font" group + int valLblFontGr = addPreference( tr( "VISU_FONT" ), valLblTab ); + setPreferenceProperty( valLblFontGr, "columns", 2 ); + + // font + addVtkFontPref( tr( "LABELS" ), valLblFontGr, "values_labeling_font", true ); + + // color + addPreference( tr( "COLOR" ), valLblFontGr, + LightApp_Preferences::Color, "VISU", "values_labeling_color" ); + } void VisuGUI::preferencesChanged( const QString& a, const QString& b) @@ -4087,3 +4115,101 @@ void VisuGUI::OnFilterScalars() VisuGUI_FilterScalarsDlg* aDlg = new VisuGUI_FilterScalarsDlg( this ); aDlg->show(); } + +/*! + \brief SLOT called when "Labeling" popup menu item of presentation is clicked + activates/deactivates labeling of results of the screen. This functionality works + to numbering in SMESH module but is intended for showing results on the screen + instead of elements numbers + \sa OnValuesLabelingParams() +*/ +void VisuGUI::OnValuesLabeling() +{ + // to do: rewrite for several actors if necessary + + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects( this ); + if ( aSelectionInfo.empty() ) + return; + + TSelectionItem aSelectionItem = GetSelectedObjects(this).front(); + VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase); + if(!aPrs3d) + return; + + SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(this); + if(!aViewWindow) + return; + + VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d); + if(!anActor) + return; + + if( VISU_ScalarMapAct* aScalarMapActor = dynamic_cast(anActor) ) + { + aScalarMapActor->SetValuesLabeled( !aScalarMapActor->GetValuesLabeled() ); + aViewWindow->Repaint(); + } + else if( VISU_GaussPtsAct* aGaussPtsAct = dynamic_cast(anActor) ) + { + aGaussPtsAct->SetValuesLabeled( !aGaussPtsAct->GetValuesLabeled() ); + aViewWindow->Repaint(); + } +} + +/*! + \brief SLOT called when "Labeling parameters" popup menu item of presentation + is clicked launch dialog box for changing parameters of labeling + \sa OnValuesLabeling() +*/ +void VisuGUI::OnValuesLabelingParams() +{ + Handle(SALOME_InteractiveObject) anIO; + if ( VISU::Prs3d_i* aPrs3d = GetPrsToModify( this, anIO ) ) + EditPrs3d(this, anIO, aPrs3d); +} +/*! + \brief Adds preferences for dfont of VTK viewer + \param label label + \param pIf group identifier + \param param parameter + \return identifier of preferences +*/ +int VisuGUI::addVtkFontPref( + const QString& label, + const int pId, + const QString& param, + const bool useSize ) +{ + int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param ); + + setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom ); + + QStringList fam; + fam.append( tr( "VISU_FONT_ARIAL" ) ); + fam.append( tr( "VISU_FONT_COURIER" ) ); + fam.append( tr( "VISU_FONT_TIMES" ) ); + + setPreferenceProperty( tfont, "fonts", fam ); + + int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow; + if ( useSize ) + f |= QtxFontEdit::UserSize | QtxFontEdit::Size; + + setPreferenceProperty( tfont, "features", f ); + + return tfont; +} + + + + + + + + + + + + + + diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 0900c1a0..6ca1a8a2 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -185,6 +185,9 @@ protected slots: void OnManageCache(); void OnFilterScalars(); + + void OnValuesLabeling(); + void OnValuesLabelingParams(); // MULTIPR void OnMultiprViewFullRes(); @@ -207,6 +210,7 @@ private: void createToolBars(); void createPopupMenus(); void createPanels(); + int addVtkFontPref( const QString& label, const int pId, const QString& param, const bool useSize ); private: QMap< PanelId, VisuGUI_Panel* > myPanels; diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 21cdc5bf..0abafd3f 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -141,4 +141,8 @@ #define VISU_SWEEP_PANEL 4300 #define VISU_FILTERSCALARS 4301 +#define VISU_VALUES_LABELING 4302 +#define VISU_VALUES_LABELING_PARAMS 4303 + + #endif -- 2.39.2