From bf4c544a906546d7f31ce782f489f092e5ee3637 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 1 Apr 2008 07:48:40 +0000 Subject: [PATCH] Preferences filling --- src/Plot2d/Plot2d_ViewManager.cxx | 78 +++++++++++++++++++ src/Plot2d/Plot2d_ViewManager.h | 3 + src/Plot2d/resources/Plot2d_msg_en.po | 52 +++++++++++++ src/Plot2d/resources/Plot2d_msg_en.ts | 68 ++++++++++++++++ src/SVTK/SVTK_ViewManager.cxx | 40 ++++++++++ src/SVTK/SVTK_ViewManager.h | 5 ++ src/SVTK/resources/SVTK_msg_en.po | 9 +++ src/SVTK/resources/SVTK_msg_en.ts | 16 ++++ src/TableViewer/TableViewer_ViewManager.cxx | 20 +++++ src/TableViewer/TableViewer_ViewManager.h | 6 ++ .../resources/TableViewer_msg_en.ts | 15 +++- src/VTKViewer/VTKViewer_ViewManager.cxx | 37 +++++++++ src/VTKViewer/VTKViewer_ViewManager.h | 5 ++ src/VTKViewer/resources/VTKViewer_msg_en.po | 12 +++ src/VTKViewer/resources/VTKViewer_msg_en.ts | 16 ++++ 15 files changed, 378 insertions(+), 4 deletions(-) diff --git a/src/Plot2d/Plot2d_ViewManager.cxx b/src/Plot2d/Plot2d_ViewManager.cxx index 7681bd3f2..cccfe1865 100755 --- a/src/Plot2d/Plot2d_ViewManager.cxx +++ b/src/Plot2d/Plot2d_ViewManager.cxx @@ -20,6 +20,9 @@ #include "Plot2d_ViewModel.h" #include "Plot2d_ViewWindow.h" +#include "SUIT_PreferenceMgr.h" +#include "SUIT_ResourceMgr.h" + /*! Constructor */ @@ -83,3 +86,78 @@ void Plot2d_ViewManager::onCloneView() if( newWnd && clonedWnd ) emit cloneView( clonedWnd->getViewFrame(), newWnd->getViewFrame() ); } + +/*! + Fills preference manager for viewer +*/ +int Plot2d_ViewManager::fillPreferences( SUIT_PreferenceMgr* thePrefMgr, const int theId ) +{ + int aGrpId = thePrefMgr->addItem( tr( "PREF_GROUP_PLOT2DVIEWER" ), theId, + SUIT_PreferenceMgr::GroupBox ); + + thePrefMgr->addItem( tr( "PREF_SHOW_LEGEND" ), aGrpId, + SUIT_PreferenceMgr::Bool, "Plot2d", "ShowLegend" ); + + int legendPosition = thePrefMgr->addItem( tr( "PREF_LEGEND_POSITION" ), aGrpId, + SUIT_PreferenceMgr::Selector, "Plot2d", "LegendPos" ); + QStringList aLegendPosList; + aLegendPosList.append( tr("PREF_LEFT") ); + aLegendPosList.append( tr("PREF_RIGHT") ); + aLegendPosList.append( tr("PREF_TOP") ); + aLegendPosList.append( tr("PREF_BOTTOM") ); + + QList anIndexesList; + anIndexesList.append(0); + anIndexesList.append(1); + anIndexesList.append(2); + anIndexesList.append(3); + + thePrefMgr->setItemProperty( "strings", aLegendPosList, legendPosition ); + thePrefMgr->setItemProperty( "indexes", anIndexesList, legendPosition ); + + int curveType = thePrefMgr->addItem( tr( "PREF_CURVE_TYPE" ), aGrpId, + SUIT_PreferenceMgr::Selector, "Plot2d", "CurveType" ); + QStringList aCurveTypesList; + aCurveTypesList.append( tr("PREF_POINTS") ); + aCurveTypesList.append( tr("PREF_LINES") ); + aCurveTypesList.append( tr("PREF_SPLINE") ); + + anIndexesList.clear(); + anIndexesList.append(0); + anIndexesList.append(1); + anIndexesList.append(2); + + thePrefMgr->setItemProperty( "strings", aCurveTypesList, curveType ); + thePrefMgr->setItemProperty( "indexes", anIndexesList, curveType ); + + int markerSize = thePrefMgr->addItem( tr( "PREF_MARKER_SIZE" ), aGrpId, + SUIT_PreferenceMgr::IntSpin, "Plot2d", "MarkerSize" ); + + thePrefMgr->setItemProperty( "min", 0, markerSize ); + thePrefMgr->setItemProperty( "max", 100, markerSize ); + + QStringList aScaleModesList; + aScaleModesList.append( tr("PREF_LINEAR") ); + aScaleModesList.append( tr("PREF_LOGARITHMIC") ); + + anIndexesList.clear(); + anIndexesList.append(0); + anIndexesList.append(1); + + int horScale = thePrefMgr->addItem( tr( "PREF_HOR_AXIS_SCALE" ), aGrpId, + SUIT_PreferenceMgr::Selector, "Plot2d", "HorScaleMode" ); + + thePrefMgr->setItemProperty( "strings", aScaleModesList, horScale ); + thePrefMgr->setItemProperty( "indexes", anIndexesList, horScale ); + + int verScale = thePrefMgr->addItem( tr( "PREF_VERT_AXIS_SCALE" ), aGrpId, + SUIT_PreferenceMgr::Selector, "Plot2d", "VerScaleMode" ); + + thePrefMgr->setItemProperty( "strings", aScaleModesList, verScale ); + thePrefMgr->setItemProperty( "indexes", anIndexesList, verScale ); + + thePrefMgr->addItem( tr( "PREF_VIEWER_BACKGROUND" ), aGrpId, + SUIT_PreferenceMgr::Color, "Plot2d", "Background" ); + + return aGrpId; +} diff --git a/src/Plot2d/Plot2d_ViewManager.h b/src/Plot2d/Plot2d_ViewManager.h index a26b01cb6..42b23a02c 100755 --- a/src/Plot2d/Plot2d_ViewManager.h +++ b/src/Plot2d/Plot2d_ViewManager.h @@ -23,6 +23,7 @@ #include "SUIT_ViewManager.h" class SUIT_Desktop; +class SUIT_PreferenceMgr; class Plot2d_Viewer; class Plot2d_ViewFrame; @@ -36,6 +37,8 @@ public: Plot2d_Viewer* getPlot2dModel() const; + static int fillPreferences( SUIT_PreferenceMgr*, const int ); + protected: bool insertView(SUIT_ViewWindow* theView); diff --git a/src/Plot2d/resources/Plot2d_msg_en.po b/src/Plot2d/resources/Plot2d_msg_en.po index e0d764da7..33937e349 100755 --- a/src/Plot2d/resources/Plot2d_msg_en.po +++ b/src/Plot2d/resources/Plot2d_msg_en.po @@ -409,3 +409,55 @@ msgstr "PostScript files (*.ps)" msgid "Plot2d_ViewManager::PLOT2D_VIEW_TITLE" msgstr "Plot2d scene:%M - viewer:%V" + +msgid "Plot2d_ViewManager::PREF_GROUP_PLOT2DVIEWER" +msgstr "Plot2d Viewer" + +msgid "Plot2d_ViewManager::PREF_SHOW_LEGEND" +msgstr "Show legend" + +msgid "Plot2d_ViewManager::PREF_LEGEND_POSITION" +msgstr "Legend position:" + +msgid "Plot2d_ViewManager::PREF_LEFT" +msgstr "Left" + +msgid "Plot2d_ViewManager::PREF_RIGHT" +msgstr "Right" + +msgid "Plot2d_ViewManager::PREF_TOP" +msgstr "Top" + +msgid "Plot2d_ViewManager::PREF_BOTTOM<" +msgstr "Bottom" + +msgid "Plot2d_ViewManager::PREF_CURVE_TYPE" +msgstr "Curve type:" + +msgid "Plot2d_ViewManager::PREF_POINTS" +msgstr "Points" + +msgid "Plot2d_ViewManager::PREF_LINES" +msgstr "Lines" + +msgid "Plot2d_ViewManager::PREF_SPLINE" +msgstr "Spline" + +msgid "Plot2d_ViewManager::PREF_MARKER_SIZE" +msgstr "Marker size:" + +msgid "Plot2d_ViewManager::PREF_LINEAR" +msgstr "Linear" + +msgid "Plot2d_ViewManager::PREF_LOGARITHMIC" +msgstr "Logarithmic" + +msgid "Plot2d_ViewManager::PREF_HOR_AXIS_SCALE" +msgstr "Horizontal axis scale:" + +msgid "Plot2d_ViewManager::PREF_VERT_AXIS_SCALE" +msgstr "Vertical axis scale:" + +msgid "Plot2d_ViewManager::PREF_VIEWER_BACKGROUND" +msgstr "Background color" + diff --git a/src/Plot2d/resources/Plot2d_msg_en.ts b/src/Plot2d/resources/Plot2d_msg_en.ts index e21439e0d..c75674898 100644 --- a/src/Plot2d/resources/Plot2d_msg_en.ts +++ b/src/Plot2d/resources/Plot2d_msg_en.ts @@ -509,5 +509,73 @@ Logarithmic scale for ordinate axis is not allowed. PLOT2D_VIEW_TITLE Plot2d scene:%M - viewer:%V + + PREF_GROUP_PLOT2DVIEWER + Plot2d Viewer + + + PREF_SHOW_LEGEND + Show legend + + + PREF_LEGEND_POSITION + Legend position: + + + PREF_LEFT + Left + + + PREF_RIGHT + Right + + + PREF_TOP + Top + + + PREF_BOTTOM + Bottom + + + PREF_CURVE_TYPE + Curve type: + + + PREF_POINTS + Points + + + PREF_LINES + Lines + + + PREF_SPLINE + Spline + + + PREF_MARKER_SIZE + Marker size: + + + PREF_LINEAR + Linear + + + PREF_LOGARITHMIC + Logarithmic + + + PREF_HOR_AXIS_SCALE + Horizontal axis scale: + + + PREF_VERT_AXIS_SCALE + Vertical axis scale: + + + PREF_VIEWER_BACKGROUND + Background color + diff --git a/src/SVTK/SVTK_ViewManager.cxx b/src/SVTK/SVTK_ViewManager.cxx index b7856fdc7..53a7a1cc6 100644 --- a/src/SVTK/SVTK_ViewManager.cxx +++ b/src/SVTK/SVTK_ViewManager.cxx @@ -21,6 +21,9 @@ #include +#include +#include + /*! Constructor */ @@ -44,3 +47,40 @@ SUIT_Desktop* SVTK_ViewManager::getDesktop() { return myDesktop; } + +/*! + Fills preference manager for viewer +*/ +int SVTK_ViewManager::fillPreferences( SUIT_PreferenceMgr* thePrefMgr, const int theId ) +{ + int aGrpId = thePrefMgr->addItem( tr( "PREF_GROUP_VTKVIEWER" ), theId, + SUIT_PreferenceMgr::GroupBox ); + + int vtkTS = thePrefMgr->addItem( tr( "PREF_TRIHEDRON_SIZE" ), aGrpId, + SUIT_PreferenceMgr::DblSpin, "VTKViewer", "trihedron_size" ); + thePrefMgr->addItem( tr( "PREF_RELATIVE_SIZE" ), aGrpId, SUIT_PreferenceMgr::Bool, + "VTKViewer", "relative_size" ); + thePrefMgr->addItem( tr( "PREF_VIEWER_BACKGROUND" ), aGrpId, + SUIT_PreferenceMgr::Color, "VTKViewer", "background" ); + + thePrefMgr->setItemProperty( "min", 1.0E-06, vtkTS ); + thePrefMgr->setItemProperty( "max", 150, vtkTS ); + + return aGrpId; +} + +/** + * Fills values from resources + */ +void SVTK_ViewManager::fillFrom( SUIT_ResourceMgr* theMgr ) +{ + SVTK_Viewer* aModel = dynamic_cast( getViewModel() ); + if ( !aModel ) + return; + + aModel->setBackgroundColor( theMgr->colorValue( "VTKViewer", "background", + aModel->backgroundColor() ) ); + aModel->setTrihedronSize( + theMgr->doubleValue( "VTKViewer", "trihedron_size", aModel->trihedronSize() ), + theMgr->booleanValue( "VTKViewer", "relative_size", aModel->trihedronRelative() ) ); +} diff --git a/src/SVTK/SVTK_ViewManager.h b/src/SVTK/SVTK_ViewManager.h index 8ff4efcc9..d14a9fa41 100644 --- a/src/SVTK/SVTK_ViewManager.h +++ b/src/SVTK/SVTK_ViewManager.h @@ -23,6 +23,8 @@ #include "SVTK.h" class SUIT_Desktop; +class SUIT_PreferenceMgr; +class SUIT_ResourceMgr; //! Extend SUIT_ViewManager to deal with SVTK_Viewer class SVTK_EXPORT SVTK_ViewManager : public SUIT_ViewManager @@ -37,6 +39,9 @@ public: virtual ~SVTK_ViewManager(); SUIT_Desktop* getDesktop(); + + static int fillPreferences( SUIT_PreferenceMgr*, const int ); + void fillFrom( SUIT_ResourceMgr* ); }; #endif diff --git a/src/SVTK/resources/SVTK_msg_en.po b/src/SVTK/resources/SVTK_msg_en.po index 609f62c2b..d2112a2dc 100755 --- a/src/SVTK/resources/SVTK_msg_en.po +++ b/src/SVTK/resources/SVTK_msg_en.po @@ -149,6 +149,15 @@ msgstr "Change background..." msgid "SVTK_ViewManager::VTK_VIEW_TITLE" msgstr "VTK scene:%1 - viewer:%2" +msgid "SVTK_ViewManager::PREF_TRIHEDRON_SIZE" +msgstr "Trihedron size" + +msgid "SVTK_ViewManager::PREF_VIEWER_BACKGROUND" +msgstr "Background color" + +msgid "SVTK_ViewManager::PREF_RELATIVE_SIZE" +msgstr "Relative size" + msgid "MNU_SHOW_TRIHEDRON" msgstr "Show/Hide trihedron" diff --git a/src/SVTK/resources/SVTK_msg_en.ts b/src/SVTK/resources/SVTK_msg_en.ts index e48e72b8f..d58468fc2 100644 --- a/src/SVTK/resources/SVTK_msg_en.ts +++ b/src/SVTK/resources/SVTK_msg_en.ts @@ -416,6 +416,22 @@ VTK_VIEW_TITLE VTK scene:%1 - viewer:%2 + + PREF_GROUP_VTKVIEWER + VTK Viewer 3d + + + PREF_TRIHEDRON_SIZE + Trihedron size + + + PREF_VIEWER_BACKGROUND + Background color + + + PREF_RELATIVE_SIZE + Relative size + SVTK_Viewer diff --git a/src/TableViewer/TableViewer_ViewManager.cxx b/src/TableViewer/TableViewer_ViewManager.cxx index 14ee13d54..8de154b77 100755 --- a/src/TableViewer/TableViewer_ViewManager.cxx +++ b/src/TableViewer/TableViewer_ViewManager.cxx @@ -22,6 +22,8 @@ #include #include +#include +#include /*! Constructor @@ -87,3 +89,21 @@ void TableViewer_ViewManager::createView() emit cloneView( clonedWnd->getViewFrame(), newWnd->getViewFrame() ); } */ + +/*! + Fills preference manager for viewer +*/ +int TableViewer_ViewManager::fillPreferences( SUIT_PreferenceMgr* thePrefMgr, const int theId ) +{ + int aGrpId = thePrefMgr->addItem( tr( "PREF_GROUP_TABLEVIEWER" ), theId, + SUIT_PreferenceMgr::GroupBox ); + return aGrpId; +} + +/** + * Fills values from resources + */ +void TableViewer_ViewManager::fillFrom( SUIT_ResourceMgr* theMgr ) +{ + +} diff --git a/src/TableViewer/TableViewer_ViewManager.h b/src/TableViewer/TableViewer_ViewManager.h index b80d8381e..dfdf0a808 100755 --- a/src/TableViewer/TableViewer_ViewManager.h +++ b/src/TableViewer/TableViewer_ViewManager.h @@ -24,6 +24,8 @@ class SUIT_Study; class SUIT_Desktop; +class SUIT_PreferenceMgr; +class SUIT_ResourceMgr; class TableViewer_Viewer; class TableViewer_ViewFrame; @@ -37,6 +39,10 @@ public: TableViewer_Viewer* getTableModel() const; + static int fillPreferences( SUIT_PreferenceMgr*, const int ); + void fillFrom( SUIT_ResourceMgr* ); + + //protected: // bool insertView(SUIT_ViewWindow* theView); diff --git a/src/TableViewer/resources/TableViewer_msg_en.ts b/src/TableViewer/resources/TableViewer_msg_en.ts index 552848f34..638f96ea1 100644 --- a/src/TableViewer/resources/TableViewer_msg_en.ts +++ b/src/TableViewer/resources/TableViewer_msg_en.ts @@ -1,10 +1,6 @@ @default - - TABLE_VIEWER_VIEW_TITLE - TableViewer scene:%M - viewer %V - LBL_TOOLBAR_LABEL View operations @@ -78,4 +74,15 @@ Export table to file + + TableViewer_ViewManager + + TABLE_VIEWER_VIEW_TITLE + TableViewer scene:%M - viewer %V + + + PREF_GROUP_TABLEVIEWER + Table Viewer + + diff --git a/src/VTKViewer/VTKViewer_ViewManager.cxx b/src/VTKViewer/VTKViewer_ViewManager.cxx index a206be6ee..0e3f32bb7 100755 --- a/src/VTKViewer/VTKViewer_ViewManager.cxx +++ b/src/VTKViewer/VTKViewer_ViewManager.cxx @@ -19,6 +19,9 @@ #include "VTKViewer_ViewManager.h" #include "VTKViewer_ViewModel.h" +#include +#include + /*!Constructor.Initialize SIUT_ViewManager by \a study and \a theDesktop. * Create new instance of VTKViewer_Viewer and set view model by it. */ @@ -33,3 +36,37 @@ VTKViewer_ViewManager::~VTKViewer_ViewManager() { /*!Do nothing.*/ } + +/*! + Fills preference manager for viewer +*/ +int VTKViewer_ViewManager::fillPreferences( SUIT_PreferenceMgr* thePrefMgr, const int theId ) +{ + int aGrpId = thePrefMgr->addItem( tr( "PREF_GROUP_VTKVIEWER" ), theId, + SUIT_PreferenceMgr::GroupBox ); + + int vtkTS = thePrefMgr->addItem( tr( "PREF_TRIHEDRON_SIZE" ), aGrpId, + SUIT_PreferenceMgr::DblSpin, "VTKViewer", "trihedron_size" ); + thePrefMgr->addItem( tr( "PREF_RELATIVE_SIZE" ), aGrpId, SUIT_PreferenceMgr::Bool, + "VTKViewer", "relative_size" ); + thePrefMgr->addItem( tr( "PREF_VIEWER_BACKGROUND" ), aGrpId, + SUIT_PreferenceMgr::Color, "VTKViewer", "background" ); + + thePrefMgr->setItemProperty( "min", 1.0E-06, vtkTS ); + thePrefMgr->setItemProperty( "max", 150, vtkTS ); + + return aGrpId; +} + +/** + * Fills values from resources + */ +void VTKViewer_ViewManager::fillFrom( SUIT_ResourceMgr* theMgr ) +{ + VTKViewer_Viewer* aModel = dynamic_cast( getViewModel() ); + if ( !aModel ) + return; + + aModel->setBackgroundColor( theMgr->colorValue( "VTKViewer", "background", + aModel->backgroundColor() ) ); +} diff --git a/src/VTKViewer/VTKViewer_ViewManager.h b/src/VTKViewer/VTKViewer_ViewManager.h index 38518fe06..c8e200817 100755 --- a/src/VTKViewer/VTKViewer_ViewManager.h +++ b/src/VTKViewer/VTKViewer_ViewManager.h @@ -24,6 +24,8 @@ #include class SUIT_Desktop; +class SUIT_PreferenceMgr; +class SUIT_ResourceMgr; /*!View manager.*/ class VTKVIEWER_EXPORT VTKViewer_ViewManager : public SUIT_ViewManager @@ -33,6 +35,9 @@ class VTKVIEWER_EXPORT VTKViewer_ViewManager : public SUIT_ViewManager public: VTKViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* ); virtual ~VTKViewer_ViewManager(); + + static int fillPreferences( SUIT_PreferenceMgr*, const int ); + void fillFrom( SUIT_ResourceMgr* ); }; #endif diff --git a/src/VTKViewer/resources/VTKViewer_msg_en.po b/src/VTKViewer/resources/VTKViewer_msg_en.po index ea26f2678..a33df6570 100755 --- a/src/VTKViewer/resources/VTKViewer_msg_en.po +++ b/src/VTKViewer/resources/VTKViewer_msg_en.po @@ -143,6 +143,18 @@ msgstr "Change background..." msgid "VTKViewer_ViewManager::VTK_VIEW_TITLE" msgstr "VTK scene:%M - viewer:%V" +msgid "VTKViewer_ViewManager::PREF_GROUP_VTKVIEWER" +msgstr "VTK Viewer 3d" + +msgid "VTKViewer_ViewManager::PREF_TRIHEDRON_SIZE" +msgstr "Trihedron size" + +msgid "VTKViewer_ViewManager::PREF_VIEWER_BACKGROUND" +msgstr "Background color" + +msgid "VTKViewer_ViewManager::PREF_RELATIVE_SIZE" +msgstr "Relative size" + msgid "MNU_SHOW_TRIHEDRON" msgstr "Show/Hide trihedron" diff --git a/src/VTKViewer/resources/VTKViewer_msg_en.ts b/src/VTKViewer/resources/VTKViewer_msg_en.ts index 4d2c8b613..2134863ee 100644 --- a/src/VTKViewer/resources/VTKViewer_msg_en.ts +++ b/src/VTKViewer/resources/VTKViewer_msg_en.ts @@ -148,6 +148,22 @@ VTK_VIEW_TITLE VTK scene:%M - viewer:%V + + PREF_GROUP_VTKVIEWER + VTK Viewer 3d + + + PREF_TRIHEDRON_SIZE + Trihedron size + + + PREF_VIEWER_BACKGROUND + Background color + + + PREF_RELATIVE_SIZE + Relative size + VTKViewer_Viewer -- 2.39.2