From: eap Date: Thu, 22 Jan 2009 13:45:55 +0000 (+0000) Subject: Merge from BR_V5_IMP_P8 X-Git-Tag: mergefrom_BR_V5_IMP_P8_22Jan09~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=af4466fde5a90dbf08c3099640131b066bfb23aa;p=modules%2Fvisu.git Merge from BR_V5_IMP_P8 --- diff --git a/doc/salome/gui/VISU/images/barproperty.png b/doc/salome/gui/VISU/images/barproperty.png index 02d449ea..f095a330 100644 Binary files a/doc/salome/gui/VISU/images/barproperty.png and b/doc/salome/gui/VISU/images/barproperty.png differ diff --git a/doc/salome/gui/VISU/images/labeling_parameters.png b/doc/salome/gui/VISU/images/labeling_parameters.png new file mode 100644 index 00000000..58ae411f Binary files /dev/null and b/doc/salome/gui/VISU/images/labeling_parameters.png differ diff --git a/doc/salome/gui/VISU/images/scalarbarproperties.png b/doc/salome/gui/VISU/images/scalarbarproperties.png index 86ca6dff..318497db 100644 Binary files a/doc/salome/gui/VISU/images/scalarbarproperties.png and b/doc/salome/gui/VISU/images/scalarbarproperties.png differ diff --git a/doc/salome/gui/VISU/images/values_labeling.png b/doc/salome/gui/VISU/images/values_labeling.png new file mode 100644 index 00000000..056b1f12 Binary files /dev/null and b/doc/salome/gui/VISU/images/values_labeling.png differ diff --git a/doc/salome/gui/VISU/input/field_presentations.doc b/doc/salome/gui/VISU/input/field_presentations.doc index ee4a01a3..aaa74a0b 100644 --- a/doc/salome/gui/VISU/input/field_presentations.doc +++ b/doc/salome/gui/VISU/input/field_presentations.doc @@ -15,6 +15,8 @@
  • \subpage plot_3d_page
  • \subpage gauss_points_presentations_page
  • +Over the Field presentation of any type you can display field values +as \subpage values_labeling_page "text labels".
    To create a field presentation (\ref fields_anchor "see also"): \par @@ -41,4 +43,4 @@ submenu of the main menu or from the Visualization Toolbar. The new field presentation will be located in the time stamp subfolder in the Object Browser and displayed -*/ \ No newline at end of file +*/ diff --git a/doc/salome/gui/VISU/input/index.doc b/doc/salome/gui/VISU/input/index.doc index d87c8b77..c82f4977 100644 --- a/doc/salome/gui/VISU/input/index.doc +++ b/doc/salome/gui/VISU/input/index.doc @@ -15,4 +15,4 @@ A MED file contains the description of a \subpage med_object_page "MED object", \n The Python interface of \b Post-Pro module is described in \subpage idl_interface_page "Access to Post-Pro module functionality" page. -*/ \ No newline at end of file +*/ diff --git a/doc/salome/gui/VISU/input/scalar_map.doc b/doc/salome/gui/VISU/input/scalar_map.doc index 0782be69..749ff40c 100644 --- a/doc/salome/gui/VISU/input/scalar_map.doc +++ b/doc/salome/gui/VISU/input/scalar_map.doc @@ -94,7 +94,7 @@ orientation of the scalar bar.
  • Origin: you can enter X & Y coordinates of the origin of the scalar bar.
  • Dimensions: you can enter \b Width and \b Height of the -scalar bar.
  • +scalar bar specified in % of the size of view.
  • Text properties button allows you to define from the following dialog box: @@ -113,11 +113,11 @@ following dialog box: \image html barproperty.png
  • Preview checkbox allows to see a preview of the @@ -134,7 +134,7 @@ along the scalar bar.
  • presentations. -/note The following option is relevant only for Gauss Points presentations. +\note The following option is relevant only for Gauss Points presentations. \n Gauss Points Presentations presume that two different scalar bars are displayed simultaneously: diff --git a/doc/salome/gui/VISU/input/values_labeling.doc b/doc/salome/gui/VISU/input/values_labeling.doc new file mode 100644 index 00000000..e6d3f930 --- /dev/null +++ b/doc/salome/gui/VISU/input/values_labeling.doc @@ -0,0 +1,34 @@ +/*! + +\page values_labeling_page Values labeling + +

    Displaying value labels

    + +In VISU you can display values applied to the cells or nodes of 3D presentation intended for visualization of calculation data. + +To display labels for values: +
      +
    1. Display your presentation in 3d viewer
    2. +
    3. Right-click on the presentation in the 3D viewer and from the associated pop-up menu choose Values labeling.
    4. +
    + +It will looks as follow: + +\image html values_labeling.png + +

    Parameters of values labeling

    + +You have ability to change parameters of values labeling such as font and color. Default parameters can be specified using "Preferences" dialog box. Also you can change parameters for each presentation. + +To change parameters of the presentation: +
      +
    1. Display your presentation in 3d viewer
    2. +
    3. Right-click on the presentation in the 3D viewer and from the associated pop-up menu choose Labeling parameters.
    4. +
    5. Use "Parameters of values labeling" dialog box for the operation
    6. +
    + +It will looks as follows: + +\image html labeling_parameters.png + +*/ diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 6460854c..f4027093 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -365,6 +365,17 @@ module VISU { * \return The type of representation of the mesh. */ PresentationType GetPresentationType(); + + /*! + * Switches shrink mode of presentation + * Note: SetPresentationType(SHRINK) is same as SetShrink(True) + */ + void SetShrink(in boolean toShrink); + + /*! + * Returns current state of shrink mode + */ + boolean IsShrank(); }; @@ -714,6 +725,16 @@ module VISU { interface ScalarMap : ColoredPrs3d, ScaledPrs3d { + /*! + * Returns visibility state of scalar bar + */ + boolean IsBarVisible(); + + /*! + * Sets visibility state of scalar bar + */ + void SetBarVisible(in boolean theVisible); + }; //------------------------------------------------------- diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 0e4ffe48..3cde8f73 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -56,19 +56,17 @@ - - - + + + - - - - + + - - + + @@ -81,12 +79,12 @@ - + - - + + - + @@ -172,6 +170,8 @@ + +
    diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index edbcbc34..431ffd68 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -23,8 +23,7 @@ // File : // Author : // Module : VISU -// $Header$ -// + #include "VISU_Actor.h" #include "VISU_PickingSettings.h" @@ -59,6 +58,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include @@ -138,6 +143,44 @@ VISU_Actor aPickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent, myEventCallbackCommand.GetPointer(), myPriority); + + //Definition of values labeling pipeline + + myValLblDataSet = vtkUnstructuredGrid::New(); + + myValCellCenters = vtkCellCenters::New(); + myValCellCenters->SetInput(myValLblDataSet); + + myValMaskPoints = vtkMaskPoints::New(); + myValMaskPoints->SetInput(myValCellCenters->GetOutput()); + myValMaskPoints->SetOnRatio(1); + + myValSelectVisiblePoints = vtkSelectVisiblePoints::New(); + myValSelectVisiblePoints->SetInput(myValMaskPoints->GetOutput()); + myValSelectVisiblePoints->SelectInvisibleOff(); + myValSelectVisiblePoints->SetTolerance(0.1); + + myValLabeledDataMapper = vtkLabeledDataMapper::New(); + myValLabeledDataMapper->SetInput(myValSelectVisiblePoints->GetOutput()); + myValLabeledDataMapper->SetLabelFormat("%g"); + myValLabeledDataMapper->SetLabelModeToLabelScalars(); + + vtkTextProperty* aClsTextProp = vtkTextProperty::New(); + aClsTextProp->SetFontFamilyToTimes(); + static int aCellsFontSize = 12; + aClsTextProp->SetFontSize(aCellsFontSize); + aClsTextProp->SetBold(1); + aClsTextProp->SetItalic(0); + aClsTextProp->SetShadow(0); + myValLabeledDataMapper->SetLabelTextProperty(aClsTextProp); + aClsTextProp->Delete(); + + myIsValLabeled = false; + + myValLabels = vtkActor2D::New(); + myValLabels->SetMapper(myValLabeledDataMapper); + myValLabels->GetProperty()->SetColor(0,1,0); + myValLabels->SetVisibility( myIsValLabeled ); } //---------------------------------------------------------------------------- @@ -181,6 +224,15 @@ VISU_Actor VISU_Actor ::~VISU_Actor() { + // Deleting of values labeling pipeline + myValLblDataSet->Delete(); + myValLabeledDataMapper->RemoveAllInputs(); + myValLabeledDataMapper->Delete(); + myValSelectVisiblePoints->Delete(); + myValMaskPoints->Delete(); + myValCellCenters->Delete(); + myValLabels->Delete(); + if(MYDEBUG) MESSAGE("~VISU_Actor() - this = "<AddActor(myAnnotationActor.GetPointer()); theRenderer->AddActor(myTextActor.GetPointer()); + + myValSelectVisiblePoints->SetRenderer( theRenderer ); + theRenderer->AddActor2D( myValLabels ); + } //================================================================== @@ -479,10 +535,20 @@ VISU_Actor { theRenderer->RemoveActor(myAnnotationActor.GetPointer()); theRenderer->RemoveActor(myTextActor.GetPointer()); + theRenderer->RemoveActor(myValLabels); Superclass::RemoveFromRender(theRenderer); myDestroySignal(this); } +//---------------------------------------------------------------------------- +void +VISU_Actor +::SetVisibility(int theMode) +{ + Superclass::SetVisibility( theMode ); + myValLabels->SetVisibility( myIsValLabeled && theMode ); +} + //---------------------------------------------------------------------------- void VISU_Actor @@ -1093,3 +1159,92 @@ VISU_Actor Update(); } + +// --------------------------------------------------------------- + +void VISU_Actor::SetValuesLabeled( const bool theIsValLabeled ) +{ + vtkDataSet* aGrid = GetValLabelsInput(); + if ( !aGrid ) + return; + + bool isOnPnt = VISU::IsDataOnPoints( aGrid ); + bool isOnCell = VISU::IsDataOnCells( aGrid ); + if ( !isOnPnt && !isOnCell ) + { + // try to specify location of scalars "manually" + vtkCellData* aCData = aGrid->GetCellData(); + if ( aCData ) + { + vtkDataArray* anArr = aCData->GetScalars(); + if ( anArr && anArr->GetNumberOfTuples() ) + isOnCell = true; + } + + if ( !isOnCell ) + { + vtkPointData* aPData = aGrid->GetPointData(); + if ( aPData ) + { + vtkDataArray* anArr = aPData->GetScalars(); + if ( anArr && anArr->GetNumberOfTuples() ) + isOnPnt = true; + } + } + + if ( !isOnPnt && !isOnCell ) + { + myValLabels->SetVisibility( false ); + return; + } + } + + myIsValLabeled = theIsValLabeled; + + if ( myIsValLabeled ) + { + vtkDataSet* aDataSet = aGrid; + + if ( isOnCell ) + { + myValCellCenters->SetInput( aDataSet ); + myValMaskPoints->SetInput( myValCellCenters->GetOutput() ); + } + else if ( isOnPnt ) + myValMaskPoints->SetInput( aDataSet ); + + myValLabels->SetVisibility( GetVisibility() ); + } + else + myValLabels->SetVisibility( false ); + + Modified(); +} + +//---------------------------------------------------------------------------- + +bool VISU_Actor::GetValuesLabeled() const +{ + return myIsValLabeled; +} + +//---------------------------------------------------------------------------- + +vtkTextProperty* VISU_Actor::GetsValLabelsProps() const +{ + return myValLabeledDataMapper->GetLabelTextProperty(); +} + +//---------------------------------------------------------------------------- + +vtkDataSet* VISU_Actor::GetValLabelsInput() +{ + vtkDataSet* aDataSet = 0; + VISU_PipeLine* aPL = GetPipeLine(); + if ( aPL ) + aDataSet = aPL->GetOutput(); + if ( !aDataSet ) + aDataSet = GetInput(); + return aDataSet; +} + diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 0f8ddca8..dbc76f86 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -23,8 +23,7 @@ // File : // Author : // Module : VISU -// $Header$ -// + #ifndef VISU_ACTOR_H #define VISU_ACTOR_H @@ -50,6 +49,12 @@ class VISU_PipeLine; class vtkPlane; class vtkImplicitFunctionCollection; class vtkFeatureEdges; +class vtkTextProperty; +class vtkCellCenters; +class vtkSelectVisiblePoints; +class vtkLabeledDataMapper; +class vtkMaskPoints; +class vtkActor2D; class VISU_FramedTextActor; @@ -99,6 +104,10 @@ class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase void SetPrs3d(VISU::Prs3d_i* thePrs3d); + virtual + void + SetVisibility(int theMode); + //---------------------------------------------------------------------------- virtual VISU_PipeLine* @@ -299,6 +308,22 @@ class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase UpdatePickingSettings(); //---------------------------------------------------------------------------- + //! Methods for values labeling + virtual + void + SetValuesLabeled( const bool theIsValLabeled ); + + virtual + bool + GetValuesLabeled() const; + + virtual + vtkDataSet* + GetValLabelsInput(); + + vtkTextProperty* + GetsValLabelsProps() const; + protected: VISU_Actor(); @@ -355,6 +380,15 @@ class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase Selection_Mode myLastSelectionMode; bool myIsSubElementsHighlighted; + + // fields for values labeling + bool myIsValLabeled; + vtkDataSet* myValLblDataSet; + vtkActor2D* myValLabels; + vtkMaskPoints* myValMaskPoints; + vtkCellCenters* myValCellCenters; + vtkLabeledDataMapper* myValLabeledDataMapper; + vtkSelectVisiblePoints* myValSelectVisiblePoints; }; #endif //VISU_ACTOR_H diff --git a/src/OBJECT/VISU_VectorsAct.cxx b/src/OBJECT/VISU_VectorsAct.cxx index aabab200..0742a57a 100644 --- a/src/OBJECT/VISU_VectorsAct.cxx +++ b/src/OBJECT/VISU_VectorsAct.cxx @@ -23,8 +23,7 @@ // File : VISU_VectorsAct.cxx // Author : Laurent CORNABE with help of Nicolas REJNERI // Module : VISU -// $Header$ -// + #include "VISU_VectorsAct.h" #include "VISU_VectorsPL.hxx" #include @@ -35,6 +34,9 @@ #include #include #include +#include +#include +#include //---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_VectorsAct); @@ -119,3 +121,24 @@ VISU_VectorsAct return aSize; } + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_VectorsAct +::GetValLabelsInput() +{ + VISU_VectorsPL* aPL = dynamic_cast( GetPipeLine() ); + if ( aPL ) + { + return aPL->GetMergedInput(); + /*VISU_UsedPointsFilter* aFilter = aPL->GetUsedPointsFilter(); + vtkSmartPointer< VISU_MergeFilter > aFilter = aPL->myMergeFilter; + if ( aFilter ) + { + aFilter->Update(); + return aFilter->GetOutput(); + }*/ + } + + return Superclass::GetValLabelsInput(); +} diff --git a/src/OBJECT/VISU_VectorsAct.h b/src/OBJECT/VISU_VectorsAct.h index 310f5501..98db4124 100644 --- a/src/OBJECT/VISU_VectorsAct.h +++ b/src/OBJECT/VISU_VectorsAct.h @@ -23,8 +23,7 @@ // File : VISU_VectorsAct.h // Author : Laurent CORNABE with help of Nicolas REJNERI // Module : VISU -// $Header$ -// + #ifndef VISU_VectorsAct_HeaderFile #define VISU_VectorsAct_HeaderFile @@ -65,6 +64,10 @@ class VISU_OBJECT_EXPORT VISU_VectorsAct : public VISU_ScalarMapAct virtual unsigned long int GetMemorySize(); + + virtual + vtkDataSet* + GetValLabelsInput(); protected: VISU_VectorsAct(); diff --git a/src/PIPELINE/VISU_ScalarBarActor.cxx b/src/PIPELINE/VISU_ScalarBarActor.cxx index afb4e58b..fcb77b2d 100644 --- a/src/PIPELINE/VISU_ScalarBarActor.cxx +++ b/src/PIPELINE/VISU_ScalarBarActor.cxx @@ -105,11 +105,9 @@ VISU_ScalarBarActor::VISU_ScalarBarActor() this->LastSize[0] = 0; this->LastSize[1] = 0; - this->TitleRatioWidth = 0; + this->TitleRatioSize = 0; this->LabelRatioWidth = 0; this->BarRatioWidth = 0; - this->TitleRatioHeight = 0; - this->LabelRatioHeight = 0; this->BarRatioHeight = 0; // RKV : Begin @@ -653,13 +651,10 @@ void VISU_ScalarBarActor::AllocateAndSizeLabels(int *labelSize, int *size, else 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]); + if ( this->Orientation == VTK_ORIENT_VERTICAL ) + targetHeight = (int)(0.86*size[1]/this->NumberOfLabels); else - targetHeight = (int)(0.01*LabelRatioHeight*size[1]); + targetHeight = (int)(0.25*size[1]); vtkTextMapper::SetMultipleConstrainedFontSize(viewport, targetWidth, @@ -682,18 +677,15 @@ void VISU_ScalarBarActor::SizeTitle(int *titleSize, int *size, int targetWidth, targetHeight; - if(TitleRatioWidth == 0) + if(TitleRatioSize == 0) targetWidth = size[0]; else - targetWidth = (int)(0.01*TitleRatioWidth*size[0]); + targetWidth = (int)(0.01*TitleRatioSize*size[0]); - if(TitleRatioHeight == 0) - if ( this->Orientation == VTK_ORIENT_VERTICAL ) - targetHeight = (int)(0.1*size[1]); - else - targetHeight = (int)(0.25*size[1]); + if ( this->Orientation == VTK_ORIENT_VERTICAL ) + targetHeight = (int)(0.1*size[1]); else - targetHeight = (int)(0.01*TitleRatioHeight*size[1]); + targetHeight = (int)(0.25*size[1]); this->TitleMapper->SetConstrainedFontSize( viewport, targetWidth, targetHeight); @@ -753,21 +745,14 @@ void VISU_ScalarBarActor::DebugOff() { } // RKV : End -void VISU_ScalarBarActor::SetRatios(int titleRatioWidth, int titleRatioHeight, - int labelRatioWidth, int labelRatioHeight, +void VISU_ScalarBarActor::SetRatios(int titleRatioSize, int labelRatioWidth, 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; + TitleRatioSize=titleRatioSize; + if(TitleRatioSize>100) + TitleRatioSize=100; + else if(TitleRatioSize<0) + TitleRatioSize=0; LabelRatioWidth=labelRatioWidth; if(LabelRatioWidth>100) @@ -775,12 +760,6 @@ void VISU_ScalarBarActor::SetRatios(int titleRatioWidth, int titleRatioHeight, 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; @@ -794,14 +773,11 @@ void VISU_ScalarBarActor::SetRatios(int titleRatioWidth, int titleRatioHeight, BarRatioHeight=0; } -void VISU_ScalarBarActor::GetRatios(int& titleRatioWidth, int& titleRatioHeight, - int& labelRatioWidth, int& labelRatioHeight, - int& barRatioWidth, int& barRatioHeight) +void VISU_ScalarBarActor::GetRatios(int& titleRatioSize, int& labelRatioWidth, + int& barRatioWidth, int& barRatioHeight) { - titleRatioWidth=TitleRatioWidth; - titleRatioHeight=TitleRatioHeight; + titleRatioSize=TitleRatioSize; labelRatioWidth=LabelRatioWidth; - labelRatioHeight=LabelRatioHeight; barRatioWidth=BarRatioWidth; barRatioHeight=BarRatioHeight; } diff --git a/src/PIPELINE/VISU_ScalarBarActor.hxx b/src/PIPELINE/VISU_ScalarBarActor.hxx index 4e790c97..e624af0d 100644 --- a/src/PIPELINE/VISU_ScalarBarActor.hxx +++ b/src/PIPELINE/VISU_ScalarBarActor.hxx @@ -130,11 +130,9 @@ public: // Description: // Set/Get the scalar bar dimention properties in persents. // 0 <= ration <= 100 - void SetRatios(int titleRatioWidth, int titleRatioHeight, - int labelRatioWidth, int labelRatioHeight, + void SetRatios(int titleRatioSize,int labelRatioWidth, int barRatioWidth, int barRatioHeight); - void GetRatios(int& titleRatioWidth, int& titleRatioHeight, - int& labelRatioWidth, int& labelRatioHeight, + void GetRatios(int& titleRatioSize, int& labelRatioWidth, int& barRatioWidth, int& barRatioHeight); // Description: @@ -173,11 +171,9 @@ protected: int Orientation; char *Title; char *LabelFormat; - int TitleRatioWidth; + int TitleRatioSize; int LabelRatioWidth; int BarRatioWidth; - int TitleRatioHeight; - int LabelRatioHeight; int BarRatioHeight; vtkTextMapper **TextMappers; diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index 239243cd..7ff78217 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -23,8 +23,7 @@ # File : Makefile.am # Author : Marc Tajchman (CEA) # Module : VISU -# $Header$ -# + include $(top_srcdir)/adm_local/unix/make_common_starter.am lib_LTLIBRARIES= libVISU.la @@ -69,7 +68,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 \ @@ -119,7 +119,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 \ @@ -162,7 +163,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/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 621323c2..6070c77b 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -427,16 +427,16 @@ Do you want to enlarge the cache? Labels format - VISU_TITLE_WIDTH - Title width (%): + VISU_TITLE_SIZE + Title size (%): VISU_TITLE_HEIGHT Title height (%): - VISU_LABEL_WIDTH - Label width (%): + VISU_LABEL_SIZE + Label size (%): VISU_LABEL_HEIGHT @@ -885,6 +885,10 @@ Please, refer to the documentation. VisuGUI + + PRECISION + Precision + DLG_LINEWIDTH_CMT1 Set value between @@ -1276,6 +1280,14 @@ Please, refer to the documentation. MEN_FILTER_SCALARS Filter by Scalars... + + + MEN_VALUES_LABELING + Values labeling + + + VISU_VALUES_LABELING_PARAMS + Labeling parameters TOOL_IMPORTImport TOOL_REPRESENTATIONRepresentation @@ -1323,6 +1335,18 @@ Please, refer to the documentation. UNKNOWN_IMPORT_ERROR Unknown error + + VALUES_LABELING + Values labeling + + + LABELS + Labels + + + COLOR + Color + VisuGUI_AxisWg @@ -2861,7 +2885,7 @@ Please, provide non-empty resulting presentation. DIMENSIONS_GRP - Dimensions + Dimensions (in % of the size of view) FIELD_RANGE_BTN @@ -2907,6 +2931,10 @@ Please, provide non-empty resulting presentation. FILTER_BY_SCALARS Filter by scalars + + VALUES_LABELING + Values labeling + LBL_WIDTH Width: @@ -2955,6 +2983,10 @@ Please, provide non-empty resulting presentation. WRN_LOGARITHMIC_RANGE Logarithmic scaling: use imposed range values > 0 + + HIDE_SCALAR_BAR + Hide scalar bar + VisuGUI_DeformedShapeAndScalarMapDlg @@ -3509,6 +3541,18 @@ Please, refer to the QT documentation. VisuGUI_BarPrefDlg + + DIMENSIONS + Dimensions (in % of the size of widget) + + + WIDTH + Width + + + PRECISION + Precision + &OK @@ -3523,15 +3567,11 @@ Please, refer to the QT documentation. LBL_TITLE_W - Title width (%) - - - LBL_TITLE_H - Title height (%) + Title size (%) LBL_LABEL_W - Label width (%) + Label size (%) LBL_LABEL_H @@ -3559,7 +3599,11 @@ Please, refer to the QT documentation. MSG_BIG_SCALE - The common (Title, Label, Bar) width or height should not be greater then 100%. + The common Label size and Bar width or height should not be greater then 100%. + + + MSG_BIG_SCALE_TLT + The Title size should not be greater then 100%. AUTO @@ -3937,4 +3981,23 @@ Please, refer to the QT documentation. Max: + + VisuGUI_ValuesLabelingDlg + + PARAMETERS_OF_VALUES_LABELING + Parameters of values labeling + + + LABELS + Labels + + + FONT + Font + + + COLOR + Color + + diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 3238d008..801b83de 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -23,7 +23,6 @@ // File : VisuGUI.cxx // Author : // Module : VISU -// $Header$ #include "VisuGUI.h" @@ -160,7 +159,9 @@ #include "VisuGUI_Slider.h" #include "VisuGUI_Sweep.h" - +#include +#include +#include using namespace VISU; @@ -2639,6 +2640,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 @@ -2765,6 +2775,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 @@ -2893,6 +2909,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'"; @@ -2907,7 +2930,8 @@ VisuGUI QString aPrsType = " and $type in {'VISU::TMESH' 'VISU::TGAUSSPOINTS' " + aPrsAll + "}"; QString aPrsType2 = " and $type in {'VISU::TMESH' 'VISU::TPOINTMAP3D'" + aPrsAll + "}"; QString anInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP'}"; - QString aSurfFrameType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP''VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP'}"; + //QString aSurfFrameType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP''VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP'}"; + QString aSurfFrameType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP''VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TCUTPLANES' 'VISU::TISOSURFACES' 'VISU::TPLOT3D' }"; //QString aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}"; QString aSurfType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " " 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TPOINTMAP3D'}"; @@ -3401,23 +3425,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 ); @@ -3436,9 +3448,12 @@ void VisuGUI::createPreferences() setPreferenceProperty( numlab, "min", 2 ); setPreferenceProperty( numlab, "max", 65 ); - addPreference( tr( "VISU_LABELS_FORMAT" ), colorsLabelsGr, - LightApp_Preferences::String, "VISU", "scalar_bar_label_format" ); + int lPrec = addPreference( tr( "PRECISION" ), colorsLabelsGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_label_precision" ); + setPreferenceProperty( lPrec, "min", 1 ); + setPreferenceProperty( lPrec, "max", 100 ); + int frame = addPreference( "", sbarTab, LightApp_Preferences::Frame, "", "" ); setPreferenceProperty( frame, "orientation", "horizontal" ); @@ -3478,16 +3493,12 @@ void VisuGUI::createPreferences() int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" ); - int twv = addPreference( tr( "VISU_TITLE_WIDTH" ), posVSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_title_width" ); - int thv = addPreference( tr( "VISU_TITLE_HEIGHT" ), posVSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_title_height" ); - - int lwv = addPreference( tr( "VISU_LABEL_WIDTH" ), posVSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_label_width" ); - int lhv = addPreference( tr( "VISU_LABEL_HEIGHT" ), posVSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_label_height" ); - + int twv = addPreference( tr( "VISU_TITLE_SIZE" ), posVSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_title_size" ); + + int lwv = addPreference( tr( "VISU_LABEL_SIZE" ), posVSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_label_size" ); + int bwv = addPreference( tr( "VISU_BAR_WIDTH" ), posVSizeGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_bar_width" ); int bhv = addPreference( tr( "VISU_BAR_HEIGHT" ), posVSizeGr, @@ -3503,12 +3514,8 @@ void VisuGUI::createPreferences() 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 ); @@ -3518,9 +3525,7 @@ void VisuGUI::createPreferences() 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 ); @@ -3539,19 +3544,15 @@ void VisuGUI::createPreferences() int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" ); - int twh = addPreference( tr( "Title width (%)" ), posHSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_title_width" ); - int thh = addPreference( tr( "Title height (%)" ), posHSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_title_height" ); - - int lwh = addPreference( tr( "Label width (%)" ), posHSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_label_width" ); - int lhh = addPreference( tr( "Label height (%)" ), posHSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_label_height" ); - - int bwh = addPreference( tr( "Bar width (%)" ), posHSizeGr, + int twh = addPreference( tr( "VISU_TITLE_SIZE" ), posHSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_title_size" ); + + int lwh = addPreference( tr( "VISU_LABEL_SIZE" ), posHSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_label_size" ); + + int bwh = addPreference( tr( "VISU_BAR_WIDTH" ), posHSizeGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_bar_width" ); - int bhh = addPreference( tr( "Bar height (%)" ), posHSizeGr, + int bhh = addPreference( tr( "VISU_BAR_HEIGHT" ), posHSizeGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_bar_height" ); setPreferenceProperty( xh, "step", 0.1 ); @@ -3564,12 +3565,8 @@ void VisuGUI::createPreferences() 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 ); @@ -3579,9 +3576,7 @@ void VisuGUI::createPreferences() 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 ); @@ -3817,6 +3812,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) @@ -3828,8 +3839,8 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b) float aTol = 1.00000009999999; QString aWarning; if(b == QString("scalar_bar_vertical_x") || b == QString("scalar_bar_vertical_width")){ - sbX1 = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_x", sbX1); - sbW = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_width", sbW); + sbX1 = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_x", 0.01); + sbW = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_width", 0.05); if(sbX1+sbW > aTol){ aWarning = "Origin and Size Vertical: X+Width > 1\n"; sbX1=0.01; @@ -3839,8 +3850,8 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b) } } else if(b == QString("scalar_bar_vertical_y") || b == QString("scalar_bar_vertical_height")){ - sbY1 = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_y", sbY1); - sbH = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_height",sbH); + sbY1 = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_y", 0.01); + sbH = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_height",0.5); if(sbY1+sbH > aTol){ aWarning = "Origin and Size Vertical: Y+Height > 1\n"; sbY1=0.01; @@ -3850,8 +3861,8 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b) } } else if(b == QString("scalar_bar_horizontal_x") || b == QString("scalar_bar_horizontal_width")){ - sbX1 = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_x", sbX1); - sbW = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_width", sbW); + sbX1 = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_x", 0.2); + sbW = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_width", 0.6); if(sbX1+sbW > aTol){ aWarning = "Origin and Size Horizontal: X+Width > 1\n"; sbX1=0.2; @@ -3861,8 +3872,8 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b) } } else if(b == QString("scalar_bar_horizontal_y") || b == QString("scalar_bar_horizontal_height")){ - sbY1 = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_y", sbY1); - sbH = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_height",sbH); + sbY1 = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_y", 0.01); + sbH = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_height",0.12); if(sbY1+sbH > aTol){ aWarning = "Origin and Size Horizontal: Y+Height > 1\n"; sbY1=0.01; @@ -3870,17 +3881,8 @@ 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_label_format")) { - QString dVal; - dVal.sprintf(aResourceMgr->stringValue("VISU", "scalar_bar_label_format",dVal).toLatin1().data(), 1.1); - if(dVal.toDouble() == 0.) { - aWarning = "Label format is incorrect "; - aWarning += dVal; - aWarning += "\n"; - dVal="%-#6.3g"; - aResourceMgr->setValue("VISU", "scalar_bar_label_format", dVal); - } - } + } + if ( !aWarning.isEmpty() ){ aWarning += "The default values are applied instead."; SUIT_MessageBox::warning(GetDesktop(this), @@ -4169,3 +4171,87 @@ 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 b4413f63..444ec045 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -23,8 +23,7 @@ // File : VisuGUI.h // Author : Laurent CORNABE & Hubert ROLLAND // Module : VISU -// $Header$ -// + #ifndef VisuGUI_HeaderFile #define VisuGUI_HeaderFile @@ -184,6 +183,9 @@ protected slots: void OnManageCache(); void OnFilterScalars(); + + void OnValuesLabeling(); + void OnValuesLabelingParams(); // MULTIPR void OnMultiprViewFullRes(); @@ -207,6 +209,7 @@ private: void createPopupMenus(); void createPanels(); void activateAppropriateViewer( Handle(SALOME_InteractiveObject) theIO ); + 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 458703c4..05b17c0f 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -143,4 +143,8 @@ #define VISU_SWEEP_PANEL 4300 #define VISU_FILTERSCALARS 4301 +#define VISU_VALUES_LABELING 4302 +#define VISU_VALUES_LABELING_PARAMS 4303 + + #endif diff --git a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx index ff349777..b7acd57f 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx @@ -427,6 +427,7 @@ void VisuGUI_DeformedShapeAndScalarMapDlg::AddAllFieldNames(){ void VisuGUI_DeformedShapeAndScalarMapDlg::AddAllTimes(const QString& theFieldName){ TEntity2Fields::const_iterator anIter = myEntity2Fields.begin(); + int currentTimeStampId = (myTimeStampsCombo->count() > 0) ? myTimeStampsCombo->currentIndex() : 0; for(; anIter != myEntity2Fields.end(); anIter++){ const TFieldName2TimeStamps& aFieldName2TimeStamps = anIter->second; TFieldName2TimeStamps::const_iterator aFieldIter = aFieldName2TimeStamps.begin(); @@ -447,6 +448,9 @@ void VisuGUI_DeformedShapeAndScalarMapDlg::AddAllTimes(const QString& theFieldNa QString aTimeStampTime = aTimeStampIter->second; myTimeStampsCombo->addItem(aTimeStampTime); } + if(currentTimeStampId >= myTimeStampID.size()) + currentTimeStampId = myTimeStampID.size()-1; + myTimeStampsCombo->setCurrentIndex(currentTimeStampId); return; } } diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index 8c12f0bd..566a9852 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -33,6 +33,7 @@ #include "VISU_ColoredPrs3dFactory.hh" #include "VISU_GaussPoints_i.hh" +#include "VISU_Prs3dUtils.hh" #include "VISU_GaussPointsPL.hxx" #include "VISU_OpenGLPointSpriteMapper.hxx" #include "VISU_Convertor.hxx" @@ -78,10 +79,10 @@ using namespace std; VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent): 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; + myVerX = 0.01; myVerY = 0.10; myVerW = 0.08; myVerH = 0.80; + myHorX = 0.10; myHorY = 0.01; myHorW = 0.80; myHorH = 0.08; + myVerTS = myVerLS = myVerBW = myVerBH = 0; + myHorTS = myHorLS = myHorBW = myHorBH = 0; Imin = 0.0; Imax = 0.0; myRangeMode = -1; @@ -475,22 +476,18 @@ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs, thePrs->GetBarOrientation()); if(RBvert->isChecked()) { - myVerTW = thePrs->GetTitleWidth(); - myVerTH = thePrs->GetTitleHeight(); - myVerLW = thePrs->GetLabelWidth(); - myVerLH = thePrs->GetLabelHeight(); + myVerTS = thePrs->GetTitleSize(); + myVerLS = thePrs->GetLabelSize(); myVerBW = thePrs->GetBarWidth(); myVerBH = thePrs->GetBarHeight(); } else { - myHorTW = thePrs->GetTitleWidth(); - myHorTH = thePrs->GetTitleHeight(); - myHorLW = thePrs->GetLabelWidth(); - myHorLH = thePrs->GetLabelHeight(); + myHorTS = thePrs->GetTitleSize(); + myHorLS = thePrs->GetLabelSize(); myHorBW = thePrs->GetBarWidth(); myHorBH = thePrs->GetBarHeight(); } - myBarDlg->setLabelsFormat(thePrs->GetLabelsFormat()); + myBarDlg->setLabelsPrecision( VISU::ToPrecision( thePrs->GetLabelsFormat() ) ); myBarDlg->setUnitsVisible(thePrs->IsUnitsVisible()); SpacingSpin->setValue(thePrs->GetSpacing()); @@ -553,7 +550,8 @@ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs, vtkFloatingPointType R, G, B; thePrs->GetTitleColor(R, G, B); - myBarDlg->setLabelsFormat(thePrs->GetLabelsFormat()); + int lp = VISU::ToPrecision( thePrs->GetLabelsFormat() ); + myBarDlg->setLabelsPrecision( lp ); myBarDlg->setUnitsVisible(thePrs->IsUnitsVisible()); myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), @@ -596,12 +594,13 @@ int VisuGUI_GaussScalarBarPane::storeToPrsObject(VISU::GaussPoints_i* thePrs) { thePrs->SetLabels(LabelSpin->value()); if(RBvert->isChecked()) { - thePrs->SetRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + thePrs->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH); } else { - thePrs->SetRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + thePrs->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH); } - thePrs->SetLabelsFormat(myBarDlg->getLabelsFormat().toLatin1().data()); + std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() ); + thePrs->SetLabelsFormat( f.c_str() ); thePrs->SetUnitsVisible(myBarDlg->isUnitsVisible()); if (myIsStoreTextProp) { @@ -757,14 +756,14 @@ void VisuGUI_GaussScalarBarPane::onTextPref() void VisuGUI_GaussScalarBarPane::onBarPref() { if(RBvert->isChecked()) - myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH); else - myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH); if(myBarDlg->exec()) { if(RBvert->isChecked()) - myBarDlg->getRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myBarDlg->getRatios(myVerTS, myVerLS, myVerBW, myVerBH); else - myBarDlg->getRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myBarDlg->getRatios(myHorTS, myHorLS, myHorBW, myHorBH); } } diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.h b/src/VISUGUI/VisuGUI_GaussPointsDlg.h index 71e232e0..6b0121d6 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.h +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.h @@ -100,8 +100,8 @@ class VisuGUI_GaussScalarBarPane : public QWidget//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 myHorTS, myHorLS, myHorBW, myHorBH; + int myVerTS, myVerLS, myVerBW, myVerBH; int myRangeMode; bool myIsStoreTextProp; diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx index 45c33b93..faae8fbe 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx @@ -41,6 +41,7 @@ #include "VISU_ScalarMapAct.h" #include "VISU_ScalarMap_i.hh" #include "VISU_Result_i.hh" +#include "VISU_Prs3dUtils.hh" #include "LightApp_Application.h" @@ -86,9 +87,9 @@ VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent) setWindowTitle(tr("TIT_TEXT_PREF")); setSizeGripEnabled(TRUE); - QVBoxLayout* TopLayout = new QVBoxLayout(this); - TopLayout->setSpacing(6); - TopLayout->setMargin(11); + QVBoxLayout* aMainLay = new QVBoxLayout(this); + aMainLay->setSpacing(6); + aMainLay->setMargin(11); // "Title" grp QGroupBox* aTitleGrp = new QGroupBox ( tr("LBL_TITLE"), this); @@ -108,7 +109,7 @@ VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent) myTitleFont = new SVTK_FontWidget (aHBox); aHBLay->addWidget( myTitleFont ); - TopLayout->addWidget(aTitleGrp); + aMainLay->addWidget(aTitleGrp); // "Labels" grp QGroupBox* aLabelsGrp = new QGroupBox (tr("LBL_LABELS"), this); @@ -124,7 +125,7 @@ VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent) myLabelFont = new SVTK_FontWidget (aHBox); aHBLay->addWidget( myLabelFont ); - TopLayout->addWidget(aLabelsGrp); + aMainLay->addWidget(aLabelsGrp); // Common buttons =========================================================== QGroupBox* GroupButtons = new QGroupBox( this ); @@ -150,7 +151,7 @@ VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent) buttonHelp->setAutoDefault( TRUE ); GroupButtonsLayout->addWidget( buttonHelp, 0, 3 ); - TopLayout->addWidget( GroupButtons ); + aMainLay->addWidget( GroupButtons ); connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); @@ -259,7 +260,8 @@ void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e ) Constructor */ VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent ) - : QDialog( parent ) + : QDialog( parent ), + myOrientation( 1 ) { setModal( true ); setWindowTitle( tr( "TIT_BAR_PREF" ) ); @@ -267,109 +269,79 @@ VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent ) QString propertyName = QString( "scalar_bar_vertical_" ); - myTitleWidth = myTitleHeight = myLabelWidth = myLabelHeight = myBarWidth = myBarHeight = 0; + myTitleSize = myLabelSize = myBarWidth = myBarHeight = 0; myUnits = true; - myUnitsFormat = "%-#6.3g"; + myPrecision = 3; - QVBoxLayout* TopLayout = new QVBoxLayout( this ); - TopLayout->setSpacing( 6 ); - TopLayout->setMargin( 11 ); + QVBoxLayout* aMainLay = new QVBoxLayout( this ); + aMainLay->setSpacing( 5 ); + aMainLay->setMargin( 5 ); + + // dimensions + + QGroupBox* aDimGrp = new QGroupBox( this ); + QGridLayout* aDimGrpLay = new QGridLayout( aDimGrp ); + aDimGrpLay->setSpacing( 5 ); + aDimGrpLay->setMargin( 5 ); + + myTitleSizeSpin = new QSpinBox( aDimGrp ); + myTitleSizeSpin->setRange( 0, 100 ); + myTitleSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myTitleSizeSpin->setMinimumWidth( 70 ); + myTitleSizeSpin->setValue( 0 ); + myTitleSizeSpin->setSpecialValueText( tr( "AUTO" ) ); + QLabel* aTitleSizeLbl = new QLabel( tr( "LBL_TITLE_W" ), aDimGrp ); + + myLabelSizeSpin = new QSpinBox( aDimGrp ); + myLabelSizeSpin->setRange( 0, 100 ); + myLabelSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myLabelSizeSpin->setMinimumWidth( 70 ); + myLabelSizeSpin->setValue( 0 ); + myLabelSizeSpin->setSpecialValueText( tr( "AUTO" ) ); + QLabel* aLabelSizeLbl = new QLabel( tr( "LBL_LABEL_W" ), aDimGrp ); + + myBarWidthSpin = new QSpinBox( aDimGrp ); + myBarWidthSpin->setRange( 0, 100 ); + myBarWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myBarWidthSpin->setMinimumWidth( 70 ); + myBarWidthSpin->setValue( 0 ); + myBarWidthSpin->setSpecialValueText( tr( "AUTO" ) ); + QLabel* aBarWidthLbl = new QLabel( tr( "LBL_BAR_W" ), aDimGrp ); + + myBarHeightSpin = new QSpinBox( aDimGrp ); + myBarHeightSpin->setRange( 0, 100 ); + myBarHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myBarHeightSpin->setMinimumWidth( 70 ); + myBarHeightSpin->setValue( 0 ); + myBarHeightSpin->setSpecialValueText( tr( "AUTO" ) ); + QLabel* aBarHeightLbl = new QLabel( tr( "LBL_BAR_H" ), aDimGrp ); + + // format and units + + QLabel* aPrecLbl = new QLabel( tr( "PRECISION" ), aDimGrp ); + myPrecisionSpin = new QSpinBox( aDimGrp ); + myPrecisionSpin->setRange( 1, 100 ); + + myUnitsChk = new QCheckBox( tr( "LBL_SHOW_UNITS" ), aDimGrp ); + + // layout + + aDimGrpLay->addWidget( aTitleSizeLbl, 0, 0 ); + aDimGrpLay->addWidget( myTitleSizeSpin, 0, 1 ); + aDimGrpLay->addWidget( aLabelSizeLbl, 0, 2 ); + aDimGrpLay->addWidget( myLabelSizeSpin, 0, 3 ); + aDimGrpLay->addWidget( aBarWidthLbl, 1, 0 ); + aDimGrpLay->addWidget( myBarWidthSpin, 1, 1 ); + aDimGrpLay->addWidget( aBarHeightLbl, 1, 2 ); + aDimGrpLay->addWidget( myBarHeightSpin, 1, 3 ); + aDimGrpLay->addWidget( aPrecLbl, 2, 0 ); + aDimGrpLay->addWidget( myPrecisionSpin, 2, 1 ); + aDimGrpLay->addWidget( myUnitsChk, 2, 2, 1, 2 ); - QGroupBox* WidthHeightGroup = new QGroupBox ( this ); - QGridLayout* WidthHeightGroupLayout = new QGridLayout( WidthHeightGroup ); - WidthHeightGroupLayout->setAlignment( Qt::AlignTop ); - WidthHeightGroupLayout->setSpacing( 6 ); - WidthHeightGroupLayout->setMargin( 11 ); - - TitleWidthSpin = new QSpinBox( WidthHeightGroup ); - TitleWidthSpin->setRange( 0, 100 ); - TitleWidthSpin->setSingleStep( 1 ); - TitleWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - TitleWidthSpin->setMinimumWidth( 70 ); - TitleWidthSpin->setValue( 0 ); - TitleWidthSpin->setSpecialValueText( tr( "AUTO" ) ); - QLabel* LabelTitleWidth = new QLabel( tr( "LBL_TITLE_W" ), WidthHeightGroup ); - LabelTitleWidth->setBuddy( TitleWidthSpin ); - - TitleHeightSpin = new QSpinBox( WidthHeightGroup ); - TitleHeightSpin->setRange( 0, 100 ); - TitleHeightSpin->setSingleStep( 1 ); - TitleHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - TitleHeightSpin->setMinimumWidth( 70 ); - TitleHeightSpin->setValue( 0 ); - TitleHeightSpin->setSpecialValueText( tr( "AUTO" ) ); - QLabel* LabelTitleHeight = new QLabel( tr( "LBL_TITLE_H" ), WidthHeightGroup ); - LabelTitleHeight->setBuddy( TitleHeightSpin ); - - CBUnits = new QCheckBox( tr( "LBL_SHOW_UNITS" ), WidthHeightGroup ); - CBUnits->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - LabelWidthSpin = new QSpinBox( WidthHeightGroup ); - LabelWidthSpin->setRange( 0, 100 ); - LabelWidthSpin->setSingleStep( 1 ); - LabelWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - LabelWidthSpin->setMinimumWidth( 70 ); - LabelWidthSpin->setValue( 0 ); - LabelWidthSpin->setSpecialValueText( tr( "AUTO" ) ); - QLabel* LabelLabelWidth = new QLabel( tr( "LBL_LABEL_W" ), WidthHeightGroup ); - LabelLabelWidth->setBuddy( LabelWidthSpin ); - - LabelHeightSpin = new QSpinBox( WidthHeightGroup ); - LabelHeightSpin->setRange( 0, 100 ); - LabelHeightSpin->setSingleStep( 1 ); - LabelHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - LabelHeightSpin->setMinimumWidth( 70 ); - LabelHeightSpin->setValue( 0 ); - LabelHeightSpin->setSpecialValueText( tr( "AUTO" ) ); - QLabel* LabelLabelHeight = new QLabel( tr( "LBL_LABEL_H" ), WidthHeightGroup ); - LabelLabelHeight->setBuddy( LabelHeightSpin ); - - UnitsEdit = new QLineEdit( WidthHeightGroup ); - UnitsEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - UnitsEdit->setMinimumWidth( 35 ); - UnitsEdit->setText( myUnitsFormat ); - QLabel* UnitsLabel = new QLabel( tr( "LBL_UNITS_FORMAT" ), WidthHeightGroup ); - UnitsLabel->setBuddy( UnitsEdit ); - - BarWidthSpin = new QSpinBox( WidthHeightGroup ); - BarWidthSpin->setRange( 0, 100 ); - BarWidthSpin->setSingleStep( 1 ); - BarWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - BarWidthSpin->setMinimumWidth( 70 ); - BarWidthSpin->setValue( 0 ); - BarWidthSpin->setSpecialValueText( tr( "AUTO" ) ); - QLabel* LabelBarWidth = new QLabel( tr( "LBL_BAR_W" ), WidthHeightGroup ); - LabelBarWidth->setBuddy( BarWidthSpin ); - - BarHeightSpin = new QSpinBox( WidthHeightGroup ); - BarHeightSpin->setRange( 0, 100 ); - BarHeightSpin->setSingleStep( 1 ); - BarHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - BarHeightSpin->setMinimumWidth( 70 ); - BarHeightSpin->setValue( 0 ); - BarHeightSpin->setSpecialValueText( tr( "AUTO" ) ); - QLabel* LabelBarHeight = new QLabel( tr( "LBL_BAR_H" ), WidthHeightGroup ); - LabelBarHeight->setBuddy( BarHeightSpin ); - - WidthHeightGroupLayout->addWidget( LabelTitleWidth, 0, 0 ); - WidthHeightGroupLayout->addWidget( TitleWidthSpin, 0, 1 ); - WidthHeightGroupLayout->addWidget( LabelTitleHeight, 0, 2 ); - WidthHeightGroupLayout->addWidget( TitleHeightSpin, 0, 3 ); - WidthHeightGroupLayout->addWidget( CBUnits, 0, 4, 1, 2 ); - WidthHeightGroupLayout->addWidget( LabelLabelWidth, 1, 0 ); - WidthHeightGroupLayout->addWidget( LabelWidthSpin, 1, 1 ); - WidthHeightGroupLayout->addWidget( LabelLabelHeight, 1, 2 ); - WidthHeightGroupLayout->addWidget( LabelHeightSpin, 1, 3 ); - WidthHeightGroupLayout->addWidget( UnitsLabel, 1, 4 ); - WidthHeightGroupLayout->addWidget( UnitsEdit, 1, 5 ); - WidthHeightGroupLayout->addWidget( LabelBarWidth, 2, 0 ); - WidthHeightGroupLayout->addWidget( BarWidthSpin, 2, 1 ); - WidthHeightGroupLayout->addWidget( LabelBarHeight, 2, 2 ); - WidthHeightGroupLayout->addWidget( BarHeightSpin, 2, 3 ); - - TopLayout->addWidget( WidthHeightGroup ); + aMainLay->addWidget( aDimGrp ); // Common buttons =========================================================== + QGroupBox* GroupButtons = new QGroupBox( this ); QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons ); GroupButtonsLayout->setAlignment( Qt::AlignTop ); @@ -392,63 +364,66 @@ VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent ) GroupButtonsLayout->addWidget( buttonCancel ); GroupButtonsLayout->addWidget( buttonHelp ); - TopLayout->addWidget( GroupButtons ); + aMainLay->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( editingFinished() ), this, SIGNAL( updatePreview() ) ); + connect( myTitleSizeSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); + connect( myLabelSizeSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); + connect( myBarWidthSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); + connect( myBarHeightSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); + connect( myUnitsChk, SIGNAL( toggled( bool ) ), this, SIGNAL( updatePreview() ) ); + connect( myPrecisionSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); } //---------------------------------------------------------------------------- -void VisuGUI_BarPrefDlg::setRatios( int titleRatioWidth, int titleRatioHeight, - int labelRatioWidth, int labelRatioHeight, - int barRatioWidth, int barRatioHeight ) +void VisuGUI_BarPrefDlg::setRatios( int titleRatioSize, int labelRatioWidth, + 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 ); + myTitleSizeSpin->setValue( myTitleSize = titleRatioSize ); + myLabelSizeSpin->setValue( myLabelSize = labelRatioWidth ); + myBarWidthSpin->setValue( myBarWidth = barRatioWidth ); + myBarHeightSpin->setValue( myBarHeight = barRatioHeight ); } //---------------------------------------------------------------------------- -void VisuGUI_BarPrefDlg::getRatios( int& titleRatioWidth, int& titleRatioHeight, - int& labelRatioWidth, int& labelRatioHeight, - int& barRatioWidth, int& barRatioHeight ) +void VisuGUI_BarPrefDlg::getRatios( int& titleRatioSize, int& labelRatioWidth, + int& barRatioWidth, int& barRatioHeight ) { - titleRatioWidth = TitleWidthSpin->value(); - titleRatioHeight = TitleHeightSpin->value(); - labelRatioWidth = LabelWidthSpin->value(); - labelRatioHeight = LabelHeightSpin->value(); - barRatioWidth = BarWidthSpin->value(); - barRatioHeight = BarHeightSpin->value(); + titleRatioSize = myTitleSizeSpin->value(); + labelRatioWidth = myLabelSizeSpin->value(); + barRatioWidth = myBarWidthSpin->value(); + barRatioHeight = myBarHeightSpin->value(); } //---------------------------------------------------------------------------- -void VisuGUI_BarPrefDlg::setLabelsFormat( const QString& format ) +void VisuGUI_BarPrefDlg::setLabelsPrecision( const int p ) { - UnitsEdit->setText( myUnitsFormat = format ); + myPrecisionSpin->setValue( p ); } +//---------------------------------------------------------------------------- +int VisuGUI_BarPrefDlg::getLabelsPrecision() const +{ + return myPrecisionSpin->value(); +} //---------------------------------------------------------------------------- -QString VisuGUI_BarPrefDlg::getLabelsFormat() +void VisuGUI_BarPrefDlg::setOrientation( const int ori ) { - return UnitsEdit->text(); + myOrientation = ori; } +//---------------------------------------------------------------------------- + +int VisuGUI_BarPrefDlg::getOrientation() const +{ + return myOrientation; +} //---------------------------------------------------------------------------- void VisuGUI_BarPrefDlg::onHelp() @@ -472,14 +447,14 @@ void VisuGUI_BarPrefDlg::onHelp() //---------------------------------------------------------------------------- void VisuGUI_BarPrefDlg::setUnitsVisible(bool isVisible) { - CBUnits->setChecked( myUnits = isVisible ); + myUnitsChk->setChecked( myUnits = isVisible ); } //---------------------------------------------------------------------------- bool VisuGUI_BarPrefDlg::isUnitsVisible() { - return CBUnits->isChecked(); + return myUnitsChk->isChecked(); } @@ -489,14 +464,12 @@ bool VisuGUI_BarPrefDlg::isUnitsVisible() */ 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 ); + myTitleSizeSpin->setValue( myTitleSize ); + myLabelSizeSpin->setValue( myLabelSize ); + myBarWidthSpin->setValue( myBarWidth ); + myBarHeightSpin->setValue( myBarHeight ); + myUnitsChk->setChecked( myUnits ); + myPrecisionSpin->setValue( myPrecision ); QDialog::reject(); } @@ -508,39 +481,26 @@ void VisuGUI_BarPrefDlg::reject() void VisuGUI_BarPrefDlg::accept() { QString dVal; - dVal.sprintf( UnitsEdit->text().toLatin1().data(), 1.1 ); - if ( dVal.toDouble() == 0. ) { - SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr ( "MSG_LABEL_FORMAT" ) ); + int aBWH = myOrientation == 1 ? myBarWidthSpin->value() : myBarHeightSpin->value(); + if( ( myLabelSizeSpin->value()+ aBWH ) > 100 ) + { + SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE" ) ); + return; } - else { - if( - ( - TitleWidthSpin->value()+ - LabelWidthSpin->value()+ - BarWidthSpin->value() - > 100 - ) || - ( - TitleHeightSpin->value()+ - LabelHeightSpin->value()+ - BarHeightSpin->value() - > 100 - ) - ) { - SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE" ) ); - } - else { - myTitleWidth = TitleWidthSpin->value(); - myTitleHeight = TitleHeightSpin->value(); - myLabelWidth = LabelWidthSpin->value(); - myLabelHeight = LabelHeightSpin->value(); - myBarWidth = BarWidthSpin->value(); - myBarHeight = BarHeightSpin->value(); - myUnits = CBUnits->isChecked(); - myUnitsFormat = UnitsEdit->text(); - QDialog::accept(); - } + + if ( myTitleSizeSpin->value() > 100 ) + { + SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE_TLT" ) ); + return; } + + myTitleSize = myTitleSizeSpin->value(); + myLabelSize = myLabelSizeSpin->value(); + myBarWidth = myBarWidthSpin->value(); + myBarHeight = myBarHeightSpin->value(); + myUnits = myUnitsChk->isChecked(); + myPrecision = myPrecisionSpin->value(); + QDialog::accept(); } @@ -582,10 +542,8 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) 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); + myVerTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0); + myVerLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0); myVerBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0); myVerBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0); @@ -594,27 +552,21 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) 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); + myHorTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0); + myHorLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0); myHorBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0); myHorBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0); - aMainLayout->setSpacing(6); - //setMargin(11); + //aMainLayout->setSpacing(6); // Range ============================================================ RangeGroup = new QButtonGroup ( this ); QGroupBox* aGB = new QGroupBox( tr("SCALAR_RANGE_GRP"),this ); aMainLayout->addWidget( aGB ); - //RangeGroup->setColumnLayout(0, Qt::Vertical ); - //RangeGroup->layout()->setSpacing( 0 ); - //RangeGroup->layout()->setMargin( 0 ); QGridLayout* RangeGroupLayout = new QGridLayout( aGB ); RangeGroupLayout->setAlignment( Qt::AlignTop ); - RangeGroupLayout->setSpacing( 6 ); - RangeGroupLayout->setMargin( 11 ); + //RangeGroupLayout->setSpacing( 6 ); + //RangeGroupLayout->setMargin( 11 ); myModeLbl = new QLabel("Scalar Mode", aGB); @@ -631,7 +583,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) MinEdit = new QLineEdit( aGB ); MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - MinEdit->setMinimumWidth( 70 ); + //MinEdit->setMinimumWidth( 70 ); MinEdit->setValidator( new QDoubleValidator(this) ); MinEdit->setText( "0.0" ); QLabel* MinLabel = new QLabel (tr("LBL_MIN"), aGB); @@ -640,7 +592,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) MaxEdit = new QLineEdit( aGB ); MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - MaxEdit->setMinimumWidth( 70 ); + //MaxEdit->setMinimumWidth( 70 ); MaxEdit->setValidator( new QDoubleValidator(this) ); MaxEdit->setText( "0.0" ); QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), aGB); @@ -657,18 +609,13 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) RangeGroupLayout->addWidget( MaxLabel, 2, 2 ); RangeGroupLayout->addWidget( MaxEdit, 2, 3 ); - //TopLayout->addWidget( RangeGroup ); - // Colors and Labels ======================================================== QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this); aMainLayout->addWidget( ColLabGroup ); - //ColLabGroup->setColumnLayout(0, Qt::Vertical ); - //ColLabGroup->layout()->setSpacing( 0 ); - //ColLabGroup->layout()->setMargin( 0 ); QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup ); ColLabGroupLayout->setAlignment( Qt::AlignTop ); - ColLabGroupLayout->setSpacing( 6 ); - ColLabGroupLayout->setMargin( 11 ); + //ColLabGroupLayout->setSpacing( 6 ); + //ColLabGroupLayout->setMargin( 11 ); QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup); ColorSpin = new QSpinBox( ColLabGroup ); @@ -676,7 +623,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) ColorSpin->setMaximum( 256 ); ColorSpin->setSingleStep( 1 ); ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - ColorSpin->setMinimumWidth( 70 ); + //ColorSpin->setMinimumWidth( 70 ); ColorSpin->setValue( 64 ); QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup); @@ -686,7 +633,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) LabelSpin->setSingleStep( 1 ); LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - LabelSpin->setMinimumWidth( 70 ); + //LabelSpin->setMinimumWidth( 70 ); LabelSpin->setValue( 5 ); ColLabGroupLayout->addWidget( ColorLabel, 0, 0); @@ -694,19 +641,14 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) ColLabGroupLayout->addWidget( LabelLabel, 0, 2); ColLabGroupLayout->addWidget( LabelSpin, 0, 3); - //TopLayout->addWidget( ColLabGroup ); - // Orientation ========================================================== QButtonGroup* OrientGroup = new QButtonGroup ( this ); QGroupBox* OrientGB = new QGroupBox( tr("ORIENTATION_GRP"),this ); aMainLayout->addWidget( OrientGB ); - //OrientGroup->setColumnLayout(0, Qt::Vertical ); - //OrientGroup->layout()->setSpacing( 0 ); - //OrientGroup->layout()->setMargin( 0 ); QGridLayout* OrientGroupLayout = new QGridLayout( OrientGB ); OrientGroupLayout->setAlignment( Qt::AlignTop ); - OrientGroupLayout->setSpacing( 6 ); - OrientGroupLayout->setMargin( 11 ); + //OrientGroupLayout->setSpacing( 6 ); + //OrientGroupLayout->setMargin( 11 ); RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGB); RBvert->setChecked( true ); @@ -716,63 +658,53 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) OrientGroupLayout->addWidget( RBvert, 0, 0 ); OrientGroupLayout->addWidget( RBhori, 0, 1 ); - // TopLayout->addWidget( OrientGroup ); - // Origin =============================================================== QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this); aMainLayout->addWidget( OriginGroup ); - //OriginGroup->setColumnLayout(0, Qt::Vertical ); - //OriginGroup->layout()->setSpacing( 0 ); - // OriginGroup->layout()->setMargin( 0 ); QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup ); OriginGroupLayout->setAlignment( Qt::AlignTop ); - OriginGroupLayout->setSpacing( 6 ); - OriginGroupLayout->setMargin( 11 ); + //OriginGroupLayout->setSpacing( 6 ); + //OriginGroupLayout->setMargin( 11 ); QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup); XSpin = new QtxDoubleSpinBox( OriginGroup ); VISU::initSpinBox(XSpin, 0.0, +1.0); XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - XSpin->setMinimumWidth( 70 ); + //XSpin->setMinimumWidth( 70 ); XSpin->setValue( 0.01 ); QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup); YSpin = new QtxDoubleSpinBox( OriginGroup ); VISU::initSpinBox(YSpin, 0.0, +1.0); YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - YSpin->setMinimumWidth( 70 ); - YSpin->setValue( 0.01 ); + //YSpin->setMinimumWidth( 70 ); + YSpin->setValue( 0.1 ); OriginGroupLayout->addWidget( XLabel, 0, 0); OriginGroupLayout->addWidget( XSpin, 0, 1); OriginGroupLayout->addWidget( YLabel, 0, 2); OriginGroupLayout->addWidget( YSpin, 0, 3); - //TopLayout->addWidget( OriginGroup ); - // Dimensions ========================================================= QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this ); aMainLayout->addWidget( DimGroup ); - //DimGroup->setColumnLayout(0, Qt::Vertical ); - //DimGroup->layout()->setSpacing( 0 ); - //DimGroup->layout()->setMargin( 0 ); QGridLayout* DimGroupLayout = new QGridLayout( DimGroup ); DimGroupLayout->setAlignment( Qt::AlignTop ); - DimGroupLayout->setSpacing( 6 ); - DimGroupLayout->setMargin( 11 ); + //DimGroupLayout->setSpacing( 6 ); + //DimGroupLayout->setMargin( 11 ); QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup); WidthSpin = new QtxDoubleSpinBox( DimGroup ); VISU::initSpinBox(WidthSpin, 0.0, +1.0); WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - WidthSpin->setMinimumWidth( 70 ); + //WidthSpin->setMinimumWidth( 70 ); WidthSpin->setValue( 0.1 ); QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup); HeightSpin = new QtxDoubleSpinBox( DimGroup ); VISU::initSpinBox(HeightSpin, 0.0, +1.0); HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - HeightSpin->setMinimumWidth( 70 ); + //HeightSpin->setMinimumWidth( 70 ); HeightSpin->setValue( 0.8 ); DimGroupLayout->addWidget( WidthLabel, 0, 0); @@ -780,8 +712,6 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) DimGroupLayout->addWidget( HeightLabel, 0, 2); DimGroupLayout->addWidget( HeightSpin, 0, 3); - //TopLayout->addWidget( DimGroup ); - // Save check box =========================================================== QWidget* aSaveBox = new QWidget(this); aMainLayout->addWidget( aSaveBox ); @@ -795,21 +725,24 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) QGroupBox* CheckGroup = new QGroupBox("", this ); aMainLayout->addWidget( CheckGroup ); - QHBoxLayout* CheckGroupLayout = new QHBoxLayout( CheckGroup ); + //QHBoxLayout* CheckGroupLayout = new QHBoxLayout( CheckGroup ); + QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup ); myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup); myPreviewCheck->setChecked(false); - //myPreviewCheck->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - CheckGroupLayout->addWidget(myPreviewCheck); + CheckGroupLayout->addWidget(myPreviewCheck, 0, 0); + myHideBar = new QCheckBox(tr("HIDE_SCALAR_BAR"), CheckGroup); + myHideBar->setChecked(false); + CheckGroupLayout->addWidget(myHideBar, 0, 1); + // RKV : Begin CBDistr = new QCheckBox (tr("SHOW_DISTRIBUTION"), CheckGroup); - //CBDistr->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - CheckGroupLayout->addWidget(CBDistr); + CheckGroupLayout->addWidget(CBDistr, 1, 0); // RKV : End if (!thePreview) { CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), CheckGroup); - CheckGroupLayout->addWidget( CBSave ); + CheckGroupLayout->addWidget( CBSave, 1, 1 ); } else { CBSave = 0; @@ -818,16 +751,17 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) } if(RBvert->isChecked()) { - myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH); } else { - myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH); } - myBarDlg->setLabelsFormat(aResourceMgr->stringValue("VISU", propertyName + "label_format", "%-#6.3g")); + int lp = aResourceMgr->integerValue( "VISU", propertyName + "scalar_bar_label_precision", 3 ); + myBarDlg->setLabelsPrecision( lp ); + myBarDlg->setUnitsVisible(aResourceMgr->booleanValue("VISU", propertyName + "display_units", true)); // signals and slots connections =========================================== - // connect( RangeGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( changeRange( int ) ) ); connect( RBFrange, SIGNAL( toggled( bool ) ), this, SLOT( onFieldRange( bool ) ) ); connect( RBIrange, SIGNAL( toggled( bool ) ), this, SLOT( onImposedRange( bool ) ) ); @@ -868,13 +802,13 @@ void VisuGUI_ScalarBarPane::storeToResources() { if(orient == 0) { sbX1=0.01; sbY1=0.1; - sbW=0.17; + sbW=0.1; sbH=0.8; } else { - sbX1=0.2; + sbX1=0.1; sbY1=0.01; - sbW=0.6; - sbH=0.12; + sbW=0.8; + sbH=0.08; } } @@ -930,7 +864,7 @@ void VisuGUI_ScalarBarPane::storeToResources() { aTitleFont.setBold(isTitleBold); aTitleFont.setItalic(isTitleItalic); - aTitleFont.setUnderline(isTitleShadow); + aTitleFont.setOverline(isTitleShadow); QString titleFontFamily; switch (aTitleFontFamily) { @@ -965,7 +899,7 @@ void VisuGUI_ScalarBarPane::storeToResources() { aLabelFont.setBold(isLabelBold); aLabelFont.setItalic(isLabelItalic); - aLabelFont.setUnderline(isLabelShadow); + aLabelFont.setOverline(isLabelShadow); QString labelFontFamily; switch (aLabelFontFamily) { @@ -1063,24 +997,20 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs) myScalarMap->GetBarOrientation()); if(RBvert->isChecked()) { - myVerTW = myScalarMap->GetTitleWidth(); - myVerTH = myScalarMap->GetTitleHeight(); - myVerLW = myScalarMap->GetLabelWidth(); - myVerLH = myScalarMap->GetLabelHeight(); + myVerTS = myScalarMap->GetTitleSize(); + myVerLS = myScalarMap->GetLabelSize(); myVerBW = myScalarMap->GetBarWidth(); myVerBH = myScalarMap->GetBarHeight(); - myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH); } else { - myHorTW = myScalarMap->GetTitleWidth(); - myHorTH = myScalarMap->GetTitleHeight(); - myHorLW = myScalarMap->GetLabelWidth(); - myHorLH = myScalarMap->GetLabelHeight(); + myHorTS = myScalarMap->GetTitleSize(); + myHorLS = myScalarMap->GetLabelSize(); myHorBW = myScalarMap->GetBarWidth(); myHorBH = myScalarMap->GetBarHeight(); - myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH); } - myBarDlg->setLabelsFormat(myScalarMap->GetLabelsFormat()); + myBarDlg->setLabelsPrecision( VISU::ToPrecision( myScalarMap->GetLabelsFormat() ) ); myBarDlg->setUnitsVisible(myScalarMap->IsUnitsVisible()); vtkFloatingPointType R, G, B; @@ -1105,6 +1035,8 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs) myScalarMap->IsItalicLabel(), myScalarMap->IsShadowLabel()); + myHideBar->setChecked(!myScalarMap->IsBarVisible()); + // Draw Preview if (myPreviewCheck->isChecked()) { createScalarBar(); @@ -1157,6 +1089,7 @@ void VisuGUI_ScalarBarPane::createScalarBar() VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar(); myPreviewActor->GetScalarBar()->VisibilityOn(); myPreviewActor->PickableOff(); + //myPreviewActor->SetBarVisibility(!myHideBar->isChecked()); myScalarMapPL->SetScalarMode(myModeCombo->currentIndex()); if(isLogarithmic()) @@ -1249,11 +1182,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); + int VerTS, VerTH, VerLS, VerBW, VerBH; + myBarDlg->getRatios(VerTS, VerLS, VerBW, VerBH); + aScalarBarActor->SetRatios(VerTS, VerLS, VerBW, VerBH); - aScalarBarActor->SetLabelFormat(myBarDlg->getLabelsFormat().toLatin1().data()); + std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() ); + aScalarBarActor->SetLabelFormat( f.c_str() ); aScalarBarActor->Modified(); @@ -1298,12 +1232,13 @@ int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { myScalarMap->SetPosition(XSpin->value(), YSpin->value()); myScalarMap->SetSize(WidthSpin->value(), HeightSpin->value()); if(RBvert->isChecked()) { - myScalarMap->SetRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myScalarMap->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH); } else { - myScalarMap->SetRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myScalarMap->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH); } - myScalarMap->SetLabelsFormat(myBarDlg->getLabelsFormat().toLatin1().data()); + std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() ); + myScalarMap->SetLabelsFormat( f.c_str() ); myScalarMap->SetUnitsVisible(myBarDlg->isUnitsVisible()); myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL); @@ -1321,6 +1256,8 @@ int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { myScalarMap->SetLabels(LabelSpin->value()); myScalarMap->SetIsDistributionVisible(isShowDistribution()); // RKV + myScalarMap->SetBarVisible(!myHideBar->isChecked()); + if (isToSave()) storeToResources(); if (myIsStoreTextProp) { @@ -1673,14 +1610,15 @@ void VisuGUI_ScalarBarPane::onTextPref() void VisuGUI_ScalarBarPane::onBarPref() { if(RBvert->isChecked()) - myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH); else - myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH); + myBarDlg->setOrientation( getOrientation() ); if(myBarDlg->exec()) { if(RBvert->isChecked()) - myBarDlg->getRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myBarDlg->getRatios(myVerTS, myVerLS, myVerBW, myVerBH); else - myBarDlg->getRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myBarDlg->getRatios(myHorTS, myHorLS, myHorBW, myHorBH); updatePreview(); } } diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.h b/src/VISUGUI/VisuGUI_Prs3dDlg.h index 3e8c66e1..734203e6 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.h +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.h @@ -104,18 +104,20 @@ class VisuGUI_BarPrefDlg: public QDialog VisuGUI_BarPrefDlg (QWidget* parent); ~VisuGUI_BarPrefDlg() {}; - void setRatios(int titleRatioWidth, int titleRatioHeight, - int labelRatioWidth, int labelRatioHeight, + void setRatios(int titleRatioSize, int labelRatioWidth, int barRatioWidth, int barRatioHeight); - void getRatios(int& titleRatioWidth, int& titleRatioHeight, - int& labelRatioWidth, int& labelRatioHeight, + void getRatios(int& titleRatioSize, int& labelRatioWidth, int& barRatioWidth, int& barRatioHeight); void setUnitsVisible(bool isVisible); bool isUnitsVisible(); - void setLabelsFormat( const QString& format); - QString getLabelsFormat(); + void setLabelsPrecision( const int p ); + int getLabelsPrecision() const; + + void setOrientation( const int ori ); + int getOrientation() const; + private: void keyPressEvent( QKeyEvent* e ); @@ -129,23 +131,20 @@ class VisuGUI_BarPrefDlg: public QDialog 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; + QSpinBox* myTitleSizeSpin; + QSpinBox* myLabelSizeSpin; + QSpinBox* myBarWidthSpin; + QSpinBox* myBarHeightSpin; + QCheckBox* myUnitsChk; + QSpinBox* myPrecisionSpin; + + int myTitleSize; + int myLabelSize; int myBarWidth; int myBarHeight; bool myUnits; - QString myUnitsFormat; + int myPrecision; + int myOrientation; }; @@ -207,6 +206,7 @@ class VisuGUI_ScalarBarPane : public QWidget//QVBox QCheckBox* CBSave; QCheckBox* CBLog; QCheckBox* CBDistr; + QCheckBox* myHideBar; QLabel* myModeLbl; QComboBox* myModeCombo; @@ -217,8 +217,8 @@ class VisuGUI_ScalarBarPane : public QWidget//QVBox 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 myHorTS, myHorLS, myHorBW, myHorBH; + int myVerTS, myVerTH, myVerLS, myVerBW, myVerBH; bool myIsStoreTextProp; private slots: diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 5d29a10a..1c5db753 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -73,6 +73,7 @@ QVariant VisuGUI_Selection::parameter( const int ind, const QString& p ) const else if ( p == "isThereAreHiddenCurves" ) val = QVariant( findDisplayedCurves( ind, true ) ); else if ( p == "hasCurves" ) val = QVariant( hasCurves( ind ) ); else if ( p == "isPlot2dViewer" ) val = QVariant( Plot2dViewerType( ind ) ); + else if ( p == "isValuesLabeled" ) val = QVariant( isValuesLabeled( ind ) ); } return val; @@ -703,3 +704,20 @@ bool VisuGUI_Selection::Plot2dViewerType( const int ind ) const return false; } +//---------------------------------------------------------------------------- +struct TIsValuesLabeled : TViewFunctor +{ + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + return theActor && theActor->GetValuesLabeled() ? "true" : "false"; + } +}; + +QString VisuGUI_Selection::isValuesLabeled( const int ind ) const +{ + return TPopupDispatcher()(myModule, entry(ind)); +} diff --git a/src/VISUGUI/VisuGUI_Selection.h b/src/VISUGUI/VisuGUI_Selection.h index 2f29ee13..15871ae2 100644 --- a/src/VISUGUI/VisuGUI_Selection.h +++ b/src/VISUGUI/VisuGUI_Selection.h @@ -60,6 +60,7 @@ private: QString isShading( const int ) const; QString isScalarMapAct( const int ) const; bool isVisuComponent( const int ) const; + QString isValuesLabeled( const int ) const; QString fullResolution( const int ) const; QString mediumResolution( const int ) const; diff --git a/src/VISUGUI/VisuGUI_Table3dDlg.cxx b/src/VISUGUI/VisuGUI_Table3dDlg.cxx index eda36881..bc38e937 100644 --- a/src/VISUGUI/VisuGUI_Table3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Table3dDlg.cxx @@ -32,6 +32,7 @@ #include "VISU_ColoredPrs3dFactory.hh" #include "VISU_ViewManager_i.hh" +#include "VISU_Prs3dUtils.hh" #include #include @@ -196,10 +197,8 @@ VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane( QWidget* parent ) 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 ); + myVerTS = aResourceMgr->integerValue( "VISU", propertyName + "title_size", 0 ); + myVerLS = aResourceMgr->integerValue( "VISU", propertyName + "label_size", 0 ); myVerBW = aResourceMgr->integerValue( "VISU", propertyName + "bar_width", 0 ); myVerBH = aResourceMgr->integerValue( "VISU", propertyName + "bar_height", 0 ); @@ -208,10 +207,8 @@ VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane( QWidget* parent ) 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 ); + myHorTS = aResourceMgr->integerValue( "VISU", propertyName + "title_size", 0 ); + myHorLS = aResourceMgr->integerValue( "VISU", propertyName + "label_size", 0 ); myHorBW = aResourceMgr->integerValue( "VISU", propertyName + "bar_width", 0 ); myHorBH = aResourceMgr->integerValue( "VISU", propertyName + "bar_height", 0 ); @@ -308,7 +305,7 @@ VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane( QWidget* parent ) QLabel* YLabel = new QLabel( tr( "LBL_Y" ), OriginGroup ); YSpin = new QtxDoubleSpinBox( 0.0, 1.0, 0.1, OriginGroup ); YSpin->setMinimumWidth( 70 ); - YSpin->setValue( 0.01 ); + YSpin->setValue( 0.1 ); OriginGroupLayout->addWidget( XLabel ); OriginGroupLayout->addWidget( XSpin ); @@ -356,12 +353,14 @@ VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane( QWidget* parent ) myBarDlg = new VisuGUI_BarPrefDlg( this ); if ( RBvert->isChecked() ) { - myBarDlg->setRatios( myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH ); + myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH ); } else { - myBarDlg->setRatios( myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH ); + myBarDlg->setRatios( myHorTS, myHorLS, myHorBW, myHorBH ); } - myBarDlg->setLabelsFormat( aResourceMgr->stringValue( "VISU", propertyName + "label_format", "%-#6.3g" ) ); + int lp = aResourceMgr->integerValue( "VISU", propertyName + "scalar_bar_label_precision", 3 ); + myBarDlg->setLabelsPrecision( lp ); + myBarDlg->setUnitsVisible( aResourceMgr->booleanValue( "VISU", propertyName + "display_units", true ) ); // signals and slots connections =========================================== @@ -381,14 +380,14 @@ VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane( QWidget* parent ) void VisuGUI_TableScalarBarPane::onBarPref() { if ( RBvert->isChecked() ) - myBarDlg->setRatios( myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH ); + myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH ); else - myBarDlg->setRatios( myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH ); + myBarDlg->setRatios( myHorTS, myHorLS, myHorBW, myHorBH ); if ( myBarDlg->exec() ) { if ( RBvert->isChecked() ) - myBarDlg->getRatios( myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH ); + myBarDlg->getRatios( myVerTS, myVerLS, myVerBW, myVerBH ); else - myBarDlg->getRatios( myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH ); + myBarDlg->getRatios( myHorTS, myHorLS, myHorBW, myHorBH ); } } @@ -429,15 +428,13 @@ void VisuGUI_TableScalarBarPane::initFromPrsObject( VISU::PointMap3d_i* thePrs ) myBarPrs->GetHeight(), myBarPrs->GetBarOrientation() ); - myVerTW = myBarPrs->GetTitleWidth(); - myVerTH = myBarPrs->GetTitleHeight(); - myVerLW = myBarPrs->GetLabelWidth(); - myVerLH = myBarPrs->GetLabelHeight(); + myVerTS = myBarPrs->GetTitleSize(); + myVerLS = myBarPrs->GetLabelSize(); myVerBW = myBarPrs->GetBarWidth(); myVerBH = myBarPrs->GetBarHeight(); - myBarDlg->setRatios( myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH ); + myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH ); - myBarDlg->setLabelsFormat( myBarPrs->GetLabelsFormat() ); + myBarDlg->setLabelsPrecision( VISU::ToPrecision( myBarPrs->GetLabelsFormat() ) ); myBarDlg->setUnitsVisible( myBarPrs->IsUnitsVisible() ); myTextDlg->myTitleFont->SetData( QColor( (int)(R*255.), (int)(G*255.), (int)(B*255.) ), @@ -467,9 +464,14 @@ int VisuGUI_TableScalarBarPane::storeToPrsObject( VISU::PointMap3d_i* thePrs ) { myBarPrs->SetPosition( XSpin->value(), YSpin->value() ); myBarPrs->SetSize( WidthSpin->value(), HeightSpin->value() ); - myBarPrs->SetRatios( myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH ); + if(RBvert->isChecked()) { + myBarPrs->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH); + } else { + myBarPrs->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH); + } - myBarPrs->SetLabelsFormat( myBarDlg->getLabelsFormat().toLatin1().constData() ); + std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() ); + myBarPrs->SetLabelsFormat( f.c_str() ); myBarPrs->SetUnitsVisible( myBarDlg->isUnitsVisible() ); myBarPrs->SetBarOrientation( ( RBvert->isChecked() )? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL ); diff --git a/src/VISUGUI/VisuGUI_Table3dDlg.h b/src/VISUGUI/VisuGUI_Table3dDlg.h index 5317671d..867e4267 100644 --- a/src/VISUGUI/VisuGUI_Table3dDlg.h +++ b/src/VISUGUI/VisuGUI_Table3dDlg.h @@ -149,8 +149,8 @@ private: 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 myHorTS, myHorLS, myHorBW, myHorBH; + int myVerTS, myVerLS, myVerBW, myVerBH; bool myIsStoreTextProp; std::string myTitle; diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 34ae14e7..768b7a5d 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -595,10 +595,13 @@ namespace VISU switch (theType) { case VISU::SHRINK: if (aPrs3d) { - if (anActor->IsShrunk()) - anActor->UnShrink(); - else - anActor->SetShrink(); + if (anActor->IsShrunk()) + anActor->UnShrink(); + else + anActor->SetShrink(); + if (VISU::Mesh_i* aMesh = dynamic_cast(aPrs3d)) { + aMesh->SetShrink(true); + } } else if (aTable) { if (anActorBase->IsShrunk()) anActorBase->UnShrink(); diff --git a/src/VISUGUI/VisuGUI_ValuesLabelingDlg.cxx b/src/VISUGUI/VisuGUI_ValuesLabelingDlg.cxx new file mode 100755 index 00000000..83ccb7b7 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ValuesLabelingDlg.cxx @@ -0,0 +1,233 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : VisuGUI_ValuesLabelingDlg.cxx +// Author : Litonin SERGEY +// Module : SALOME + +#include "VisuGUI_ValuesLabelingDlg.h" +#include "VisuGUI.h" + +#include +#include +#include +#include +#include +#include +#include + +/*! + \class VisuGUI_ValuesLabelingDlg + \brief This class is intended for changing parameters of labeling values + of 3D colored presentations +*/ + +/*! + \brief Constructor + \param theModule module +*/ +VisuGUI_ValuesLabelingDlg::VisuGUI_ValuesLabelingDlg( SalomeApp_Module* theModule ) +: VisuGUI_Prs3dDlg( theModule ) +{ + setWindowTitle( tr( "PARAMETERS_OF_VALUES_LABELING" ) ); + + // font groups + + QGroupBox* aFGrp = new QGroupBox( tr( "LABELS" ), this ); + + QLabel* aFont = new QLabel( tr( "FONT" ) ); + QLabel* aColor = new QLabel( tr( "COLOR" ) ); + myFont = new QtxFontEdit( aFGrp ); + myColor = new QtxColorButton( aFGrp ); + myColor->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + QGridLayout* aFLay = new QGridLayout( aFGrp ); + aFLay->setSpacing( 5 ); + aFLay->setMargin( 5 ); + + aFLay->addWidget( aFont, 0, 0 ); + aFLay->addWidget( myFont, 0, 1 ); + aFLay->addWidget( aColor, 1, 0 ); + aFLay->addWidget( myColor, 1, 1 ); + + // buttons + + QGroupBox* aBtnGrp = new QGroupBox( this ); + QGridLayout* aBtnLay = new QGridLayout( aBtnGrp ); + aBtnLay->setAlignment( Qt::AlignTop ); + aBtnLay->setSpacing( 5 ); + aBtnLay->setMargin( 5 ); + + QPushButton* anOK = new QPushButton( tr("BUT_OK"), aBtnGrp ); + anOK->setAutoDefault( true ); + anOK->setDefault( true ); + aBtnLay->addWidget( anOK, 0, 0 ); + aBtnLay->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + QPushButton* aCancel = new QPushButton( tr("BUT_CANCEL") , aBtnGrp ); + aCancel->setAutoDefault( true ); + aBtnLay->addWidget( aCancel, 0, 2 ); + + QPushButton* aHelp = new QPushButton( tr("BUT_HELP") , aBtnGrp ); + aHelp->setAutoDefault( true ); + aBtnLay->addWidget( aHelp, 0, 3 ); + + myFont->setMode( QtxFontEdit::Custom ); + myFont->setFeatures( QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | + QtxFontEdit::Shadow | QtxFontEdit::UserSize | QtxFontEdit::Size ); + QStringList fam; + fam.append( tr( "VISU_FONT_ARIAL" ) ); + fam.append( tr( "VISU_FONT_COURIER" ) ); + fam.append( tr( "VISU_FONT_TIMES" ) ); + myFont->setFonts( fam ); + + // Layout widgets + + QVBoxLayout* aMainLay = new QVBoxLayout( this ); + aMainLay->setSpacing( 5 ); + aMainLay->setMargin( 5 ); + aMainLay->addWidget( aFGrp ); + aMainLay->addWidget( aBtnGrp ); + + // Connect signals and slots + connect( anOK,SIGNAL( clicked() ), SLOT( accept() ) ); + connect( aCancel, SIGNAL( clicked() ), SLOT( reject() ) ); + connect( aHelp, SIGNAL( clicked() ), SLOT( onHelp() ) ); + + setFixedSize( minimumSizeHint() ); +} + +/*! + \brief Destructor +*/ +VisuGUI_ValuesLabelingDlg::~VisuGUI_ValuesLabelingDlg() +{ +} + +/*! + \brief Initializes dialog fields using specified presentation + \param thePrs presentation + \param theInit not used + \sa storeToPrsObject() +*/ +void VisuGUI_ValuesLabelingDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, bool ) +{ + if ( !thePrs ) + return; + + int aFType = thePrs->GetValLblFontType(); + + double aSize = thePrs->GetValLblFontSize(); + + bool isBold = thePrs->IsBoldValLbl(); + bool isItalic = thePrs->IsItalicValLbl(); + bool isShadow = thePrs->IsShadowValLbl(); + + vtkFloatingPointType aGRB[ 3 ]; + thePrs->GetValLblFontColor( aGRB[ 0 ], aGRB[ 1 ], aGRB[ 2 ] ); + + // font + QFont aFont; + + QString aFamily; + if ( aFType == VTK_ARIAL ) + aFamily = "Arial"; + else if ( aFType == VTK_COURIER ) + aFamily = "Courier"; + else if ( aFType == VTK_TIMES ) + aFamily = "Times"; + + aFont.setFamily( aFamily ); + aFont.setPointSize( aSize ); + aFont.setBold( isBold ); + aFont.setItalic( isItalic ); + aFont.setOverline( isShadow ); + + myFont->setCurrentFont( aFont ); + + // color + QColor aColor( aGRB[ 0 ] * 255, aGRB[ 1 ] * 255, aGRB[ 2 ] * 255 ); + myColor->setColor( aColor ); +} + +/*! + \brief Updates presentation in accordance with dialog input data + \param thePrs to be updated + \sa initFromPrsObject() +*/ +int VisuGUI_ValuesLabelingDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) +{ + if ( !thePrs ) + return 0; + + QFont aFont = myFont->currentFont(); + + // type + if ( aFont.family() == "Arial" ) + thePrs->SetValLblFontType( VTK_ARIAL ); + else if ( aFont.family() == "Courier" ) + thePrs->SetValLblFontType( VTK_COURIER ); + else if ( aFont.family() == "Times" ) + thePrs->SetValLblFontType( VTK_TIMES ); + + // size + int aSize = aFont.pointSize(); + if ( aSize > 0 ) + thePrs->SetValLblFontSize( aSize ); + + // bold, italic, shadow + thePrs->SetBoldValLbl( aFont.bold() ); + thePrs->SetItalicValLbl( aFont.italic() ); + thePrs->SetShadowValLbl( aFont.overline() ); + + // color + QColor aColor = myColor->color(); + thePrs->SetValLblFontColor( + aColor.red() / 255., aColor.green() / 255., aColor.blue() / 255. ); + + return 1; +} + +/*! + \brief Gets help file name +*/ +QString VisuGUI_ValuesLabelingDlg::GetContextHelpFilePath() +{ + return "values_labeling_page.html"; +} + + + + + + + + + + + + + + + + + + + + diff --git a/src/VISUGUI/VisuGUI_ValuesLabelingDlg.h b/src/VISUGUI/VisuGUI_ValuesLabelingDlg.h new file mode 100755 index 00000000..6f8d0e23 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ValuesLabelingDlg.h @@ -0,0 +1,66 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : VisuGUI_ValuesLabelingDlg.h +// Author : Sergey LITONIN +// Module : SALOME + +#ifndef VisuGUI_ValuesLabelingDlg_H +#define VisuGUI_ValuesLabelingDlg_H + +#include + +class QtxFontEdit; +class QtxColorButton; + +class VisuGUI_ValuesLabelingDlg : public VisuGUI_Prs3dDlg +{ + Q_OBJECT + +public: + VisuGUI_ValuesLabelingDlg( SalomeApp_Module* theModule ); + ~VisuGUI_ValuesLabelingDlg(); + + virtual void initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, bool theInit ); + + virtual int storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ); + +protected: + virtual QString GetContextHelpFilePath(); + +private: + QtxFontEdit* myFont; + QtxColorButton* myColor; +}; + +#endif // VisuGUI_ValuesLabelingDlg_H + + + + + + + + + + + + + + diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 572c5752..d82c7d7c 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -697,8 +697,8 @@ VISU::ColoredPrs3d_i SetUnitsVisible(anOrigin->IsUnitsVisible()); SetIsDistributionVisible(anOrigin->GetIsDistributionVisible()); - SetLabelsFormat(anOrigin->GetLabelsFormat()); - + SetLabelsFormat( anOrigin->GetLabelsFormat() ); + SetBarOrientation(anOrigin->GetBarOrientation()); SetMinMaxController( anOrigin ); @@ -713,8 +713,7 @@ VISU::ColoredPrs3d_i SetPosition(anOrigin->GetPosX(), anOrigin->GetPosY()); SetSize(anOrigin->GetWidth(), anOrigin->GetHeight()); - SetRatios(anOrigin->GetTitleWidth(), anOrigin->GetTitleHeight(), - anOrigin->GetLabelWidth(), anOrigin->GetLabelHeight(), + SetRatios(anOrigin->GetTitleSize(), anOrigin->GetLabelSize(), anOrigin->GetBarWidth(), anOrigin->GetBarHeight()); SetLabels(anOrigin->GetLabels()); @@ -1008,14 +1007,11 @@ VISU::ColoredPrs3d_i //---------------------------------------------------------------------------- void VISU::ColoredPrs3d_i -::SetRatios(CORBA::Long theTitleWidth, CORBA::Long theTitleHeight, - CORBA::Long theLabelWidth, CORBA::Long theLabelHeight, +::SetRatios(CORBA::Long theTitleSize, CORBA::Long theLabelSize, 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); + bool anIsSameValue = VISU::CheckIsSameValue(myTitleSize, theTitleSize); + anIsSameValue &= VISU::CheckIsSameValue(myLabelSize, theLabelSize); anIsSameValue &= VISU::CheckIsSameValue(myBarWidth, theBarWidth); anIsSameValue &= VISU::CheckIsSameValue(myBarHeight, theBarHeight); if(anIsSameValue) @@ -1023,10 +1019,8 @@ VISU::ColoredPrs3d_i VISU::TSetModified aModified(this); - myTitleWidth = theTitleWidth; - myTitleHeight = theTitleHeight; - myLabelWidth = theLabelWidth; - myLabelHeight = theLabelHeight; + myTitleSize = theTitleSize; + myLabelSize = theLabelSize; myBarWidth = theBarWidth; myBarHeight = theBarHeight; myParamsTime.Modified(); @@ -1035,33 +1029,17 @@ VISU::ColoredPrs3d_i //---------------------------------------------------------------------------- CORBA::Long VISU::ColoredPrs3d_i -::GetTitleWidth() +::GetTitleSize() { - return myTitleWidth; -} - -//---------------------------------------------------------------------------- -CORBA::Long -VISU::ColoredPrs3d_i -::GetTitleHeight() -{ - return myTitleHeight; + return myTitleSize; } //---------------------------------------------------------------------------- CORBA::Long VISU::ColoredPrs3d_i -::GetLabelWidth() +::GetLabelSize() { - return myLabelWidth; -} - -//---------------------------------------------------------------------------- -CORBA::Long -VISU::ColoredPrs3d_i -::GetLabelHeight() -{ - return myLabelHeight; + return myLabelSize; } //---------------------------------------------------------------------------- @@ -1102,6 +1080,8 @@ VISU::ColoredPrs3d_i return myNumberOfLabels; } +//---------------------------------------------------------------------------- + //---------------------------------------------------------------------------- void VISU::ColoredPrs3d_i @@ -1510,8 +1490,8 @@ VISU::ColoredPrs3d_i SetIsDistributionVisible( aResourceMgr->booleanValue("VISU", "scalar_bar_show_distribution", false) ); // RKV - QString aLabelsFormat = aResourceMgr->stringValue( "VISU", "scalar_bar_label_format", "%-#6.3g" ); - SetLabelsFormat(aLabelsFormat.toLatin1().data()); + int lp = aResourceMgr->integerValue( "VISU", "scalar_bar_label_precision", 3 ); + SetLabelsFormat( VISU::ToFormat( lp ).c_str() ); // Orientation int anOrientation = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0); @@ -1523,32 +1503,26 @@ VISU::ColoredPrs3d_i // Scalar Bar origin QString propertyName = QString( "scalar_bar_%1_" ).arg( anOrientation == 0 ? "vertical" : "horizontal" ); - vtkFloatingPointType aXorigin = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.01 : 0.2; + vtkFloatingPointType aXorigin = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.01 : 0.1; aXorigin = aResourceMgr->doubleValue("VISU", propertyName + "x", aXorigin); myPosition[0] = aXorigin; - vtkFloatingPointType aYorigin = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.1 : 0.012; + vtkFloatingPointType aYorigin = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.1 : 0.01; aYorigin = aResourceMgr->doubleValue("VISU", propertyName + "y", aYorigin); myPosition[1] = aYorigin; // Scalar Bar size - myWidth = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.1 : 0.6; + myWidth = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.08 : 0.8; myWidth = aResourceMgr->doubleValue("VISU", propertyName + "width", myWidth); - myHeight = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.8:0.12; + myHeight = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.8:0.08; 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); + myTitleSize = 0; + myTitleSize = aResourceMgr->integerValue("VISU", propertyName + "title_size", myTitleSize); - myLabelWidth = 0; - myLabelWidth = aResourceMgr->integerValue("VISU", propertyName + "label_width", myLabelWidth); - - myLabelHeight = 0; - myLabelHeight = aResourceMgr->integerValue("VISU", propertyName + "label_height", myLabelHeight); + myLabelSize = 0; + myLabelSize = aResourceMgr->integerValue("VISU", propertyName + "label_size", myLabelSize); myBarWidth = 0; myBarWidth = aResourceMgr->integerValue("VISU", propertyName + "bar_width", myBarWidth); @@ -1586,7 +1560,7 @@ VISU::ColoredPrs3d_i myIsBoldTitle = f.bold(); myIsItalicTitle = f.italic(); - myIsShadowTitle = f.underline(); + myIsShadowTitle = f.overline(); } QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) ); @@ -1611,7 +1585,7 @@ VISU::ColoredPrs3d_i myIsBoldLabel = f.bold(); myIsItalicLabel = f.italic(); - myIsShadowLabel = f.underline(); + myIsShadowLabel = f.overline(); } QColor aLabelColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) ); @@ -1621,7 +1595,41 @@ VISU::ColoredPrs3d_i myLabelColor[0] = aLabelColor.red() / 255.; myLabelColor[1] = aLabelColor.green() / 255.; myLabelColor[2] = aLabelColor.blue() / 255.; + + // Parameters of labels displaed field values + myValLblFontType = VTK_ARIAL; + myIsBoldValLbl = true; + myIsItalicValLbl = myIsShadowValLbl = false; + myValLblFontSize = 12; + if( aResourceMgr->hasValue( "VISU", "values_labeling_font" ) ) + { + // family + QFont f = aResourceMgr->fontValue( "VISU", "values_labeling_font" ); + if ( f.family() == "Arial" ) + myValLblFontType = VTK_ARIAL; + else if ( f.family() == "Courier" ) + myValLblFontType = VTK_COURIER; + else if ( f.family() == "Times" ) + myValLblFontType = VTK_TIMES; + + // size + if ( f.pointSize() > -1 ) + myValLblFontSize = f.pointSize(); + + // color + QColor aColor = aResourceMgr->colorValue( + "VISU", "values_labeling_color", QColor( 255, 255, 255 ) ); + myValLblFontColor[ 0 ] = aColor.red() / 255.; + myValLblFontColor[ 1 ] = aColor.green() / 255.; + myValLblFontColor[ 2 ] = aColor.blue()/ 255.; + + // bold, italic, shadow + myIsBoldValLbl = f.bold(); + myIsItalicValLbl = f.italic(); + myIsShadowValLbl = f.overline(); + } + return this; } @@ -1695,10 +1703,8 @@ 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(); + myTitleSize = VISU::Storable::FindValue(theMap,"myTitleSize").toInt(); + myLabelSize = VISU::Storable::FindValue(theMap,"myLabelSize").toInt(); myBarWidth = VISU::Storable::FindValue(theMap,"myBarWidth").toInt(); myBarHeight = VISU::Storable::FindValue(theMap,"myBarHeight").toInt(); @@ -1731,6 +1737,18 @@ VISU::ColoredPrs3d_i } } } + + // Parameters of labels displayed field values + + myValLblFontType = VISU::Storable::FindValue( theMap, "myValLblFontType", "0" ).toInt(); + myIsBoldValLbl = VISU::Storable::FindValue( theMap, "myIsBoldValLbl", "1" ).toInt(); + myIsItalicValLbl = VISU::Storable::FindValue( theMap, "myIsItalicValLbl", "0" ).toInt(); + myIsShadowValLbl = VISU::Storable::FindValue( theMap, "myIsShadowValLbl", "0" ).toInt(); + myValLblFontSize = VISU::Storable::FindValue( theMap, "myValLblFontSize", "12" ).toDouble(); + myValLblFontColor[ 0 ] = VISU::Storable::FindValue( theMap, "myValLblFontColor[0]", "1" ).toFloat(); + myValLblFontColor[ 1 ] = VISU::Storable::FindValue( theMap, "myValLblFontColor[1]", "1" ).toFloat(); + myValLblFontColor[ 2 ] = VISU::Storable::FindValue( theMap, "myValLblFontColor[2]", "1" ).toFloat(); + return this; } @@ -1763,15 +1781,15 @@ VISU::ColoredPrs3d_i 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, "myTitleSize", myTitleSize ); + Storable::DataToStream( theStr, "myLabelSize", myLabelSize ); Storable::DataToStream( theStr, "myBarWidth", myBarWidth ); Storable::DataToStream( theStr, "myBarHeight", myBarHeight ); @@ -1790,6 +1808,18 @@ VISU::ColoredPrs3d_i Storable::DataToStream( theStr, "myLabelColor[0]", myLabelColor[0] ); Storable::DataToStream( theStr, "myLabelColor[1]", myLabelColor[1] ); Storable::DataToStream( theStr, "myLabelColor[2]", myLabelColor[2] ); + + // Parameters of labels displayed field values + + Storable::DataToStream( theStr, "myValLblFontType", myValLblFontType ); + Storable::DataToStream( theStr, "myIsBoldValLbl", myIsBoldValLbl ); + Storable::DataToStream( theStr, "myIsItalicValLbl", myIsItalicValLbl ); + Storable::DataToStream( theStr, "myIsShadowValLbl", myIsShadowValLbl ); + Storable::DataToStream( theStr, "myValLblFontSize", myValLblFontSize ); + Storable::DataToStream( theStr, "myValLblFontColor[0]", myValLblFontColor[ 0 ] ); + Storable::DataToStream( theStr, "myValLblFontColor[1]", myValLblFontColor[ 1 ] ); + Storable::DataToStream( theStr, "myValLblFontColor[2]", myValLblFontColor[ 2 ] ); + std::ostringstream aGeomNameList; std::string aMeshName = GetCMeshName(); @@ -1943,3 +1973,159 @@ VISU::ColoredPrs3d_i } //---------------------------------------------------------------------------- + + +int +VISU::ColoredPrs3d_i +::GetValLblFontType() const +{ + return myValLblFontType; +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::SetValLblFontType( const int theType ) +{ + if ( myValLblFontType == theType ) + return; + + VISU::TSetModified aModified( this ); + + myValLblFontType = theType; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- + +double +VISU::ColoredPrs3d_i +::GetValLblFontSize() const +{ + return myValLblFontSize; +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::SetValLblFontSize( const double theSize ) +{ + if ( VISU::CheckIsSameValue( myValLblFontSize, theSize ) ) + return; + + VISU::TSetModified aModified( this ); + + myValLblFontSize = theSize; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::GetValLblFontColor( vtkFloatingPointType& theR, + vtkFloatingPointType& theG, + vtkFloatingPointType& theB ) const +{ + theR = myValLblFontColor[ 0 ]; + theG = myValLblFontColor[ 1 ]; + theB = myValLblFontColor[ 2 ]; +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::SetValLblFontColor( const vtkFloatingPointType theR, + const vtkFloatingPointType theG, + const vtkFloatingPointType theB ) +{ + if ( VISU::CheckIsSameValue( myValLblFontColor[ 0 ], theR ) && + VISU::CheckIsSameValue( myValLblFontColor[ 1 ], theG ) && + VISU::CheckIsSameValue (myValLblFontColor[ 2 ], theB ) ) + return; + + VISU::TSetModified aModified(this); + + myValLblFontColor[ 0 ] = theR; + myValLblFontColor[ 1 ] = theG; + myValLblFontColor[ 2 ] = theB; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- + +bool +VISU::ColoredPrs3d_i +::IsBoldValLbl() const +{ + return myIsBoldValLbl; +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::SetBoldValLbl( const bool theVal ) +{ + if ( myIsBoldValLbl == theVal ) + return; + + VISU::TSetModified aModified( this ); + + myIsBoldValLbl = theVal; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- + +bool +VISU::ColoredPrs3d_i +::IsItalicValLbl() const +{ + return myIsItalicValLbl; +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::SetItalicValLbl( const bool theVal ) +{ + if ( myIsItalicValLbl == theVal ) + return; + + VISU::TSetModified aModified( this ); + + myIsItalicValLbl = theVal; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- + +bool +VISU::ColoredPrs3d_i +::IsShadowValLbl() const +{ + return myIsShadowValLbl; +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::SetShadowValLbl( const bool theVal ) +{ + if ( myIsShadowValLbl == theVal ) + return; + + VISU::TSetModified aModified( this ); + + myIsShadowValLbl = theVal; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- + diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 582a9ee1..5548bfed 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -284,8 +284,7 @@ namespace VISU virtual void - SetRatios(CORBA::Long theTitleWidth, CORBA::Long theTitleHeight, - CORBA::Long theLabelWidth, CORBA::Long theLabelHeight, + SetRatios(CORBA::Long theTitleSize, CORBA::Long theLabelSize, CORBA::Long theBarWidth, CORBA::Long theBarHeight); virtual @@ -298,19 +297,11 @@ namespace VISU virtual CORBA::Long - GetTitleWidth(); - - virtual - CORBA::Long - GetTitleHeight(); + GetTitleSize(); virtual CORBA::Long - GetLabelWidth(); - - virtual - CORBA::Long - GetLabelHeight(); + GetLabelSize(); virtual CORBA::Long @@ -581,6 +572,58 @@ namespace VISU return myColoredPL; } + virtual + int + GetValLblFontType() const; + + virtual + void + SetValLblFontType( const int theType ); + + virtual + double + GetValLblFontSize() const; + + virtual + void + SetValLblFontSize( const double theSize ); + + virtual + bool + IsBoldValLbl() const; + + virtual + void + SetBoldValLbl( const bool theVal ); + + virtual + bool + IsItalicValLbl() const; + + virtual + void + SetItalicValLbl( const bool theVal ); + + virtual + bool + IsShadowValLbl() const; + + virtual + void + SetShadowValLbl( const bool theVal ); + + virtual + void + GetValLblFontColor( vtkFloatingPointType& theR, + vtkFloatingPointType& theG, + vtkFloatingPointType& theB ) const; + + virtual + void + SetValLblFontColor( const vtkFloatingPointType theR, + const vtkFloatingPointType theG, + const vtkFloatingPointType theB ); + //---------------------------------------------------------------------------- protected: /*! @@ -688,11 +731,11 @@ namespace VISU int myNumberOfLabels; std::string myLabelsFormat; + VISU::ColoredPrs3dBase::Orientation myOrientation; vtkFloatingPointType myPosition[2], myWidth, myHeight, - myTitleWidth, myTitleHeight, - myLabelWidth, myLabelHeight, + myTitleSize, myLabelSize, myBarWidth, myBarHeight; //Font management @@ -713,6 +756,13 @@ namespace VISU bool myIsDistributionVisible; // RKV + // Result labels + int myValLblFontType; + double myValLblFontSize; + bool myIsBoldValLbl; + bool myIsItalicValLbl; + bool myIsShadowValLbl; + vtkFloatingPointType myValLblFontColor[ 3 ]; }; diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index 3e47457b..c91a9c01 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -434,7 +434,9 @@ namespace VISU aParam = "VISU.LOGARITHMIC"; break; } + std::string aVisible = theServant->IsBarVisible()? "True" : "False"; theStr<IsShrank()? "True" : "False")<<")"<SetTitle(GetScalarBarTitle().c_str()); theScalarBar->SetOrientation(GetBarOrientation()); theScalarBar->SetNumberOfLabels(GetLabels()); - theScalarBar->SetRatios(GetTitleWidth(), GetTitleHeight(), - GetLabelWidth(), GetLabelHeight(), + theScalarBar->SetRatios(GetTitleSize(), GetLabelSize(), GetBarWidth(), GetBarHeight()); theScalarBar->SetLabelFormat(GetLabelsFormat()); @@ -1002,7 +1001,24 @@ VISU::GaussPoints_i theActor->SetRepresentation( VTK_POINTS ); else theActor->SetRepresentation( VTK_SURFACE ); + + // Update values labels + + vtkTextProperty* aProp = anActor->GetsValLabelsProps(); + if ( aProp ) + { + aProp->SetFontFamily( GetValLblFontType() ); + aProp->SetFontSize( GetValLblFontSize() ); + aProp->SetBold( IsBoldValLbl() ); + aProp->SetItalic( IsItalicValLbl() ); + aProp->SetShadow( IsShadowValLbl() ); + + vtkFloatingPointType anRGB[ 3 ]; + GetValLblFontColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] ); + aProp->SetColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] ); + } } + TSuperClass::UpdateActor(theActor); } diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index 9adab276..c2983431 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -129,6 +129,8 @@ VISU::Mesh_i SetMeshName(theMeshName.c_str()); myEntity = int(theEntity);//jfa IPAL9284 mySubMeshName = theFamilyName; + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + myIsShrank = aResourceMgr->booleanValue("VISU", "mesh_shrink", false); return Build(false); } @@ -191,6 +193,8 @@ VISU::Mesh_i throw std::runtime_error("Mesh_i::Build - GetCResult()->GetInput() == NULL !!!"); if (!theRestoring) { myPresentType = VISU::PresentationType(VISU::GetResourceMgr()->integerValue("VISU" , "mesh_represent", 2)); + myIsShrank = (myPresentType == VISU::SHRINK); + if(myEntity == VISU::NODE_ENTITY) myPresentType = VISU::POINT; SetName((const char*)GenerateName().toLatin1(), false); @@ -399,7 +403,9 @@ VISU::Mesh_i return; VISU::TSetModified aModified(this); - + if (theType == VISU::SHRINK) { + myIsShrank = true; + } myPresentType = theType; myParamsTime.Modified(); } @@ -446,6 +452,8 @@ VISU::Mesh_i myPresentType = VISU::PresentationType(VISU::Storable::FindValue(theMap,"myPresentType").toInt()); + myIsShrank = (VISU::Storable::FindValue(theMap,"myIsShrank", "0").toInt() == 1)? true: false; + myCellColor.R = VISU::Storable::FindValue(theMap,"myCellColor.R").toDouble(); myCellColor.G = VISU::Storable::FindValue(theMap,"myCellColor.G").toDouble(); myCellColor.B = VISU::Storable::FindValue(theMap,"myCellColor.B").toDouble(); @@ -487,6 +495,8 @@ VISU::Mesh_i Storable::DataToStream( theStr, "myPresentType", int(myPresentType) ); + Storable::DataToStream( theStr, "myIsShrank", (myIsShrank? "1":"0")); + Storable::DataToStream( theStr, "myCellColor.R", myCellColor.R ); Storable::DataToStream( theStr, "myCellColor.G", myCellColor.G ); Storable::DataToStream( theStr, "myCellColor.B", myCellColor.B ); @@ -510,9 +520,14 @@ VISU::Mesh_i try{ VISU::Prs3d_i::CreateActor(anActor); SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - bool toShrink = aResourceMgr->booleanValue("VISU", "mesh_shrink", false); - if (toShrink) anActor->SetShrink(); - + //bool toShrink = aResourceMgr->booleanValue("VISU", "mesh_shrink", false); + //if (toShrink) anActor->SetShrink(); + if (anActor->IsShrunkable()) { + if (myIsShrank) + anActor->SetShrink(); + else + anActor->UnShrink(); + } anActor->SetFeatureEdgesAngle( aResourceMgr->doubleValue("VISU", "feature_edges_angle", 0.0) ); anActor->SetFeatureEdgesFlags( aResourceMgr->booleanValue("VISU", "show_feature_edges", false), aResourceMgr->booleanValue("VISU", "show_boundary_edges", false), @@ -538,6 +553,12 @@ VISU::Mesh_i if(MYDEBUG) MESSAGE("Mesh_i::UpdateActor"); VISU::Prs3d_i::UpdateActor(anActor); anActor->SetRepresentation(myPresentType); + if (anActor->IsShrunkable()) { + if (myIsShrank) + anActor->SetShrink(); + else + anActor->UnShrink(); + } anActor->GetSurfaceProperty()->SetColor(myCellColor.R, myCellColor.G, myCellColor.B); anActor->GetEdgeProperty()->SetColor(myLinkColor.R, myLinkColor.G, myLinkColor.B); anActor->GetNodeProperty()->SetColor(myNodeColor.R, myNodeColor.G, myNodeColor.B); @@ -545,3 +566,20 @@ VISU::Mesh_i } //---------------------------------------------------------------------------- + + +void VISU::Mesh_i::SetShrink(CORBA::Boolean toShrink) +{ + if(toShrink == myIsShrank) + return; + VISU::TSetModified aModified(this); + myIsShrank = toShrink; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- +CORBA::Boolean VISU::Mesh_i::IsShrank() +{ + return myIsShrank; +} + diff --git a/src/VISU_I/VISU_Mesh_i.hh b/src/VISU_I/VISU_Mesh_i.hh index 828667cd..de7e3142 100644 --- a/src/VISU_I/VISU_Mesh_i.hh +++ b/src/VISU_I/VISU_Mesh_i.hh @@ -95,6 +95,11 @@ namespace VISU VISU::PresentationType GetPresentationType(); + + virtual void SetShrink(CORBA::Boolean toShrink); + + virtual CORBA::Boolean IsShrank(); + VISU_MeshPL* GetSpecificPL() const { return myMeshPL; @@ -114,6 +119,7 @@ namespace VISU SALOMEDS::Color myCellColor; SALOMEDS::Color myNodeColor; SALOMEDS::Color myLinkColor; + bool myIsShrank; public: static diff --git a/src/VISU_I/VISU_PointMap3d_i.cc b/src/VISU_I/VISU_PointMap3d_i.cc index 33493def..f03b72ca 100644 --- a/src/VISU_I/VISU_PointMap3d_i.cc +++ b/src/VISU_I/VISU_PointMap3d_i.cc @@ -217,8 +217,8 @@ VISU::Storable* VISU::PointMap3d_i::Create() SetRange(aMin, aMax); } - QString aLabelsFormat = aResourceMgr->stringValue( "VISU", "scalar_bar_label_format", "%-#6.3g" ); - SetLabelsFormat(aLabelsFormat.toLatin1().constData()); + int lp = aResourceMgr->integerValue( "VISU", "scalar_bar_label_precision", 3 ); + SetLabelsFormat( VISU::ToFormat( lp ).c_str() ); // Orientation int anOrientation = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0); @@ -245,10 +245,8 @@ VISU::Storable* VISU::PointMap3d_i::Create() myHeight = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.8:0.12; myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight); - myTitleWidth = aResourceMgr->doubleValue("VISU", propertyName + "title_width", 0); - myTitleHeight = aResourceMgr->doubleValue("VISU", propertyName + "title_height", 0); - myLabelWidth = aResourceMgr->doubleValue("VISU", propertyName + "label_width", 0); - myLabelHeight = aResourceMgr->doubleValue("VISU", propertyName + "label_height", 0); + myTitleSize = aResourceMgr->doubleValue("VISU", propertyName + "title_size", 0); + myLabelSize = aResourceMgr->doubleValue("VISU", propertyName + "label_size", 0); myBarWidth = aResourceMgr->doubleValue("VISU", propertyName + "bar_width", 0); myBarHeight = aResourceMgr->doubleValue("VISU", propertyName + "bar_height", 0); @@ -270,7 +268,7 @@ VISU::Storable* VISU::PointMap3d_i::Create() myIsBoldTitle = f.bold(); myIsItalicTitle = f.italic(); - myIsShadowTitle = f.underline(); + myIsShadowTitle = f.overline(); } QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) ); @@ -293,7 +291,7 @@ VISU::Storable* VISU::PointMap3d_i::Create() myIsBoldLabel = f.bold(); myIsItalicLabel = f.italic(); - myIsShadowLabel = f.underline(); + myIsShadowLabel = f.overline(); } QColor aLabelColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) ); @@ -404,8 +402,7 @@ void VISU::PointMap3d_i::UpdateActor(VISU_ActorBase* theActor) aScalarBar->SetWidth(GetWidth()); aScalarBar->SetHeight(GetHeight()); aScalarBar->SetNumberOfLabels(GetLabels()); - aScalarBar->SetRatios(myTitleWidth, myTitleHeight, - myLabelWidth, myLabelHeight, + aScalarBar->SetRatios(myTitleSize, myLabelSize, myBarWidth, myBarHeight); aScalarBar->SetNumberOfLabels(GetLabels()); aScalarBar->SetLabelFormat(GetLabelsFormat()); @@ -583,10 +580,8 @@ VISU::Storable* VISU::PointMap3d_i::Restore( const Storable::TRestoringMap& theM 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(); + myTitleSize = VISU::Storable::FindValue(theMap,"myTitleSize").toInt(); + myLabelSize = VISU::Storable::FindValue(theMap,"myLabelSize").toInt(); myBarWidth = VISU::Storable::FindValue(theMap,"myBarWidth").toInt(); myBarHeight = VISU::Storable::FindValue(theMap,"myBarHeight").toInt(); @@ -633,10 +628,8 @@ void VISU::PointMap3d_i::ToStream( std::ostringstream& theStr ) 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, "myTitleSize", myTitleSize ); + Storable::DataToStream( theStr, "myLabelSize", myLabelSize ); Storable::DataToStream( theStr, "myBarWidth", myBarWidth ); Storable::DataToStream( theStr, "myBarHeight", myBarHeight ); @@ -1188,27 +1181,15 @@ void VISU::PointMap3d_i::SetLabelColor(vtkFloatingPointType theR, } //---------------------------------------------------------------------------- -CORBA::Long VISU::PointMap3d_i::GetTitleWidth() +CORBA::Long VISU::PointMap3d_i::GetTitleSize() { - return myTitleWidth; + return myTitleSize; } //---------------------------------------------------------------------------- -CORBA::Long VISU::PointMap3d_i::GetTitleHeight() -{ - return myTitleHeight; -} - -//---------------------------------------------------------------------------- -CORBA::Long VISU::PointMap3d_i::GetLabelWidth() +CORBA::Long VISU::PointMap3d_i::GetLabelSize() { - return myLabelWidth; -} - -//---------------------------------------------------------------------------- -CORBA::Long VISU::PointMap3d_i::GetLabelHeight() -{ - return myLabelHeight; + return myLabelSize; } //---------------------------------------------------------------------------- @@ -1255,23 +1236,19 @@ CORBA::Boolean VISU::PointMap3d_i::IsUnitsVisible() } //---------------------------------------------------------------------------- -void VISU::PointMap3d_i::SetRatios(CORBA::Long theTitleWidth, CORBA::Long theTitleHeight, - CORBA::Long theLabelWidth, CORBA::Long theLabelHeight, +void VISU::PointMap3d_i::SetRatios(CORBA::Long theTitleSize, + CORBA::Long theLabelSize, 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); + bool anIsSameValue = VISU::CheckIsSameValue(myTitleSize, theTitleSize); + anIsSameValue &= VISU::CheckIsSameValue(myLabelSize, theLabelSize); anIsSameValue &= VISU::CheckIsSameValue(myBarWidth, theBarWidth); anIsSameValue &= VISU::CheckIsSameValue(myBarHeight, theBarHeight); if(anIsSameValue) return; - myTitleWidth = theTitleWidth; - myTitleHeight = theTitleHeight; - myLabelWidth = theLabelWidth; - myLabelHeight = theLabelHeight; + myTitleSize = theTitleSize; + myLabelSize = theLabelSize; myBarWidth = theBarWidth; myBarHeight = theBarHeight; myParamsTime.Modified(); diff --git a/src/VISU_I/VISU_PointMap3d_i.hh b/src/VISU_I/VISU_PointMap3d_i.hh index 0db0c5f0..547191d8 100644 --- a/src/VISU_I/VISU_PointMap3d_i.hh +++ b/src/VISU_I/VISU_PointMap3d_i.hh @@ -100,8 +100,7 @@ namespace VISU virtual void SetSize(CORBA::Double theWidth, CORBA::Double theHeight); - virtual void SetRatios(CORBA::Long theTitleWidth, CORBA::Long theTitleHeight, - CORBA::Long theLabelWidth, CORBA::Long theLabelHeight, + virtual void SetRatios(CORBA::Long theTitleSize, CORBA::Long theLabelSize, CORBA::Long theBarWidth, CORBA::Long theBarHeight); virtual CORBA::Double GetWidth(); @@ -115,7 +114,7 @@ namespace VISU virtual void SetLabelsFormat(const char* theFormat); virtual char* GetLabelsFormat(); - + virtual void SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theOrientation); virtual VISU::ColoredPrs3dBase::Orientation GetBarOrientation(); @@ -188,10 +187,8 @@ namespace VISU vtkFloatingPointType theB); //------------------------------------------------------------------- - virtual CORBA::Long GetTitleWidth(); - virtual CORBA::Long GetTitleHeight(); - virtual CORBA::Long GetLabelWidth(); - virtual CORBA::Long GetLabelHeight(); + virtual CORBA::Long GetTitleSize(); + virtual CORBA::Long GetLabelSize(); virtual CORBA::Long GetBarWidth(); virtual CORBA::Long GetBarHeight(); @@ -213,8 +210,8 @@ namespace VISU std::string myLabelsFormat; vtkFloatingPointType myPosition[2], myWidth, myHeight, - myTitleWidth, myTitleHeight, - myLabelWidth, myLabelHeight, + myTitleSize, + myLabelSize, myBarWidth, myBarHeight; bool myIsFixedRange; CORBA::Float myOffset[3]; diff --git a/src/VISU_I/VISU_Prs3dUtils.cc b/src/VISU_I/VISU_Prs3dUtils.cc index dbb37815..35685d9f 100644 --- a/src/VISU_I/VISU_Prs3dUtils.cc +++ b/src/VISU_I/VISU_Prs3dUtils.cc @@ -70,6 +70,59 @@ namespace VISU ProcessVoidEvent(new TEvent(this)); } + //---------------------------------------------------------------------------- + + std::string ToFormat( const int thePrec ) + { + // "%-#6.3g" + char str[ 255 ]; + sprintf( str, "%%-#.%dg", thePrec ); + return str; + } //---------------------------------------------------------------------------- + + int ToPrecision( const char* theFormat ) + { + int N = strlen( theFormat ); + int k = -1; + char str[ 255 ]; + bool isOk = false; + for ( int i = 0; i < N; i++ ) + { + if ( theFormat[ i ] == '.' ) + k = 0; + else if ( theFormat[ i ] == 'g' ) + { + str[ k ] = 0; + isOk = true; + break; + } + else if ( k >= 0 ) + str[ k++ ] = theFormat[ i ]; + } + + int res = 0; + if ( isOk ) + res = atoi( str ); + + return res; + } }; + + + + + + + + + + + + + + + + + diff --git a/src/VISU_I/VISU_Prs3dUtils.hh b/src/VISU_I/VISU_Prs3dUtils.hh index 4abe53ca..7cf7fd20 100644 --- a/src/VISU_I/VISU_Prs3dUtils.hh +++ b/src/VISU_I/VISU_Prs3dUtils.hh @@ -31,7 +31,6 @@ #include - namespace VISU { //---------------------------------------------------------------------------- @@ -44,6 +43,9 @@ namespace VISU ~TSetModified(); }; + Standard_EXPORT std::string ToFormat( const int thePrec ); + Standard_EXPORT int ToPrecision( const char* theFormat ); + //---------------------------------------------------------------------------- } diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index 63f28310..2ad8a3be 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -172,7 +172,8 @@ VISU::ScalarMap_i //---------------------------------------------------------------------------- VISU::ScalarMap_i:: ScalarMap_i(EPublishInStudyMode thePublishInStudyMode) : - ColoredPrs3d_i(thePublishInStudyMode) + ColoredPrs3d_i(thePublishInStudyMode), + myShowBar(true) {} //---------------------------------------------------------------------------- @@ -192,7 +193,7 @@ VISU::ScalarMap_i ScalarMap_i* anOrigin = const_cast(aPrs3d); SetScaling(anOrigin->GetScaling()); - + SetBarVisible(anOrigin->IsBarVisible()); Update(); } } @@ -218,6 +219,7 @@ VISU::ScalarMap_i else SetScaling(VISU::LINEAR); + myShowBar = true; return this; } @@ -240,6 +242,9 @@ VISU::ScalarMap_i SetScaling(VISU::Scaling(VISU::Storable::FindValue(theMap,"myScaling").toInt())); + QString aVal = VISU::Storable::FindValue(theMap,"myShowBar", "1"); + SetBarVisible((aVal.toInt() == 1)? true : false); + // Check if the icon needs to be updated, update if necessary SALOMEDS::Study_var aStudy = theSObject->GetStudy(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); @@ -262,6 +267,7 @@ VISU::ScalarMap_i TSuperClass::ToStream(theStr); Storable::DataToStream( theStr, "myScaling", GetScaling() ); + Storable::DataToStream( theStr, "myShowBar", (IsBarVisible()? 1:0) ); } @@ -363,6 +369,14 @@ VISU::ScalarMap_i return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true); } +void VISU::ScalarMap_i::SetBarVisible(CORBA::Boolean theVisible) +{ + if (myShowBar == theVisible) + return; + VISU::TSetModified aModified(this); + myShowBar = theVisible; + myParamsTime.Modified(); +} //---------------------------------------------------------------------------- void @@ -387,7 +401,7 @@ VISU::ScalarMap_i VISU_ScalarMapAct* anActor = VISU_ScalarMapAct::New(); try{ TSuperClass::CreateActor(anActor); - anActor->SetBarVisibility(true); + anActor->SetBarVisibility(myShowBar); SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); int aDispMode = aResourceMgr->integerValue("VISU", "scalar_map_represent", 2); bool toShrink = aResourceMgr->booleanValue("VISU", "scalar_map_shrink", false); @@ -446,8 +460,7 @@ VISU::ScalarMap_i aScalarBar->GetPositionCoordinate()->SetValue(GetPosX(),GetPosY()); aScalarBar->SetWidth(GetWidth()); aScalarBar->SetHeight(GetHeight()); - aScalarBar->SetRatios(GetTitleWidth(), GetTitleHeight(), - GetLabelWidth(), GetLabelHeight(), + aScalarBar->SetRatios(GetTitleSize(), GetLabelSize(), GetBarWidth(), GetBarHeight()); aScalarBar->SetNumberOfLabels(GetLabels()); aScalarBar->SetLabelFormat(GetLabelsFormat()); @@ -474,7 +487,25 @@ VISU::ScalarMap_i IsItalicLabel()? aLabelProp->ItalicOn() : aLabelProp->ItalicOff(); IsShadowLabel()? aLabelProp->ShadowOn() : aLabelProp->ShadowOff(); + anActor->SetBarVisibility(myShowBar); + aScalarBar->Modified(); + + // Update values labels + + vtkTextProperty* aProp = anActor->GetsValLabelsProps(); + if ( aProp ) + { + aProp->SetFontFamily( GetValLblFontType() ); + aProp->SetFontSize( GetValLblFontSize() ); + aProp->SetBold( IsBoldValLbl() ); + aProp->SetItalic( IsItalicValLbl() ); + aProp->SetShadow( IsShadowValLbl() ); + + vtkFloatingPointType anRGB[ 3 ]; + GetValLblFontColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] ); + aProp->SetColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] ); + } } TSuperClass::UpdateActor(theActor); } diff --git a/src/VISU_I/VISU_ScalarMap_i.hh b/src/VISU_I/VISU_ScalarMap_i.hh index 463800c2..0b640af6 100644 --- a/src/VISU_I/VISU_ScalarMap_i.hh +++ b/src/VISU_I/VISU_ScalarMap_i.hh @@ -98,6 +98,10 @@ namespace VISU { return myScalarMapPL; } + + virtual CORBA::Boolean IsBarVisible() { return myShowBar; } + + virtual void SetBarVisible(CORBA::Boolean theVisible); protected: //! Redefines VISU_ColoredPrs3d_i::DoSetInput @@ -189,6 +193,7 @@ namespace VISU private: VISU_ScalarMapPL* myScalarMapPL; + bool myShowBar; }; }