From c6fb4e591f98fabcb9f07b9e08675b9c51a53daa Mon Sep 17 00:00:00 2001 From: vtn Date: Tue, 11 Dec 2007 15:48:48 +0000 Subject: [PATCH] NPAL16707: Evaluations of Scalar Bar --- resources/SalomeApp.xml | 14 + src/OBJECT/VISU_GaussPtsAct.cxx | 1 - src/PIPELINE/VISU_ScalarBarActor.cxx | 133 ++++++-- src/PIPELINE/VISU_ScalarBarActor.hxx | 19 ++ src/PIPELINE/VISU_ScalarBarCtrl.cxx | 30 +- src/PIPELINE/VISU_ScalarBarCtrl.hxx | 24 +- src/VISUGUI/VISU_msg_en.po | 65 +++- src/VISUGUI/VisuGUI.cxx | 88 +++++- src/VISUGUI/VisuGUI_GaussPointsDlg.cxx | 49 +++ src/VISUGUI/VisuGUI_GaussPointsDlg.h | 5 + src/VISUGUI/VisuGUI_Prs3dDlg.cxx | 400 ++++++++++++++++++++++++- src/VISUGUI/VisuGUI_Prs3dDlg.h | 59 ++++ src/VISU_I/VISU_ColoredPrs3d_i.cc | 174 ++++++++++- src/VISU_I/VISU_ColoredPrs3d_i.hh | 54 +++- src/VISU_I/VISU_GaussPoints_i.cc | 12 +- src/VISU_I/VISU_GaussPoints_i.hh | 8 +- src/VISU_I/VISU_ScalarMap_i.cc | 4 + 17 files changed, 1062 insertions(+), 77 deletions(-) diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 236affb8..dfd869d5 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -31,8 +31,15 @@ + + + + + + + @@ -40,10 +47,17 @@ + + + + + + + diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index ea046177..c9d5880d 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -43,7 +43,6 @@ #include #include #include -#include #include #include diff --git a/src/PIPELINE/VISU_ScalarBarActor.cxx b/src/PIPELINE/VISU_ScalarBarActor.cxx index 058f3025..9adbc387 100644 --- a/src/PIPELINE/VISU_ScalarBarActor.cxx +++ b/src/PIPELINE/VISU_ScalarBarActor.cxx @@ -102,6 +102,13 @@ VISU_ScalarBarActor::VISU_ScalarBarActor() this->LastOrigin[1] = 0; this->LastSize[0] = 0; this->LastSize[1] = 0; + + this->TitleRatioWidth = 0; + this->LabelRatioWidth = 0; + this->BarRatioWidth = 0; + this->TitleRatioHeight = 0; + this->LabelRatioHeight = 0; + this->BarRatioHeight = 0; } void VISU_ScalarBarActor::ReleaseGraphicsResources(vtkWindow *win) @@ -311,16 +318,16 @@ int VISU_ScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport) // find the best size for the ticks int labelSize[2]; - this->AllocateAndSizeLabels(labelSize, size, viewport,range); + this->AllocateAndSizeLabels(labelSize, size, viewport, range); this->NumberOfLabelsBuilt = this->NumberOfLabels; + this->SizeBar(barWidth, barHeight, size, viewport, range); + // generate points vtkFloatingPointType x[3]; x[2] = 0.0; vtkFloatingPointType delta, val; if ( this->Orientation == VTK_ORIENT_VERTICAL ) { - barWidth = size[0] - 4 - labelSize[0]; - barHeight = (int)(0.86*size[1]); delta=(vtkFloatingPointType)barHeight/numColors; for (i=0; iOrientation == VTK_ORIENT_VERTICAL ) - { - targetWidth = (int)(0.6*size[0]); - targetHeight = (int)(0.86*size[1]/this->NumberOfLabels); - } + if(LabelRatioWidth == 0) + if ( this->Orientation == VTK_ORIENT_VERTICAL ) + targetWidth = (int)(0.6*size[0]); + else + targetWidth = (int)(size[0]*0.8/this->NumberOfLabels); else - { - targetWidth = (int)(size[0]*0.8/this->NumberOfLabels); - targetHeight = (int)(0.25*size[1]); - } + targetWidth = (int)(0.01*LabelRatioWidth*size[0]); + + if(LabelRatioHeight == 0) + if ( this->Orientation == VTK_ORIENT_VERTICAL ) + targetHeight = (int)(0.86*size[1]/this->NumberOfLabels); + else + targetHeight = (int)(0.25*size[1]); + else + targetHeight = (int)(0.01*LabelRatioHeight*size[1]); vtkTextMapper::SetMultipleConstrainedFontSize(viewport, targetWidth, @@ -590,18 +600,97 @@ void VISU_ScalarBarActor::SizeTitle(int *titleSize, int *size, int targetWidth, targetHeight; - targetWidth = size[0]; - if ( this->Orientation == VTK_ORIENT_VERTICAL ) - { - targetHeight = (int)(0.1*size[1]); - } + if(TitleRatioWidth == 0) + targetWidth = size[0]; else - { - targetHeight = (int)(0.25*size[1]); - } + targetWidth = (int)(0.01*TitleRatioWidth*size[0]); + + if(TitleRatioHeight == 0) + if ( this->Orientation == VTK_ORIENT_VERTICAL ) + targetHeight = (int)(0.1*size[1]); + else + targetHeight = (int)(0.25*size[1]); + else + targetHeight = (int)(0.01*TitleRatioHeight*size[1]); this->TitleMapper->SetConstrainedFontSize( viewport, targetWidth, targetHeight); this->TitleMapper->GetSize(viewport, titleSize); } + +void VISU_ScalarBarActor::SetRatios(int titleRatioWidth, int titleRatioHeight, + int labelRatioWidth, int labelRatioHeight, + int barRatioWidth, int barRatioHeight) +{ + TitleRatioWidth=titleRatioWidth; + if(TitleRatioWidth>100) + TitleRatioWidth=100; + else if(TitleRatioWidth<0) + TitleRatioWidth=0; + + TitleRatioHeight=titleRatioHeight; + if(TitleRatioHeight>100) + TitleRatioHeight=100; + else if(TitleRatioHeight<0) + TitleRatioHeight=0; + + LabelRatioWidth=labelRatioWidth; + if(LabelRatioWidth>100) + LabelRatioWidth=100; + else if(LabelRatioWidth<0) + LabelRatioWidth=0; + + LabelRatioHeight=labelRatioHeight; + if(LabelRatioHeight>100) + LabelRatioHeight=100; + else if(LabelRatioHeight<0) + LabelRatioHeight=0; + + BarRatioWidth=barRatioWidth; + if(BarRatioWidth>100) + BarRatioWidth=100; + else if(BarRatioWidth<0) + BarRatioWidth=0; + + BarRatioHeight=barRatioHeight; + if(BarRatioHeight>100) + BarRatioHeight=100; + else if(BarRatioHeight<0) + BarRatioHeight=0; +} + +void VISU_ScalarBarActor::GetRatios(int& titleRatioWidth, int& titleRatioHeight, + int& labelRatioWidth, int& labelRatioHeight, + int& barRatioWidth, int& barRatioHeight) +{ + titleRatioWidth=TitleRatioWidth; + titleRatioHeight=TitleRatioHeight; + labelRatioWidth=LabelRatioWidth; + labelRatioHeight=LabelRatioHeight; + barRatioWidth=BarRatioWidth; + barRatioHeight=BarRatioHeight; +} + +void VISU_ScalarBarActor::SizeBar(int& barSizeWidth, int& barSizeHeight, int *size, + vtkViewport *viewport, vtkFloatingPointType *range) +{ + if(BarRatioWidth == 0) + if ( this->Orientation == VTK_ORIENT_VERTICAL ) + { + int labelSize[2]; + this->AllocateAndSizeLabels(labelSize, size, viewport,range); + barSizeWidth = size[0] - 4 - labelSize[0]; + } else + barSizeWidth = size[0]; + else + barSizeWidth = (int)(0.01*BarRatioWidth*size[0]); + + if(BarRatioHeight == 0) + if ( this->Orientation == VTK_ORIENT_VERTICAL ) + barSizeHeight = (int)(0.86*size[1]); + else + barSizeHeight = (int)(0.4*size[1]); + else + barSizeHeight = (int)(0.01*BarRatioHeight*size[1]); +} diff --git a/src/PIPELINE/VISU_ScalarBarActor.hxx b/src/PIPELINE/VISU_ScalarBarActor.hxx index 598f70ae..3252e6e8 100644 --- a/src/PIPELINE/VISU_ScalarBarActor.hxx +++ b/src/PIPELINE/VISU_ScalarBarActor.hxx @@ -107,6 +107,16 @@ public: virtual void SetLabelTextProperty(vtkTextProperty *p); vtkGetObjectMacro(LabelTextProperty,vtkTextProperty); + // Description: + // Set/Get the scalar bar dimention properties in persents. + // 0 <= ration <= 100 + void SetRatios(int titleRatioWidth, int titleRatioHeight, + int labelRatioWidth, int labelRatioHeight, + int barRatioWidth, int barRatioHeight); + void GetRatios(int& titleRatioWidth, int& titleRatioHeight, + int& labelRatioWidth, int& labelRatioHeight, + int& barRatioWidth, int& barRatioHeight); + // Description: // Set/Get the format with which to print the labels on the scalar // bar. @@ -136,6 +146,12 @@ protected: int Orientation; char *Title; char *LabelFormat; + int TitleRatioWidth; + int LabelRatioWidth; + int BarRatioWidth; + int TitleRatioHeight; + int LabelRatioHeight; + int BarRatioHeight; vtkTextMapper **TextMappers; virtual void AllocateAndSizeLabels(int *labelSize, int *size, @@ -157,6 +173,9 @@ private: void SizeTitle(int *titleSize, int *size, vtkViewport *viewport); + void SizeBar(int& barSizeWidth, int& barSizeHeight, int *size, + vtkViewport *viewport, vtkFloatingPointType *range); + private: VISU_ScalarBarActor(const VISU_ScalarBarActor&); // Not implemented. void operator=(const VISU_ScalarBarActor&); // Not implemented. diff --git a/src/PIPELINE/VISU_ScalarBarCtrl.cxx b/src/PIPELINE/VISU_ScalarBarCtrl.cxx index 6f7fbebb..5dbf6e47 100644 --- a/src/PIPELINE/VISU_ScalarBarCtrl.cxx +++ b/src/PIPELINE/VISU_ScalarBarCtrl.cxx @@ -25,15 +25,15 @@ // Module : VISU #include "VISU_ScalarBarCtrl.hxx" +#include +#include #include #include #include #include #include -#include #include -#include #include #include @@ -44,7 +44,7 @@ namespace { inline void - MarkValueByColor(vtkLookupTable* theTable, + MarkValueByColor(VISU_LookupTable* theTable, vtkFloatingPointType theValue, unsigned char* theColor) { @@ -65,7 +65,7 @@ namespace } void - FillByColor(vtkLookupTable* theTable, + FillByColor(VISU_LookupTable* theTable, unsigned char* theColor) { vtkIdType aNbColors = theTable->GetNumberOfColors(); @@ -76,7 +76,7 @@ namespace } void - MakeBiColor(vtkLookupTable* theTable) + MakeBiColor(VISU_LookupTable* theTable) { unsigned char aRedPtr[3] = {255, 0, 0}; unsigned char aBluePtr[3] = {0, 0, 255}; @@ -119,18 +119,18 @@ VISU_ScalarBarCtrl SetMode(eSimple); // Initilize global scalar bar - myGlobalLookupTable = vtkLookupTable::New(); + myGlobalLookupTable = VISU_LookupTable::New(); myGlobalLookupTable->SetHueRange(0.667,0.0); - myGlobalScalarBar = vtkScalarBarActor::New(); + myGlobalScalarBar = VISU_ScalarBarActor::New(); myGlobalScalarBar->SetLookupTable(myGlobalLookupTable); myGlobalLookupTable->Delete(); // Initilize local scalar bar - myLocalLookupTable = vtkLookupTable::New(); + myLocalLookupTable = VISU_LookupTable::New(); myLocalLookupTable->SetHueRange(0.667,0.0); - myLocalScalarBar = vtkScalarBarActor::New(); + myLocalScalarBar = VISU_ScalarBarActor::New(); myLocalScalarBar->SetLookupTable(myLocalLookupTable); myLocalLookupTable->Delete(); @@ -245,14 +245,14 @@ VISU_ScalarBarCtrl //---------------------------------------------------------------------------- -vtkScalarBarActor* +VISU_ScalarBarActor* VISU_ScalarBarCtrl ::GetLocalBar() { return myLocalScalarBar; } -vtkScalarBarActor* +VISU_ScalarBarActor* VISU_ScalarBarCtrl ::GetGlobalBar() { @@ -261,14 +261,14 @@ VISU_ScalarBarCtrl //---------------------------------------------------------------------------- -vtkLookupTable* +VISU_LookupTable* VISU_ScalarBarCtrl ::GetLocalTable() { return myLocalLookupTable; } -vtkLookupTable* +VISU_LookupTable* VISU_ScalarBarCtrl ::GetGlobalTable() { @@ -452,8 +452,8 @@ VISU_ScalarBarCtrl //---------------------------------------------------------------------------- void VISU_ScalarBarCtrl -::PrepareTables(vtkScalarBarActor* theScalarBarActor, - vtkLookupTable *theLookupTable, +::PrepareTables(VISU_ScalarBarActor* theScalarBarActor, + VISU_LookupTable *theLookupTable, vtkIdType theId) { vtkCoordinate * aCoordinate = theScalarBarActor->GetPositionCoordinate(); diff --git a/src/PIPELINE/VISU_ScalarBarCtrl.hxx b/src/PIPELINE/VISU_ScalarBarCtrl.hxx index 17f75414..86866d75 100644 --- a/src/PIPELINE/VISU_ScalarBarCtrl.hxx +++ b/src/PIPELINE/VISU_ScalarBarCtrl.hxx @@ -34,8 +34,8 @@ #include "VTKViewer.h" class vtkRenderer; -class vtkLookupTable; -class vtkScalarBarActor; +class VISU_LookupTable; +class VISU_ScalarBarActor; class VISU_PIPELINE_EXPORT VISU_ScalarBarCtrl : public vtkObject { @@ -71,16 +71,16 @@ public: SetRangeLocal(vtkFloatingPointType *theRange); // Selectors - vtkScalarBarActor* + VISU_ScalarBarActor* GetLocalBar(); - vtkLookupTable* + VISU_LookupTable* GetLocalTable(); - vtkScalarBarActor* + VISU_ScalarBarActor* GetGlobalBar(); - vtkLookupTable* + VISU_LookupTable* GetGlobalTable(); // // Renderer @@ -172,8 +172,8 @@ protected: PrepareTables(); void - PrepareTables(vtkScalarBarActor* theScalarBarActor, - vtkLookupTable *theLookupTable, + PrepareTables(VISU_ScalarBarActor* theScalarBarActor, + VISU_LookupTable *theLookupTable, vtkIdType theId); protected: @@ -191,11 +191,11 @@ protected: bool myMarked; vtkFloatingPointType myMarkedValue; // - vtkScalarBarActor *myGlobalScalarBar; - vtkLookupTable *myGlobalLookupTable; + VISU_ScalarBarActor *myGlobalScalarBar; + VISU_LookupTable *myGlobalLookupTable; - vtkScalarBarActor *myLocalScalarBar; - vtkLookupTable *myLocalLookupTable; + VISU_ScalarBarActor *myLocalScalarBar; + VISU_LookupTable *myLocalLookupTable; }; #endif diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 957e3684..0ed7243d 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "POT-Creation-Date: 2002-02-22 16:56:46 CET\n" -"PO-Revision-Date: 2005-06-27 12:38+0400\n" +"PO-Revision-Date: 2007-12-11 17:26+0300\n" "Last-Translator: FULLNAME \n" "Content-Type: text/plain; charset=iso-8859-1\n" @@ -93,9 +93,15 @@ msgstr "Colors && Labels" msgid "VISU_NB_COLORS" msgstr "Nb. of colors" +msgid "VISU_IS_UNITS" +msgstr "Display units in title" + msgid "VISU_NB_LABELS" msgstr "Nb. of labels" +msgid "VISU_LABELS_FORMAT" +msgstr "Labels format" + msgid "VISU_ORIENTATION" msgstr "Orientation" @@ -120,6 +126,24 @@ msgstr "Width:" msgid "VISU_HEIGHT" msgstr "Height:" +msgid "VISU_TITLE_WIDTH" +msgstr "Title width (%):" + +msgid "VISU_TITLE_HEIGHT" +msgstr "Title height (%):" + +msgid "VISU_LABEL_WIDTH" +msgstr "Label width (%):" + +msgid "VISU_LABEL_HEIGHT" +msgstr "Label height (%):" + +msgid "VISU_BAR_WIDTH" +msgstr "Bar width (%):" + +msgid "VISU_BAR_HEIGHT" +msgstr "Bar height (%):" + msgid "VISU_PREF_SECOND_TAB" msgstr "Scalar range, Sweep, MED import, Shading" @@ -904,6 +928,45 @@ msgstr "Shadow" msgid "VisuGUI_TextPrefDlg::LBL_LABELS" msgstr "Labels" +msgid "VisuGUI_BarPrefDlg::&OK" +msgstr "" + +msgid "VisuGUI_BarPrefDlg::&Cancel" +msgstr "" + +msgid "VisuGUI_BarPrefDlg::TIT_BAR_PREF" +msgstr "Bar property" + +msgid "VisuGUI_BarPrefDlg::LBL_TITLE_W" +msgstr "Title width (%)" + +msgid "VisuGUI_BarPrefDlg::LBL_TITLE_H" +msgstr "Title height (%)" + +msgid "VisuGUI_BarPrefDlg::LBL_LABEL_W" +msgstr "Label width (%)" + +msgid "VisuGUI_BarPrefDlg::LBL_LABEL_H" +msgstr "Label height (%)" + +msgid "VisuGUI_BarPrefDlg::LBL_BAR_W" +msgstr "Bar width (%)" + +msgid "VisuGUI_BarPrefDlg::LBL_BAR_H" +msgstr "Bar height (%)" + +msgid "VisuGUI_BarPrefDlg::LBL_SHOW_UNITS" +msgstr "Display units" + +msgid "VisuGUI_BarPrefDlg::LBL_UNITS_FORMAT" +msgstr "Format:" + +msgid "VisuGUI_BarPrefDlg::MSG_LABEL_FORMAT" +msgstr "Labels format is invalid." + +msgid "VisuGUI_BarPrefDlg::AUTO" +msgstr "auto" + #: VisuGUI_StreamLinesDlg.cxx diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index c48e417b..e682621e 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -3066,11 +3066,17 @@ void VisuGUI::createPreferences() setPreferenceProperty( numcol, "min", 2 ); setPreferenceProperty( numcol, "max", 256 ); + addPreference( tr( "VISU_IS_UNITS" ), colorsLabelsGr, + LightApp_Preferences::Bool, "VISU", "scalar_bar_display_units" ); + int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" ); setPreferenceProperty( numlab, "min", 2 ); setPreferenceProperty( numlab, "max", 65 ); + addPreference( tr( "VISU_LABELS_FORMAT" ), colorsLabelsGr, + LightApp_Preferences::String, "VISU", "scalar_bar_label_format" ); + // group: "Orientation" int orientGr = addPreference( tr( "VISU_ORIENTATION" ), sbarTab ); int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr, @@ -3086,14 +3092,28 @@ void VisuGUI::createPreferences() // group: "Origin & Size Vertical" int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ), sbarTab ); + setPreferenceProperty( posVSizeGr, "columns", 5 ); int xv = addPreference( tr( "VISU_X" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" ); - int yv = addPreference( tr( "VISU_Y" ), posVSizeGr, - LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" ); int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" ); + int twv = addPreference( tr( "VISU_TITLE_WIDTH" ), posVSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_title_width" ); + int lwv = addPreference( tr( "VISU_LABEL_WIDTH" ), posVSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_label_width" ); + int bwv = addPreference( tr( "VISU_BAR_WIDTH" ), posVSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_bar_width" ); + + int yv = addPreference( tr( "VISU_Y" ), posVSizeGr, + LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" ); int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" ); + int thv = addPreference( tr( "VISU_TITLE_HEIGHT" ), posVSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_title_height" ); + int lhv = addPreference( tr( "VISU_LABEL_HEIGHT" ), posVSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_label_height" ); + int bhv = addPreference( tr( "VISU_BAR_HEIGHT" ), posVSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_bar_height" ); setPreferenceProperty( xv, "step", 0.1 ); setPreferenceProperty( yv, "step", 0.1 ); setPreferenceProperty( wv, "step", 0.1 ); @@ -3102,21 +3122,53 @@ void VisuGUI::createPreferences() setPreferenceProperty( yv, "min", 0.0 ); setPreferenceProperty( wv, "min", 0.0 ); setPreferenceProperty( hv, "min", 0.0 ); + setPreferenceProperty( twv, "min", 0 ); + setPreferenceProperty( twv, "special", "auto" ); + setPreferenceProperty( thv, "min", 0 ); + setPreferenceProperty( thv, "special", "auto" ); + setPreferenceProperty( lwv, "min", 0 ); + setPreferenceProperty( lwv, "special", "auto" ); + setPreferenceProperty( lhv, "min", 0 ); + setPreferenceProperty( lhv, "special", "auto" ); + setPreferenceProperty( bwv, "min", 0 ); + setPreferenceProperty( bwv, "special", "auto" ); + setPreferenceProperty( bhv, "min", 0 ); + setPreferenceProperty( bhv, "special", "auto" ); setPreferenceProperty( xv, "max", 1.0 ); setPreferenceProperty( yv, "max", 1.0 ); setPreferenceProperty( wv, "max", 1.0 ); setPreferenceProperty( hv, "max", 1.0 ); + setPreferenceProperty( twv, "max", 100 ); + setPreferenceProperty( thv, "max", 100 ); + setPreferenceProperty( lwv, "max", 100 ); + setPreferenceProperty( lhv, "max", 100 ); + setPreferenceProperty( bwv, "max", 100 ); + setPreferenceProperty( bhv, "max", 100 ); // group: "Origin & Size Horizontal" int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ), sbarTab ); + setPreferenceProperty( posHSizeGr, "columns", 5 ); int xh = addPreference( tr( "VISU_X" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" ); - int yh = addPreference( tr( "VISU_Y" ), posHSizeGr, - LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" ); int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" ); + int twh = addPreference( tr( "Title width (%)" ), posHSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_title_width" ); + int lwh = addPreference( tr( "Label width (%)" ), posHSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_label_width" ); + int bwh = addPreference( tr( "Bar width (%)" ), posHSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_bar_width" ); + + int yh = addPreference( tr( "VISU_Y" ), posHSizeGr, + LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" ); int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" ); + int thh = addPreference( tr( "Title height (%)" ), posHSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_title_height" ); + int lhh = addPreference( tr( "Label height (%)" ), posHSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_label_height" ); + int bhh = addPreference( tr( "Bar height (%)" ), posHSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_bar_height" ); setPreferenceProperty( xh, "step", 0.1 ); setPreferenceProperty( yh, "step", 0.1 ); setPreferenceProperty( wh, "step", 0.1 ); @@ -3125,10 +3177,28 @@ void VisuGUI::createPreferences() setPreferenceProperty( yh, "min", 0.0 ); setPreferenceProperty( wh, "min", 0.0 ); setPreferenceProperty( hh, "min", 0.0 ); + setPreferenceProperty( twh, "min", 0 ); + setPreferenceProperty( twh, "special", "auto" ); + setPreferenceProperty( thh, "min", 0 ); + setPreferenceProperty( thh, "special", "auto" ); + setPreferenceProperty( lwh, "min", 0 ); + setPreferenceProperty( lwh, "special", "auto" ); + setPreferenceProperty( lhh, "min", 0 ); + setPreferenceProperty( lhh, "special", "auto" ); + setPreferenceProperty( bwh, "min", 0 ); + setPreferenceProperty( bwh, "special", "auto" ); + setPreferenceProperty( bhh, "min", 0 ); + setPreferenceProperty( bhh, "special", "auto" ); setPreferenceProperty( xh, "max", 1.0 ); setPreferenceProperty( yh, "max", 1.0 ); setPreferenceProperty( wh, "max", 1.0 ); setPreferenceProperty( hh, "max", 1.0 ); + setPreferenceProperty( twh, "max", 100 ); + setPreferenceProperty( thh, "max", 100 ); + setPreferenceProperty( lwh, "max", 100 ); + setPreferenceProperty( lhh, "max", 100 ); + setPreferenceProperty( bwh, "max", 100 ); + setPreferenceProperty( bhh, "max", 100 ); // group: "Scalar bars default position" int scalarBarGr = addPreference( tr( "Scalar bars default position" ), sbarTab ); @@ -3367,6 +3437,16 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b) aResourceMgr->setValue("VISU", "scalar_bar_horizontal_y", sbY1); aResourceMgr->setValue("VISU", "scalar_bar_horizontal_height",sbH); } + } else if(b == QString("scalar_bar_labels_format")) { + QString dVal; + dVal.sprintf(aResourceMgr->stringValue("VISU", "scalar_bar_label_format",dVal), 1.1); + if(dVal.toDouble() == 0.) { + aWarning = "Label format is incorrect "; + aWarning += dVal.latin1(); + aWarning += "\n"; + dVal="%-#6.3g"; + aResourceMgr->setValue("VISU", "scalar_bar_labels_format", dVal); + } } if (aWarning.size() != 0){ aWarning += "The default values are applied instead."; diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index d1728070..5c8ca103 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -79,6 +79,8 @@ VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent): { myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80; myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12; + myVerTW = myVerTH = myVerLW = myVerLH = myVerBW = myVerBH = 0; + myHorTW = myHorTH = myHorLW = myHorLH = myHorBW = myHorBH = 0; Imin = 0.0; Imax = 0.0; myRangeMode = -1; @@ -278,8 +280,10 @@ VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent): QHBox* aSaveBox = new QHBox(this); myTextBtn = new QPushButton("Text properties...", aSaveBox); + myBarBtn = new QPushButton("Bar properties...", aSaveBox); myTextDlg = new VisuGUI_TextPrefDlg(this); myTextDlg->setTitleVisible(true); + myBarDlg = new VisuGUI_BarPrefDlg(this); // signals and slots connections =========================================== connect( RBFieldRange, SIGNAL( clicked() ), this, SLOT( fieldRangeClicked() ) ); @@ -298,6 +302,7 @@ VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent): connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) ); connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) ); connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) ); + connect( myBarBtn, SIGNAL( clicked() ), this, SLOT( onBarPref() ) ); changeDefaults( 0 ); myIsStoreTextProp = false; @@ -428,6 +433,25 @@ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs, thePrs->GetHeight(), thePrs->GetBarOrientation()); + if(RBvert->isChecked()) { + myVerTW = thePrs->GetTitleWidth(); + myVerTH = thePrs->GetTitleHeight(); + myVerLW = thePrs->GetLabelWidth(); + myVerLH = thePrs->GetLabelHeight(); + myVerBW = thePrs->GetBarWidth(); + myVerBH = thePrs->GetBarHeight(); + } else { + myHorTW = thePrs->GetTitleWidth(); + myHorTH = thePrs->GetTitleHeight(); + myHorLW = thePrs->GetLabelWidth(); + myHorLH = thePrs->GetLabelHeight(); + myHorBW = thePrs->GetBarWidth(); + myHorBH = thePrs->GetBarHeight(); + } + + myBarDlg->setLabelsFormat(thePrs->GetLabelsFormat()); + myBarDlg->setUnitsVisible(thePrs->IsUnitsVisible()); + SpacingSpin->setValue(thePrs->GetSpacing()); myRBLocal->setChecked( activeLocal ); @@ -488,6 +512,9 @@ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs, vtkFloatingPointType R, G, B; thePrs->GetTitleColor(&R, &G, &B); + myBarDlg->setLabelsFormat(thePrs->GetLabelsFormat()); + myBarDlg->setUnitsVisible(thePrs->IsUnitsVisible()); + myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), thePrs->GetTitFontType(), thePrs->IsBoldTitle(), @@ -527,6 +554,15 @@ int VisuGUI_GaussScalarBarPane::storeToPrsObject(VISU::GaussPoints_i* thePrs) { thePrs->SetNbColors(ColorSpin->value()); thePrs->SetLabels(LabelSpin->value()); + if(RBvert->isChecked()) { + thePrs->SetRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + } else { + thePrs->SetRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + } + + thePrs->SetLabelsFormat(myBarDlg->getLabelsFormat()); + thePrs->SetUnitsVisible(myBarDlg->isUnitsVisible()); + if (myIsStoreTextProp) { // "Title" thePrs->SetTitle(myTextDlg->getTitleText().latin1()); @@ -677,6 +713,19 @@ void VisuGUI_GaussScalarBarPane::onTextPref() myIsStoreTextProp = myTextDlg->exec(); } +void VisuGUI_GaussScalarBarPane::onBarPref() +{ + if(RBvert->isChecked()) + myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + else + myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + if(myBarDlg->exec()) { + if(RBvert->isChecked()) + myBarDlg->getRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + else + myBarDlg->getRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + } +} /*! * Constructor diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.h b/src/VISUGUI/VisuGUI_GaussPointsDlg.h index d66df5fc..d5c28d99 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.h +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.h @@ -93,7 +93,9 @@ class VisuGUI_GaussScalarBarPane : public QVBox QLabel* myModeLbl; QComboBox* myModeCombo; QPushButton* myTextBtn; + QPushButton* myBarBtn; VisuGUI_TextPrefDlg* myTextDlg; + VisuGUI_BarPrefDlg* myBarDlg; QRadioButton* myRBLocal; QRadioButton* myRBGlobal; QCheckBox* myCBDisplayed; @@ -101,6 +103,8 @@ class VisuGUI_GaussScalarBarPane : public QVBox double Imin, Imax; double myHorX, myHorY, myHorW, myHorH; double myVerX, myVerY, myVerW, myVerH; + int myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH; + int myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH; int myRangeMode; bool myIsStoreTextProp; @@ -117,6 +121,7 @@ class VisuGUI_GaussScalarBarPane : public QVBox void changeDefaults( int ); void XYChanged( double ); void onTextPref(); + void onBarPref(); }; //! Create Gauss Points Presentation Dialog. diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx index ead00b29..f982e4ac 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx @@ -238,6 +238,276 @@ void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e ) } } +//----------------------------------------------------------------------- +// Scalar Bar Preferences Dialog +//----------------------------------------------------------------------- +/*! + Constructor +*/ +VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg (QWidget* parent) + : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + setName("VisuGUI_BarPrefDlg"); + setCaption(tr("TIT_BAR_PREF")); + setSizeGripEnabled(TRUE); + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + QString propertyName; + propertyName = QString("scalar_bar_vertical_"); + + myTitleWidth = myTitleHeight = myLabelWidth = myLabelHeight = myBarWidth = myBarHeight = 0; + myUnits = true; + myUnitsFormat = "%-#6.3g"; + + QVBoxLayout* TopLayout = new QVBoxLayout(this); + TopLayout->setSpacing(6); + TopLayout->setMargin(11); + + QGroupBox* WidthHeightGroup = new QGroupBox (tr(""), this, "WidthHeightGroup"); + WidthHeightGroup->setColumnLayout(0, Qt::Vertical ); + WidthHeightGroup->layout()->setSpacing( 0 ); + WidthHeightGroup->layout()->setMargin( 0 ); + QGridLayout* WidthHeightGroupLayout = new QGridLayout( WidthHeightGroup->layout() ); + WidthHeightGroupLayout->setAlignment( Qt::AlignTop ); + WidthHeightGroupLayout->setSpacing( 6 ); + WidthHeightGroupLayout->setMargin( 11 ); + + QLabel* LabelTitleWidth = new QLabel (tr("LBL_TITLE_W"), WidthHeightGroup, "LabelTitleWidth"); + TitleWidthSpin = new QSpinBox( 0, 100, 1, WidthHeightGroup ); + TitleWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + TitleWidthSpin->setMinimumWidth( 70 ); + TitleWidthSpin->setValue( 0 ); + TitleWidthSpin->setSpecialValueText( tr("AUTO") ); + WidthHeightGroupLayout->addMultiCellWidget( LabelTitleWidth, 0, 0, 0, 0); + WidthHeightGroupLayout->addMultiCellWidget( TitleWidthSpin, 0, 0, 1, 1); + + QLabel* LabelTitleHeight = new QLabel (tr("LBL_TITLE_H"), WidthHeightGroup, "LabelTitleHeight"); + TitleHeightSpin = new QSpinBox( 0, 100, 1, WidthHeightGroup ); + TitleHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + TitleHeightSpin->setMinimumWidth( 70 ); + TitleHeightSpin->setValue( 0 ); + TitleHeightSpin->setSpecialValueText( tr("AUTO") ); + WidthHeightGroupLayout->addMultiCellWidget( LabelTitleHeight, 0, 0, 2, 2); + WidthHeightGroupLayout->addMultiCellWidget( TitleHeightSpin, 0, 0, 3, 3); + + CBUnits = new QCheckBox (tr("LBL_SHOW_UNITS"), WidthHeightGroup); + CBUnits->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + WidthHeightGroupLayout->addMultiCellWidget( CBUnits, 0, 0, 4, 5); + + QLabel* LabelLabelWidth = new QLabel (tr("LBL_LABEL_W"), WidthHeightGroup, "LabelLabelWidth"); + LabelWidthSpin = new QSpinBox( 0, 100, 1, WidthHeightGroup ); + LabelWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + LabelWidthSpin->setMinimumWidth( 70 ); + LabelWidthSpin->setValue( 0 ); + LabelWidthSpin->setSpecialValueText( tr("AUTO") ); + WidthHeightGroupLayout->addMultiCellWidget( LabelLabelWidth, 1, 1, 0, 0); + WidthHeightGroupLayout->addMultiCellWidget( LabelWidthSpin, 1, 1, 1, 1); + + QLabel* LabelLabelHeight = new QLabel (tr("LBL_LABEL_H"), WidthHeightGroup, "LabelLabelHeight"); + LabelHeightSpin = new QSpinBox( 0, 100, 1, WidthHeightGroup ); + LabelHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + LabelHeightSpin->setMinimumWidth( 70 ); + LabelHeightSpin->setValue( 0 ); + LabelHeightSpin->setSpecialValueText( tr("AUTO") ); + WidthHeightGroupLayout->addMultiCellWidget( LabelLabelHeight, 1, 1, 2, 2); + WidthHeightGroupLayout->addMultiCellWidget( LabelHeightSpin, 1, 1, 3, 3); + + UnitsEdit = new QLineEdit(WidthHeightGroup , "UnirsEdit" ); + UnitsEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + UnitsEdit->setMinimumWidth( 35 ); + UnitsEdit->setText( myUnitsFormat ); + QLabel* UnitsLabel = new QLabel (tr("LBL_UNITS_FORMAT"), WidthHeightGroup, "UnitsLabel"); + UnitsLabel->setBuddy(UnitsEdit); + WidthHeightGroupLayout->addMultiCellWidget( UnitsLabel, 1, 1, 4, 4); + WidthHeightGroupLayout->addMultiCellWidget( UnitsEdit, 1, 1, 5, 5); + + QLabel* LabelBarWidth = new QLabel (tr("LBL_BAR_W"), WidthHeightGroup, "LabelBarWidth"); + BarWidthSpin = new QSpinBox( 0, 100, 1, WidthHeightGroup ); + BarWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + BarWidthSpin->setMinimumWidth( 70 ); + BarWidthSpin->setValue( 0 ); + BarWidthSpin->setSpecialValueText( tr("AUTO") ); + WidthHeightGroupLayout->addMultiCellWidget( LabelBarWidth, 2, 2, 0, 0); + WidthHeightGroupLayout->addMultiCellWidget( BarWidthSpin, 2, 2, 1, 1); + + QLabel* LabelBarHeight = new QLabel (tr("LBL_BAR_H"), WidthHeightGroup, "LabelBarHeight"); + BarHeightSpin = new QSpinBox( 0, 100, 1, WidthHeightGroup ); + BarHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + BarHeightSpin->setMinimumWidth( 70 ); + BarHeightSpin->setValue( 0 ); + BarHeightSpin->setSpecialValueText( tr("AUTO") ); + WidthHeightGroupLayout->addMultiCellWidget( LabelBarHeight, 2, 2, 2, 2); + WidthHeightGroupLayout->addMultiCellWidget( BarHeightSpin, 2, 2, 3, 3); + + TopLayout->addWidget( WidthHeightGroup ); + + // Common buttons =========================================================== + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" ); + buttonHelp->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonHelp, 0, 3 ); + + TopLayout->addWidget( GroupButtons ); + + connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); + connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())); + connect(TitleWidthSpin, SIGNAL(valueChanged( int )), this, SIGNAL(updatePreview())); + connect(TitleHeightSpin, SIGNAL(valueChanged( int )), this, SIGNAL(updatePreview())); + connect(LabelWidthSpin, SIGNAL(valueChanged( int )), this, SIGNAL(updatePreview())); + connect(LabelHeightSpin, SIGNAL(valueChanged( int )), this, SIGNAL(updatePreview())); + connect(BarWidthSpin, SIGNAL(valueChanged( int )), this, SIGNAL(updatePreview())); + connect(BarHeightSpin, SIGNAL(valueChanged( int )), this, SIGNAL(updatePreview())); + connect(CBUnits, SIGNAL( toggled( bool )), this, SIGNAL(updatePreview())); + connect(UnitsEdit, SIGNAL( lostFocus() ), this, SIGNAL(updatePreview())); +} + + +//---------------------------------------------------------------------------- +void VisuGUI_BarPrefDlg::setRatios(int titleRatioWidth, int titleRatioHeight, + int labelRatioWidth, int labelRatioHeight, + int barRatioWidth, int barRatioHeight) +{ + TitleWidthSpin->setValue( myTitleWidth=titleRatioWidth ); + TitleHeightSpin->setValue( myTitleHeight=titleRatioHeight ); + LabelWidthSpin->setValue( myLabelWidth=labelRatioWidth ); + LabelHeightSpin->setValue( myLabelHeight=labelRatioHeight ); + BarWidthSpin->setValue( myBarWidth=barRatioWidth ); + BarHeightSpin->setValue( myBarHeight=barRatioHeight ); +} + + +//---------------------------------------------------------------------------- +void VisuGUI_BarPrefDlg::getRatios(int& titleRatioWidth, int& titleRatioHeight, + int& labelRatioWidth, int& labelRatioHeight, + int& barRatioWidth, int& barRatioHeight) +{ + titleRatioWidth=TitleWidthSpin->value(); + titleRatioHeight=TitleHeightSpin->value(); + labelRatioWidth=LabelWidthSpin->value(); + labelRatioHeight=LabelHeightSpin->value(); + barRatioWidth=BarWidthSpin->value(); + barRatioHeight=BarHeightSpin->value(); +} + + +//---------------------------------------------------------------------------- +void VisuGUI_BarPrefDlg::setLabelsFormat(QString format) +{ + UnitsEdit->setText(myUnitsFormat=format); +} + + +//---------------------------------------------------------------------------- +QString VisuGUI_BarPrefDlg::getLabelsFormat() +{ + return UnitsEdit->text(); +} + + +//---------------------------------------------------------------------------- +void VisuGUI_BarPrefDlg::onHelp() +{ + QString aHelpFileName = "scalar_map_page.html"; + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) { + VisuGUI* aVisuGUI = dynamic_cast( app->activeModule() ); + app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName); + } + else { + SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName), + QObject::tr("BUT_OK")); + } +} + + +//---------------------------------------------------------------------------- +void VisuGUI_BarPrefDlg::setUnitsVisible(bool isVisible) +{ + CBUnits->setChecked(myUnits=isVisible); +} + + +//---------------------------------------------------------------------------- +bool VisuGUI_BarPrefDlg::isUnitsVisible() +{ + return CBUnits->isChecked(); +} + + +//---------------------------------------------------------------------------- +/*! + Called when button is clicked, restore begin values +*/ +void VisuGUI_BarPrefDlg::reject() +{ + TitleWidthSpin->setValue( myTitleWidth ); + TitleHeightSpin->setValue( myTitleHeight ); + LabelWidthSpin->setValue( myLabelWidth ); + LabelHeightSpin->setValue( myLabelHeight ); + BarWidthSpin->setValue( myBarWidth ); + BarHeightSpin->setValue( myBarHeight ); + CBUnits->setChecked(myUnits); + UnitsEdit->setText(myUnitsFormat); + QDialog::reject(); +} + + +//---------------------------------------------------------------------------- +/*! + Called when button is clicked, store begin values +*/ +void VisuGUI_BarPrefDlg::accept() +{ + QString dVal; + dVal.sprintf(UnitsEdit->text(),1.1); + if(dVal.toDouble() == 0.) { + SUIT_MessageBox::warn1( this,tr("WRN_VISU"), + tr("MSG_LABEL_FORMAT"), + tr("BUT_OK")); + } else { + QDialog::accept(); + } +} + + +//---------------------------------------------------------------------------- +/*! + Provides help on F1 button click +*/ +void VisuGUI_BarPrefDlg::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Key_F1 ) + { + e->accept(); + onHelp(); + } +} + //----------------------------------------------------------------------- // Scalar Bar Pane //----------------------------------------------------------------------- @@ -253,16 +523,28 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent): SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); QString propertyName; propertyName = QString("scalar_bar_vertical_"); - myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.); - myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.); - myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.); - myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.); + myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.); + myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.); + myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.); + myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.); + myVerTW = aResourceMgr->integerValue("VISU", propertyName + "title_width", 0); + myVerTH = aResourceMgr->integerValue("VISU", propertyName + "title_height",0); + myVerLW = aResourceMgr->integerValue("VISU", propertyName + "label_width", 0); + myVerLH = aResourceMgr->integerValue("VISU", propertyName + "label_height",0); + myVerBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0); + myVerBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0); propertyName = QString("scalar_bar_horizontal_"); - myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.); - myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.); - myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.); - myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.); + myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.); + myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.); + myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.); + myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.); + myHorTW = aResourceMgr->integerValue("VISU", propertyName + "title_width", 0); + myHorTH = aResourceMgr->integerValue("VISU", propertyName + "title_height",0); + myHorLW = aResourceMgr->integerValue("VISU", propertyName + "label_width", 0); + myHorLH = aResourceMgr->integerValue("VISU", propertyName + "label_height",0); + myHorBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0); + myHorBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0); setSpacing(6); //setMargin(11); @@ -424,8 +706,10 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent): // Save check box =========================================================== QHBox* aSaveBox = new QHBox(this); myTextBtn = new QPushButton("Text properties...", aSaveBox); + myBarBtn = new QPushButton("Bar properties...", aSaveBox); myTextDlg = new VisuGUI_TextPrefDlg(this); myTextDlg->setTitleVisible(TRUE); + myBarDlg = new VisuGUI_BarPrefDlg(this); QGroupBox* CheckGroup = new QGroupBox("", this, "CheckGroup"); CheckGroup->setColumnLayout(0, Qt::Vertical ); @@ -437,6 +721,15 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent): myPreviewCheck->setChecked(false); CheckGroupLayout->addWidget(myPreviewCheck , 0, 0 ); + if(RBvert->isChecked()) { + myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + } else { + myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + } + + myBarDlg->setLabelsFormat(aResourceMgr->stringValue("VISU", propertyName + "label_format", "%-#6.3g")); + myBarDlg->setUnitsVisible(aResourceMgr->booleanValue("VISU", propertyName + "display_units", true)); + // signals and slots connections =========================================== connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) ); connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) ); @@ -444,12 +737,14 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent): connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) ); connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) ); connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) ); + connect( myBarBtn, SIGNAL( clicked() ), this, SLOT( onBarPref() ) ); connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) ); connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() )); connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() )); connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() )); connect( HeightSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() )); connect( CBLog, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() )); + connect( myBarDlg, SIGNAL( updatePreview() ), this, SLOT( updatePreview() )); changeDefaults( 0 ); myIsStoreTextProp = false; myBusy = false; @@ -533,6 +828,27 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs) myScalarMap->GetHeight(), myScalarMap->GetBarOrientation()); + if(RBvert->isChecked()) { + myVerTW = myScalarMap->GetTitleWidth(); + myVerTH = myScalarMap->GetTitleHeight(); + myVerLW = myScalarMap->GetLabelWidth(); + myVerLH = myScalarMap->GetLabelHeight(); + myVerBW = myScalarMap->GetBarWidth(); + myVerBH = myScalarMap->GetBarHeight(); + myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + } else { + myHorTW = myScalarMap->GetTitleWidth(); + myHorTH = myScalarMap->GetTitleHeight(); + myHorLW = myScalarMap->GetLabelWidth(); + myHorLH = myScalarMap->GetLabelHeight(); + myHorBW = myScalarMap->GetBarWidth(); + myHorBH = myScalarMap->GetBarHeight(); + myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + } + + myBarDlg->setLabelsFormat(myScalarMap->GetLabelsFormat()); + myBarDlg->setUnitsVisible(myScalarMap->IsUnitsVisible()); + myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), myScalarMap->GetTitFontType(), myScalarMap->IsBoldTitle(), @@ -608,8 +924,13 @@ void VisuGUI_ScalarBarPane::createScalarBar() else myScalarMapPL->SetScaling(VISU::LINEAR); vtkFloatingPointType theRange[2]; - theRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble(); - theRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble(); + if(RBFrange->isChecked()) { + theRange[0] = myScalarMap->GetSourceMin(); + theRange[1] = myScalarMap->GetSourceMax(); + } else { + theRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble(); + theRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble(); + } myScalarMapPL->SetScalarRange(theRange); myScalarMapPL->SetNbColors(sbCol); @@ -617,8 +938,31 @@ void VisuGUI_ScalarBarPane::createScalarBar() aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable()); - if (myTextDlg->getTitleText().latin1() != "") - aScalarBarActor->SetTitle(myTextDlg->getTitleText().latin1()); + if (myTextDlg->getTitleText().latin1() != "") { + VISU::PValForTime aValForTime; + const VISU::PField& aField = myScalarMap->GetScalarField(); + const VISU::TValField& aValField = aField->myValField; + VISU::TValField::const_iterator anIter = aValField.find(myScalarMap->GetScalarTimeStampNumber()); + if (anIter != aValField.end()) + aValForTime = anIter->second; + + if (aValForTime) { + std::strstream aStream; + const VISU::TTime& aTime = aValForTime->myTime; + aStream<< myTextDlg->getTitleText() <<" "; + if(myBarDlg->isUnitsVisible()) + aStream<SetTitle(aScalarBarTitle.c_str()); + } else { + aScalarBarActor->SetTitle(myTextDlg->getTitleText().latin1()); + } + } else aScalarBarActor->SetTitle(myTitle.c_str()); aScalarBarActor->SetOrientation(getOrientation()); @@ -663,6 +1007,12 @@ void VisuGUI_ScalarBarPane::createScalarBar() (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff(); (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff(); + int VerTW, VerTH, VerLW, VerLH, VerBW, VerBH; + myBarDlg->getRatios(VerTW, VerTH, VerLW, VerLH, VerBW, VerBH); + aScalarBarActor->SetRatios(VerTW, VerTH, VerLW, VerLH, VerBW, VerBH); + + aScalarBarActor->SetLabelFormat(myBarDlg->getLabelsFormat()); + aScalarBarActor->Modified(); VISU::GetActiveViewWindow()->AddActor(myPreviewActor); @@ -705,6 +1055,15 @@ int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { myScalarMap->SetScalarMode(myModeCombo->currentItem()); myScalarMap->SetPosition(XSpin->value(), YSpin->value()); myScalarMap->SetSize(WidthSpin->value(), HeightSpin->value()); + if(RBvert->isChecked()) { + myScalarMap->SetRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + } else { + myScalarMap->SetRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + } + + myScalarMap->SetLabelsFormat(myBarDlg->getLabelsFormat()); + myScalarMap->SetUnitsVisible(myBarDlg->isUnitsVisible()); + myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3d::VERTICAL : VISU::ColoredPrs3d::HORIZONTAL); if(isLogarithmic()) myScalarMap->SetScaling(VISU::LOGARITHMIC); @@ -1024,6 +1383,23 @@ void VisuGUI_ScalarBarPane::onTextPref() } +//---------------------------------------------------------------------------- +void VisuGUI_ScalarBarPane::onBarPref() +{ + if(RBvert->isChecked()) + myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + else + myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + if(myBarDlg->exec()) { + if(RBvert->isChecked()) + myBarDlg->getRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + else + myBarDlg->getRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + updatePreview(); + } +} + + //---------------------------------------------------------------------------- void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview) { diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.h b/src/VISUGUI/VisuGUI_Prs3dDlg.h index 13c589b6..5ba245ec 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.h +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.h @@ -97,6 +97,60 @@ class VisuGUI_TextPrefDlg: public QDialog }; +//---------------------------------------------------------------------------- +class VisuGUI_BarPrefDlg: public QDialog +{ + Q_OBJECT; + + public: + VisuGUI_BarPrefDlg (QWidget* parent); + ~VisuGUI_BarPrefDlg() {}; + + void setRatios(int titleRatioWidth, int titleRatioHeight, + int labelRatioWidth, int labelRatioHeight, + int barRatioWidth, int barRatioHeight); + void getRatios(int& titleRatioWidth, int& titleRatioHeight, + int& labelRatioWidth, int& labelRatioHeight, + int& barRatioWidth, int& barRatioHeight); + + void setUnitsVisible(bool isVisible); + bool isUnitsVisible(); + + void setLabelsFormat(QString format); + QString getLabelsFormat(); + + private: + void keyPressEvent( QKeyEvent* e ); + + signals: + void updatePreview(); + + protected slots: + void accept(); + void reject(); + void onHelp(); + + protected: + QSpinBox* TitleWidthSpin; + QSpinBox* TitleHeightSpin; + QSpinBox* LabelWidthSpin; + QSpinBox* LabelHeightSpin; + QSpinBox* BarWidthSpin; + QSpinBox* BarHeightSpin; + QCheckBox* CBUnits; + QLineEdit* UnitsEdit; + + int myTitleWidth; + int myTitleHeight; + int myLabelWidth; + int myLabelHeight; + int myBarWidth; + int myBarHeight; + bool myUnits; + QString myUnitsFormat; +}; + + //---------------------------------------------------------------------------- class VisuGUI_ScalarBarPane : public QVBox { @@ -152,10 +206,14 @@ class VisuGUI_ScalarBarPane : public QVBox QLabel* myModeLbl; QComboBox* myModeCombo; QPushButton* myTextBtn; + QPushButton* myBarBtn; VisuGUI_TextPrefDlg* myTextDlg; + VisuGUI_BarPrefDlg* myBarDlg; double myHorX, myHorY, myHorW, myHorH; double myVerX, myVerY, myVerW, myVerH; + int myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH; + int myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH; bool myIsStoreTextProp; private slots: @@ -164,6 +222,7 @@ class VisuGUI_ScalarBarPane : public QVBox void XYChanged( double ); void changeScalarMode( int ); void onTextPref(); + void onBarPref(); void onPreviewCheck(bool thePreview); void updatePreview(); diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 56160927..7df71bef 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -660,6 +660,10 @@ VISU::ColoredPrs3d_i SetScalarMode(anOrigin->GetScalarMode()); SetNbColors(anOrigin->GetNbColors()); + + SetUnitsVisible(anOrigin->IsUnitsVisible()); + SetLabelsFormat(anOrigin->GetLabelsFormat()); + SetBarOrientation(anOrigin->GetBarOrientation()); SetMinMaxController(anOrigin->GetMinMaxController()); @@ -671,6 +675,9 @@ VISU::ColoredPrs3d_i SetPosition(anOrigin->GetPosX(), anOrigin->GetPosY()); SetSize(anOrigin->GetWidth(), anOrigin->GetHeight()); + SetRatios(anOrigin->GetTitleWidth(), anOrigin->GetTitleHeight(), + anOrigin->GetLabelWidth(), anOrigin->GetLabelHeight(), + anOrigin->GetBarWidth(), anOrigin->GetBarHeight()); SetLabels(anOrigin->GetLabels()); SetTitle(anOrigin->GetTitle()); @@ -983,6 +990,81 @@ VISU::ColoredPrs3d_i return myHeight; } +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::SetRatios(CORBA::Long theTitleWidth, CORBA::Long theTitleHeight, + CORBA::Long theLabelWidth, CORBA::Long theLabelHeight, + CORBA::Long theBarWidth, CORBA::Long theBarHeight) +{ + bool anIsSameValue = VISU::CheckIsSameValue(myTitleWidth, theTitleWidth); + anIsSameValue &= VISU::CheckIsSameValue(myTitleHeight, theTitleHeight); + anIsSameValue &= VISU::CheckIsSameValue(myLabelWidth, theLabelWidth); + anIsSameValue &= VISU::CheckIsSameValue(myLabelHeight, theLabelHeight); + anIsSameValue &= VISU::CheckIsSameValue(myBarWidth, theBarWidth); + anIsSameValue &= VISU::CheckIsSameValue(myBarHeight, theBarHeight); + if(anIsSameValue) + return; + + VISU::TSetModified aModified(this); + + myTitleWidth = theTitleWidth; + myTitleHeight = theTitleHeight; + myLabelWidth = theLabelWidth; + myLabelHeight = theLabelHeight; + myBarWidth = theBarWidth; + myBarHeight = theBarHeight; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- +CORBA::Long +VISU::ColoredPrs3d_i +::GetTitleWidth() +{ + return myTitleWidth; +} + +//---------------------------------------------------------------------------- +CORBA::Long +VISU::ColoredPrs3d_i +::GetTitleHeight() +{ + return myTitleHeight; +} + +//---------------------------------------------------------------------------- +CORBA::Long +VISU::ColoredPrs3d_i +::GetLabelWidth() +{ + return myLabelWidth; +} + +//---------------------------------------------------------------------------- +CORBA::Long +VISU::ColoredPrs3d_i +::GetLabelHeight() +{ + return myLabelHeight; +} + +//---------------------------------------------------------------------------- +CORBA::Long +VISU::ColoredPrs3d_i +::GetBarWidth() +{ + return myBarWidth; +} + +//---------------------------------------------------------------------------- +CORBA::Long +VISU::ColoredPrs3d_i +::GetBarHeight() +{ + return myBarHeight; +} + //---------------------------------------------------------------------------- void VISU::ColoredPrs3d_i @@ -1005,6 +1087,27 @@ VISU::ColoredPrs3d_i return myNumberOfLabels; } +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::SetLabelsFormat(const char* theFormat) +{ + if( myLabelsFormat != theFormat ){ + VISU::TSetModified aModified(this); + myLabelsFormat = theFormat; + myParamsTime.Modified(); + } +} + + +//---------------------------------------------------------------------------- +char* +VISU::ColoredPrs3d_i +::GetLabelsFormat() +{ + return CORBA::string_dup(myLabelsFormat.c_str()); +} + //---------------------------------------------------------------------------- void VISU::ColoredPrs3d_i @@ -1019,7 +1122,15 @@ VISU::ColoredPrs3d_i if (aValForTime) { std::strstream aStream; const VISU::TTime& aTime = aValForTime->myTime; - aStream<integerValue( "VISU", "scalar_bar_num_colors", 64 ); SetNbColors(aNumberOfColors); + bool isUnits = aResourceMgr->booleanValue( "VISU", "scalar_bar_display_units", true ); + SetUnitsVisible(isUnits); + + QString aLabelsFormat = aResourceMgr->stringValue( "VISU", "scalar_bar_label_format", "%-#6.3g" ); + const char *lf=aLabelsFormat.latin1(); + SetLabelsFormat(lf); + // Orientation int anOrientation = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0); if(anOrientation == 1) @@ -1379,6 +1517,24 @@ VISU::ColoredPrs3d_i myHeight = (myOrientation == VISU::ColoredPrs3d::VERTICAL)? 0.8:0.12; myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight); + myTitleWidth = 0; + myTitleWidth = aResourceMgr->integerValue("VISU", propertyName + "title_width", myTitleWidth); + + myTitleHeight = 0; + myTitleHeight = aResourceMgr->integerValue("VISU", propertyName + "title_height", myTitleHeight); + + myLabelWidth = 0; + myLabelWidth = aResourceMgr->integerValue("VISU", propertyName + "label_width", myLabelWidth); + + myLabelHeight = 0; + myLabelHeight = aResourceMgr->integerValue("VISU", propertyName + "label_height", myLabelHeight); + + myBarWidth = 0; + myBarWidth = aResourceMgr->integerValue("VISU", propertyName + "bar_width", myBarWidth); + + myBarHeight = 0; + myBarHeight = aResourceMgr->integerValue("VISU", propertyName + "bar_height", myBarHeight); + // scalar bar default position bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0); int aPlace = 1; @@ -1494,6 +1650,8 @@ VISU::ColoredPrs3d_i UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange", "0").toInt()); SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt()); + SetUnitsVisible(VISU::Storable::FindValue(theMap,"myUnitsVisible", "1").toInt()); + SetLabelsFormat(VISU::Storable::FindValue(theMap,"myLabelsFormat", "%-#6.3g")); SetBarOrientation((VISU::ColoredPrs3d::Orientation)VISU::Storable::FindValue(theMap,"myOrientation").toInt()); SetTitle(VISU::Storable::FindValue(theMap,"myTitle").latin1()); @@ -1502,6 +1660,12 @@ VISU::ColoredPrs3d_i myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble(); myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble(); myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble(); + myTitleWidth = VISU::Storable::FindValue(theMap,"myTitleWidth").toInt(); + myTitleHeight = VISU::Storable::FindValue(theMap,"myTitleHeight").toInt(); + myLabelWidth = VISU::Storable::FindValue(theMap,"myLabelWidth").toInt(); + myLabelHeight = VISU::Storable::FindValue(theMap,"myLabelHeight").toInt(); + myBarWidth = VISU::Storable::FindValue(theMap,"myBarWidth").toInt(); + myBarHeight = VISU::Storable::FindValue(theMap,"myBarHeight").toInt(); myTitFontType = VISU::Storable::FindValue(theMap,"myTitFontType").toInt(); myIsBoldTitle = VISU::Storable::FindValue(theMap,"myIsBoldTitle").toInt(); @@ -1556,11 +1720,19 @@ VISU::ColoredPrs3d_i Storable::DataToStream( theStr, "myOrientation", myOrientation ); Storable::DataToStream( theStr, "myTitle", myTitle.c_str() ); + Storable::DataToStream( theStr, "myUnitsVisible", myIsUnits ); Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels ); + Storable::DataToStream( theStr, "myLabelsFormat", myLabelsFormat.c_str() ); Storable::DataToStream( theStr, "myPosition[0]", myPosition[0] ); Storable::DataToStream( theStr, "myPosition[1]", myPosition[1] ); Storable::DataToStream( theStr, "myWidth", myWidth ); Storable::DataToStream( theStr, "myHeight", myHeight ); + Storable::DataToStream( theStr, "myTitleWidth", myTitleWidth ); + Storable::DataToStream( theStr, "myTitleHeight", myTitleHeight ); + Storable::DataToStream( theStr, "myLabelWidth", myLabelWidth ); + Storable::DataToStream( theStr, "myLabelHeight", myLabelHeight ); + Storable::DataToStream( theStr, "myBarWidth", myBarWidth ); + Storable::DataToStream( theStr, "myBarHeight", myBarHeight ); Storable::DataToStream( theStr, "myTitFontType", myTitFontType ); Storable::DataToStream( theStr, "myIsBoldTitle", myIsBoldTitle ); diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 60fae154..9b1c3ecb 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -275,6 +275,12 @@ namespace VISU void SetSize(CORBA::Double theWidth, CORBA::Double theHeight); + virtual + void + SetRatios(CORBA::Long theTitleWidth, CORBA::Long theTitleHeight, + CORBA::Long theLabelWidth, CORBA::Long theLabelHeight, + CORBA::Long theBarWidth, CORBA::Long theBarHeight); + virtual CORBA::Double GetWidth(); @@ -283,6 +289,30 @@ namespace VISU CORBA::Double GetHeight(); + virtual + CORBA::Long + GetTitleWidth(); + + virtual + CORBA::Long + GetTitleHeight(); + + virtual + CORBA::Long + GetLabelWidth(); + + virtual + CORBA::Long + GetLabelHeight(); + + virtual + CORBA::Long + GetBarWidth(); + + virtual + CORBA::Long + GetBarHeight(); + virtual void SetLabels(CORBA::Long theNbLabels); @@ -291,6 +321,14 @@ namespace VISU CORBA::Long GetLabels(); + virtual + void + SetLabelsFormat(const char* theFormat); + + virtual + char* + GetLabelsFormat(); + virtual void SetTitle(const char* theTitle); @@ -302,6 +340,14 @@ namespace VISU std::string GetCTitle(); + virtual + void + SetUnitsVisible(CORBA::Boolean isVisible); + + virtual + CORBA::Boolean + IsUnitsVisible(); + //---------------------------------------------------------------------------- //! Gets memory size actually used by the presentation (Mb). virtual @@ -593,10 +639,16 @@ namespace VISU std::string myTitle; std::string myScalarBarTitle; + bool myIsUnits; int myNumberOfLabels; + std::string myLabelsFormat; VISU::ColoredPrs3d::Orientation myOrientation; - vtkFloatingPointType myPosition[2], myWidth, myHeight; + vtkFloatingPointType myPosition[2], + myWidth, myHeight, + myTitleWidth, myTitleHeight, + myLabelWidth, myLabelHeight, + myBarWidth, myBarHeight; //Font management bool myIsBoldTitle; diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index ede97ab9..befdcf63 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -35,6 +35,7 @@ #include "VISU_OpenGLPointSpriteMapper.hxx" #include "VISU_ScalarBarCtrl.hxx" +#include #include "VISU_LookupTable.hxx" #include "VISU_Convertor.hxx" @@ -44,7 +45,6 @@ #include #include -#include #include #include @@ -871,14 +871,18 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::UpdateScalarBar(vtkScalarBarActor *theScalarBar, - vtkLookupTable* theLookupTable) +::UpdateScalarBar(VISU_ScalarBarActor *theScalarBar, + VISU_LookupTable* theLookupTable) { theScalarBar->SetTitle(GetScalarBarTitle().c_str()); theScalarBar->SetOrientation(GetBarOrientation()); theScalarBar->SetNumberOfLabels(GetLabels()); + theScalarBar->SetRatios(GetTitleWidth(), GetTitleHeight(), + GetLabelWidth(), GetLabelHeight(), + GetBarWidth(), GetBarHeight()); + theScalarBar->SetLabelFormat(GetLabelsFormat()); - vtkLookupTable* aLookupTable = GetSpecificPL()->GetBarTable(); + VISU_LookupTable* aLookupTable = GetSpecificPL()->GetBarTable(); theLookupTable->SetNumberOfColors(aLookupTable->GetNumberOfColors()); theScalarBar->SetMaximumNumberOfColors(aLookupTable->GetNumberOfColors()); diff --git a/src/VISU_I/VISU_GaussPoints_i.hh b/src/VISU_I/VISU_GaussPoints_i.hh index 13dc605f..117ab8ab 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -30,8 +30,8 @@ #include "VISU_ColoredPrs3d_i.hh" #include "VISU_GaussPtsActorFactory.h" -class vtkLookupTable; -class vtkScalarBarActor; +class VISU_LookupTable; +class VISU_ScalarBarActor; class VISU_GaussPointsPL; @@ -320,8 +320,8 @@ namespace VISU OnCreateActor2(); void - UpdateScalarBar(vtkScalarBarActor *theScalarBar, - vtkLookupTable* theLookupTable); + UpdateScalarBar(VISU_ScalarBarActor *theScalarBar, + VISU_LookupTable* theLookupTable); protected: VISU_GaussPointsPL *myGaussPointsPL; diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index 900e3621..38b32823 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -431,7 +431,11 @@ VISU::ScalarMap_i aScalarBar->GetPositionCoordinate()->SetValue(GetPosX(),GetPosY()); aScalarBar->SetWidth(GetWidth()); aScalarBar->SetHeight(GetHeight()); + aScalarBar->SetRatios(GetTitleWidth(), GetTitleHeight(), + GetLabelWidth(), GetLabelHeight(), + GetBarWidth(), GetBarHeight()); aScalarBar->SetNumberOfLabels(GetLabels()); + aScalarBar->SetLabelFormat(GetLabelsFormat()); vtkFloatingPointType anRGB[3]; -- 2.39.2