From c5bd91653d39848bd158031d4765f91043d422f6 Mon Sep 17 00:00:00 2001 From: enk Date: Thu, 26 Jan 2006 07:51:34 +0000 Subject: [PATCH] Improvement Bug PAL8685: Displaying a scalar field on a deformed shape --- idl/VISU_Gen.idl | 33 ++ resources/VISU_en.xml | 2 + resources/VISU_fr.xml | 2 + resources/Visu_scalarmapondeformedshape.png | Bin 0 -> 531 bytes src/PIPELINE/Makefile.in | 6 +- .../VISU_ScalarMapOnDeformedShapePL.cxx | 239 +++++++++++ .../VISU_ScalarMapOnDeformedShapePL.hxx | 95 +++++ src/VISUGUI/Makefile.in | 2 + src/VISUGUI/VISU_icons.po | 3 + src/VISUGUI/VISU_images.po | 3 + src/VISUGUI/VISU_msg_en.po | 29 ++ src/VISUGUI/VisuGUI.cxx | 52 ++- src/VISUGUI/VisuGUI.h | 2 + src/VISUGUI/VisuGUI_ActionsDef.h | 2 + src/VISUGUI/VisuGUI_PopupTools.cxx | 1 + src/VISUGUI/VisuGUI_ScalarBarDlg.cxx | 8 + src/VISUGUI/VisuGUI_ScalarBarDlg.h | 1 + .../VisuGUI_ScalarMapOnDeformedShapeDlg.cxx | 380 ++++++++++++++++++ .../VisuGUI_ScalarMapOnDeformedShapeDlg.h | 108 +++++ src/VISUGUI/VisuGUI_TimeAnimation.cxx | 41 +- src/VISUGUI/VisuGUI_Tools.cxx | 1 + src/VISU_I/Makefile.in | 6 +- src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc | 265 ++++++++++++ src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh | 129 ++++++ src/VISU_I/VISU_TimeAnimation.cxx | 9 + 25 files changed, 1410 insertions(+), 9 deletions(-) create mode 100644 resources/Visu_scalarmapondeformedshape.png create mode 100644 src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx create mode 100644 src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx create mode 100644 src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx create mode 100644 src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h create mode 100644 src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc create mode 100644 src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 79237353..5f7648d6 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -59,6 +59,7 @@ module VISU { TSCALARMAP, /*!< Scalarmap 3D presentation object */ TISOSURFACE, /*!< Iso surface 3D presentation object */ TDEFORMEDSHAPE, /*!< Deformed shape 3D presentation object */ + TSCALARMAPONDEFORMEDSHAPE, /*!< Scalar map on deformed shape 3D presentation object */ TGAUSSPOINTS, /*!< Gauss Points 3D presentation object */ TPLOT3D, /*!< Plot3D 3D presentation object */ TCUTPLANES, /*!< Cut planes 3D presentation object */ @@ -567,6 +568,38 @@ module VISU { void SetColor(in SALOMEDS::Color theColor); }; + //------------------------------------------------------- + /*! \brief Scalar Map on Deformed shape presentation interface + * + * Presentation parameters of the scalar map on deformed shape presentation. + */ + interface ScalarMapOnDeformedShape : ScalarMap { + + /*! + * Sets the source ranges of pipeline + */ + void SetSourceRange(in double theMinRange,in double theMaxRange); + /*! + * Gets the minimum source range of pipeline + */ + double GetSourceRangeMin(); + /*! + * Gets the maximum source range of pipeline + */ + double GetSourceRangeMax(); + + /*! + * Sets the scale of the presentatable object. + * \param theScale Double value defining the scale of this presentable object. + */ + void SetScale(in double theScale); + + /*! + * Gets the scale of the presentatable object. + */ + double GetScale(); + + }; //------------------------------------------------------- /*! * \brief Plot3D interface diff --git a/resources/VISU_en.xml b/resources/VISU_en.xml index 4e3aedae..d2c013d9 100644 --- a/resources/VISU_en.xml +++ b/resources/VISU_en.xml @@ -32,6 +32,7 @@ + @@ -91,6 +92,7 @@ + diff --git a/resources/VISU_fr.xml b/resources/VISU_fr.xml index b10a3084..7a3230b9 100644 --- a/resources/VISU_fr.xml +++ b/resources/VISU_fr.xml @@ -32,6 +32,7 @@ + @@ -89,6 +90,7 @@ + diff --git a/resources/Visu_scalarmapondeformedshape.png b/resources/Visu_scalarmapondeformedshape.png new file mode 100644 index 0000000000000000000000000000000000000000..29df0932e62452555bc29b9515846a5b109759bf GIT binary patch literal 531 zcmV+u0_^>XP)ljA6u|MnqYM|};Z8)*3JC-YLdg(yK$%;KFX0i?!5|j4)T5ON7#R?Z8R>uo0}{-h zA`gkIF0ERrl0io20o2h9%{fl&3q|5Bb}qSJ-n)A~JF__Ae@1)Lm;J%8F!!@Ka;^fl zHenCmOv=wk$LGcA+0WwpkKcuDjx|GrCBBEb>P*vdJ4ht`!CnnD71Y3W%tV@{1p5I1 zdMYmmcR}TOS%GMaRnUe31fu}0C7iH=X(=zSiwas-!GMieI1Wj(l#5>%II}of+0At< z@x8xd073}1yW7hQo3i>BOu7=`3VRTYr8_Vu#N-e6etDt+8qN2H$AFthmIzI%>rr0pElhw)9m@iJ7Ruuw!TU0Y^3iBt9c?BFDpBFmQq*-e1F*9jiIlb4%{s5Ev V`LqkYEVKXs002ovPDHLkV1j)p_W%F@ literal 0 HcmV?d00001 diff --git a/src/PIPELINE/Makefile.in b/src/PIPELINE/Makefile.in index cc97361b..8f775a80 100644 --- a/src/PIPELINE/Makefile.in +++ b/src/PIPELINE/Makefile.in @@ -56,7 +56,8 @@ EXPORT_HEADERS = \ VISU_ScalarBarCtrl.hxx \ VISU_PlanesWidget.hxx \ VISU_SphereWidget.hxx \ - VISU_WidgetCtrl.hxx + VISU_WidgetCtrl.hxx \ + VISU_ScalarMapOnDeformedShapePL.hxx # Libraries targets @@ -85,7 +86,8 @@ LIB_SRC = \ VISU_PlanesWidget.cxx \ VISU_SphereWidget.cxx \ VISU_WidgetCtrl.cxx \ - VISU_ScalarBarCtrl.cxx + VISU_ScalarBarCtrl.cxx \ + VISU_ScalarMapOnDeformedShapePL.cxx # Executables targets diff --git a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx new file mode 100644 index 00000000..0d0ccad5 --- /dev/null +++ b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx @@ -0,0 +1,239 @@ +// VISU ScalarMapOnDeformedShapePL +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// File: VISU_ScalarMapOnDeformedShapePL.cxx +// Author: Eugeny Nikolaev +// Module : VISU + +#include "VISU_ScalarMapOnDeformedShapePL.hxx" +#include "VISU_DeformedShapePL.hxx" +#include "VISU_PipeLineUtils.hxx" +#include "VTKViewer_TransformFilter.h" +#include "VTKViewer_Transform.h" + +#include +#include +#include +#include +#include + +#include + +vtkStandardNewMacro(VISU_ScalarMapOnDeformedShapePL) + +/*! + * Constructor. Creating new instances of vtkWarpVector,vtkMergeFilter,vtkUnstructuredGrid + * Where: + * \li myDeformVectors is vtkWarpVector - deformation vectors data + * \li myMergeFilter is vtkMergeFilter - merge filter. + * Merge filter which unify the deformation and scalars + * \li myScalars is vtk shared pointer to vtkUnstructuredGrid - scalars data +*/ +VISU_ScalarMapOnDeformedShapePL::VISU_ScalarMapOnDeformedShapePL(){ + myDeformVectors = vtkWarpVector::New(); + myMergeFilter = vtkMergeFilter::New(); + myExtractorScalars = VISU_Extractor::New(); + myCellDataToPointData = vtkCellDataToPointData::New(); +} + +/*! + * Destructor. + * Delete all fields. +*/ +VISU_ScalarMapOnDeformedShapePL::~VISU_ScalarMapOnDeformedShapePL(){ + myDeformVectors->UnRegisterAllOutputs(); + myDeformVectors->Delete(); + + myMergeFilter->UnRegisterAllOutputs(); + myMergeFilter->Delete(); + + myExtractorScalars->UnRegisterAllOutputs(); + myExtractorScalars->Delete(); + + myCellDataToPointData->UnRegisterAllOutputs(); + myCellDataToPointData->Delete(); +} + +/*! + * Initial method + */ +void VISU_ScalarMapOnDeformedShapePL::Init(){ + + if (GetScalars() == NULL) SetScalars(GetInput2()); + + Superclass::Init(); + + float aScalarRange[2]; + GetSourceRange(aScalarRange); + static double EPS = 1.0 / VTK_LARGE_FLOAT; + if(aScalarRange[1] > EPS) + SetScale(VISU_DeformedShapePL::GetScaleFactor(GetInput2())/aScalarRange[1]); + else + SetScale(0.0); + + myMapper->SetColorModeToMapScalars(); + myMapper->ScalarVisibilityOn(); + + // Sets input for field transformation filter + myFieldTransform->SetInput(myExtractor->GetOutput()); + +} + +/*! + * Build method + * Building of deformation and puts result to merge filter. + */ +void VISU_ScalarMapOnDeformedShapePL::Build() +{ + // Set input for extractor + myExtractor->SetInput(GetInput2()); + + VISU::CellDataToPoint(myDeformVectors,myCellDataToPointData, + GetInput2(),myFieldTransform); + + // Sets geometry for merge filter + myMergeFilter->SetGeometry(myDeformVectors->GetOutput()); + // Sets data to mapper + myMapper->SetInput(myMergeFilter->GetOutput()); +} + +/*! + * Update method + */ +void VISU_ScalarMapOnDeformedShapePL::Update(){ + this->UpdateScalars(); + + float aRange[2]; + GetSourceRange(aRange); + float aScalarRange[2] = {aRange[0], aRange[1]}; + + if(myBarTable->GetScale() == VTK_SCALE_LOG10) + VISU_LookupTable::ComputeLogRange(aRange,aScalarRange); + myMapperTable->SetRange(aScalarRange); + + myMapperTable->Build(); + myBarTable->Build(); + + myMapper->SetLookupTable(myMapperTable); + myMapper->SetScalarRange(aScalarRange); + + VISU_PipeLine::Update(); +} + +/*! + * Update scalars method. + * Put scalars to merge filter. + */ +void VISU_ScalarMapOnDeformedShapePL::UpdateScalars(){ + if(myScalars->GetCellData()->GetVectors() != NULL || + myScalars->GetPointData()->GetVectors() != NULL) + myMergeFilter->SetScalars(myExtractorScalars->GetOutput()); + else + myMergeFilter->SetScalars(GetScalars()); +} + +/*! + * Copy information about pipline. + * Copy scale and scalars. + */ +void VISU_ScalarMapOnDeformedShapePL::ShallowCopy(VISU_PipeLine *thePipeLine){ + VISU_ScalarMapOnDeformedShapePL *aPipeLine = dynamic_cast(thePipeLine); + if(aPipeLine){ + SetScale(aPipeLine->GetScale()); + SetScalars(aPipeLine->GetScalars()); + float aRange[2]; + aPipeLine->GetSourceRange(aRange); + SetScalarRange(aRange); + } + Superclass::ShallowCopy(thePipeLine); +} + +/*! + * Set scalars. + * Sets vtkDataSet with scalars values to VISU_Extractor filter for scalars extraction. + */ +void VISU_ScalarMapOnDeformedShapePL::SetScalars(vtkDataSet *theScalars){ + myScalars = theScalars; + vtkUnstructuredGrid* aScalars = GetScalars(); + myExtractorScalars->SetInput(aScalars); + Modified(); +} + +/*! + * Get pointer to input scalars. + */ +vtkUnstructuredGrid* VISU_ScalarMapOnDeformedShapePL::GetScalars(){ + return myScalars.GetPointer(); +} + +/*! + * Sets scale for deformed shape + */ +void VISU_ScalarMapOnDeformedShapePL::SetScale(float theScale) { + if(myScaleFactor == theScale) return; + myScaleFactor = theScale; + myDeformVectors->SetScaleFactor(myScaleFactor); + Modified(); +} + +/*! + * Gets scale of deformed shape. + */ +float VISU_ScalarMapOnDeformedShapePL::GetScale() { + float aScale=myDeformVectors->GetScaleFactor(); + return aScale; +} + +/*! + * Set scale factor of deformation. + */ +void VISU_ScalarMapOnDeformedShapePL::SetMapScale(float theMapScale){ + myDeformVectors->SetScaleFactor(myScaleFactor*theMapScale); + Modified(); +} + +/*! + * Gets scalar mode. + */ +int VISU_ScalarMapOnDeformedShapePL::GetScalarMode(){ + int aMode=myExtractorScalars->GetScalarMode(); + return aMode; +} + +/*! + * Sets scalar mode. + */ +void VISU_ScalarMapOnDeformedShapePL::SetScalarMode(int theScalarMode){ + myExtractorScalars->SetScalarMode(theScalarMode); + Modified(); +} + +/*! + * Gets ranges of extracted scalars + * \param theRange[2] - output values + * \li theRange[0] - minimum value + * \li theRange[1] - maximum value + */ +void VISU_ScalarMapOnDeformedShapePL::GetSourceRange(float theRange[2]){ + myExtractorScalars->Update(); + myExtractorScalars->GetUnstructuredGridOutput()->GetScalarRange(theRange); +} diff --git a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx new file mode 100644 index 00000000..6d1ccf9a --- /dev/null +++ b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx @@ -0,0 +1,95 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// File: VISU_ScalarMapOnDeformedShapePL.hxx +// Author: Eugeny Nikolaev +// Module : VISU + +#ifndef VISU_ScalarMapOnDeformedShapePL_HeaderFile +#define VISU_ScalarMapOnDeformedShapePL_HeaderFile + +#include "VISU_ScalarMapPL.hxx" + +class vtkMergeFilter; +class vtkWarpVector; +class vtkUnstructuredGrid; +class vtkCellDataToPointData; +class vtkPointDataToCellData; + +class VISU_ScalarMapOnDeformedShapePL : public VISU_ScalarMapPL +{ +protected: + VISU_ScalarMapOnDeformedShapePL(); + + virtual ~VISU_ScalarMapOnDeformedShapePL(); + + VISU_ScalarMapOnDeformedShapePL(const VISU_ScalarMapOnDeformedShapePL&); +public: + vtkTypeMacro(VISU_ScalarMapOnDeformedShapePL,VISU_ScalarMapPL); + + static VISU_ScalarMapOnDeformedShapePL* New(); + + virtual void ShallowCopy(VISU_PipeLine *thePipeLine); + + virtual void SetScale(float theScale); + virtual float GetScale(); + + virtual int GetScalarMode(); + virtual void SetScalarMode(int theScalarMode = 0); + + virtual void GetSourceRange(float theRange[2]); + + virtual void SetScalars(vtkDataSet *theScalars); + virtual vtkUnstructuredGrid* GetScalars(); + +public: + //! Redefined method for initialization of the pipeline. + virtual + void + Init(); + + //! Redefined method for building the pipeline. + virtual + void + Build(); + + //! Redefined method for updating the pipeline. + virtual + void + Update(); + + //! Update scalars. + void + UpdateScalars(); + + virtual void SetMapScale(float theMapScale = 1.0); + +protected: + float myScaleFactor; + vtkWarpVector *myDeformVectors; + vtkMergeFilter *myMergeFilter; + vtkSmartPointer myScalars; + VISU_Extractor* myExtractorScalars; + vtkCellDataToPointData* myCellDataToPointData; +}; + +#endif diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index cb4e7176..1c2f20f1 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -71,6 +71,7 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_StreamLinesDlg.cxx \ VisuGUI_VectorsDlg.cxx \ VisuGUI_Displayer.cxx \ + VisuGUI_ScalarMapOnDeformedShapeDlg.cxx \ VisuGUI_SetupPlot2dDlg.cxx \ VisuGUI_BuildProgressDlg.cxx \ VisuGUI_TransparencyDlg.cxx \ @@ -96,6 +97,7 @@ LIB_MOC = VisuGUI.h \ VisuGUI_CutPlanesDlg.h \ VisuGUI_StreamLinesDlg.h \ VisuGUI_VectorsDlg.h \ + VisuGUI_ScalarMapOnDeformedShapeDlg.h \ VisuGUI_SetupPlot2dDlg.h \ VisuGUI_BuildProgressDlg.h \ VisuGUI_TransparencyDlg.h diff --git a/src/VISUGUI/VISU_icons.po b/src/VISUGUI/VISU_icons.po index 4422d48d..525994aa 100644 --- a/src/VISUGUI/VISU_icons.po +++ b/src/VISUGUI/VISU_icons.po @@ -42,6 +42,9 @@ msgstr "Visu_scalars.png" msgid "ICON_DEFORMED_SHAPE" msgstr "Visu_deformed.png" +msgid "ICON_SCALAR_MAP_ON_DEFORMED_SHAPE" +msgstr "Visu_scalarmapondeformedshape.png" + msgid "ICON_VECTORS" msgstr "Visu_vectors.png" diff --git a/src/VISUGUI/VISU_images.po b/src/VISUGUI/VISU_images.po index 0f7909b9..7357d06a 100644 --- a/src/VISUGUI/VISU_images.po +++ b/src/VISUGUI/VISU_images.po @@ -42,6 +42,9 @@ msgstr "Visu_scalars.png" msgid "ICON_DEFORMED_SHAPE" msgstr "Visu_deformed.png" +msgid "ICON_SCALAR_MAP_ON_DEFORMED_SHAPE" +msgstr "Visu_scalarmapondeformedshape.png" + msgid "ICON_VECTORS" msgstr "Visu_vectors.png" diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index e25236e9..0cd7807b 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -178,6 +178,9 @@ msgstr "Scalar Map" msgid "VisuGUI::MEN_DEFORMED_SHAPE" msgstr "Deformed Shape" +msgid "VisuGUI::MEN_SCALAR_MAP_ON_DEFORMED_SHAPE" +msgstr "Scalar Map on Deformed Shape" + msgid "VisuGUI::MEN_VISUALIZATION" msgstr "Visualization" @@ -555,6 +558,32 @@ msgid "VisuGUI_DeformedShapeDlg::SCALE_FACTOR" msgstr "Scale Factor:" +#: VisuGUI_ScalarMapOnDeformedShapeDlg.cxx + +msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::DLG_TITLE" +msgstr "Scalar Map on Deformed Shape" + +msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::&Cancel" +msgstr "" + +msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::&OK" +msgstr "" + +msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::SCALAR_MAP_ON_DEFORMED_SHAPE_TAB" +msgstr "Scalar Map on Deformed Shape" + +msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::SCALAR_BAR_TAB" +msgstr "Scalar Bar" + +msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::SCALE_FACTOR" +msgstr "Scale Factor:" + +msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::FIELD_ITEM" +msgstr "Fields" + +msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::TIMESTAMP_ITEM" +msgstr "Time stamp" + #: VisuGUI_EditContainerDlg.cxx msgid "VisuGUI_EditContainerDlg::&Cancel" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 0c935ffa..f59460c8 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -113,6 +113,9 @@ #include "VISU_DeformedShape_i.hh" #include "VisuGUI_DeformedShapeDlg.h" +#include "VISU_ScalarMapOnDeformedShape_i.hh" +#include "VisuGUI_ScalarMapOnDeformedShapeDlg.h" + #include "VISU_IsoSurfaces_i.hh" #include "VisuGUI_IsoSurfacesDlg.h" @@ -514,6 +517,13 @@ OnCreateDeformedShape() CreatePrs3d(this); } +void +VisuGUI:: +OnCreateScalarMapOnDeformedShape() +{ + CreatePrs3d(this); +} + void VisuGUI:: OnCreateVectors() @@ -699,6 +709,18 @@ OnEditDeformedShape() } } +void +VisuGUI:: +OnEditScalarMapOnDeformedShape() +{ + Handle(SALOME_InteractiveObject) anIO; + if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ + EditPrs3d(this, aPrs3d); + if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + aViewWindow->highlight(anIO, 1); + } + } +} void VisuGUI:: @@ -1690,6 +1712,14 @@ OnCopyPresentation() UpdateViewer(this, aSameDeformed); } break; + case VISU::TSCALARMAPONDEFORMEDSHAPE: + { + VISU::ScalarMapOnDeformedShape_i* aDefPrs = dynamic_cast(aPrsObject); + VISU::ScalarMapOnDeformedShape_i* aSameScalarMapOnDeformed = new VISU::ScalarMapOnDeformedShape_i(aDefPrs->GetResult(),true); + aSameScalarMapOnDeformed->SameAs(aDefPrs); + UpdateViewer(this, aSameScalarMapOnDeformed); + } + break; case VISU::TCUTPLANES: { VISU::CutPlanes_i* aCutPrs = dynamic_cast(aPrsObject); @@ -1948,6 +1978,11 @@ createActions() tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false, this, SLOT(OnCreateDeformedShape())); + aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP_ON_DEFORMED_SHAPE")); + createAction( VISU_SCALAR_MAP_ON_DEFORMED_SHAPE, tr("MEN_SCALAR_MAP_ON_DEFORMED_SHAPE"), QIconSet(aPixmap), + tr("MEN_SCALAR_MAP_ON_DEFORMED_SHAPE"), "", 0, aParent, false, + this, SLOT(OnCreateScalarMapOnDeformedShape())); + aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS")); createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIconSet(aPixmap), tr("MEN_VECTORS"), "", 0, aParent, false, @@ -2173,6 +2208,10 @@ createActions() tr("MEN_EDIT_PRS"), "", 0, aParent, false, this, SLOT(OnEditPlot3D())); + createAction( VISU_EDIT_SCALARMAPONDEFORMEDSHAPE, tr("MEN_EDIT_PRS"), QIconSet(), + tr("MEN_EDIT_PRS"), "", 0, aParent, false, + this, SLOT(OnEditScalarMapOnDeformedShape())); + createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(), tr("MEN_CREATE_TABLE"), "", 0, aParent, false, @@ -2239,6 +2278,7 @@ createMenus() createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d + createMenu( VISU_SCALAR_MAP_ON_DEFORMED_SHAPE, aMenuId, 10 ); // scalar map on deformed shape aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 ); createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info @@ -2267,6 +2307,7 @@ createToolBars() createTool( VISU_CUT_LINES, aToolId ); createTool( VISU_STREAM_LINES, aToolId ); createTool( VISU_PLOT_3D, aToolId ); + createTool( VISU_SCALAR_MAP_ON_DEFORMED_SHAPE, aToolId ); aToolId = createTool(tr("TOOL_REPRESENTATION")); createTool( VISU_POINTS, aToolId ); @@ -2300,6 +2341,7 @@ createPopupMenus() mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines mgr->insert( action( VISU_PLOT_3D ), -1, -1, -1 ); // Plot3d + mgr->insert( action( VISU_SCALAR_MAP_ON_DEFORMED_SHAPE ), -1, -1, -1 ); // scalar map on deformed shape mgr->insert( action( VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations @@ -2315,6 +2357,7 @@ createPopupMenus() mgr->insert( action( VISU_EDIT_VECTORS ), -1, -1, -1 ); mgr->insert( action( VISU_EDIT_STREAMLINES ), -1, -1, -1 ); mgr->insert( action( VISU_EDIT_PLOT3D ), -1, -1, -1 ); + mgr->insert( action( VISU_EDIT_SCALARMAPONDEFORMEDSHAPE ), -1, -1, -1 ); mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 ); // rename @@ -2387,7 +2430,7 @@ createPopupMenus() // Rules QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " - "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'"); + "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'"); // VISU root commands QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'"; @@ -2406,6 +2449,7 @@ createPopupMenus() mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true ); mgr->setRule( action( VISU_VECTORS ), aRule, true ); mgr->setRule( action( VISU_STREAM_LINES ), aRule, true ); + mgr->setRule( action( VISU_SCALAR_MAP_ON_DEFORMED_SHAPE ), aRule, true ); // display/erase commands QString andInvisible = " and (((not isVisible) and isActiveView) or (not isActiveView))"; @@ -2451,9 +2495,9 @@ createPopupMenus() QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}"; QString aSurfType = " and $type in {'VISU::TMESH'}"; QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' " - "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D'}"; + "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}"; QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' " - "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'}"; + "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' }"; aRule = "selcount=1"; mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType, true ); @@ -2509,6 +2553,8 @@ createPopupMenus() "selcount=1 and type='VISU::TSCALARMAP'", true ); mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ), "selcount=1 and type='VISU::TDEFORMEDSHAPE'", true ); + mgr->setRule( action( VISU_EDIT_SCALARMAPONDEFORMEDSHAPE ), + "selcount=1 and type='VISU::TSCALARMAPONDEFORMEDSHAPE'", true ); mgr->setRule( action( VISU_EDIT_CUTPLANES ), "selcount=1 and type='VISU::TCUTPLANES'", true ); mgr->setRule( action( VISU_EDIT_CUTLINES ), diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 411b0bfc..22224d72 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -97,6 +97,7 @@ protected slots: void OnCreatePlot3D(); void OnCreateManyMesh(); void OnCreatePlot2dView(); + void OnCreateScalarMapOnDeformedShape(); void OnEditScalarMap(); void OnEditDeformedShape(); @@ -106,6 +107,7 @@ protected slots: void OnEditVectors(); void OnEditStreamLines(); void OnEditPlot3D(); + void OnEditScalarMapOnDeformedShape(); virtual void OnDisplayPrs(); virtual void OnDisplayOnlyPrs(); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 923247d8..1fe7a7b2 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -40,6 +40,7 @@ #define VISU_CUT_LINES 4017 #define VISU_PLOT2D 4018 #define VISU_PLOT_3D 4019 +#define VISU_SCALAR_MAP_ON_DEFORMED_SHAPE 40110 //#define VISU_DELETE 4021 #define VISU_DELETE_OBJS 4022 @@ -91,6 +92,7 @@ #define VISU_EDIT_VECTORS 40625 #define VISU_EDIT_STREAMLINES 40626 #define VISU_EDIT_PLOT3D 40627 +#define VISU_EDIT_SCALARMAPONDEFORMEDSHAPE 40628 #define VISU_EDIT_PRS 4062 #define VISU_CREATE_TABLE 4063 diff --git a/src/VISUGUI/VisuGUI_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx index ef22f154..b4ca7c20 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ b/src/VISUGUI/VisuGUI_PopupTools.cxx @@ -92,6 +92,7 @@ QString VisuGUI_Selection::type( const int ind ) const ENUM2STRING( aResStr, VISU::TSCALARMAP ); ENUM2STRING( aResStr, VISU::TISOSURFACE ); ENUM2STRING( aResStr, VISU::TDEFORMEDSHAPE ); + ENUM2STRING( aResStr, VISU::TSCALARMAPONDEFORMEDSHAPE ); ENUM2STRING( aResStr, VISU::TCUTPLANES ); ENUM2STRING( aResStr, VISU::TCUTLINES ); ENUM2STRING( aResStr, VISU::TVECTORS ); diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 9e811e47..fa9da21b 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -909,6 +909,14 @@ void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, d changeRange( 0 ); } +/*! + Sets default values and range mode +*/ +void VisuGUI_ScalarBarPane::setDefaultRange(double imin, double imax){ + Rmin = imin; + Rmax = imax; +} + /*! Sets size and position */ diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.h b/src/VISUGUI/VisuGUI_ScalarBarDlg.h index f68b0f42..cec542c6 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.h @@ -95,6 +95,7 @@ class VisuGUI_ScalarBarPane : public QVBox ~VisuGUI_ScalarBarPane() {}; void setRange( double imin, double imax, /*double fmin, double fmax,*/ bool sbRange ); + void setDefaultRange(double imin, double imax); bool isIRange() {return RBIrange->isChecked();} double getMin() {return MinEdit->text().toDouble();} double getMax() {return MaxEdit->text().toDouble();} diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx new file mode 100644 index 00000000..95e13191 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx @@ -0,0 +1,380 @@ +// VISU VISUGUI : GUI of VISU component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_ScalarMapOnDeformedShapeDlg.cxx +// Author : Eugeny Nikolaev +// Module : VISU + +#include "VisuGUI_ScalarMapOnDeformedShapeDlg.h" +#include "VisuGUI_Tools.h" +#include "VISU_ScalarMapOnDeformedShape_i.hh" +#include "VISU_ScalarMapOnDeformedShapePL.hxx" +#include "SalomeApp_Module.h" +#include "LightApp_SelectionMgr.h" +#include "SUIT_Desktop.h" +#include "VISU_ScalarMapPL.hxx" + +#include "SALOME_ListIO.hxx" + +#include "VISU_Convertor.hxx" + +#include "SALOMEDSClient_AttributeComment.hxx" +#include "SALOMEDSClient_AttributeName.hxx" + +#include +#include + +using namespace std; + +#define MYDEBUG 0 + +/*! + * Constructor + */ +VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (SalomeApp_Module* theModule) + : QDialog(VISU::GetDesktop(theModule), "VisuGUI_ScalarMapOnDeformedShapeDlg", false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + myVisuGUI(theModule) +{ + myPrs = NULL; + setCaption(tr("DLG_TITLE")); + setSizeGripEnabled(TRUE); + + QVBoxLayout* TopLayout = new QVBoxLayout (this); + TopLayout->setSpacing(6); + TopLayout->setMargin(11); + + QTabWidget* aTabBox = new QTabWidget (this); + + // Scalar Map on Deformed shape pane + QVBox* aBox = new QVBox (this); + aBox->setMargin(11); + QFrame* TopGroup = new QFrame (aBox, "TopGroup"); + TopGroup->setFrameStyle(QFrame::Box | QFrame::Sunken); + TopGroup->setLineWidth(1); + QGridLayout* TopGroupLayout = new QGridLayout (TopGroup); + TopGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + TopGroupLayout->setSpacing(6); + TopGroupLayout->setMargin(11); + + // Scale factor + QLabel* ScaleLabel = new QLabel (tr("SCALE_FACTOR"), TopGroup, "ScaleLabel"); + TopGroupLayout->addWidget(ScaleLabel, 0, 0); + + ScalFact = new QtxDblSpinBox (0.0, 1.0E+38, 0.1, TopGroup); + ScalFact->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + ScalFact->setPrecision(5); + ScalFact->setValue(0.1); + TopGroupLayout->addWidget(ScalFact, 0, 1); + + // Fields combo box + QLabel* FieldLabel = new QLabel (tr("FIELD_ITEM"), TopGroup, "FieldLabel"); + myFieldsCombo = new QComboBox (TopGroup,"Fields"); + + TopGroupLayout->addWidget(FieldLabel, 1, 0); + TopGroupLayout->addWidget(myFieldsCombo,1,1); + + // TimeStamps combo box + QLabel* TimeStampLabel = new QLabel (tr("TIMESTAMP_ITEM"), TopGroup, "TimeStampLabel"); + myTimeStampsCombo = new QComboBox (TopGroup,"TimeStamp"); + + TopGroupLayout->addWidget(TimeStampLabel, 2, 0); + TopGroupLayout->addWidget(myTimeStampsCombo,2,1); + + // + aTabBox->addTab(aBox, tr("SCALAR_MAP_ON_DEFORMED_SHAPE_TAB")); + + // Scalar bar pane + myScalarPane = new VisuGUI_ScalarBarPane (this, false); + myScalarPane->setMargin(5); + + aTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB")); + + // Buttons + QGroupBox* GroupButtons = new QGroupBox (this, "GroupButtons"); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + QGridLayout* GroupButtonsLayout = new QGridLayout (GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + + QPushButton* buttonOk = new QPushButton (tr("&OK"), GroupButtons, "buttonOk"); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + + GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding, + QSizePolicy::Minimum), 0, 1); + + QPushButton* buttonCancel = new QPushButton (tr("&Cancel") , GroupButtons, "buttonCancel"); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 2); + + // Add Tab box and Buttons to the top layout + TopLayout->addWidget(aTabBox); + TopLayout->addWidget(GroupButtons); + + // signals and slots connections + connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); + connect(myFieldsCombo, SIGNAL(activated(int)), this, SLOT(onFieldChanged(int))); + connect(myTimeStampsCombo, SIGNAL(activated(int)), this, SLOT(onTimeStampChanged(int))); + +} + +void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject (VISU::ScalarMapOnDeformedShape_i* thePrs,bool isAnim) +{ + myPrs = thePrs; + + setFactor(thePrs->GetScale()); + myTimeStampsCombo->setDisabled(isAnim); + + QString aFieldName(thePrs->GetScalarFieldName()); + float aIterFloat = GetFloatValueOfTimeStamp(thePrs->GetScalarIteration()); + QString aIteration(QString("%1").arg(aIterFloat)); + + if (myMeshFieldsTimes.size() == 0) + { + // find all fields and time stamps on it + _PTR(Study) aActiveStudy = VISU::GetCStudy(VISU::GetAppStudy(myVisuGUI)); + LightApp_SelectionMgr* aSel = VISU::GetSelectionMgr(myVisuGUI); + SALOME_ListIO selected; + aSel->selectedObjects(selected); + if (selected.Extent() > 0) { + Handle(SALOME_InteractiveObject) aIO = selected.First(); + if (aIO->hasEntry()) { + _PTR(SObject) aSObject = aActiveStudy->FindObjectID(aIO->getEntry()); + aSObject = aSObject->GetFather(); + aSObject = aSObject->GetFather(); + aSObject = aSObject->GetFather(); + aSObject = aSObject->GetFather(); + mySelectionObj = aSObject; + CORBA::Object_var anObject = VISU::ClientSObjectToObject(mySelectionObj); + VISU::Result_var aResult; + if (CORBA::is_nil(anObject)) { + mySelectionObj = mySelectionObj->GetFather(); + } + _PTR(ChildIterator) aIter = aActiveStudy->NewChildIterator(mySelectionObj); + + for (aIter->InitEx(true); aIter->More(); aIter->Next()) { + _PTR(SObject) aChildSObj = aIter->Value(); + CORBA::Object_var aChildObject = VISU::ClientSObjectToObject(aChildSObj); + + _PTR(GenericAttribute) anAttr; + if (aChildSObj->FindAttribute(anAttr, "AttributeComment")) { + _PTR(AttributeComment) aComment (anAttr); + string aComm = aComment->Value(); + QString strIn (aComm.c_str()); + VISU::Storable::TRestoringMap aMap; + VISU::Storable::StrToMap(strIn,aMap); + bool isExist; + VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); + if (isExist) { + if ((aType == VISU::TTIMESTAMP)) { + _PTR(GenericAttribute) aNameAttr; + if (aChildSObj->FindAttribute(aNameAttr, "AttributeName")) { + _PTR(AttributeName) aName (aNameAttr); + VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject); + QString aMeshName = VISU::getValue(aChildSObj,"myMeshName"); + if(QString(thePrs->GetMeshName().c_str()) != aMeshName) continue; + myCurrMeshName = aMeshName; + QString aFieldName = VISU::getValue(aChildSObj,"myFieldName"); + QString aTimeIter = VISU::getValue(aChildSObj,"myTimeStampId"); + QString aEntity = VISU::getValue(aChildSObj,"myEntityId"); + VISU::TEntity anEntity; + switch(aEntity.toInt()){ + case 0: anEntity = VISU::NODE_ENTITY; break; + case 1: anEntity = VISU::EDGE_ENTITY; break; + case 2: anEntity = VISU::FACE_ENTITY; break; + case 3: anEntity = VISU::CELL_ENTITY; break; + } + TFT &aFieldsMap = myMeshFieldsTimes[aMeshName.latin1()]; + TFE aKey(aFieldName.latin1(),anEntity); + aFieldsMap[aKey][aTimeIter.toInt()] = GetFloatValueOfTimeStamp(aTimeIter.toInt()); + } + } + } + } + } + } + } + + AddAllFieldNames(); + + } + myFieldsCombo->setCurrentText(aFieldName); + AddAllTimes(myFieldsCombo->currentText()); + myTimeStampsCombo->setCurrentText(aIteration); + SetScalarField(); + + myScalarPane->initFromPrsObject(myPrs); +} + +int VisuGUI_ScalarMapOnDeformedShapeDlg::storeToPrsObject(VISU::ScalarMapOnDeformedShape_i* thePrs, bool theUpdateScalar) { + + thePrs->SetScale(getFactor()); + + thePrs->SetScalarField(myPrs->GetScalarMeshName().c_str(), + myPrs->GetScalarFieldName().c_str(), + myPrs->GetScalarIteration(), + myPrs->GetScalarEntity()); + + if (theUpdateScalar) SetScalarField(); + + thePrs->ShowColored(true); + + myScalarPane->storeToPrsObject(thePrs); + + myPrs = thePrs; + + return 1; +} + +int VisuGUI_ScalarMapOnDeformedShapeDlg::getCurrentScalarFieldNamePos(){ + return myFieldsCombo->currentItem(); +} + +QString VisuGUI_ScalarMapOnDeformedShapeDlg::getCurrentScalarFieldName(){ + return myFieldsCombo->currentText(); +} + +int VisuGUI_ScalarMapOnDeformedShapeDlg::getCurrentScalarNbIterations(){ + return myTimeStampsCombo->count(); +} + +VISU::TEntity VisuGUI_ScalarMapOnDeformedShapeDlg::getCurrentScalarEntity(){ + VISU::TEntity anEntity; + TFT::const_iterator aIterField = myMeshFieldsTimes[myCurrMeshName].begin(); + for(;aIterField != myMeshFieldsTimes[myCurrMeshName].end();aIterField++){ + if (aIterField->first.first == myFieldsCombo->currentText()){ + anEntity = aIterField->first.second; + break; + } + } + return anEntity; +} + +void VisuGUI_ScalarMapOnDeformedShapeDlg::SetScalarField(){ + SetScalarField(myTimeStampsCombo->currentItem()+1); +} + +void VisuGUI_ScalarMapOnDeformedShapeDlg::SetScalarField(int theIter,QString theFieldName){ + + QString aFieldName; + + if(theFieldName.isEmpty()) + aFieldName = myFieldsCombo->currentText(); + else + aFieldName = theFieldName; + + VISU::TEntity anEntity = getCurrentScalarEntity(); + + myPrs->SetScalarField(myCurrMeshName.latin1(), + aFieldName.latin1(), + theIter, + anEntity); + + myScalarPane->storeToPrsObject(myPrs); + + UpdateScalarField(); +} + +void VisuGUI_ScalarMapOnDeformedShapeDlg::accept() +{ + if (myScalarPane->check()){ + myScalarPane->deletePreview(); + QDialog::accept(); + } +} + +void VisuGUI_ScalarMapOnDeformedShapeDlg::reject() +{ + myScalarPane->deletePreview(); + QDialog::reject(); +} + +void VisuGUI_ScalarMapOnDeformedShapeDlg::AddAllFieldNames(){ + TMF::const_iterator aIterMesh = myMeshFieldsTimes.begin(); + for(;aIterMesh != myMeshFieldsTimes.end();aIterMesh++){ + QString aMeshName = aIterMesh->first; + TFT::const_iterator aIterField = (aIterMesh->second).begin(); + for(;aIterField != (aIterMesh->second).end(); aIterField++){ + QString aFieldName = aIterField->first.first; + myFieldsCombo->insertItem(aFieldName); + } + } +} + +void VisuGUI_ScalarMapOnDeformedShapeDlg::AddAllTimes(const QString& theFieldName){ + TMF::const_iterator aIterMesh = myMeshFieldsTimes.begin(); + for(;aIterMesh != myMeshFieldsTimes.end();aIterMesh++){ + QString aMeshName = aIterMesh->first; + TFT::const_iterator aIterField = (aIterMesh->second).begin(); + for(;aIterField != (aIterMesh->second).end(); aIterField++){ + QString aFieldName = aIterField->first.first; + if(theFieldName != aFieldName) continue; + myTimeStampsCombo->clear(); + TTL::const_iterator aTimeIter = (aIterField->second).begin(); + for(;aTimeIter != (aIterField->second).end(); aTimeIter++) + myTimeStampsCombo->insertItem(QString("%1").arg(aTimeIter->second)); + return; + } + } +} + +void VisuGUI_ScalarMapOnDeformedShapeDlg::onFieldChanged(int){ + AddAllTimes(myFieldsCombo->currentText()); + SetScalarField(); + UpdateScalarField(); +} + +void VisuGUI_ScalarMapOnDeformedShapeDlg::onTimeStampChanged(int){ + SetScalarField(); + UpdateScalarField(); +} + +void VisuGUI_ScalarMapOnDeformedShapeDlg::UpdateScalarField(){ + myPrs->SetScale(getFactor()); + float aRange[2]; + myPrs->GetScalarMapOnDeformedShapePL()->Build(); + myPrs->GetScalarMapOnDeformedShapePL()->Update(); + myPrs->GetScalarMapOnDeformedShapePL()->GetSourceRange(aRange); + double aDoubleRange[2]; + aDoubleRange[0] = double(aRange[0]); + aDoubleRange[1] = double(aRange[1]); + myScalarPane->initFromPrsObject(myPrs); + myScalarPane->setRange(aDoubleRange[0],aDoubleRange[1],myScalarPane->isIRange()); +} + +float VisuGUI_ScalarMapOnDeformedShapeDlg::GetFloatValueOfTimeStamp(int theIter){ + float ret=1; + VISU::PField aField = myPrs->GetField(); + VISU::TValField& aValField = aField->myValField; + VISU::PValForTime aValForTime = aValField.find(theIter)->second; + if(aValForTime) + ret = float(aValForTime->myTime.first); + return ret; +} diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h new file mode 100644 index 00000000..c49a3de1 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h @@ -0,0 +1,108 @@ +// VISU VISUGUI : GUI of VISU component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_ScalarMapOnDeformedShapeDlg.h +// Author : Eugeny Nikolaev +// Module : VISU + +#ifndef VISUGUI_SCALARMAPONDEFORMEDSHAPEDLS_H +#define VISUGUI_SCALARMAPONDEFORMEDSHAPEDLS_H + +#include "VisuGUI_ScalarBarDlg.h" + +#include "QtxDblSpinBox.h" + +#include +#include +#include +#include +#include + +#include + +class SalomeApp_Module; +class QComboBox; +class QString; + +namespace VISU{ + class ScalarMapOnDeformedShape_i; +} + +class VisuGUI_ScalarMapOnDeformedShapeDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_ScalarMapOnDeformedShapeDlg (SalomeApp_Module* theModule); + ~VisuGUI_ScalarMapOnDeformedShapeDlg() {}; + + double getFactor() + { return ScalFact->value(); } + void setFactor(double theFactor) + { ScalFact->setValue(theFactor); } + + + void initFromPrsObject(VISU::ScalarMapOnDeformedShape_i* thePrs,bool isAnim=false); + int storeToPrsObject(VISU::ScalarMapOnDeformedShape_i* thePrs,bool theUpdateScalar=true); + + int getCurrentScalarFieldNamePos(); + QString getCurrentScalarFieldName(); + int getCurrentScalarNbIterations(); + VISU::TEntity getCurrentScalarEntity(); + void SetScalarField(int theIter,QString theFieldName=QString("")); + +protected slots: + void accept(); + void reject(); + +private slots: + void onFieldChanged(int i=0); + void onTimeStampChanged(int i=0); + +private: + QtxDblSpinBox* ScalFact; + VisuGUI_ScalarBarPane* myScalarPane; + QComboBox *myFieldsCombo; + QComboBox *myTimeStampsCombo; + + typedef std::map TTL; // Times map definition (iteration time, real value of time) + typedef std::pair TFE; // pair field name and entity + typedef std::map TFT; // Field name and enity to Times + typedef std::map TMF; // Mesh to fields map + + TMF myMeshFieldsTimes; + QString myCurrMeshName; + + _PTR(SObject) mySelectionObj; + VISU::ScalarMapOnDeformedShape_i* myPrs; + SalomeApp_Module* myVisuGUI; + +protected: + void UpdateScalarField(); + void SetScalarField(); + void AddAllFieldNames(); + void AddAllTimes(const QString& theFieldName); + float GetFloatValueOfTimeStamp(int iteration); +}; + +#endif // VISUGUI_DEFORMEDSHAPEDLS_H diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 4d46d01d..2ade8740 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -18,6 +18,7 @@ #include "VisuGUI_VectorsDlg.h" #include "VisuGUI_IsoSurfacesDlg.h" #include "VisuGUI_StreamLinesDlg.h" +#include "VisuGUI_ScalarMapOnDeformedShapeDlg.h" #include "VisuGUI_GaussPointsDlg.h" #include "VISU_TimeAnimation.h" @@ -30,6 +31,7 @@ #include "VISU_CutLines_i.hh" #include "VISU_Vectors_i.hh" #include "VISU_StreamLines_i.hh" +#include "VISU_ScalarMapOnDeformedShape_i.hh" #include "VISU_GaussPoints_i.hh" #include "VISU_ViewManager_i.hh" @@ -562,7 +564,8 @@ enum PrsComboItem { TDEFORMEDSHAPE_ITEM = 4, // VISU::TDEFORMEDSHAPE TVECTORS_ITEM = 5, // VISU::TVECTORS TSTREAMLINES_ITEM = 6, // VISU::TSTREAMLINES - TGAUSSPOINTS_ITEM = 7 // VISU::TGAUSSPOINTS + TGAUSSPOINTS_ITEM = 7, // VISU::TGAUSSPOINTS + TSCALARMAPONDEFORMEDSHAPE_ITEM = 8 // VISU::TSCALARMAPONDEFORMEDSHAPE }; //------------------------------------------------------------------------ @@ -604,6 +607,11 @@ void SetupDlg::onFieldChange (int theIndex) myTypeCombo->insertItem("Stream Lines"); // item 6 myTypeId2ComboId[TSTREAMLINES_ITEM] = myComboId2TypeId.size(); myComboId2TypeId.push_back(TSTREAMLINES_ITEM);; + + myTypeCombo->insertItem("Scalar map on Deformed shape"); // item 8 + myTypeId2ComboId[TSCALARMAPONDEFORMEDSHAPE_ITEM] = myComboId2TypeId.size(); + myComboId2TypeId.push_back(TSCALARMAPONDEFORMEDSHAPE_ITEM);; + } long anEntityId = VISU::getValue(aSObject, "myEntityId").toLong(); @@ -629,6 +637,9 @@ void SetupDlg::onFieldChange (int theIndex) case VISU::TDEFORMEDSHAPE: //Deformed Shape myTypeCombo->setCurrentItem(myTypeId2ComboId[TDEFORMEDSHAPE_ITEM]); break; + case VISU::TSCALARMAPONDEFORMEDSHAPE: //Scalar Map on Deformed Shape + myTypeCombo->setCurrentItem(TSCALARMAPONDEFORMEDSHAPE_ITEM); + break; case VISU::TVECTORS: //Vectors myTypeCombo->setCurrentItem(myTypeId2ComboId[TVECTORS_ITEM]); break; @@ -663,6 +674,9 @@ void SetupDlg::onTypeChanged (int theIndex) case TDEFORMEDSHAPE_ITEM: //Deformed Shape aData.myPrsType = VISU::TDEFORMEDSHAPE; break; + case TSCALARMAPONDEFORMEDSHAPE_ITEM: //Scalar Map on Deformed Shape + aData.myPrsType = VISU::TSCALARMAPONDEFORMEDSHAPE; + break; case TVECTORS_ITEM: //Vectors aData.myPrsType = VISU::TVECTORS; break; @@ -695,7 +709,8 @@ namespace delete aDlg; } } - + + void SetupDlg::onPreferencesDlg() { SUIT_OverrideCursor c; @@ -725,6 +740,28 @@ void SetupDlg::onPreferencesDlg() c.suspend(); EditPrs(myModule,aData); break; + case TSCALARMAPONDEFORMEDSHAPE_ITEM: //Scalar Map on Deformed Shape + c.suspend(); + { + typedef VisuGUI_ScalarMapOnDeformedShapeDlg DLG; + typedef VISU::ScalarMapOnDeformedShape_i TYPE; + DLG* aDlg = new DLG (myModule); + aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0]),true); + if (aDlg->exec()) + { + int anbFrames=aDlg->getCurrentScalarNbIterations(); + for (int i = 0; i < aData.myNbFrames; i++){ + TYPE* aCurrPrs_i = dynamic_cast(aData.myPrs[i]); + if(i+1 > anbFrames) + aDlg->SetScalarField(anbFrames); + else + aDlg->SetScalarField(i+1); + aDlg->storeToPrsObject(aCurrPrs_i,false); + } + } + delete aDlg; + } + break; case TVECTORS_ITEM: //Vectors c.suspend(); EditPrs(myModule,aData); diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index b59e97ca..1259dbee 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -1319,6 +1319,7 @@ namespace VISU case VISU::TVECTORS: case VISU::TSTREAMLINES: case VISU::TPLOT3D: + case VISU::TSCALARMAPONDEFORMEDSHAPE: { PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject); if (aServant.in()) { diff --git a/src/VISU_I/Makefile.in b/src/VISU_I/Makefile.in index 68d8f5cb..20168853 100644 --- a/src/VISU_I/Makefile.in +++ b/src/VISU_I/Makefile.in @@ -40,7 +40,8 @@ LIB_SRC = \ VISU_View_i.cc \ VISU_TimeAnimation.cxx \ VISU_CorbaMedConvertor.cxx \ - VISU_DumpPython.cc + VISU_DumpPython.cc \ + VISU_ScalarMapOnDeformedShape_i.cc LIB_MOC = \ VISU_TimeAnimation.h @@ -84,7 +85,8 @@ EXPORT_HEADERS = \ VISU_GaussPoints_i.hh \ VISU_ViewManager_i.hh \ VISU_View_i.hh \ - VISU_TimeAnimation.h + VISU_TimeAnimation.h \ + VISU_ScalarMapOnDeformedShape_i.hh # additionnal information to compil and link file CPPFLAGS += \ diff --git a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc new file mode 100644 index 00000000..116c8a32 --- /dev/null +++ b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc @@ -0,0 +1,265 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// File : VISU_ScalarMapOnDeformedShape_i.cc +// Author : Eugeny Nikolaev +// Module : VISU + +#include "VISU_ScalarMapOnDeformedShapePL.hxx" +#include "VISU_Result_i.hh" +#include "VISU_ScalarMap_i.hh" +#include "VISU_ScalarMapOnDeformedShape_i.hh" +#include "VISU_Convertor.hxx" +#include "VISU_Actor.h" +#include "VISU_ScalarMapAct.h" + +#include + +using namespace VISU; +using namespace std; + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +static int INCMEMORY = 4+12; + +int VISU::ScalarMapOnDeformedShape_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, int theIteration, int isMemoryCheck) +{ + bool aResult = false; + try{ + aResult = VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,false); + if(isMemoryCheck && aResult){ + float aSize = INCMEMORY* + theResult->GetInput()->GetTimeStampSize(theMeshName,(VISU::TEntity)theEntity,theFieldName,theIteration); + aResult = VISU_PipeLine::CheckAvailableMemory(aSize); + MESSAGE("ScalarMapOnDeformedShape_i::IsPossible - CheckAvailableMemory = "<GetStudyDocument()), + Prs3d_i(theResult,theAddToStudy), + ColoredPrs3d_i(theResult,theAddToStudy), + ScalarMap_i(theResult,theAddToStudy), + myScalarMapOnDeformedShapePL(NULL), + myScalarIteration(1) +{ +} + +VISU::ScalarMapOnDeformedShape_i:: +ScalarMapOnDeformedShape_i(Result_i* theResult, + SALOMEDS::SObject_ptr theSObject) : + PrsObject_i(theResult->GetStudyDocument()), + Prs3d_i(theResult,theSObject), + ColoredPrs3d_i(theResult,theSObject), + ScalarMap_i(theResult,theSObject), + myScalarMapOnDeformedShapePL(NULL), + myScalarIteration(1) +{ +} + +VISU::Storable* VISU::ScalarMapOnDeformedShape_i::Create(const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, int theIteration) +{ + myIsColored = true; + myColor.R = myColor.G = myColor.B = 0.5; + VISU::Storable* aRes = TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration); + SetScalarFieldName(theFieldName); + SetScalarIteration(theIteration); + SetScalarMeshName(theMeshName); + int anEntity = theEntity; + SetScalarEntity(VISU::TEntity(anEntity)); + SetScalarField(myScalarMeshName.c_str(),myScalarFieldName.c_str(),myScalarIteration,myScalarEntity); + return aRes; +} + +VISU::Storable* VISU::ScalarMapOnDeformedShape_i::Restore(const Storable::TRestoringMap& theMap) +{ + TSuperClass::Restore(theMap); + + SetScalarFieldName(VISU::Storable::FindValue(theMap,"myScalarFieldName")); + SetScalarMeshName(VISU::Storable::FindValue(theMap,"myScalarMeshName")); + SetScalarIteration(VISU::Storable::FindValue(theMap,"myScalarIteration").toInt()); + SetScalarEntity(VISU::TEntity(VISU::Storable::FindValue(theMap,"myScalarEntity").toInt())); + SetScalarField(GetScalarFieldName().c_str(), + GetScalarFieldName().c_str(), + GetScalarIteration(), + GetScalarEntity()); + + SetScale(VISU::Storable::FindValue(theMap,"myFactor").toDouble()); + myIsColored = VISU::Storable::FindValue(theMap,"myIsColored").toInt(); + myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble(); + myColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble(); + myColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble(); + + return this; +} + +void VISU::ScalarMapOnDeformedShape_i::ToStream(std::ostringstream& theStr) +{ + TSuperClass::ToStream(theStr); + + Storable::DataToStream( theStr, "myScalarFieldName", myScalarFieldName.c_str()); + Storable::DataToStream( theStr, "myScalarMeshName", myScalarMeshName.c_str()); + Storable::DataToStream( theStr, "myScalarIteration", myScalarIteration); + Storable::DataToStream( theStr, "myScalarEntity", int(myScalarEntity)); + + Storable::DataToStream( theStr, "myFactor", GetScale() ); + Storable::DataToStream( theStr, "myIsColored", myIsColored ); + Storable::DataToStream( theStr, "myColor.R", myColor.R ); + Storable::DataToStream( theStr, "myColor.G", myColor.G ); + Storable::DataToStream( theStr, "myColor.B", myColor.B ); + +} + +VISU::ScalarMapOnDeformedShape_i::~ScalarMapOnDeformedShape_i(){ + if(MYDEBUG) MESSAGE("ScalarMapOnDeformedShape_i::~ScalarMapOnDeformedShape_i()"); +} + +void VISU::ScalarMapOnDeformedShape_i::SetScale(CORBA::Double theScale) { + myScalarMapOnDeformedShapePL->SetScale(theScale); +} + +CORBA::Double VISU::ScalarMapOnDeformedShape_i::GetScale(){ + return myScalarMapOnDeformedShapePL->GetScale(); +} + +void VISU::ScalarMapOnDeformedShape_i::SetSourceRange(CORBA::Double theMinRange,CORBA::Double theMaxRange){ + float aRange[2]; + aRange[0] = float(theMinRange); + aRange[1] = float(theMaxRange); + myScalarMapOnDeformedShapePL->SetScalarRange(aRange); +} + +CORBA::Double VISU::ScalarMapOnDeformedShape_i::GetSourceRangeMin(){ + float aRange[2]; + myScalarMapOnDeformedShapePL->GetSourceRange(aRange); + return aRange[0]; +} + +CORBA::Double VISU::ScalarMapOnDeformedShape_i::GetSourceRangeMax(){ + float aRange[2]; + myScalarMapOnDeformedShapePL->GetSourceRange(aRange); + return aRange[1]; +} + +void VISU::ScalarMapOnDeformedShape_i::DoHook() +{ + if(!myPipeLine) + myPipeLine = VISU_ScalarMapOnDeformedShapePL::New(); + + myScalarMapOnDeformedShapePL = dynamic_cast(myPipeLine); + myPipeLine->GetMapper()->SetScalarVisibility(IsColored()); + + TSuperClass::DoHook(); +} + +VISU_Actor* VISU::ScalarMapOnDeformedShape_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) +{ + VISU_Actor* anActor = TSuperClass::CreateActor(theIO); + anActor->SetRepresentation(2); + anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B); + anActor->SetVTKMapping(false); + return anActor; +} + + +void VISU::ScalarMapOnDeformedShape_i::UpdateActor(VISU_Actor* theActor) { + if(VISU_ScalarMapAct* anActor = dynamic_cast(theActor)){ + if(IsColored()){ + anActor->SetBarVisibility(true); + myPipeLine->GetMapper()->SetScalarVisibility(1); + }else{ + anActor->SetBarVisibility(false); + myPipeLine->GetMapper()->SetScalarVisibility(0); + anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B); + } + TSuperClass::UpdateActor(theActor); + } +} + +void VISU::ScalarMapOnDeformedShape_i::SetScalarField(const char* theMeshName, + const char* theFieldName, + const int theIteration, + const VISU::TEntity theEntity) +{ + if (myScalarMapOnDeformedShapePL){ + myField = myResult->GetInput()->GetField(theMeshName,theEntity,theFieldName); + TVTKOutput* aOut = myResult->GetInput()->GetTimeStampOnMesh(theMeshName, + theEntity, + theFieldName, + theIteration)->GetVTKOutput(); + myScalarMapOnDeformedShapePL->SetScalars(aOut); + + SetScalarMeshName(theMeshName); + SetScalarFieldName(theFieldName); + SetScalarIteration(theIteration); + SetScalarEntity(theEntity); + } +} + + +void VISU::ScalarMapOnDeformedShape_i::SetScalarMeshName(const char* theName){ + myScalarMeshName = theName; +} +std::string VISU::ScalarMapOnDeformedShape_i::GetScalarMeshName(){ + return myScalarMeshName; +} + +void VISU::ScalarMapOnDeformedShape_i::SetScalarFieldName(const char* theName){ + myScalarFieldName = theName; +} +std::string VISU::ScalarMapOnDeformedShape_i::GetScalarFieldName(){ + return myScalarFieldName; +} + +void VISU::ScalarMapOnDeformedShape_i::SetScalarIteration(const int theValue){ + myScalarIteration = theValue; +} +int VISU::ScalarMapOnDeformedShape_i::GetScalarIteration(){ + return myScalarIteration; +} + +void VISU::ScalarMapOnDeformedShape_i::SetScalarEntity(const VISU::TEntity theValue){ + myScalarEntity = theValue; +} +VISU::TEntity VISU::ScalarMapOnDeformedShape_i::GetScalarEntity(){ + return myScalarEntity; +} diff --git a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh new file mode 100644 index 00000000..6cfd5afc --- /dev/null +++ b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh @@ -0,0 +1,129 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// File: VISU_ScalarMapOnDeformedShape_i.hh +// Author: Eugeny Nikolaev +// Module : VISU + +#ifndef VISU_ScalarMapOnDeformedShape_i_HeaderFile +#define VISU_ScalarMapOnDeformedShape_i_HeaderFile + +#include "VISU_ScalarMap_i.hh" + +class VISU_ScalarMapOnDeformedShapePL; + +namespace VISU{ + + //! Class of Scalar Map on Deformed Shape presentation. + class ScalarMapOnDeformedShape_i : public virtual POA_VISU::ScalarMapOnDeformedShape, + public virtual ScalarMap_i + { + static int myNbPresent; + ScalarMapOnDeformedShape_i(); + ScalarMapOnDeformedShape_i(const ScalarMapOnDeformedShape_i&); + + public: + + typedef ScalarMap_i TSuperClass; + + explicit + ScalarMapOnDeformedShape_i(Result_i* theResult, + bool theAddToStudy); + explicit + ScalarMapOnDeformedShape_i(Result_i* theResult, + SALOMEDS::SObject_ptr theSObject); + + virtual ~ScalarMapOnDeformedShape_i(); + + virtual VISU::VISUType GetType() + { + return VISU::TSCALARMAPONDEFORMEDSHAPE; + }; + + typedef VISU::ScalarMapOnDeformedShape TInterface; + + virtual void SetScale(CORBA::Double theScale); + virtual CORBA::Double GetScale(); + + virtual CORBA::Boolean IsColored() { return myIsColored; } + virtual void ShowColored(CORBA::Boolean theColored) { myIsColored = theColored; } + + virtual SALOMEDS::Color GetColor() { return myColor;} + virtual void SetColor(const SALOMEDS::Color& theColor) { myColor = theColor;} + + virtual void SetSourceRange(CORBA::Double theMinRange,CORBA::Double theMaxRange); + virtual CORBA::Double GetSourceRangeMin(); + virtual CORBA::Double GetSourceRangeMax(); + + VISU_ScalarMapOnDeformedShapePL* GetScalarMapOnDeformedShapePL(){ return myScalarMapOnDeformedShapePL;} + + protected: + + virtual + void + DoHook(); + + VISU_ScalarMapOnDeformedShapePL *myScalarMapOnDeformedShapePL; + SALOMEDS::Color myColor; + bool myIsColored; + std::string myScalarMeshName; + std::string myScalarFieldName; + VISU::TEntity myScalarEntity; + int myScalarIteration; + + public: + static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, int theIteration, int isMemoryCheck = true); + virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, int theIteration); + + virtual void ToStream(std::ostringstream& theStr); + + virtual Storable* Restore(const Storable::TRestoringMap& theMap); + + static Storable* Restore(SALOMEDS::SObject_ptr theSObject, + const std::string& thePrefix, const Storable::TRestoringMap& theMap); + + static const std::string myComment; + virtual const char* GetComment() const; + virtual QString GenerateName(); + + virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL); + + virtual void UpdateActor(VISU_Actor* theActor) ; + + virtual void SetScalarField(const char* theMeshName, + const char* theFieldName, + const int theIteration, + const VISU::TEntity theEntity); + + virtual void SetScalarFieldName(const char* theName); + virtual std::string GetScalarFieldName(); + virtual void SetScalarIteration(const int theValue); + virtual int GetScalarIteration(); + virtual void SetScalarMeshName(const char* theName); + virtual std::string GetScalarMeshName(); + virtual void SetScalarEntity(const VISU::TEntity theValue); + virtual VISU::TEntity GetScalarEntity(); + }; +} +#endif diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index ff511dba..22733a95 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -16,6 +16,7 @@ #include "VISU_ScalarMap_i.hh" #include "VISU_IsoSurfaces_i.hh" #include "VISU_DeformedShape_i.hh" +#include "VISU_ScalarMapOnDeformedShape_i.hh" #include "VISU_CutPlanes_i.hh" #include "VISU_Plot3D_i.hh" #include "VISU_CutLines_i.hh" @@ -260,6 +261,9 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { case VISU::TGAUSSPOINTS: // Gauss Points GeneratePresentations(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal); break; + case VISU::TSCALARMAPONDEFORMEDSHAPE: // Scalar map on deformed shape + GeneratePresentations(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal); + break; default: MESSAGE("Not implemented for this presentation type: " << aData.myPrsType); return; @@ -665,6 +669,9 @@ std::string GetPresentationComment (VISU::VISUType thePrsType) case VISU::TGAUSSPOINTS: aPrsCmt = VISU::GaussPoints_i::myComment; break; + case VISU::TSCALARMAPONDEFORMEDSHAPE: + aPrsCmt = VISU::ScalarMapOnDeformedShape_i::myComment; + break; default: aPrsCmt = "Unknown presentation"; break; @@ -831,6 +838,8 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField) aData.myPrsType = VISU::TSTREAMLINES; else if (strName == VISU::GaussPoints_i::myComment.c_str()) aData.myPrsType = VISU::TGAUSSPOINTS; + else if (strName == VISU::ScalarMapOnDeformedShape_i::myComment.c_str()) + aData.myPrsType = VISU::TSCALARMAPONDEFORMEDSHAPE; else continue; generatePresentations(getNbFields()-1); -- 2.39.2