From: vsr Date: Fri, 25 Jul 2008 12:25:54 +0000 (+0000) Subject: Merge from V4_1_0_maintainance branch (from tag mergeto_BR_QT4_Dev_08Jul08) X-Git-Tag: before_mergefrom_V4_1_0_maintainance_29Jul08 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4922083dfe43efd741e1b34d52a84546ab820802;p=modules%2Fvisu.git Merge from V4_1_0_maintainance branch (from tag mergeto_BR_QT4_Dev_08Jul08) --- diff --git a/doc/salome/gui/VISU/images/cutplanes.png b/doc/salome/gui/VISU/images/cutplanes.png index 579332ac..03f972aa 100644 Binary files a/doc/salome/gui/VISU/images/cutplanes.png and b/doc/salome/gui/VISU/images/cutplanes.png differ diff --git a/doc/salome/gui/VISU/images/deformedshape.png b/doc/salome/gui/VISU/images/deformedshape.png index aea06271..e196d395 100644 Binary files a/doc/salome/gui/VISU/images/deformedshape.png and b/doc/salome/gui/VISU/images/deformedshape.png differ diff --git a/doc/salome/gui/VISU/images/smds1.png b/doc/salome/gui/VISU/images/smds1.png index 24c5feda..f74008d4 100644 Binary files a/doc/salome/gui/VISU/images/smds1.png and b/doc/salome/gui/VISU/images/smds1.png differ diff --git a/doc/salome/gui/VISU/images/table.png b/doc/salome/gui/VISU/images/table.png new file mode 100644 index 00000000..473aeff1 Binary files /dev/null and b/doc/salome/gui/VISU/images/table.png differ diff --git a/doc/salome/gui/VISU/images/table3d.png b/doc/salome/gui/VISU/images/table3d.png new file mode 100644 index 00000000..1b199906 Binary files /dev/null and b/doc/salome/gui/VISU/images/table3d.png differ diff --git a/doc/salome/gui/VISU/images/tablesn1.png b/doc/salome/gui/VISU/images/tablesn1.png new file mode 100644 index 00000000..4db643e3 Binary files /dev/null and b/doc/salome/gui/VISU/images/tablesn1.png differ diff --git a/doc/salome/gui/VISU/images/tablesn2.png b/doc/salome/gui/VISU/images/tablesn2.png new file mode 100644 index 00000000..4b3b85d1 Binary files /dev/null and b/doc/salome/gui/VISU/images/tablesn2.png differ diff --git a/doc/salome/gui/VISU/input/calar_map_on_deformed_shape.doc b/doc/salome/gui/VISU/input/calar_map_on_deformed_shape.doc index 0ec95fb5..bc7ea730 100644 --- a/doc/salome/gui/VISU/input/calar_map_on_deformed_shape.doc +++ b/doc/salome/gui/VISU/input/calar_map_on_deformed_shape.doc @@ -1,30 +1,30 @@ /*! -\page scalar_map_on_deformed_shape_page Scalar Map on Deformed Shape presentation +\page scalar_map_on_deformed_shape_page Deformed Shape and Scalar Map presentation -\n Scalar Map on Deformed Shape presentation is a mix of the +\n Deformed Shape and Scalar Map presentation is a mix of the two: \ref scalar_map_page "Scalar Map" and \ref deformed_shape_page "Deformed Shape". In this presentation the Scalar Map is built on a Deformed Shape. -To create a Scalar Map on Deformed Shape presentation: +To create a Deformed Shape and Scalar Map presentation: \par – Right-click on one of the time stamps of the field in the -Object browser and from the pop-up menu choose Scalar Map on -Deformed Shape, or +Object browser and from the pop-up menu choose Deformed Shape and +Scalar Map, or \n – Click on one of the time stamps of the field in the Object -browser and select from the main menu Visualization > Scalar Map on -Deformed Shape, or click "Scalar Map on Deformed Shape" +browser and select from the main menu Visualization > Deformed Shape and +Scalar Map, or click "Deformed Shape and Scalar Map" icon in the Visualization Toolbar. \image html image40.gif -
"Scalar Map on Deformed Shape" icon
+
"Deformed Shape and Scalar Map" icon
\image html smds1.png \par -Scalar Map on Deformed Shape tab allows you to set additional -parameters of your Scalar Map on Deformed Shape presentation: +Deformed Shape and Scalar Map tab allows you to set additional +parameters of your Deformed Shape and Scalar Map presentation: @@ -48,4 +52,4 @@ the viewer: \image html cutplpresent.png -*/ \ 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 e82b2bc7..402f3a69 100644 --- a/doc/salome/gui/VISU/input/index.doc +++ b/doc/salome/gui/VISU/input/index.doc @@ -51,6 +51,7 @@
  • \ref importing_exporting_tables_page
  • \ref displaying_tables_page
  • \ref creating_tables_from_cut_lines_page
  • +
  • \ref table_3d_page
  • \subpage xy_plots_page
  • */ \ No newline at end of file diff --git a/doc/salome/gui/VISU/pics/smds1.png b/doc/salome/gui/VISU/pics/smds1.png index 24c5feda..f74008d4 100755 Binary files a/doc/salome/gui/VISU/pics/smds1.png and b/doc/salome/gui/VISU/pics/smds1.png differ diff --git a/doc/salome/gui/VISU/visugenidl_doc/VISU__Gen_8idl.html b/doc/salome/gui/VISU/visugenidl_doc/VISU__Gen_8idl.html index 5d34130d..25789b67 100644 --- a/doc/salome/gui/VISU/visugenidl_doc/VISU__Gen_8idl.html +++ b/doc/salome/gui/VISU/visugenidl_doc/VISU__Gen_8idl.html @@ -74,7 +74,7 @@ Include dependency graph for VISU_Gen.idl:

     Deformed shape presentation interface. More...
    interface  VISU.ScalarMapOnDeformedShape - Scalar Map on Deformed shape presentation interface. More...
    + Deformed shape and Scalar Map presentation interface. More...
    interface  VISU.Plot3D  Plot3D interface. More...
    diff --git a/doc/salome/gui/VISU/visugenidl_doc/interfaceVISU_1_1ScalarMapOnDeformedShape.html b/doc/salome/gui/VISU/visugenidl_doc/interfaceVISU_1_1ScalarMapOnDeformedShape.html index 878345b4..79095052 100644 --- a/doc/salome/gui/VISU/visugenidl_doc/interfaceVISU_1_1ScalarMapOnDeformedShape.html +++ b/doc/salome/gui/VISU/visugenidl_doc/interfaceVISU_1_1ScalarMapOnDeformedShape.html @@ -14,7 +14,7 @@ -

    VISU.ScalarMapOnDeformedShape Interface Reference

    Scalar Map on Deformed shape presentation interface. +

    VISU.ScalarMapOnDeformedShape Interface Reference

    Deformed shape and Scalar Map presentation interface. More...

    import "VISU_Gen.idl"; diff --git a/doc/salome/gui/VISU/visugenidl_doc/namespaceVISU.html b/doc/salome/gui/VISU/visugenidl_doc/namespaceVISU.html index 9543044b..8de0ca8a 100644 --- a/doc/salome/gui/VISU/visugenidl_doc/namespaceVISU.html +++ b/doc/salome/gui/VISU/visugenidl_doc/namespaceVISU.html @@ -60,7 +60,7 @@  Deformed shape presentation interface. More...
    interface  ScalarMapOnDeformedShape - Scalar Map on Deformed shape presentation interface. More...
    + Deformed shape and Scalar Map presentation interface. More...
    interface  Plot3D  Plot3D interface. More...
    diff --git a/doc/salome/gui/VISU/whdata/whftdata0.htm b/doc/salome/gui/VISU/whdata/whftdata0.htm index eae6a624..5acacd5e 100755 --- a/doc/salome/gui/VISU/whdata/whftdata0.htm +++ b/doc/salome/gui/VISU/whdata/whftdata0.htm @@ -49,7 +49,7 @@ aTE("Plot2D Viewer","plot2d_viewer.htm"); aTE("Plot 3D presentation","plot_3d_presentation.htm"); aTE("Primitive Types","primitive_types.htm"); aTE("Scalar Bar","scalar_bar.htm"); -aTE("Scalar Map on Deformed Shape presentation","scalar_map_on_deformed_shape_presentation.htm"); +aTE("Deformed Shape and Scalar Map presentation","scalar_map_on_deformed_shape_presentation.htm"); aTE("Segmentation","segmentation.htm"); aTE("Types of Gauss Points Presentations","types_of_gauss_points_presentations.htm"); aTE("VTK 3D Viewer","vtk_3d_viewer.htm"); diff --git a/doc/salome/gui/VISU/whdata/whtdata0.htm b/doc/salome/gui/VISU/whdata/whtdata0.htm index fe3b5c79..67da6bc2 100755 --- a/doc/salome/gui/VISU/whdata/whtdata0.htm +++ b/doc/salome/gui/VISU/whdata/whtdata0.htm @@ -24,7 +24,7 @@ aTE(2,0,"Deformed Shape presentation","files/deformed_shape_presentation.htm"); aTE(2,0,"Vectors Presentation","files/vectors_presentation.htm"); aTE(2,0,"Stream Lines presentation","files/stream_lines_presentation.htm"); - aTE(2,0,"Scalar Map on Deformed Shape presentation","scalar_map_on_deformed_shape_presentation.htm"); + aTE(2,0,"Deformed Shape and Scalar Map presentation","scalar_map_on_deformed_shape_presentation.htm"); aTE(2,0,"Plot 3D presentation","plot_3d_presentation.htm"); aTE(2,0,"Animating presentations","files/animating_presentations.htm"); aTE(1,9,"Gauss Points Presentations"); diff --git a/doc/salome/gui/VISU/whgdata/whlstt3.htm b/doc/salome/gui/VISU/whgdata/whlstt3.htm index d960e94d..56224cc4 100755 --- a/doc/salome/gui/VISU/whgdata/whlstt3.htm +++ b/doc/salome/gui/VISU/whgdata/whlstt3.htm @@ -53,7 +53,7 @@ img {vertial-align:middle;}           Deformed Shape presentation
              Vectors Presentation
              Stream Lines presentation
    -          Scalar Map on Deformed Shape presentation
    +          Deformed Shape and Scalar Map presentation
              Plot 3D presentation
              Animating presentations
              Gauss Points Presentations
    diff --git a/doc/salome/gui/VISU/whgdata/whlstt4.htm b/doc/salome/gui/VISU/whgdata/whlstt4.htm index 253afb61..49593c24 100755 --- a/doc/salome/gui/VISU/whgdata/whlstt4.htm +++ b/doc/salome/gui/VISU/whgdata/whlstt4.htm @@ -53,7 +53,7 @@ img {vertial-align:middle;}           Deformed Shape presentation
              Vectors Presentation
              Stream Lines presentation
    -          Scalar Map on Deformed Shape presentation
    +          Deformed Shape and Scalar Map presentation
              Plot 3D presentation
              Animating presentations
              Gauss Points Presentations
    diff --git a/doc/salome/gui/VISU/whxdata/whftdata0.xml b/doc/salome/gui/VISU/whxdata/whftdata0.xml index 18b3f31d..37c3d337 100755 --- a/doc/salome/gui/VISU/whxdata/whftdata0.xml +++ b/doc/salome/gui/VISU/whxdata/whftdata0.xml @@ -37,7 +37,7 @@ - + diff --git a/doc/salome/gui/VISU/whxdata/whtdata0.xml b/doc/salome/gui/VISU/whxdata/whtdata0.xml index 14a0dff2..13b3a715 100755 --- a/doc/salome/gui/VISU/whxdata/whtdata0.xml +++ b/doc/salome/gui/VISU/whxdata/whtdata0.xml @@ -16,7 +16,7 @@ - + diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index d1b5c73e..36b383b4 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -78,7 +78,8 @@ module VISU { TSCALARMAP, /*!< Scalarmap 3D presentation object */ TISOSURFACES, /*!< Iso surface 3D presentation object */ TDEFORMEDSHAPE, /*!< Deformed shape 3D presentation object */ - TSCALARMAPONDEFORMEDSHAPE, /*!< Scalar map on deformed shape 3D presentation object */ + TSCALARMAPONDEFORMEDSHAPE, /*!< Scalar map on deformed shape 3D presentation object. It is obsolete. Use TDEFORMEDSHAPEANDSCALARMAP instead */ + TDEFORMEDSHAPEANDSCALARMAP, /*!< Deformed shape and scalar map 3D presentation object */ TGAUSSPOINTS, /*!< Gauss Points 3D presentation object */ TPLOT3D, /*!< Plot3D 3D presentation object */ TPOINTMAP3D, /*!< 3D presentation for table object */ @@ -824,22 +825,12 @@ module VISU { long GetFaceLimit(); }; - /*! \brief Deformed shape presentation interface + + /*! \brief MonoColor presentation presentation interface * - * Presentation parameters of the deformed shape presentation. + * Presentation parameters of the MonoColor presentation. */ - interface DeformedShape : ScalarMap - { - /*! - * 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(); + interface MonoColorPrs : ScalarMap { /*! This boolean method returns True if this deformed shape presentation is colored. */ @@ -864,12 +855,87 @@ module VISU { }; + /*! \brief Deformed shape presentation interface + * + * Presentation parameters of the deformed shape presentation. + */ + interface DeformedShape : MonoColorPrs + { + /*! + * 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 Deformation interface + * + * This is base interface for building of the deformed presentations + */ + interface Deformation{ + /*! + * 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(); + + /*! + * Sets the vectorial field + * \param theEntity - entity of vectorial field + * \param theFieldName - the name of vectorial field + */ + void SetVectorialField(in Entity theEntity, + in string theFieldName); + + /*! + * Get vectorial entity + */ + Entity GetVectorialFieldEntity(); + + /*! + * Get scalar field name + */ + string GetVectorialFieldName(); + + }; + + //------------------------------------------------------- + /*! \brief OptionalDeformation interface + * + * This is interface for switch on/off of the deformation of the presentation + */ + interface OptionalDeformation : Deformation{ + + /*! + * Sets the deformation flag of the presentatable object. + * \param theFlag Boolean value defining the deformation flag of this presentable object. + */ + void UseDeformation(in boolean theFlag); + + /*! + * Gets the deformation flag of the presentatable object. + */ + boolean IsDeformed(); + }; + //------------------------------------------------------- /*! \brief Scalar Map on Deformed shape presentation interface * * Presentation parameters of the scalar map on deformed shape presentation. */ - interface ScalarMapOnDeformedShape : ScalarMap { + interface DeformedShapeAndScalarMap : ScalarMap { /*! * Sets the scale of the presentatable object. @@ -1079,7 +1145,7 @@ module VISU { * consists of cutting your initial mesh by a definite number of planes. As the * result you will see these planes which will be cutted by the borders of the mesh. */ - interface CutPlanes : ScalarMap { + interface CutPlanes : ScalarMap, OptionalDeformation { /*! * This enumeration contains a set of elements defining the type of orientation in 3D space * of the cut planes. @@ -1342,7 +1408,7 @@ module VISU { * Streamlines are used to convey the structure of a vector field. * Usually streamlines are created to explore the most interesting features in the field. */ - interface StreamLines : DeformedShape { + interface StreamLines : MonoColorPrs { /*! This enumerations contains a set of elements necessary * for definition of direction of the stream lines. */ @@ -1412,7 +1478,7 @@ module VISU { * values on the cells and on the basis of them constructs * isobaric surfaces, which form this presentation. */ - interface IsoSurfaces : ScalarMap { + interface IsoSurfaces : MonoColorPrs { /*! * Sets the number of isometric surfaces. * \param theNb A long value defining the number of isometric surfaces @@ -1424,6 +1490,22 @@ module VISU { * Gets the number of isometric surfaces */ long GetNbSurfaces(); + + /*! + * Returns TRUE if labels with values are shown + */ + boolean IsLabeled(); + + /*! + * Set show or not value labels + */ + void ShowLabels(in boolean theShow, in long theNb); + + /*! + * Returns Nb of labels per surface + */ + long GetNbLabels(); + }; //------------------------------------------------------- @@ -1986,6 +2068,18 @@ module VISU { in Entity theEntity, in string theFieldName, in long theTimeStampNumber); + /*! + * Creates a deformed shape presentation. This function is obsolete. Use DeformedShapeAndScalarMapOnField instead. + * \param theResult Data generated in other sources. (MED object or file) + * \param theMeshName One of the meshes presented in MED file + * \param theEntity Type of entity where the field is defined + * \param theFieldName Group of data attributed to the %MESH. The data can be scalar or vector. + * \param theTimeStampNumber Number of iteration on the field + */ + DeformedShapeAndScalarMap ScalarMapOnDeformedShapeOnField(in Result theResult, in string theMeshName, + in Entity theEntity, in string theFieldName, + in long theTimeStampNumber); + /*! * Creates a deformed shape presentation. * \param theResult Data generated in other sources. (MED object or file) @@ -1994,9 +2088,9 @@ module VISU { * \param theFieldName Group of data attributed to the %MESH. The data can be scalar or vector. * \param theTimeStampNumber Number of iteration on the field */ - ScalarMapOnDeformedShape ScalarMapOnDeformedShapeOnField(in Result theResult, in string theMeshName, - in Entity theEntity, in string theFieldName, - in long theTimeStampNumber); + DeformedShapeAndScalarMap DeformedShapeAndScalarMapOnField(in Result theResult, in string theMeshName, + in Entity theEntity, in string theFieldName, + in long theTimeStampNumber); /*! * Creates a vector presentation. diff --git a/src/CONVERTOR/Makefile.am b/src/CONVERTOR/Makefile.am index 1f377fb6..3953664f 100644 --- a/src/CONVERTOR/Makefile.am +++ b/src/CONVERTOR/Makefile.am @@ -28,6 +28,7 @@ lib_LTLIBRARIES = libVisuConvertor.la salomeinclude_HEADERS= \ VISU_TypeList.hxx \ + VISU_VTKTypeList.hxx \ VISU_IDMapper.hxx \ VISU_ConvertorDef.hxx \ VISU_Structures.hxx \ @@ -35,6 +36,7 @@ salomeinclude_HEADERS= \ VISU_ConvertorDef_impl.hxx \ VISU_Structures_impl.hxx \ VISU_MeshValue.hxx \ + VISU_ElnoMeshValue.hxx \ VISU_PointCoords.hxx \ VISU_Convertor_impl.hxx \ VISU_ConvertorUtils.hxx \ diff --git a/src/CONVERTOR/VISUConvertor.cxx b/src/CONVERTOR/VISUConvertor.cxx index db268df7..c2b748e2 100644 --- a/src/CONVERTOR/VISUConvertor.cxx +++ b/src/CONVERTOR/VISUConvertor.cxx @@ -42,6 +42,8 @@ #include +#include "utilities.h" + using namespace std; #ifdef DEBUG @@ -102,7 +104,7 @@ void ParseMEDFile(const char* theFileName) vtkDataSet* aDataSet = aGaussMesh->GetOutput(); aDataSet->Update(); int aNbCells = aDataSet->GetNumberOfCells(); - cout<<"aNbCells = "<GetNodeVTKID(anObjID.first)<GetElemObjID(anCellId); aVTKID = anIDMapper->GetElemVTKID(anObjID); - cout< 1 || IsMergingInputs() || IsMappingInputs()) + if( IsMergingInputs() || IsMappingInputs() ) anIsExecuted = VISU::UnstructuredGridRequestData(theInputVector, - this->GetNumberOfInputConnections(0), + GetNumberOfInputConnections( 0 ), theOutputVector, GetSharedPointSet(), IsMergingInputs(), IsMappingInputs()); - if(!anIsExecuted) + if( !anIsExecuted ) anIsExecuted = Superclass::RequestData(theRequest, theInputVector, theOutputVector); diff --git a/src/CONVERTOR/VISU_AppendFilterUtilities.cxx b/src/CONVERTOR/VISU_AppendFilterUtilities.cxx index 3294684d..4ff6233c 100644 --- a/src/CONVERTOR/VISU_AppendFilterUtilities.cxx +++ b/src/CONVERTOR/VISU_AppendFilterUtilities.cxx @@ -191,14 +191,33 @@ namespace bool theIsMergingInputs, bool theIsMappingInputs) { - if(theSharedPointSet){ + if ( theNumberOfInputConnections == 1 ) { + // get the input and ouptut + vtkDataSet *anInput = VISU::GetInput( theInputVector, 0 ); + vtkDataSet* anOutput = VISU::GetOutput( theOutputVector ); + + if ( anInput->GetDataObjectType() != anOutput->GetDataObjectType() ) + return false; + + // This has to be here because it initialized all field datas. + anOutput->CopyStructure( anInput ); + + // Pass all. (data object's field data is passed by the + // superclass after this method) + anOutput->GetPointData()->PassData( anInput->GetPointData() ); + anOutput->GetCellData()->PassData( anInput->GetCellData() ); + + return true; + } + + if ( theSharedPointSet ) { vtkPoints* aPoints = theSharedPointSet->GetPoints(); if(aPoints->GetNumberOfPoints() < 1) return true; TDataSet* anOutput = TDataSet::SafeDownCast(VISU::GetOutput(theOutputVector)); vtkIdType anNbInputs = theNumberOfInputConnections; - if(theIsMergingInputs){ + if ( theIsMergingInputs ) { TCellIdMerger aFunctor(anNbInputs); ForEachInput(theInputVector, anNbInputs, aFunctor); diff --git a/src/CONVERTOR/VISU_ConvertorUtils.cxx b/src/CONVERTOR/VISU_ConvertorUtils.cxx index a4cee79f..9a2dd969 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.cxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.cxx @@ -233,6 +233,23 @@ namespace VISU return aDataSetAttributes->GetArray("VISU_FIELD") != NULL; } + //--------------------------------------------------------------- + bool + IsElnoData(vtkDataSet* theDataSet) + { + theDataSet->Update(); + + if ( vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData() ) + if ( aDataSetAttributes->GetArray( "ELNO_FIELD" ) != NULL ) + return true; + + if ( vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData() ) + if ( aDataSetAttributes->GetArray( "ELNO_POINT_COORDS" ) != NULL ) + return true; + + return false; + } + //--------------------------------------------------------------- vtkIdType diff --git a/src/CONVERTOR/VISU_ConvertorUtils.hxx b/src/CONVERTOR/VISU_ConvertorUtils.hxx index 17c12fde..2c1bff92 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.hxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.hxx @@ -90,6 +90,11 @@ namespace VISU bool IsDataOnCells(vtkDataSet* theDataSet); + //--------------------------------------------------------------- + VISU_CONVERTOR_EXPORT + bool + IsElnoData(vtkDataSet* theDataSet); + //--------------------------------------------------------------- VISU_CONVERTOR_EXPORT diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 0e8a49a1..e35b3626 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -82,18 +82,12 @@ namespace //--------------------------------------------------------------- + inline void - PrintCells(int& theStartId, - vtkCellArray* theConnectivity, - const VISU::TConnect& theVector) + PrintCells( vtkCellArray* theConnectivity, + const VISU::TConnect& theVector) { - vtkIdList *anIdList = vtkIdList::New(); - int kEnd = theVector.size(); - anIdList->SetNumberOfIds(kEnd); - for(int k = 0; k < kEnd; k++) - anIdList->SetId(k,theVector[k]); - theConnectivity->InsertNextCell(anIdList); - anIdList->Delete(); + theConnectivity->InsertNextCell( theVector.size(), &theVector[ 0 ] ); } @@ -121,7 +115,7 @@ namespace aCellTypesArray->SetNumberOfTuples(aNbCells); for(vtkIdType anID = 0; anID < aNbCells; anID++){ - PrintCells(anID,aConnectivity,anArray[anID]); + PrintCells( aConnectivity, anArray[ anID ] ); aCellTypesArray->SetValue(anID,(unsigned char)theGeom); } @@ -216,7 +210,7 @@ namespace VISU::TSubMeshID::const_iterator aSubMeshIDIter = aSubMeshID.begin(); for(; aSubMeshIDIter != aSubMeshID.end(); aSubMeshIDIter++, aCellId++){ vtkIdType anID = *aSubMeshIDIter; - PrintCells(aCellId, aConnectivity, anArray[anID]); + PrintCells( aConnectivity, anArray[ anID ] ); aCellTypesArray->SetValue(aCellId, (unsigned char)aVGeom); vtkIdType anObjID = aSubMesh.GetElemObjID(anID); anElemObj2VTKID[anObjID] = aCellId; @@ -281,7 +275,7 @@ namespace VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin(); for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){ const VISU::TConnect& anArray = aCell2Connect[anId]; - PrintCells(aConnId,aConnectivity,anArray); + PrintCells( aConnectivity, anArray ); aCellTypesArray->SetValue(anId,(unsigned char)aVGeom); aConnId += aNbNodes; anId++; @@ -291,7 +285,7 @@ namespace for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){ vtkIdType aSubId = *anIter; const VISU::TConnect& anArray = aCell2Connect[aSubId]; - PrintCells(aConnId,aConnectivity,anArray); + PrintCells( aConnectivity, anArray ); aCellTypesArray->SetValue(anId,(unsigned char)aVGeom); aConnId += aNbNodes; anId++; @@ -844,81 +838,63 @@ VISU_Convertor_impl //--------------------------------------------------------------- vtkUnstructuredGrid* VISU_Convertor_impl -::GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh, - const VISU::PMeshOnEntityImpl& theMeshOnEntity, - const VISU::PFieldImpl& theField, - const VISU::PValForTimeImpl& theValForTime, - const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper, - const VISU::PProfileImpl& theProfile, - const VISU::TEntity& theEntity) +::GetTimeStampOnProfile( const VISU::PMeshImpl& theMesh, + const VISU::PMeshOnEntityImpl& theMeshOnEntity, + const VISU::PFieldImpl& theField, + const VISU::PValForTimeImpl& theValForTime, + const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper, + const VISU::PProfileImpl& theProfile, + const VISU::TEntity& theEntity ) { - vtkUnstructuredGrid* anOutput = NULL; - - LoadMeshOnEntity(theMesh, theMeshOnEntity); - GetMeshOnEntity(theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity); - GetMeshOnProfile(theMesh, theMeshOnEntity, theProfile); - - bool isNeedInCells = false; + LoadMeshOnEntity( theMesh, theMeshOnEntity ); + GetMeshOnEntity( theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity ); + GetMeshOnProfile( theMesh, theMeshOnEntity, theProfile ); theUnstructuredGridIDMapper->myIDMapper = theProfile; - if(theMeshOnEntity->myEntity == VISU::NODE_ENTITY){ + + if ( theMeshOnEntity->myEntity == VISU::NODE_ENTITY ) { // add geometry elements to output, // if timestamp on NODE_ENTITY and // on profiles with status eAddPart - VISU::TGeom2SubProfile::const_iterator anIter = theProfile->myGeom2SubProfile.begin(); - for(; anIter != (theProfile->myGeom2SubProfile).end(); anIter++){ - const VISU::EGeometry aGeom = anIter->first; - const VISU::PSubProfileImpl aSubProfile = anIter->second; - if(aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1){ - isNeedInCells = true; - break; + const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile; + VISU::TGeom2SubProfile::const_iterator aSubProfileIter = aGeom2SubProfile.begin(); + for ( ; aSubProfileIter != aGeom2SubProfile.end(); aSubProfileIter++ ) { + const VISU::EGeometry& aGeom = aSubProfileIter->first; + const VISU::PSubProfileImpl& aSubProfile = aSubProfileIter->second; + if ( aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1 ) { + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; + VISU::TMeshOnEntityMap::const_reverse_iterator aMeshOnEntityIter = aMeshOnEntityMap.rbegin(); + for( ; aMeshOnEntityIter != aMeshOnEntityMap.rend(); aMeshOnEntityIter++ ) { + VISU::TEntity anEntity = aMeshOnEntityIter->first; + if ( anEntity == VISU::NODE_ENTITY ) + continue; + VISU::PNamedIDMapper aNamedIDMapper = GetMeshOnEntity( theMesh->myName, anEntity ); + if( aNamedIDMapper ) { + theUnstructuredGridIDMapper->SetReferencedMesh( aNamedIDMapper ); + VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource(); + VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity ); + + return theUnstructuredGridIDMapper->GetUnstructuredGridOutput(); + } + } } } - if(isNeedInCells){ - theUnstructuredGridIDMapper->myIsSpecialKey = true; - GetTimeStampOnNodalProfile(theMesh,theUnstructuredGridIDMapper,theField,theValForTime,theEntity); - anOutput = theUnstructuredGridIDMapper->GetUnstructuredGridOutput(); - } } - if(!isNeedInCells){ - vtkUnstructuredGrid* anOutput = theUnstructuredGridIDMapper->GetUnstructuredGridOutput(); - const VISU::PUnstructuredGrid& aSource = theUnstructuredGridIDMapper->mySource.GetSource(); - VISU::GetTimeStampOnProfile(aSource, theField, theValForTime, theEntity); - } - return anOutput; -} -void -VISU_Convertor_impl -::GetTimeStampOnNodalProfile(const VISU::PMeshImpl& theMesh, - const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter, - const VISU::PFieldImpl& theField, - const VISU::PValForTimeImpl& theValForTime, - const VISU::TEntity& theEntity) -{ - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; - VISU::TMeshOnEntityMap::const_iterator aIter = aMeshOnEntityMap.begin(); - for(;aIter!=aMeshOnEntityMap.end();aIter++){ - VISU::TEntity aEntity = aIter->first; - if(aEntity != VISU::NODE_ENTITY){ - VISU::PNamedIDMapper aMapper = GetMeshOnEntity(theMesh->myName,aEntity); - if(aMapper) - theIDMapperFilter->myMappers[aEntity] = aMapper; - } - } + VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource(); + VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity ); - theIDMapperFilter->GetUnstructuredGridOutput(); - const VISU::PUnstructuredGrid& aSource = theIDMapperFilter->mySource.GetSource(); - VISU::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity); + return theUnstructuredGridIDMapper->GetUnstructuredGridOutput(); } + //--------------------------------------------------------------- VISU::PUnstructuredGridIDMapper VISU_Convertor_impl -::GetTimeStampOnMesh(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum) +::GetTimeStampOnMesh( const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum ) { INITMSG(MYDEBUG,"GetTimeStampOnMesh"<< "; theMeshName = '"<myIDMapper = aGaussMesh; aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh; - vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput(); - const VISU::PPolyData& aSource = aGaussPtsIDFilter->mySource.GetSource(); + VISU::PPolyData aSource = aGaussPtsIDFilter->GetSource(); VISU::GetTimeStampOnGaussMesh(aSource, aField, aValForTime); + vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput(); aGaussPtsIDFilter->myIsVTKDone = true; @@ -1357,29 +1333,29 @@ VISU_Convertor_impl VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity; - if(theEntity == VISU::NODE_ENTITY){ - if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) != aMeshOnEntityMap.end()) - aVTKMeshOnEntity = aMeshOnEntityMap[VISU::CELL_ENTITY]; - else if(aMeshOnEntityMap.find(VISU::FACE_ENTITY) != aMeshOnEntityMap.end()) - aVTKMeshOnEntity = aMeshOnEntityMap[VISU::FACE_ENTITY]; - else if(aMeshOnEntityMap.find(VISU::EDGE_ENTITY) != aMeshOnEntityMap.end()) - aVTKMeshOnEntity = aMeshOnEntityMap[VISU::EDGE_ENTITY]; - else if(aMeshOnEntityMap.find(VISU::NODE_ENTITY) != aMeshOnEntityMap.end()) - aVTKMeshOnEntity = aMeshOnEntityMap[VISU::NODE_ENTITY]; + if ( theEntity == VISU::NODE_ENTITY ) { + if(aMeshOnEntityMap.find( VISU::CELL_ENTITY ) != aMeshOnEntityMap.end()) + aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::CELL_ENTITY ]; + else if (aMeshOnEntityMap.find( VISU::FACE_ENTITY ) != aMeshOnEntityMap.end() ) + aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::FACE_ENTITY ]; + else if (aMeshOnEntityMap.find( VISU::EDGE_ENTITY ) != aMeshOnEntityMap.end() ) + aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::EDGE_ENTITY ]; + else if ( aMeshOnEntityMap.find( VISU::NODE_ENTITY ) != aMeshOnEntityMap.end() ) + aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::NODE_ENTITY ]; }else aVTKMeshOnEntity = aMeshOnEntity; VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; - VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find(theFieldName); + VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find( theFieldName ); if(aFieldIter == aFieldMap.end()) EXCEPTION(std::runtime_error,"FindField >> There is no field on the mesh!!!"); VISU::PFieldImpl aField = aFieldIter->second; - return TFindField(aMesh, - aMeshOnEntity, - aVTKMeshOnEntity, - aField); + return TFindField( aMesh, + aMeshOnEntity, + aVTKMeshOnEntity, + aField ); } diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index f6cffc0e..14beaf5e 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -120,10 +120,10 @@ public: //! Implemention of the VISU_Convertor::GetTimeStampOnMesh virtual VISU::PUnstructuredGridIDMapper - GetTimeStampOnMesh(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theTimeStampNumber); + GetTimeStampOnMesh( const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theTimeStampNumber ); //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on mesh virtual @@ -206,9 +206,9 @@ protected: VISU::PMeshOnEntityImpl, VISU::PFieldImpl> TFindField; TFindField - FindField(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName); + FindField( const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName ); //! An utility method to find TTimeStamp by name of its parent mesh, corresponding entity, field name and its number typedef boost::tuple + + +/*! + \file VISU_ElnoMeshValue.hxx + \brief The file contains declarations for the acess to the specific ELNO MED data +*/ + +namespace VISU +{ + //--------------------------------------------------------------- + template< int elno_type > + struct TGetElnoNodeData + { + typedef typename TL::TEnum2VTKArrayType< elno_type >::TResult TVTKDataArray; + typedef typename TL::TEnum2VTKBasicType< elno_type >::TResult TDataType; + TVTKDataArray *myElnoDataArray; + vtkIntArray *myElnoDataMapper; + int myElemInfo[3]; + + + //---------------------------------------------------------------------------- + TGetElnoNodeData( vtkDataArray *theElnoDataArray, + vtkDataArray *theElnoDataMapper ) + : myElnoDataArray( TVTKDataArray::SafeDownCast( theElnoDataArray ) ) + , myElnoDataMapper( vtkIntArray::SafeDownCast( theElnoDataMapper ) ) + {} + + + //---------------------------------------------------------------------------- + TDataType* + operator () ( vtkIdType theCellId, vtkIdType theLocalPntId ) + { + myElnoDataMapper->GetTupleValue( theCellId, myElemInfo ); + + vtkIdType aPos = myElemInfo[ 0 ] + theLocalPntId * myElemInfo[ 1 ]; + + return myElnoDataArray->GetPointer( aPos ); + } + + + //---------------------------------------------------------------------------- + int + getNbComp() + { + myElnoDataMapper->GetTupleValue( 0, myElemInfo ); + + return myElemInfo[ 1 ]; + } + }; + + + //---------------------------------------------------------------------------------------------- + template< int elno_type > + struct TSetElnoNodeData + { + typedef typename TL::TEnum2VTKArrayType< elno_type >::TResult TVTKDataArray; + typedef typename TL::TEnum2VTKBasicType< elno_type >::TResult TDataType; + + //---------------------------------------------------------------------------------------------- + TSetElnoNodeData( vtkIdType theEffectNbComp, + vtkIdType theRealNbComp, + vtkIdType theNbTuples, + const char* theDataArrayName, + const char* theMapperArrayName ) + : myElnoDataArray( TVTKDataArray::New() ) + , myElnoDataMapper( vtkIntArray::New() ) + { + myElnoDataArray->SetNumberOfComponents( theEffectNbComp ); + myElnoDataArray->SetNumberOfTuples( theNbTuples ); + myElnoDataArray->SetName( theDataArrayName ); + + myElnoDataMapper->SetNumberOfComponents( 3 ); + myElnoDataMapper->Allocate( theNbTuples * 3 ); + myElnoDataMapper->SetName( theMapperArrayName ); + + myElemInfo[ 0 ] = 0; + myElemInfo[ 1 ] = theRealNbComp; + myElemInfo[ 2 ] = 0; + } + + + //---------------------------------------------------------------------------------------------- + ~TSetElnoNodeData() + { + myElnoDataArray->Delete(); + myElnoDataMapper->Delete(); + } + + + //---------------------------------------------------------------------------------------------- + int + AddNextPointData( TDataType* theDataPtr ) + { + vtkIdType aPos = myElemInfo[ 0 ] + myElemInfo[ 2 ] * myElemInfo[ 1 ]; + + TDataType* aDataPtr = myElnoDataArray->GetPointer( aPos ); + + for ( vtkIdType aCompId = 0; aCompId < myElemInfo[ 1 ]; aCompId++ ) + *aDataPtr++ = *theDataPtr++; + + return myElemInfo[ 2 ]++; + } + + + //---------------------------------------------------------------------------------------------- + void + InsertNextCellData() + { + myElnoDataMapper->InsertNextTupleValue( myElemInfo ); + myElemInfo[ 0 ] += myElemInfo[ 2 ] * myElemInfo[ 1 ]; + myElemInfo[ 2 ] = 0; + } + + + //---------------------------------------------------------------------------------------------- + void + AddData( vtkDataSetAttributes* theDataSetAttributes ) + { + theDataSetAttributes->AddArray( myElnoDataArray ); + theDataSetAttributes->AddArray( myElnoDataMapper ); + } + + protected: + TVTKDataArray *myElnoDataArray; + vtkIntArray *myElnoDataMapper; + int myElemInfo[ 3 ]; + }; + + + //--------------------------------------------------------------- +} + +#endif diff --git a/src/CONVERTOR/VISU_IDMapper.cxx b/src/CONVERTOR/VISU_IDMapper.cxx index bf1e8fca..55e2cc20 100644 --- a/src/CONVERTOR/VISU_IDMapper.cxx +++ b/src/CONVERTOR/VISU_IDMapper.cxx @@ -103,8 +103,8 @@ namespace VISU ::GetIndexesOfNode(vtkIdType theNodeId) { if ( IsStructured() ) { - TObj2StructuredId::const_iterator aIter = myObj2StructuredId->find( theNodeId ); - if ( aIter != myObj2StructuredId->end() ) + TObj2StructuredId::const_iterator aIter = myObj2StructuredId.find( theNodeId ); + if ( aIter != myObj2StructuredId.end() ) return aIter->second; } @@ -115,8 +115,8 @@ namespace VISU TStructured ::GetObjectIDByIndexes(TStructuredId theVec) { - TObj2StructuredId::const_iterator aIter = myObj2StructuredId->begin(); - for (; aIter != myObj2StructuredId->end(); aIter++ ) { + TObj2StructuredId::const_iterator aIter = myObj2StructuredId.begin(); + for (; aIter != myObj2StructuredId.end(); aIter++ ) { if ( theVec == aIter->second ) return aIter->first; } diff --git a/src/CONVERTOR/VISU_IDMapper.hxx b/src/CONVERTOR/VISU_IDMapper.hxx index 2657165c..4ef68e30 100644 --- a/src/CONVERTOR/VISU_IDMapper.hxx +++ b/src/CONVERTOR/VISU_IDMapper.hxx @@ -124,7 +124,7 @@ namespace VISU */ TStructuredId myGrilleStructure; - PObj2StructuredId myObj2StructuredId;//!< map of object id to i,j,k ids of structured grid nodes + TObj2StructuredId myObj2StructuredId;//!< map of object id to i,j,k ids of structured grid nodes }; //--------------------------------------------------------------- diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index df36b0c9..e86e2e16 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -138,15 +138,29 @@ namespace //--------------------------------------------------------------- VISU::TEntity - MEDEntityToVTK(MED::EEntiteMaillage theMEDEntity) + MEDEntityToVTK( MED::EEntiteMaillage theMEDEntity ) { + VISU::TEntity anEntity = VISU::TEntity( -1 ); + switch(theMEDEntity){ - case MED::eNOEUD: return VISU::NODE_ENTITY; - case MED::eARETE: return VISU::EDGE_ENTITY; - case MED::eFACE: return VISU::FACE_ENTITY; - case MED::eMAILLE: return VISU::CELL_ENTITY; + case MED::eNOEUD : + anEntity = VISU::NODE_ENTITY; + break; + case MED::eARETE : + anEntity = VISU::EDGE_ENTITY; + break; + case MED::eFACE : + anEntity = VISU::FACE_ENTITY; + break; + case MED::eMAILLE : + anEntity = VISU::CELL_ENTITY; + break; + case MED::eNOEUD_ELEMENT : + anEntity = VISU::CELL_ENTITY; + break; } - return VISU::TEntity(-1); + + return anEntity; } @@ -200,7 +214,7 @@ namespace MED::PPolygoneInfo aPolygoneInfo = theMEDWrapper->GetPPolygoneInfo(theMeshInfo,theMEntity,theMGeom); for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){ - TInt aNbConn = aPolygoneInfo->GetNbConn(anElemNum[anElemId]); + TInt aNbConn = aPolygoneInfo->GetNbConn( anElemNum[ anElemId ] - 1 ); aSubProfile->myCellsSize += aNbConn; } break; @@ -210,7 +224,7 @@ namespace theMEDWrapper->GetPPolyedreInfo(theMeshInfo,theMEntity,theMGeom); for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){ MED::TCConnSliceArr aConnSliceArr = - aPolyedreInfo->GetConnSliceArr(anElemNum[anElemId]); + aPolyedreInfo->GetConnSliceArr( anElemNum[ anElemId ] - 1 ); TInt aNbFaces = aConnSliceArr.size(); TInt aCellSize = 0; for(TInt iFace = 0; iFace < aNbFaces; iFace++){ @@ -754,9 +768,9 @@ namespace if(aNbTimeStamps < 1) continue; - VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::TEntity aVEntity = MEDEntityToVTK( aMEntity ); vtkIdType aDataType = VTK_DOUBLE; - if(aFieldInfo->GetType() != MED::eFLOAT64){ + if ( aFieldInfo->GetType() != MED::eFLOAT64 ) { #if defined(HAVE_F77INT64) aDataType = VTK_LONG; #else @@ -772,7 +786,8 @@ namespace aField->myName = aFieldName; aField->myMeshName = aMeshName; aField->myDataSize = aMeshOnEntity->myNbCells * aNbComp; - + aField->myIsELNO = ( aMEntity == MED::eNOEUD_ELEMENT ); + INITMSG(MYDEBUG,"myName = '"<myName<<"'"<< "; myId = "<myId<< "; myEntity = "<myEntity<< @@ -813,9 +828,13 @@ namespace MED::TGeom2NbGauss::const_iterator anIter = aMGeom2NbGauss.begin(); for(; anIter != aMGeom2NbGauss.end(); anIter++){ const MED::EGeometrieElement& aMGeom = anIter->first; - VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); + VISU::EGeometry aEGeom = MEDGeom2VISU( aMGeom ); TInt aNbGauss = anIter->second; - aVGeom2NbGauss[aEGeom] = aNbGauss; + aVGeom2NbGauss[ aEGeom ] = aNbGauss; + + // ELNO data should satisfy the following condition ( implicitly ) + vtkIdType aNbNodes = MEDGeom2NbNodes( aMGeom ); + aField->myIsELNO &= ( aNbGauss == aNbNodes ); } } } @@ -1238,8 +1257,7 @@ namespace VISU //--------------------------------------------------------------- vtkIdType TMEDGaussSubMesh - ::GetVTKID(const TGaussPointID& theID, - vtkIdType theStartID) const + ::GetVTKID( const TGaussPointID& theID ) const { vtkIdType aResult = -1; @@ -1253,9 +1271,9 @@ namespace VISU if ( myIsElemNum ) { aCellID = GetElemVTKID( aCellID ); } else - aCellID -= theStartID; + aCellID -= myStartID; - return aCellID * aNbPoints + aLocalPntID + theStartID; + return aCellID * aNbPoints + aLocalPntID + myStartID; } @@ -1277,6 +1295,7 @@ namespace VISU ::Init(const MED::PElemInfo& theElemInfo, MED::EVersion theVersion) { + myVersion = theVersion; myIsElemNum = theElemInfo->IsElemNum(); if(myIsElemNum) myElemNum = theElemInfo->myElemNum; diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index 4529ecb3..ec1f3cee 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -245,8 +245,7 @@ namespace VISU virtual vtkIdType - GetVTKID(const TGaussPointID& theID, - vtkIdType theStartID) const; + GetVTKID( const TGaussPointID& theID ) const; //! Gets memory size used by the instance (bytes). virtual diff --git a/src/CONVERTOR/VISU_MergeFilterUtilities.cxx b/src/CONVERTOR/VISU_MergeFilterUtilities.cxx index 48846369..2d1eafc2 100644 --- a/src/CONVERTOR/VISU_MergeFilterUtilities.cxx +++ b/src/CONVERTOR/VISU_MergeFilterUtilities.cxx @@ -81,6 +81,9 @@ namespace vtkCellData *anOutputCellData = theOutput->GetCellData(); anOutputCellData->CopyAllocate(aCellData); + if(theVectorsDataSet && theVectorsDataSet != theScalarsDataSet) + anOutputCellData->CopyVectorsOff(); + vtkIdType aNbTuples = anIntersection.size(); theOutput->Allocate(aNbTuples); vtkIdList *aCellIds = vtkIdList::New(); @@ -100,13 +103,68 @@ namespace aCellIds->Delete(); theOutput->SetPoints(theInput->GetPoints()); + }else{ theOutput->CopyStructure(theInput); theOutput->GetCellData()->ShallowCopy(theScalarsDataSet->GetCellData()); } theOutput->GetPointData()->ShallowCopy(theInput->GetPointData()); + + //If need, copy vectors data. + if(theVectorsDataSet && theVectorsDataSet != theScalarsDataSet){ + bool isVectorsOnCells = theVectorsDataSet->GetCellData()->GetVectors() != NULL; + bool isVectorsDataOnPoints = theVectorsDataSet->GetPointData()->GetVectors() != NULL; + if(isVectorsOnCells) { + CopyVectorsOnCells(theVectorsDataSet,theOutput); + } + else if(isVectorsDataOnPoints){ + CopyVectorsOnPoints(theVectorsDataSet,theOutput); + } + } } + void CopyVectorsOnCells(vtkDataSet *theVectorsDataSet, + vtkDataSet *theOutput) + { + vtkDataArray *anInputVectors = theVectorsDataSet->GetCellData()->GetVectors(); + vtkDataArray *anOutputVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType()); + + //Clear output vector data + theOutput->GetCellData()->SetVectors(NULL); + + //Copy vectors data + vtkIntArray* anOutputIDMapper = GetIDMapper(theOutput, + TGetCellData(), + "VISU_CELLS_MAPPER"); + + vtkIntArray* anInputIDMapper = GetIDMapper(theVectorsDataSet, + TGetCellData(), + "VISU_CELLS_MAPPER"); + + TObjectIdArray anIntersection; + GetIntersection(anOutputIDMapper, + anInputIDMapper, + anIntersection); + + vtkIdType aNbTuples = anIntersection.size(); + anOutputVectors->SetNumberOfComponents(anInputVectors->GetNumberOfComponents()); + anOutputVectors->SetNumberOfTuples(aNbTuples); + theOutput->GetCellData()->SetVectors(anOutputVectors); + anOutputVectors->Delete(); + + TObjectId2TupleIdMap anOutputObjectId2TupleIdMap; + GetObjectId2TupleIdMap(anOutputIDMapper, anOutputObjectId2TupleIdMap); + + TObjectId2TupleIdMap anInputObjectId2TupleIdMap; + GetObjectId2TupleIdMap(anInputIDMapper, anInputObjectId2TupleIdMap); + + for(vtkIdType iTupleId = 0; iTupleId < aNbTuples; iTupleId++ ){ + TObjectId &anObjectId = anIntersection[iTupleId]; + vtkIdType anOutputCellId = anOutputObjectId2TupleIdMap[anObjectId]; + vtkIdType anInputCellId = anInputObjectId2TupleIdMap[anObjectId]; + anOutputVectors->SetTuple(anOutputCellId,anInputVectors->GetTuple(anInputCellId)); + } + } //--------------------------------------------------------------- template @@ -200,7 +258,118 @@ namespace theOutput->GetCellData()->ShallowCopy(theInput->GetCellData()); } theOutput->GetPointData()->ShallowCopy(theScalarsDataSet->GetPointData()); + + //If need, copy vectors data. + if(theVectorsDataSet && theVectorsDataSet != theScalarsDataSet){ + bool isVectorsOnCells = theVectorsDataSet->GetCellData()->GetVectors() != NULL; + bool isVectorsDataOnPoints = theVectorsDataSet->GetPointData()->GetVectors() != NULL; + + //Merge cells if need + //rnv + if(!IsDifferent(theGeometryPointMapper, theDataPointMapper)){ + vtkIntArray* theGeometryCellMapper = GetIDMapper(theVectorsDataSet, + TGetCellData(), + "VISU_CELLS_MAPPER"); + + vtkIntArray* theDataCellMapper = GetIDMapper(theScalarsDataSet, + TGetCellData(), + "VISU_CELLS_MAPPER"); + + + if(IsDifferent(theGeometryCellMapper, theDataCellMapper)){ + TObjectIdArray anIntersection; + + GetIntersection(theGeometryCellMapper, + theDataCellMapper, + anIntersection); + + TObjectId2TupleIdMap aGeomObjectId2TupleIdMap; + GetObjectId2TupleIdMap(theGeometryCellMapper, aGeomObjectId2TupleIdMap); + + TObjectId2TupleIdMap aDataObjectId2TupleIdMap; + GetObjectId2TupleIdMap(theDataCellMapper, aDataObjectId2TupleIdMap); + + vtkCellData *aCellData = theScalarsDataSet->GetCellData(); + vtkCellData *anOutputCellData = theOutput->GetCellData(); + anOutputCellData->CopyAllocate(aCellData); + + vtkIdType aNbTuples = anIntersection.size(); + theOutput->Allocate(aNbTuples); + vtkIdList *aCellIds = vtkIdList::New(); + for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){ + TObjectId& anObjectId = anIntersection[aTupleId]; + vtkIdType aCellId = aGeomObjectId2TupleIdMap[anObjectId]; + vtkCell *aCell = theInput->GetCell(aCellId); + aCellIds->Reset(); + vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds(); + for(vtkIdType anId = 0; anId < aNbPointIds; anId++) + aCellIds->InsertNextId(aCell->GetPointIds()->GetId(anId)); + vtkIdType aCellType = theInput->GetCellType(aCellId); + vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds); + vtkIdType aDataCellId = aDataObjectId2TupleIdMap[anObjectId]; + anOutputCellData->CopyData(aCellData, aDataCellId, aNewCellId); + } + aCellIds->Delete(); + + } + } + + if(isVectorsOnCells) { + CopyVectorsOnCells(theVectorsDataSet,theOutput); + } + else if(isVectorsDataOnPoints){ + CopyVectorsOnPoints(theVectorsDataSet,theOutput); + } + } } + + void CopyVectorsOnPoints(vtkDataSet *theVectorsDataSet, + vtkDataSet *theOutput) + { + vtkDataArray *anInputVectors = theVectorsDataSet->GetPointData()->GetVectors(); + + //Clear output vector data + theOutput->GetPointData()->SetVectors(NULL); + + vtkDataArray *anOutputVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType()); + + //Copy vectors data + vtkIntArray* anOutputIDMapper = GetIDMapper(theOutput, + TGetPointData(), + "VISU_POINTS_MAPPER"); + + vtkIntArray* anInputIDMapper = GetIDMapper(theVectorsDataSet, + TGetPointData(), + "VISU_POINTS_MAPPER"); + TObjectIdArray anIntersection; + + GetIntersection(anOutputIDMapper, + anInputIDMapper, + anIntersection); + + vtkIdType aNbTuples = anIntersection.size(); + anOutputVectors->SetNumberOfComponents(anInputVectors->GetNumberOfComponents()); + anOutputVectors->SetNumberOfTuples(aNbTuples); + + + + TObjectId2TupleIdMap anOutputObjectId2TupleIdMap; + GetObjectId2TupleIdMap(anOutputIDMapper, anOutputObjectId2TupleIdMap); + + TObjectId2TupleIdMap anInputObjectId2TupleIdMap; + GetObjectId2TupleIdMap(anInputIDMapper, anInputObjectId2TupleIdMap); + + for(vtkIdType iTupleId = 0; iTupleId < aNbTuples; iTupleId++ ){ + TObjectId& anObjectId = anIntersection[iTupleId]; + vtkIdType anOutputPointId = anOutputObjectId2TupleIdMap[anObjectId]; + vtkIdType anInputPointId = anInputObjectId2TupleIdMap[anObjectId]; + anOutputVectors->SetTuple(anOutputPointId,anInputVectors->GetTuple(anInputPointId)); + } + + theOutput->GetPointData()->SetVectors(anOutputVectors); + anOutputVectors->Delete(); + } + //--------------------------------------------------------------- typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)(); diff --git a/src/CONVERTOR/VISU_MeshValue.cxx b/src/CONVERTOR/VISU_MeshValue.cxx index 4b7a2785..b4b265ed 100644 --- a/src/CONVERTOR/VISU_MeshValue.cxx +++ b/src/CONVERTOR/VISU_MeshValue.cxx @@ -25,11 +25,12 @@ // Module : VISU #include "VISU_MeshValue.hxx" +#include "VISU_ElnoMeshValue.hxx" #include "VISU_Structures_impl.hxx" #include "VISU_ConvertorUtils.hxx" #include "VISU_PointCoords.hxx" -#include "VISU_TypeList.hxx" +#include "VISU_VTKTypeList.hxx" #include #include @@ -113,76 +114,6 @@ namespace VISU } - namespace TL - { - //---------------------------------------------------------------------------- - typedef TList > > > > > > > > > - TVTKBasicTypeList; - - - //---------------------------------------------------------------------------- - typedef TList > > > > > > > > > - TVTKArrayTypeList; - - - typedef TList, - TList, - TList, - TList, - TList, - TList, - TList, - TList, - TList, - TList, - TNullType> > > > > > > > > > - TVTKBasicEnumList; - - - //---------------------------------------------------------------------------- - template - struct TEnum2VTKBasicType - { - typedef typename TTypeAt >::value >::TResult TResult; - }; - - //---------------------------------------------------------------------------- - template - struct TEnum2VTKArrayType - { - typedef typename TTypeAt >::value >::TResult TResult; - }; - - //---------------------------------------------------------------------------- - template - struct TVTKBasicType2Enum - { - typedef typename TTypeAt::value >::TResult TResult; - }; - - } - - //---------------------------------------------------------------------------- template void @@ -349,7 +280,7 @@ namespace VISU std::string aFieldName = VISU::GenerateFieldName(theField, theValForTime); vtkDataSetAttributes* aDataSetAttributes; - switch(theEntity){ + switch ( theEntity ) { case VISU::NODE_ENTITY : aDataSetAttributes = theSource->GetPointData(); break; @@ -360,49 +291,51 @@ namespace VISU typedef typename TL::TEnum2VTKArrayType::TResult TVTKDataArray; TVTKDataArray *aSelectedDataArray = TVTKDataArray::New(); vtkIdType aNbComp = theField->myNbComp; - switch(aNbComp) { + + switch ( aNbComp ) { case 1: - aSelectedDataArray->SetNumberOfComponents(1); - aDataSetAttributes->SetScalars(aSelectedDataArray); + aSelectedDataArray->SetNumberOfComponents( 1 ); + aDataSetAttributes->SetScalars( aSelectedDataArray ); break; default: - aSelectedDataArray->SetNumberOfComponents(3); - aDataSetAttributes->SetVectors(aSelectedDataArray); + aSelectedDataArray->SetNumberOfComponents( 3 ); + aDataSetAttributes->SetVectors( aSelectedDataArray ); } - aSelectedDataArray->SetNumberOfTuples(aNbTuples); - aSelectedDataArray->SetName(aFieldName.c_str()); + aSelectedDataArray->SetNumberOfTuples( aNbTuples ); + aSelectedDataArray->SetName( aFieldName.c_str() ); TVTKDataArray *aFullDataArray = TVTKDataArray::New(); - aFullDataArray->SetNumberOfComponents(aNbComp); - aFullDataArray->SetNumberOfTuples(aNbTuples); - aFullDataArray->SetName("VISU_FIELD"); - aDataSetAttributes->AddArray(aFullDataArray); + aFullDataArray->SetNumberOfComponents( aNbComp ); + aFullDataArray->SetNumberOfTuples( aNbTuples ); + aFullDataArray->SetName( "VISU_FIELD" ); + aDataSetAttributes->AddArray( aFullDataArray ); INITMSG(MYDEBUG,"InitTimeStampOnProfile "<< "- theEntity = "<GetGeom2MeshValue(); - typedef typename TL::TEnum2VTKBasicType::TResult TVTKBasicType; - typedef TTMeshValue TMeshValue; - typedef MED::SharedPtr TMeshValuePtr; + typedef typename TL::TEnum2VTKBasicType< EDataType >::TResult TVTKBasicType; + typedef TTMeshValue< TVTKBasicType > TMeshValue; + typedef MED::SharedPtr< TMeshValue > TMeshValuePtr; - typedef TDataArrayHolder TTDataArrayHolder; - typedef MED::SharedPtr PDataArrayHolder; + typedef TDataArrayHolder< EDataType > TTDataArrayHolder; + typedef MED::SharedPtr< TTDataArrayHolder > PDataArrayHolder; TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue(); - if(aGeom2MeshValue.size() == 1 && aMeshValue->GetNbGauss() == 1){ + if ( aGeom2MeshValue.size() == 1 && aMeshValue->GetNbGauss() == 1 ) { aFullDataArray->SetVoidArray(aMeshValue->GetPointer(), aMeshValue->size(), true); INITMSG(MYDEBUG,"InitTimeStampOnProfile - aFullDataArray->SetVoidArray()"<SetVoidArray(aMeshValue->GetPointer(), - aMeshValue->size(), - true); + if ( aNbComp == 1 ) { + aSelectedDataArray->SetVoidArray( aMeshValue->GetPointer(), + aMeshValue->size(), + true ); INITMSG(MYDEBUG,"InitTimeStampOnProfile - aSelectedDataArray->SetVoidArray()"<Delete(); aFullDataArray->Delete(); + + // Process the case for ELNO data + //------------------------------- + if ( theField->myIsELNO ) { + // To calculate effective number of components for the VTK compatibel ELNO data representation + vtkIdType aEffectNbTuples = 0; + TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin(); + for ( ; anIter != aGeom2MeshValue.end(); anIter++ ) { + const PMeshValue& aMeshValue = anIter->second; + aEffectNbTuples += aMeshValue->GetNbElem() * aMeshValue->GetNbGauss(); + } + + vtkIdType anEffectNbComp = ( aEffectNbTuples * aNbComp ) / aNbTuples + 1; + + // To create corresponding VTK representation for the ELNO data + TSetElnoNodeData< EDataType > aSetElnoNodeData( anEffectNbComp, + aNbComp, + aNbTuples, + "ELNO_FIELD", + "ELNO_COMPONENT_MAPPER" ); + + std::vector< TVTKBasicType > aDataValues( aNbComp ); // To reserve a temproary value holder + + // To initilize these VTK representation for the ELNO data from the MED + anIter = aGeom2MeshValue.begin(); + for ( ; anIter != aGeom2MeshValue.end(); anIter++ ) { + EGeometry aEGeom = anIter->first; + const TMeshValuePtr aMeshValue = anIter->second; + + vtkIdType aNbElem = aMeshValue->GetNbElem(); + vtkIdType aNbGauss = aMeshValue->GetNbGauss(); + + INITMSG(MYDEBUG, + "- aEGeom = "<AddField("VISU_CELLS_MAPPER",aDataSet); - aFilter->AddField("VISU_POINTS_MAPPER",aDataSet); - - myCommonCellsFilter->SetProfileUG(aFilter->GetUnstructuredGridOutput()); + aFilter->SetGeometry( aGeometry ); + aFilter->SetScalars( aDataSet ); + aFilter->SetVectors( aDataSet ); + aFilter->AddField( "VISU_FIELD", aDataSet ); + aFilter->AddField( "VISU_CELLS_MAPPER", aDataSet ); + aFilter->AddField( "ELNO_FIELD", aDataSet ); + aFilter->AddField( "ELNO_COMPONENT_MAPPER", aDataSet ); + aFilter->AddField( "VISU_POINTS_MAPPER", aDataSet ); + + myCommonCellsFilter->SetProfileUG( aFilter->GetUnstructuredGridOutput() ); } + } + + vtkUnstructuredGrid* + TUnstructuredGridIDMapperImpl + ::GetUnstructuredGridOutput() + { + Build(); return myCommonCellsFilter->GetOutput(); } @@ -733,17 +730,25 @@ namespace VISU return GetUnstructuredGridOutput(); } + PUnstructuredGrid + TUnstructuredGridIDMapperImpl + ::GetSource() + { + Build(); + return mySource.GetSource(); + } + unsigned long int TUnstructuredGridIDMapperImpl ::GetMemorySize() { size_t aSize = myIDMapper->GetMemorySize(); + aSize += mySource.GetMemorySize(); - if(vtkUnstructuredGrid* anOutput = myCommonCellsFilter->GetOutput()) + + if ( vtkUnstructuredGrid* anOutput = myCommonCellsFilter->GetOutput() ) aSize += anOutput->GetActualMemorySize() * 1024; - PNamedIDMapperMap::const_iterator aIter = myMappers.begin(); - for(;aIter!=myMappers.end();aIter++) - aSize += (aIter->second)->GetMemorySize(); + return aSize; } @@ -790,26 +795,33 @@ namespace VISU return myIDMapper->GetElemCell(theObjID); } - vtkPolyData* + void TPolyDataIDMapperImpl - ::GetPolyDataOutput() + ::Build() { - if(!myFilter.GetPointer()){ + if ( !myFilter.GetPointer() ) { const PAppendPolyData& anAppendFilter = myIDMapper->GetFilter(); vtkPolyData* aGeometry = anAppendFilter->GetOutput(); const PPolyData& aSource = mySource.GetSource(); vtkPolyData* aDataSet = aSource.GetPointer(); - aDataSet->ShallowCopy(aGeometry); + aDataSet->ShallowCopy( aGeometry ); const PMergeFilter& aFilter = GetFilter(); - aFilter->SetGeometry(aGeometry); - aFilter->SetScalars(aDataSet); - aFilter->SetVectors(aDataSet); - aFilter->AddField("VISU_FIELD",aDataSet); - aFilter->AddField("VISU_CELLS_MAPPER",aDataSet); - aFilter->AddField("VISU_POINTS_MAPPER",aDataSet); + aFilter->SetGeometry( aGeometry ); + aFilter->SetScalars( aDataSet ); + aFilter->SetVectors( aDataSet ); + aFilter->AddField( "VISU_FIELD", aDataSet ); + aFilter->AddField( "VISU_CELLS_MAPPER", aDataSet ); + aFilter->AddField( "VISU_POINTS_MAPPER", aDataSet ); } + } + + vtkPolyData* + TPolyDataIDMapperImpl + ::GetPolyDataOutput() + { + Build(); return myFilter->GetPolyDataOutput(); } @@ -820,6 +832,14 @@ namespace VISU return GetPolyDataOutput(); } + PPolyData + TPolyDataIDMapperImpl + ::GetSource() + { + Build(); + return mySource.GetSource(); + } + unsigned long int TPolyDataIDMapperImpl ::GetMemorySize() @@ -971,7 +991,6 @@ namespace VISU return aResult; size_t aSubMeshEnd = myGaussSubMeshArr.size(); - const PAppendFilter& anAppendFilter = GetFilter(); const PGaussSubMeshImpl& aGaussSubMesh = anIter->second; for ( size_t aSubMeshId = 0; aSubMeshId < aSubMeshEnd; aSubMeshId++ ) { const PGaussSubMeshImpl& aSubMesh = myGaussSubMeshArr[aSubMeshId]; @@ -1337,9 +1356,10 @@ namespace VISU //--------------------------------------------------------------- TFieldImpl - ::TFieldImpl(): - myDataSize(0), - myDataType(0) + ::TFieldImpl() + : myDataSize( 0 ) + , myDataType( 0 ) + , myIsELNO( false ) {} void diff --git a/src/CONVERTOR/VISU_Structures_impl.hxx b/src/CONVERTOR/VISU_Structures_impl.hxx index fbcabfef..8819f492 100644 --- a/src/CONVERTOR/VISU_Structures_impl.hxx +++ b/src/CONVERTOR/VISU_Structures_impl.hxx @@ -157,14 +157,6 @@ namespace VISU virtual unsigned long int GetMemorySize(); - - //! if false, TIDCommonCellsFilter - same as TIDMapperFilter - //! if true, TIDCommonCellsFilter - use VISU_CommonCellsFilter - bool myIsSpecialKey; - - //! Vector of id mappers, which consist of meshonentity in next sequence: - //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY - PNamedIDMapperMap myMappers; }; //--------------------------------------------------------------- @@ -348,9 +340,8 @@ namespace VISU struct TUnstructuredGridIDMapperImpl: virtual TMergeFilterHolder, virtual TUnstructuredGridIDMapper { - PAppendFilterHolder myIDMapper; //!< Responsible for numbering - PCommonCellsFilter myCommonCellsFilter; - TUnstructuredGridHolder mySource; //!< Keeps assigned data + PAppendFilterHolder myIDMapper; //!< Responsible for numbering + PCommonCellsFilter myCommonCellsFilter; TUnstructuredGridIDMapperImpl(); @@ -399,13 +390,16 @@ namespace VISU unsigned long int GetMemorySize(); - //! if false, Not using CommonCellsFilter - //! if true, Using CommonCellsFilter - bool myIsSpecialKey; + void + SetReferencedMesh( const PNamedIDMapper& theNamedIDMapper ); + + PUnstructuredGrid + GetSource(); + + protected: + void Build(); - //! Vector of id mappers, which consist of meshonentity in next sequence: - //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY - PNamedIDMapperMap myMappers; + TUnstructuredGridHolder mySource; //!< Keeps assigned data }; //--------------------------------------------------------------- @@ -414,7 +408,6 @@ namespace VISU virtual TPolyDataIDMapper { PAppendPolyDataHolder myIDMapper; //!< Responsible for numbering - TPolyDataHolder mySource; //!< Keeps assigned data //! Reimplement the TIDMapper::GetNodeObjID virtual @@ -460,6 +453,14 @@ namespace VISU virtual unsigned long int GetMemorySize(); + + PPolyData + GetSource(); + + protected: + void Build(); + + TPolyDataHolder mySource; //!< Keeps assigned data }; @@ -830,6 +831,7 @@ namespace VISU vtkIdType myDataSize; //!< Keeps size of the assigned data vtkIdType myDataType; //!< Keeps type idetificator of the mesh data TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD + bool myIsELNO; //!< Defines whether this field contains specific "ELNO" data or not }; diff --git a/src/CONVERTOR/VISU_TypeList.hxx b/src/CONVERTOR/VISU_TypeList.hxx index 1a09efc3..a2eda5b7 100644 --- a/src/CONVERTOR/VISU_TypeList.hxx +++ b/src/CONVERTOR/VISU_TypeList.hxx @@ -20,77 +20,122 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // -// File : VISU_ColoredPrs3dCache_i.hh +// File : VISU_TypeList.hxx // Author : Oleg UVAROV // Module : VISU #ifndef VISU_TypeList_HeaderFile #define VISU_TypeList_HeaderFile + +//---------------------------------------------------------------------------- namespace VISU { + //---------------------------------------------------------------------------- namespace TL { //---------------------------------------------------------------------------- - template + struct TNullType {}; + + + //---------------------------------------------------------------------------- + template < class T, class U > struct TList { typedef T THead; typedef U TTail; }; - template + template < int v > struct TInt2Type { enum { value = v }; }; - struct TNullType {}; - + //---------------------------------------------------------------------------- - template + template < class TypeList, unsigned int index > struct TTypeAt; - template - struct TTypeAt, 0> + template < class THead, class TTail > + struct TTypeAt< TList< THead, TTail >, 0 > { typedef THead TResult; }; - template - struct TTypeAt, index> + template < class THead, class TTail, unsigned int index > + struct TTypeAt< TList< THead, TTail >, index > { - typedef typename TTypeAt::TResult TResult; + typedef typename TTypeAt< TTail, index - 1 >::TResult TResult; }; + //---------------------------------------------------------------------------- - template + template < class TypeList, class T > struct TIndexOf; - template - struct TIndexOf + template < class T > + struct TIndexOf< TNullType, T > { enum { value = -1 }; }; - template - struct TIndexOf, T> + template < class T, class TTail > + struct TIndexOf< TList< T, TTail >, T > { enum { value = 0 }; }; - template - struct TIndexOf, T> + template < class THead, class TTail, class T > + struct TIndexOf< TList< THead, TTail >, T > { private: - enum { temp = TIndexOf::value }; + enum { temp = TIndexOf< TTail, T >::value }; public: enum { value = temp == -1? -1 : 1 + temp }; }; + + //---------------------------------------------------------------------------- + template + < + class T01 = TNullType, class T02 = TNullType, class T03 = TNullType, class T04 = TNullType, class T05 = TNullType, + class T06 = TNullType, class T07 = TNullType, class T08 = TNullType, class T09 = TNullType, class T10 = TNullType, + class T11 = TNullType, class T12 = TNullType, class T13 = TNullType, class T14 = TNullType, class T15 = TNullType, + class T16 = TNullType, class T17 = TNullType, class T18 = TNullType, class T19 = TNullType, class T20 = TNullType, + class T21 = TNullType, class T22 = TNullType, class T23 = TNullType, class T24 = TNullType, class T25 = TNullType, + class T26 = TNullType, class T27 = TNullType, class T28 = TNullType, class T29 = TNullType, class T30 = TNullType, + class T31 = TNullType, class T32 = TNullType, class T33 = TNullType, class T34 = TNullType, class T35 = TNullType, + class T36 = TNullType, class T37 = TNullType, class T38 = TNullType, class T39 = TNullType, class T40 = TNullType + > + struct TSequence + { + private: + typedef typename TSequence< T02, T03, T04, T05, T06, T07, T08, T09, T10, + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40 + >::TResult + TailResult; + public: + typedef TList< T01, TailResult > TResult; + }; + + + //---------------------------------------------------------------------------- + template<> + struct TSequence<> + { + typedef TNullType TResult; + }; + + //---------------------------------------------------------------------------- } + + + //---------------------------------------------------------------------------- } #endif diff --git a/src/CONVERTOR/VISU_VTKTypeList.hxx b/src/CONVERTOR/VISU_VTKTypeList.hxx new file mode 100644 index 00000000..f210f652 --- /dev/null +++ b/src/CONVERTOR/VISU_VTKTypeList.hxx @@ -0,0 +1,120 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_VTKTypeList.hxx +// Author : Oleg UVAROV +// Module : VISU + +#ifndef VISU_VTKTypeList_HeaderFile +#define VISU_VTKTypeList_HeaderFile + +#include "VISU_TypeList.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//---------------------------------------------------------------------------- +namespace VISU +{ + //---------------------------------------------------------------------------- + namespace TL + { + //---------------------------------------------------------------------------- + typedef TSequence< char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + float, + double >::TResult TVTKBasicTypeList; + + + //---------------------------------------------------------------------------- + typedef TSequence< vtkCharArray, + vtkUnsignedCharArray, + vtkShortArray, + vtkUnsignedShortArray, + vtkIntArray, + vtkUnsignedIntArray, + vtkLongArray, + vtkUnsignedLongArray, + vtkFloatArray, + vtkDoubleArray >::TResult TVTKArrayTypeList; + + + //---------------------------------------------------------------------------- + typedef TSequence< TInt2Type< VTK_CHAR >, + TInt2Type< VTK_UNSIGNED_CHAR >, + TInt2Type< VTK_SHORT >, + TInt2Type< VTK_UNSIGNED_SHORT >, + TInt2Type< VTK_INT >, + TInt2Type< VTK_UNSIGNED_INT >, + TInt2Type< VTK_LONG >, + TInt2Type< VTK_UNSIGNED_LONG >, + TInt2Type< VTK_FLOAT >, + TInt2Type< VTK_DOUBLE > >::TResult TVTKBasicEnumList; + + + //---------------------------------------------------------------------------- + template< unsigned int type_enum > + struct TEnum2VTKBasicType + { + typedef typename TTypeAt< TVTKBasicTypeList, TIndexOf< TVTKBasicEnumList, TInt2Type< type_enum > >::value >::TResult TResult; + }; + + + //---------------------------------------------------------------------------- + template< unsigned int type_enum > + struct TEnum2VTKArrayType + { + typedef typename TTypeAt< TVTKArrayTypeList, TIndexOf< TVTKBasicEnumList, TInt2Type< type_enum > >::value >::TResult TResult; + }; + + + //---------------------------------------------------------------------------- + template< class T > + struct TVTKBasicType2Enum + { + typedef typename TTypeAt< TVTKBasicEnumList, TIndexOf< TVTKBasicTypeList, T >::value >::TResult TResult; + }; + + + //---------------------------------------------------------------------------- + } + + + //---------------------------------------------------------------------------- +} + +#endif diff --git a/src/ENGINE/VISU_Engine_i.cc b/src/ENGINE/VISU_Engine_i.cc index 80b53607..d857f644 100644 --- a/src/ENGINE/VISU_Engine_i.cc +++ b/src/ENGINE/VISU_Engine_i.cc @@ -278,7 +278,7 @@ namespace VISU{ return myVisuGen->DeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); } - ScalarMapOnDeformedShape_ptr + DeformedShapeAndScalarMap_ptr VISU_Gen_i ::ScalarMapOnDeformedShapeOnField(Result_ptr theResult, const char* theMeshName, @@ -286,7 +286,18 @@ namespace VISU{ const char* theFieldName, CORBA::Long theIteration) { - return myVisuGen->ScalarMapOnDeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + return DeformedShapeAndScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + } + + DeformedShapeAndScalarMap_ptr + VISU_Gen_i + ::DeformedShapeAndScalarMapOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Long theIteration) + { + return myVisuGen->DeformedShapeAndScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); } Vectors_ptr diff --git a/src/ENGINE/VISU_Engine_i.hh b/src/ENGINE/VISU_Engine_i.hh index 8c5964c6..247a1074 100644 --- a/src/ENGINE/VISU_Engine_i.hh +++ b/src/ENGINE/VISU_Engine_i.hh @@ -152,14 +152,23 @@ namespace VISU const char* theFieldName, CORBA::Long theIteration); + //This function is obsolete. Use DeformedShapeAndScalarMapOnField instead. virtual - ScalarMapOnDeformedShape_ptr + DeformedShapeAndScalarMap_ptr ScalarMapOnDeformedShapeOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, CORBA::Long theIteration); + virtual + DeformedShapeAndScalarMap_ptr + DeformedShapeAndScalarMapOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Long theIteration); + //Create Digital Presentation virtual Table_ptr CreateTable(const char* theTableEntry); virtual Curve_ptr CreateCurve(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow); diff --git a/src/OBJECT/Makefile.am b/src/OBJECT/Makefile.am index 0f022b75..ff0a1471 100644 --- a/src/OBJECT/Makefile.am +++ b/src/OBJECT/Makefile.am @@ -41,7 +41,8 @@ salomeinclude_HEADERS = \ VISU_GaussPtsAct.h \ VISU_VectorsAct.h \ VISU_PointMap3dActor.h \ - VISU_ActorBase.h + VISU_ActorBase.h \ + VISU_IsoSurfActor.h dist_libVisuObject_la_SOURCES = \ VISU_Actor.cxx \ @@ -53,7 +54,8 @@ dist_libVisuObject_la_SOURCES = \ VISU_GaussPtsAct.cxx \ VISU_VectorsAct.cxx \ VISU_PointMap3dActor.cxx \ - VISU_ActorBase.cxx + VISU_ActorBase.cxx \ + VISU_IsoSurfActor.cxx libVisuObject_la_CPPFLAGS= \ $(QT_INCLUDES) \ diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index 43b6c761..f4d26b4e 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -167,43 +167,6 @@ VISU_Actor return myPrs3d; } -//---------------------------------------------------------------------------- -/*VISU::TActorFactory* -VISU_Actor -::GetFactory() -{ - return myActorFactory; -}*/ - -/*void -VISU_Actor -::SetFactory(VISU::TActorFactory* theActorFactory) -{ - using namespace VISU; - - if(myActorFactory == theActorFactory) - return; - - if(theActorFactory) - myDestroySignal.connect(boost::bind(&TActorFactory::RemoveActor, - theActorFactory, - _1)); - - myActorFactory = theActorFactory; -}*/ - -//---------------------------------------------------------------------------- -/*void -VISU_Actor -::UpdateFromFactory() -{ - if(myUpdateFromFactoryTime.GetMTime() < myActorFactory->GetMTime()){ - myUpdateFromFactoryTime.Modified(); - myActorFactory->UpdateActor(this); - Update(); - } -}*/ - void VISU_Actor ::RemoveFromRender() @@ -217,11 +180,11 @@ VISU_Actor ::SetPipeLine(VISU_PipeLine* thePipeLine) { myPipeLine = thePipeLine; - if(thePipeLine){ - if(vtkMapper *aMapper = myPipeLine->GetMapper()){ - if(vtkDataSet *aDataSet = aMapper->GetInput()){ - SetShrinkable(thePipeLine->IsShrinkable()); - SetMapperInput(aDataSet); + if ( thePipeLine ) { + if ( vtkMapper *aMapper = myPipeLine->GetMapper() ) { + if ( vtkDataSet *aDataSet = aMapper->GetInput() ) { + SetShrinkable( thePipeLine->IsShrinkable() ); + SetMapperInput( aDataSet ); } } } diff --git a/src/OBJECT/VISU_ActorBase.cxx b/src/OBJECT/VISU_ActorBase.cxx index 812f790d..c794a7d5 100644 --- a/src/OBJECT/VISU_ActorBase.cxx +++ b/src/OBJECT/VISU_ActorBase.cxx @@ -28,14 +28,31 @@ #include "VISU_ActorBase.h" #include "VISU_ActorFactory.h" +#include "VTKViewer_ShrinkFilter.h" #include +#include +#include +#include +#include +#include +#include + +#include "utilities.h" + #include VISU_ActorBase -::VISU_ActorBase() +::VISU_ActorBase() : + myIsShrinkable(true), + myIsShrunk(false), + myShrinkFilter(VTKViewer_ShrinkFilter::New()) { - + myShrinkFilter->Delete(); + + myStoreMapping = true; + + myShrinkFilter->SetStoreMapping(true); } VISU_ActorBase @@ -80,3 +97,67 @@ VISU_ActorBase } } +//-------------------------------------------------------------------------- + +void +VISU_ActorBase +::SetLineWidth(vtkFloatingPointType theLineWidth) +{ + GetProperty()->SetLineWidth(theLineWidth); +} + +vtkFloatingPointType +VISU_ActorBase +::GetLineWidth() +{ + return GetProperty()->GetLineWidth(); +} + +//-------------------------------------------------------------------------- +void +VISU_ActorBase +::SetRepresentation(int theMode) +{ + Superclass::SetRepresentation(theMode); + if(myRepresentation == VTK_POINTS) + UnShrink(); +} + +//---------------------------------------------------------------------------- +void VISU_ActorBase::SetShrink() +{ + if(!myIsShrinkable) + return; + if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){ + myShrinkFilter->SetInput(aDataSet); + myPassFilter[1]->SetInput(myShrinkFilter->GetOutput()); + myIsShrunk = true; + } +} + +void VISU_ActorBase::UnShrink() +{ + if(!myIsShrunk) + return; + if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){ + myPassFilter[1]->SetInput(aDataSet); + myPassFilter[1]->Modified(); + myIsShrunk = false; + Modified(); + } +} + +bool VISU_ActorBase::IsShrunk() +{ + return myIsShrunk; +} + +void VISU_ActorBase::SetShrinkable(bool theIsShrinkable) +{ + myIsShrinkable = theIsShrinkable; +} + +bool VISU_ActorBase::IsShrunkable() +{ + return myIsShrinkable; +} diff --git a/src/OBJECT/VISU_ActorBase.h b/src/OBJECT/VISU_ActorBase.h index 84909cbe..2b9e414d 100644 --- a/src/OBJECT/VISU_ActorBase.h +++ b/src/OBJECT/VISU_ActorBase.h @@ -32,6 +32,8 @@ #include "SALOME_Actor.h" #include "VISU_BoostSignals.h" +class VTKViewer_ShrinkFilter; + #ifdef _WIN32 #define VTKOCC_EXPORT __declspec (dllexport) #else @@ -54,18 +56,25 @@ class VTKOCC_EXPORT VISU_ActorBase: public SALOME_Actor, vtkTypeMacro(VISU_ActorBase, SALOME_Actor); //---------------------------------------------------------------------------- - VISU::TActorFactory* - GetFactory(); - - virtual - void - SetFactory(VISU::TActorFactory* theActorFactory); + VISU::TActorFactory* GetFactory(); + virtual void SetFactory(VISU::TActorFactory* theActorFactory); //---------------------------------------------------------------------------- - virtual - void - UpdateFromFactory(); + virtual void UpdateFromFactory(); + + //---------------------------------------------------------------------------- + + virtual void SetLineWidth(vtkFloatingPointType theLineWidth); + virtual vtkFloatingPointType GetLineWidth(); + + virtual void SetShrink(); + virtual void UnShrink(); + virtual bool IsShrunkable(); + virtual bool IsShrunk(); + virtual void SetShrinkable(bool theIsShrinkable); + virtual void SetRepresentation(int theMode); + protected: VISU_ActorBase(); virtual ~VISU_ActorBase(); @@ -73,6 +82,11 @@ class VTKOCC_EXPORT VISU_ActorBase: public SALOME_Actor, VISU::TActorFactory* myActorFactory; vtkTimeStamp myUpdateFromFactoryTime; boost::signal1 myDestroySignal; + + vtkSmartPointer myShrinkFilter; + + bool myIsShrinkable; + bool myIsShrunk; }; #endif //VISU_ACTOR_BASE_H diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 8ca84bc9..04837dc4 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,7 @@ #include #include #include +#include #include #include @@ -154,7 +156,10 @@ VISU_GaussPtsAct myEventCallbackCommand->SetClientData(this); myEventCallbackCommand->SetCallback(VISU_GaussPtsAct::ProcessEvents); + vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New(); + myDeviceActor->SetProperty(GetProperty()); + myDeviceActor->SetUserMatrix(aMatrix); myDeviceActor->SetVisibility(true); myDeviceActor->SetPickable(false); @@ -174,6 +179,7 @@ VISU_GaussPtsAct myScalarBarCtrl->Delete(); myMapper->Delete(); + aMatrix->Delete(); } VISU_GaussPtsAct @@ -330,6 +336,7 @@ int VISU_GaussPtsAct ::RenderOpaqueGeometry(vtkViewport *viewport) { + GetMatrix(myDeviceActor->GetUserMatrix()); return 1; } @@ -337,6 +344,7 @@ int VISU_GaussPtsAct ::RenderTranslucentGeometry(vtkViewport *viewport) { + GetMatrix(myDeviceActor->GetUserMatrix()); return 1; } @@ -733,27 +741,47 @@ VISU_GaussPtsAct if(myIsPreselected){ anIsChanged = (myLastPreHighlightObjID != anObjId); if(anIsChanged){ - vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId); + vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId); + //Take into account translation + vtkFloatingPointType aLocalNodeCoord[3]; + this->Transform->Push(); + this->Transform->PostMultiply(); + this->Transform->Identity(); + + this->Transform->Translate(this->Position[0], + this->Position[1], + this->Position[2]); + double aPosition[3]; + this->Transform->GetPosition(aPosition); + + aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0]; + aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1]; + aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2]; + vtkDataSet* aDataSet = GetInput(); vtkPointData* aPointData = aDataSet->GetPointData(); if(vtkDataArray *aScalarArray = aPointData->GetScalars()){ - vtkFloatingPointType aPyramidHeight = myPickingSettings->GetPyramidHeight(); - aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize(); - //vtkFloatingPointType aColor[3] = myPreHighlightActor->GetProperty()->GetColor(); - vtkFloatingPointType aColor[3]; - theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor ); - aColor[0] = 1. - aColor[0]; - aColor[1] = 1. - aColor[1]; - aColor[2] = 1. - aColor[2]; - - myCursorPyramid->Init(aPyramidHeight, - myPickingSettings->GetCursorSize(), - GetRadius(anObjId,aVtkId,aScalarArray), - GetMagnification(anObjId), - GetClamp(anObjId), - aNodeCoord, - aColor); + if ( myPickingSettings ){ + vtkFloatingPointType aPyramidHeight = myPickingSettings->GetPyramidHeight(); + aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize(); + //vtkFloatingPointType aColor[3] = myPreHighlightActor->GetProperty()->GetColor(); + vtkFloatingPointType aColor[3]; + theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor ); + aColor[0] = 1. - aColor[0]; + aColor[1] = 1. - aColor[1]; + aColor[2] = 1. - aColor[2]; + + myCursorPyramid->Init(aPyramidHeight, + myPickingSettings->GetCursorSize(), + GetRadius(anObjId,aVtkId,aScalarArray), + GetMagnification(anObjId), + GetClamp(anObjId), + aLocalNodeCoord, + aColor); + } + } + this->Transform->Pop(); myLastPreHighlightObjID = anObjId; } myCursorPyramid->SetVisibility(true); @@ -776,7 +804,7 @@ ChangeZoom(VISU_PickingSettings *thePickingSettings, vtkIdType theInitialHasIndex, vtkIdType theCurrentHasIndex) { - if(theInitialHasIndex + theCurrentHasIndex == 1){ + if( (theInitialHasIndex + theCurrentHasIndex == 1) && thePickingSettings){ vtkCamera *aCamera = theRenderer->GetActiveCamera(); vtkFloatingPointType aZoomFactor = thePickingSettings->GetZoomFactor(); @@ -901,6 +929,13 @@ VISU_GaussPtsAct return false; } + + +void VISU_GaussPtsAct::SetPosition(double _arg[3]){ + Superclass::SetPosition(_arg); + Highlight(isHighlighted()); +} + //================================================================== // function : Highlight // purpose : @@ -912,6 +947,12 @@ VISU_GaussPtsAct if(!mySelector.GetPointer()) return; + if ( !myPickingSettings ) + { + Superclass::Highlight(theIsHighlight); + return; + } + Selection_Mode aSelectionMode = mySelector->SelectionMode(); bool anInitialHasIndex = isHighlighted() && mySelectionMode == GaussPointSelection; @@ -923,20 +964,9 @@ VISU_GaussPtsAct myOutlineActor->SetVisibility(false); myCursorPyramid->SetVisibility(false); - - myTextActor->SetVisibility(anIsVisible); - myCellActor->SetVisibility(anIsVisible); - GetScalarBarCtrl()->SetIsMarked(anIsVisible); - myCursorPyramidSelected->SetVisibility(anIsVisible); - //GetScalarBarCtrl()->Update(); - - myIsHighlighted = aCurrentHasIndex; - - // Zoom if necessary - ChangeZoom(myPickingSettings, - GetRenderer(), - anInitialHasIndex, - aCurrentHasIndex); + myTextActor->SetVisibility(false); + myCellActor->SetVisibility(false); + myCursorPyramidSelected->SetVisibility(false); if(!theIsHighlight) return; @@ -952,6 +982,20 @@ VISU_GaussPtsAct if ( !aCurrentHasIndex || !myBarVisibility ) return; + myTextActor->SetVisibility(anIsVisible); + myCellActor->SetVisibility(anIsVisible && myPickingSettings->GetDisplayParentMesh()); + GetScalarBarCtrl()->SetIsMarked(anIsVisible); + myCursorPyramidSelected->SetVisibility(anIsVisible); +//GetScalarBarCtrl()->Update(); + + myIsHighlighted = aCurrentHasIndex; + + // Zoom if necessary + ChangeZoom(myPickingSettings, + GetRenderer(), + anInitialHasIndex, + aCurrentHasIndex); + // TColStd_IndexedMapOfInteger aMapIndex; mySelector->GetIndex( getIO(), aMapIndex ); if(aMapIndex.Extent() != 1 || !myBarVisibility) { @@ -963,11 +1007,27 @@ VISU_GaussPtsAct int anObjId = aMapIndex(1); vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId); + if ( !aNodeCoord ) + return; + //Take into account translation + vtkFloatingPointType aLocalNodeCoord[3]; + this->Transform->Push(); + this->Transform->PostMultiply(); + this->Transform->Identity(); + this->Transform->Translate(this->Position[0], + this->Position[1], + this->Position[2]); + double aPosition[3]; + this->Transform->GetPosition(aPosition); + aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0]; + aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1]; + aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2]; + this->Transform->Pop(); vtkFloatingPointType aFocalPnt[3]; aCamera->GetFocalPoint(aFocalPnt); - if ( !aNodeCoord || CheckIsSameVector( aNodeCoord, aFocalPnt, 3 ) ) + if ( CheckIsSameVector(aLocalNodeCoord, aFocalPnt, 3 ) ) return; // FlyTo @@ -977,11 +1037,11 @@ VISU_GaussPtsAct anInteractor->SetDolly(0.0); anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber()); - anInteractor->FlyTo(aRenderer, aNodeCoord); + anInteractor->FlyTo(aRenderer, aLocalNodeCoord); aRenderer->ResetCameraClippingRange(); anInteractor->SetDolly(aDollyWas); anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas); - anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord); + anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aLocalNodeCoord); // std::ostringstream aStr; // int anObjId = aMapIndex(1); @@ -989,8 +1049,7 @@ VISU_GaussPtsAct // vtkIdType aVtkId = GetNodeVTKID(anObjId); if(aVtkId >= 0){ - vtkFloatingPointType *aNodeCoord = GetNodeCoord(anObjId); - vtkFloatingPointType aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.}; + vtkFloatingPointType aWorldCoord[4] = {aLocalNodeCoord[0], aLocalNodeCoord[1], aLocalNodeCoord[2], 1.}; // vtkDataSet* aDataSet = GetInput(); vtkPointData* aDataSetAttributes = aDataSet->GetPointData(); @@ -1009,7 +1068,7 @@ VISU_GaussPtsAct GetRadius(anObjId,aVtkId,aScalarArray), GetMagnification(anObjId), GetClamp(anObjId), - aNodeCoord, + aLocalNodeCoord, myHighlightActor->GetProperty()->GetColor()); myCursorPyramidSelected->SetVisibility(anIsVisible && theIsHighlight); // @@ -1071,6 +1130,8 @@ VISU_GaussPtsAct myCellActor->SetVisibility(anIsVisible && theIsHighlight); myCellActor->SetRepresentation(VTK_WIREFRAME); } + else + myCellActor->SetVisibility(false); } } @@ -1101,7 +1162,7 @@ void VISU_GaussPtsAct ::UpdatePickingSettings() { - if(!myPickingSettings || myPickingSettings->GetInitial()) + if(!myPickingSettings) return; myTextActor->SetModePosition(myPickingSettings->GetInfoWindowPosition()); @@ -1210,13 +1271,18 @@ VISU_GaussPtsAct1 myEventCallbackCommand->SetCallback(VISU_GaussPtsAct1::ProcessEvents); + vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New(); + myInsideDeviceActor->SetVisibility(false); myInsideDeviceActor->SetPickable(false); + myInsideDeviceActor->SetUserMatrix(aMatrix); myInsideDeviceActor->Delete(); myOutsideDeviceActor->SetVisibility(false); myOutsideDeviceActor->SetPickable(false); + myOutsideDeviceActor->SetUserMatrix(aMatrix); myOutsideDeviceActor->Delete(); + aMatrix->Delete(); } VISU_GaussPtsAct1 @@ -1273,6 +1339,28 @@ VISU_GaussPtsAct1 } +int +VISU_GaussPtsAct1 +::RenderOpaqueGeometry(vtkViewport *viewport) +{ + + Superclass::RenderOpaqueGeometry(viewport); + GetMatrix(myInsideDeviceActor->GetUserMatrix()); + GetMatrix(myOutsideDeviceActor->GetUserMatrix()); + return 1; +} + +int +VISU_GaussPtsAct1 +::RenderTranslucentGeometry(vtkViewport *viewport) +{ + Superclass::RenderTranslucentGeometry(viewport); + GetMatrix(myInsideDeviceActor->GetUserMatrix()); + GetMatrix(myOutsideDeviceActor->GetUserMatrix()); + + return 1; +} + //---------------------------------------------------------------------------- void VISU_GaussPtsAct1 @@ -1378,11 +1466,20 @@ VISU_GaussPtsAct1 //---------------------------------------------------------------- + +void +VISU_GaussPtsAct1::SetPosition(double _arg[3]){ + if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetPosition - this = "< +#include #include #include +#include + //---------------------------------------------------------------- vtkStandardNewMacro( VISU_GaussPtsSettings ); vtkStandardNewMacro( VISU_InsideCursorSettings ); @@ -86,19 +90,38 @@ VISU_OutsideCursorSettings::~VISU_OutsideCursorSettings() //---------------------------------------------------------------- VISU_PickingSettings::VISU_PickingSettings() { - this->Initial = true; + float aCursorSize = 0.5; + float aPyramidHeight = 10.0; + float aPointTolerance = 0.1; + QColor aColor = Qt::yellow; + int anInfoWindowTransparency = 50; + int anInfoWindowPosition = VISU_PickingSettings::BelowPoint; + float aZoomFactor = 1.5; + int aStepNumber = 10; + bool aDisplayParentMesh = false; + + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); - this->PyramidHeight = -1; - this->CursorSize = -1; - this->PointTolerance = -1; - this->Color[0] = -1; - this->Color[1] = -1; - this->Color[2] = -1; - this->InfoWindowTransparency = -1; - this->InfoWindowPosition = -1; - this->ZoomFactor = -1; - this->StepNumber = -1; - this->DisplayParentMesh = false; + this->CursorSize = aResourceMgr->doubleValue( "VISU", "picking_cursor_size", aCursorSize ); + + this->PyramidHeight = aResourceMgr->doubleValue( "VISU", "picking_pyramid_height", aPyramidHeight ); + + this->PointTolerance = aResourceMgr->doubleValue( "VISU", "picking_point_tolerance", aPointTolerance ); + + aColor = aResourceMgr->colorValue( "VISU", "picking_selection_color", aColor ); + this->Color[0] = aColor.red() / 255.0; + this->Color[1] = aColor.green() / 255.0; + this->Color[2] = aColor.blue() / 255.0; + + this->InfoWindowTransparency = aResourceMgr->integerValue( "VISU", "picking_transparency", anInfoWindowTransparency ) / 100.0; + + this->InfoWindowPosition = aResourceMgr->integerValue( "VISU", "picking_position", anInfoWindowPosition ); + + this->ZoomFactor = aResourceMgr->doubleValue( "VISU", "picking_zoom_factor", aZoomFactor ); + + this->StepNumber = aResourceMgr->integerValue( "VISU", "picking_step_number", aStepNumber ); + + this->DisplayParentMesh = aResourceMgr->booleanValue( "VISU", "picking_display_parent_mesh", aDisplayParentMesh ); } VISU_PickingSettings::~VISU_PickingSettings() diff --git a/src/OBJECT/VISU_GaussPtsSettings.h b/src/OBJECT/VISU_GaussPtsSettings.h index 473ddd10..a34dbca6 100644 --- a/src/OBJECT/VISU_GaussPtsSettings.h +++ b/src/OBJECT/VISU_GaussPtsSettings.h @@ -186,9 +186,6 @@ class VTKOCC_EXPORT VISU_PickingSettings : public vtkObject VISU_PickingSettings* New(); - vtkSetMacro( Initial, bool ); - vtkGetMacro( Initial, bool ); - vtkSetMacro( PyramidHeight, vtkFloatingPointType ); vtkGetMacro( PyramidHeight, vtkFloatingPointType ); @@ -217,8 +214,6 @@ class VTKOCC_EXPORT VISU_PickingSettings : public vtkObject vtkGetMacro( DisplayParentMesh, bool ); private: - bool Initial; - vtkFloatingPointType PyramidHeight; vtkFloatingPointType CursorSize; vtkFloatingPointType PointTolerance; diff --git a/src/OBJECT/VISU_IsoSurfActor.cxx b/src/OBJECT/VISU_IsoSurfActor.cxx new file mode 100644 index 00000000..3c58fc47 --- /dev/null +++ b/src/OBJECT/VISU_IsoSurfActor.cxx @@ -0,0 +1,165 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VISU_IsoSurfActor.cxx +// Author : Vitaly Smetannikov +// Module : VISU + + +#include "VISU_IsoSurfActor.h" +#include "VISU_PipeLine.hxx" +#include "VISU_LabelPointsFilter.hxx" + + +#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include + + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(VISU_IsoSurfActor); + + +//---------------------------------------------------------------------------- +VISU_IsoSurfActor::VISU_IsoSurfActor(): + VISU_ScalarMapAct(), + myIsLinesLabeled(true) +{ + myLabelsDataSet = vtkPolyData::New(); + +// myMaskPoints = vtkMaskPoints::New(); +// myMaskPoints->SetInput(myLabelsDataSet); +// myMaskPoints->SetOnRatio(100); + + myMaskPoints = VISU_LabelPointsFilter::New(); + myMaskPoints->SetInput(myLabelsDataSet); + + myLabeledDataMapper = vtkLabeledDataMapper::New(); + myLabeledDataMapper->SetInput(myMaskPoints->GetOutput()); + //myLabeledDataMapper->SetLabelFormat("%e"); + myLabeledDataMapper->SetLabelModeToLabelScalars(); + + myLabels = vtkActor2D::New(); + myLabels->SetMapper(myLabeledDataMapper); + myLabels->GetProperty()->SetColor(1,1,1); + myLabels->SetVisibility(myIsLinesLabeled); +} + + +//---------------------------------------------------------------------------- +VISU_IsoSurfActor::~VISU_IsoSurfActor() +{ + myLabelsDataSet->Delete(); + myMaskPoints->Delete(); + myLabeledDataMapper->Delete(); + myLabels->Delete(); +} + +//---------------------------------------------------------------------------- +void VISU_IsoSurfActor::SetLinesLabeled(bool theIsLinesLabeled, int theNbLbl) +{ + myIsLinesLabeled = theIsLinesLabeled; + myMaskPoints->SetPointsNb(theNbLbl); + Modified(); +} + +//---------------------------------------------------------------------------- +int VISU_IsoSurfActor::GetNbLabels() const +{ + return myMaskPoints->GetPointsNb(); +} + + +//---------------------------------------------------------------------------- +void VISU_IsoSurfActor::UpdateLabels() +{ + if (myIsLinesLabeled) { + vtkDataSet* aDataSet = GetPipeLine()->GetOutput(); + if (aDataSet != NULL) { + unsigned long aTime = myLabelsDataSet->GetMTime(); + unsigned long anObjTime = GetMTime(); + if (aTime < anObjTime) { + myLabelsDataSet->ShallowCopy(aDataSet); + myLabelsDataSet->Modified(); + } + } + } + myLabels->SetVisibility(myIsLinesLabeled); +} + + +//---------------------------------------------------------------------------- +void VISU_IsoSurfActor::AddToRender(vtkRenderer* theRenderer) +{ + VISU_ScalarMapAct::AddToRender(theRenderer); + theRenderer->AddActor2D(myLabels); +} + +//---------------------------------------------------------------------------- +void VISU_IsoSurfActor::RemoveFromRender(vtkRenderer* theRenderer) +{ + VISU_ScalarMapAct::RemoveFromRender(theRenderer); + theRenderer->RemoveActor(myLabels); +} + +//From vtkFollower +int VISU_IsoSurfActor::RenderOpaqueGeometry(vtkViewport *vp) +{ + UpdateLabels(); + return VISU_ScalarMapAct::RenderOpaqueGeometry(vp); +} + + +int VISU_IsoSurfActor::RenderTranslucentGeometry(vtkViewport *vp) +{ + UpdateLabels(); + return VISU_ScalarMapAct::RenderTranslucentGeometry(vp); +} + +void VISU_IsoSurfActor::SetVisibility(int theMode){ + VISU_ScalarMapAct::SetVisibility(theMode); + if(GetVisibility()) + myLabels->VisibilityOn(); + else + myLabels->VisibilityOff(); + Modified(); +} + + +///!!!! For test purposes only +// void VISU_IsoSurfActor::SetMapperInput(vtkDataSet* theDataSet) +// { +// VISU_ScalarMapAct::SetMapperInput(theDataSet); + +// vtkFeatureEdges* aFilter = vtkFeatureEdges::New(); +// aFilter->SetInput(VISU_ScalarMapAct::GetInput()); +// SetInput(aFilter->GetOutput()); +// } diff --git a/src/OBJECT/VISU_IsoSurfActor.h b/src/OBJECT/VISU_IsoSurfActor.h new file mode 100644 index 00000000..0377ae6a --- /dev/null +++ b/src/OBJECT/VISU_IsoSurfActor.h @@ -0,0 +1,88 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VISU_IsoSurfActor.h +// Author : Vitaly Smetannikov +// Module : VISU + + +#ifndef VISU_VectorsAct_HeaderFile +#define VISU_VectorsAct_HeaderFile + +#include "VISU_ScalarMapAct.h" + +class vtkActor2D; +//class vtkMaskPoints; +class vtkLabeledDataMapper; +class vtkPolyData; +class VISU_LabelPointsFilter; + + +class VTKOCC_EXPORT VISU_IsoSurfActor : public VISU_ScalarMapAct +{ + public: + vtkTypeMacro(VISU_IsoSurfActor, VISU_ScalarMapAct); + + static VISU_IsoSurfActor* New(); + + + //---------------------------------------------------------------------------- + virtual void AddToRender( vtkRenderer* ); + + virtual void RemoveFromRender( vtkRenderer* ); + + virtual int RenderOpaqueGeometry(vtkViewport *viewport); + virtual int RenderTranslucentGeometry(vtkViewport *viewport); + + //virtual void SetPipeLine(VISU_PipeLine* thePipeLine); + + void SetLinesLabeled(bool theIsLinesLabeled, int theNbLbl); + bool GetLinesLabeled() const { return myIsLinesLabeled;} + + int GetNbLabels() const; + + + //---------------------------------------------------------------------------- + //! Visibility management + virtual void SetVisibility( int ); + + + protected: + + VISU_IsoSurfActor(); + ~VISU_IsoSurfActor(); + + void UpdateLabels(); + + vtkActor2D *myLabels; + vtkLabeledDataMapper* myLabeledDataMapper; + //vtkMaskPoints* myMaskPoints; + VISU_LabelPointsFilter* myMaskPoints; + vtkPolyData* myLabelsDataSet; + + bool myIsLinesLabeled; + //int myNbLabels; +}; + + +#endif diff --git a/src/OBJECT/VISU_PointMap3dActor.cxx b/src/OBJECT/VISU_PointMap3dActor.cxx index 99e31230..933cf60b 100644 --- a/src/OBJECT/VISU_PointMap3dActor.cxx +++ b/src/OBJECT/VISU_PointMap3dActor.cxx @@ -33,10 +33,16 @@ #include +#include "utilities.h" #include #include -//using namespace std; +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + vtkStandardNewMacro(VISU_PointMap3dActor); //================================================================== @@ -47,6 +53,7 @@ vtkStandardNewMacro(VISU_PointMap3dActor); VISU_PointMap3dActor ::VISU_PointMap3dActor() { + if(MYDEBUG) MESSAGE("VISU_PointMap3dActor::VISU_PointMap3dActor - this = "< // VTK Includes #include @@ -58,8 +59,9 @@ void VISU_VectorsAct ::SetPipeLine(VISU_PipeLine* thePipeLine) { - myVectorsPL = dynamic_cast(thePipeLine); - VISU_Actor::SetPipeLine(myVectorsPL.GetPointer()); + myVectorsPL = dynamic_cast( thePipeLine ); + + Superclass::SetPipeLine( myVectorsPL.GetPointer() ); } @@ -77,8 +79,9 @@ void VISU_VectorsAct ::SetTransform(VTKViewer_Transform* theTransform) { - Superclass::SetTransform(theTransform); - myVectorsPL->SetTransform(theTransform); + // To perform only vector's specific action, + // there is nothing to be done for the Superclass + myVectorsPL->SetTransform( theTransform ); } @@ -101,6 +104,7 @@ VISU_VectorsAct else if(vtkPolyDataMapper* aMapper = dynamic_cast(theMapper)) aMapper->SetInput(myPassFilter[3]->GetPolyDataOutput()); } + vtkLODActor::SetMapper(theMapper); } diff --git a/src/PIPELINE/Makefile.am b/src/PIPELINE/Makefile.am index adb0d87b..425f955c 100644 --- a/src/PIPELINE/Makefile.am +++ b/src/PIPELINE/Makefile.am @@ -63,8 +63,13 @@ salomeinclude_HEADERS= \ VISU_PlanesWidget.hxx \ VISU_SphereWidget.hxx \ VISU_WidgetCtrl.hxx \ - VISU_ScalarMapOnDeformedShapePL.hxx \ - VISUPipeline.hxx + VISU_DeformedShapeAndScalarMapPL.hxx \ + VISUPipeline.hxx \ + VISU_LabelPointsFilter.hxx \ + VISU_ElnoDisassembleFilter.hxx \ + VISU_ElnoAssembleFilter.hxx \ + VISU_DeformationPL.hxx \ + VISU_OptionalDeformationPL.hxx dist_libVisuPipeLine_la_SOURCES= \ VISU_MapperHolder.cxx \ @@ -101,7 +106,12 @@ dist_libVisuPipeLine_la_SOURCES= \ VISU_SphereWidget.cxx \ VISU_WidgetCtrl.cxx \ VISU_ScalarBarCtrl.cxx \ - VISU_ScalarMapOnDeformedShapePL.cxx + VISU_DeformedShapeAndScalarMapPL.cxx \ + VISU_LabelPointsFilter.cxx \ + VISU_ElnoDisassembleFilter.cxx \ + VISU_ElnoAssembleFilter.cxx \ + VISU_DeformationPL.cxx \ + VISU_OptionalDeformationPL.cxx libVisuPipeLine_la_CPPFLAGS= \ $(VTK_INCLUDES) \ diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 4b658ba1..291c457a 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -24,6 +24,11 @@ // Author: Alexey PETROV // Module : VISU + +// Salome includes +#include "VISU_Convertor.hxx" +#include "VISU_ConvertorUtils.hxx" + #include "VISU_MeshPL.hxx" #include "VISU_ScalarMapPL.hxx" #include "VISU_IsoSurfacesPL.hxx" @@ -33,354 +38,289 @@ #include "VISU_VectorsPL.hxx" #include "VISU_StreamLinesPL.hxx" #include "VISU_GaussPointsPL.hxx" -#include "VISU_ScalarMapOnDeformedShapePL.hxx" +#include "VISU_DeformedShapeAndScalarMapPL.hxx" #include "VISU_Plot3DPL.hxx" -#include "VISU_ScalarBarActor.hxx" - -#include "VISU_DeformedGridPL.hxx" +#include "VISU_ScalarBarActor.hxx" #include "VISU_OpenGLPointSpriteMapper.hxx" #include "VTKViewer_GeometryFilter.h" -#include -#include "VISU_Convertor.hxx" -#include "VISU_TableReader.hxx" -#include "VISU_ConvertorUtils.hxx" +#include "VISU_ElnoDisassembleFilter.hxx" +#include "VISU_ElnoAssembleFilter.hxx" -typedef VISU_StreamLinesPL TPresent; +typedef VISU_ScalarMapPL TPresent; +// VTK includes +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include - #include #include #include #include +#include #include #include #include #include - #include -#include - -#include - -//#define _DEBUG_ID_MAPPING_ - -//---------------------------------------------------------------------------- -template -VISU_ColoredPL* -CreateColoredPL(VISU_Convertor* theConvertor, - const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theTimeStampNumber); - +#include "utilities.h" -//---------------------------------------------------------------------------- -template<> -VISU_ColoredPL* -CreateColoredPL(VISU_Convertor* theConvertor, - const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theTimeStampNumber) -{ - VISU_GaussPointsPL* aPresent = VISU_GaussPointsPL::New(); - VISU::PGaussPtsIDMapper aGaussPtsIDMapper = - theConvertor->GetTimeStampOnGaussPts(theMeshName, - theEntity, - theFieldName, - theTimeStampNumber); - aPresent->SetGaussPtsIDMapper(aGaussPtsIDMapper); - - char aMainTexture[80]; - strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) ); - strcat( aMainTexture, "/share/salome/resources/visu/sprite_texture.bmp" ); - - char anAlphaTexture[80]; - strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) ); - strcat( anAlphaTexture, "/share/salome/resources/visu/sprite_alpha.bmp" ); - - vtkSmartPointer aTextureValue = - VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture ); - aPresent->SetImageData( aTextureValue.GetPointer() ); - - aPresent->Update(); - -#ifdef _DEBUG_ID_MAPPING_ - vtkDataSet* aDataSet = aPresent->GetOutput(); - aDataSet->Update(); - int aNbCells = aDataSet->GetNumberOfCells(); - cout<<"aNbCells = "<GetNodeObjID(anCellId); - vtkIdType aVtkID = aPresent->GetNodeVTKID(anObjID); - cout<GetNodeCoord(anObjID); - cout< -VISU_ColoredPL* -CreateColoredPL(VISU_Convertor* theConvertor, - const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theTimeStampNumber) -{ - TPipeLine* aPresent = TPipeLine::New(); - VISU::PUnstructuredGridIDMapper anUnstructuredGridIDMapper = - theConvertor->GetTimeStampOnMesh(theMeshName, - theEntity, - theFieldName, - theTimeStampNumber); - aPresent->SetUnstructuredGridIDMapper(anUnstructuredGridIDMapper); - - //aPresent->ClearGeometry(); - //{ - // VISU::PUnstructuredGridIDMapper anIDMapper = - // theConvertor->GetMeshOnGroup(theMeshName, - // "groupe1"); - // aPresent->AddGeometry(anIDMapper->GetOutput()); - //} - //{ - // VISU::PUnstructuredGridIDMapper anIDMapper = - // theConvertor->GetMeshOnGroup(theMeshName, - // "TUBEH "); - // aPresent->AddGeometry(anIDMapper->GetOutput()); - //} - //{ - // VISU::PUnstructuredGridIDMapper anIDMapper = - // theConvertor->GetMeshOnGroup(theMeshName, - // "STRI "); - // aPresent->AddGeometry(anIDMapper->GetOutput()); - //} - aPresent->Update(); - return aPresent; +void PrintHelp(){ + MESSAGE_ADD(std::endl << " Usage: VISUPipeLine filename meshname fieldname [timestamp] [component] " << + std::endl << "filename - Name of the med file. " << + std::endl << "meshname - Name of the mesh in the med file. " << + std::endl << "fieldname - Name of the mesh field. " << + std::endl << "timestamp - Number of the time stamp in the field 1,2,3 ... (optionally)" << + std::endl << " by default used first time stamp. " << + std::endl << "component - Number of the component in the field 0,1,2,3 ...(optionally)" << + std::endl << " 0 - modulus, 1 - first component, 2 - second component, ... " << + std::endl << " by default used modulus. "); } - -//---------------------------------------------------------------------------- -struct TMEDSource -{ - std::auto_ptr myConvertor; - - TMEDSource(char** argv): myConvertor(CreateConvertor(argv[1])) - { - myConvertor->BuildEntities(); - } -}; - - -//---------------------------------------------------------------------------- -struct TMeshBulder: TMEDSource -{ - TMeshBulder(char** argv): TMEDSource(argv) - {} - - int Publish(vtkRenderer *theRenderer) const - { - const VISU::TMeshMap& aMeshMap = myConvertor->GetMeshMap(); - VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - if(aMeshMapIter == aMeshMap.end()) - return 0; - - const std::string& aMeshName = aMeshMapIter->first; - const VISU::PMesh aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; - VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; - - VISU::TEntity anEntity = VISU::CELL_ENTITY; - aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity); - - VISU::PNamedIDMapper anIDMapper = myConvertor->GetMeshOnEntity(aMeshName, anEntity); - - VISU_MeshPL* aPresent = VISU_MeshPL::New(); - aPresent->SetUnstructuredGridIDMapper(anIDMapper); - - vtkActor* anActor = vtkActor::New(); - anActor->SetMapper(aPresent->GetMapper()); - anActor->GetProperty()->SetRepresentation(VTK_WIREFRAME); - - theRenderer->AddActor(anActor); - anActor->Delete(); - - return 0; - } -}; +void PrintErr(){ + MESSAGE("***************************ERROR*****************************************"); +} //---------------------------------------------------------------------------- -struct TColoredPrsBulder: TMEDSource +int +main(int argc, char** argv) { - TColoredPrsBulder(char** argv): TMEDSource(argv) - {} - - int Publish(vtkRenderer *theRenderer) const - { - myConvertor->BuildGroups(); - myConvertor->BuildFields(); - myConvertor->BuildMinMax(); - const VISU::TMeshMap& aMeshMap = myConvertor->GetMeshMap(); - VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - if(aMeshMapIter == aMeshMap.end()) - return 0; - - const std::string& aMeshName = aMeshMapIter->first; - const VISU::PMesh aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; - VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; - - //Import fields - aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++) { - const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; - VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); - for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ - const VISU::PField aField = aFieldMapIter->second; - //if(aField->myNbComp == 1) - // continue; - const std::string& aFieldName = aFieldMapIter->first; - const VISU::TValField& aValField = aField->myValField; - VISU::TValField::const_reverse_iterator aValFieldIter = aValField.rbegin(); - if(aValFieldIter == aValField.rend()) - return 0; - - int aTimeStamp = aValFieldIter->first; - - VISU_ColoredPL* aPresent = NULL; - if(anEntity != VISU::NODE_ENTITY){ - aPresent = CreateColoredPL(myConvertor.get(), - aMeshName, - anEntity, - aFieldName, - aTimeStamp); - - }else{ - continue; - aPresent = CreateColoredPL(myConvertor.get(), - aMeshName, - anEntity, - aFieldName, - aTimeStamp); - } - - vtkActor* anActor = vtkActor::New(); - anActor->SetMapper(aPresent->GetMapper()); - - VISU_ScalarBarActor * aScalarBar = VISU_ScalarBarActor::New(); - aScalarBar->SetLookupTable(aPresent->GetBarTable()); - - theRenderer->AddActor(anActor); - anActor->Delete(); - - theRenderer->AddActor2D(aScalarBar); - aScalarBar->Delete(); - } + try{ + if(argc == 1){ + PrintMissing(); + return 1; + } + if(argc == 2 && !strcmp(argv[1],"-h")) { + PrintHelp(); + return 1; } - return 0; - } -}; - - -//---------------------------------------------------------------------------- -struct TXLSSource -{ - VISU::TTableContainer myContainer; - - TXLSSource(char** argv) - { - VISU::ImportTables( argv[1], myContainer ); - } - - int Publish(vtkRenderer *theRenderer) const - { - if ( myContainer.empty() ) - return 0; - - VISU::PPolyDataIDMapper anIDMapper = myContainer[0]; - - VISU_DeformedGridPL* aPresent = VISU_DeformedGridPL::New(); - aPresent->SetPolyDataIDMapper(anIDMapper); - //aPresent->SetContourPrs( true ); - aPresent->Update(); - - vtkActor* anActor = vtkActor::New(); - anActor->SetMapper(aPresent->GetMapper()); - - theRenderer->AddActor(anActor); - anActor->Delete(); - VISU_ScalarBarActor * aScalarBar = VISU_ScalarBarActor::New(); - aScalarBar->SetLookupTable(aPresent->GetBarTable()); + char* aFileName =0; + char* aMeshName =0; + char* aFieldName =0; + int aTimeStampNumber = 1; + int aComponentNumber = 0; + bool allInit = false; + bool isMeshOk = false; + bool isFieldOk = false; + bool isTimeStampOk = false; + bool isComponentOk = false; + + if(argc == 4 ){ + aFileName = new char[static_cast(strlen(argv[1])) + 1]; + aMeshName = new char[static_cast(strlen(argv[2])) + 1]; + aFieldName = new char[static_cast(strlen(argv[3])) + 1]; + + strcpy(aFileName,argv[1]); + strcpy(aMeshName,argv[2]); + strcpy(aFieldName,argv[3]); + + allInit = true; + } + + if(argc == 5) { + aFileName = new char[static_cast(strlen(argv[1])) + 1]; + aMeshName = new char[static_cast(strlen(argv[2])) + 1]; + aFieldName = new char[static_cast(strlen(argv[3])) + 1]; + + strcpy(aFileName,argv[1]); + strcpy(aMeshName,argv[2]); + strcpy(aFieldName,argv[3]); + + aTimeStampNumber = atoi(argv[4]); + allInit = true; + } - theRenderer->AddActor2D(aScalarBar); - aScalarBar->Delete(); + if(argc == 6) { + aFileName = new char[static_cast(strlen(argv[1])) + 1]; + aMeshName = new char[static_cast(strlen(argv[2])) + 1]; + aFieldName = new char[static_cast(strlen(argv[3])) + 1]; + + strcpy(aFileName,argv[1]); + strcpy(aMeshName,argv[2]); + strcpy(aFieldName,argv[3]); + + aTimeStampNumber = atoi(argv[4]); + aComponentNumber = atoi(argv[5]); + allInit = true; + } - return 0; - } -}; - -//---------------------------------------------------------------------------- -template -int RenderPresentation(const TPrsBuilder& thePrsBuilder) -{ - vtkRenderWindow *aWindow = vtkRenderWindow::New(); - vtkRenderer *aRenderer = vtkRenderer::New(); - - aWindow->AddRenderer(aRenderer); - aRenderer->GetActiveCamera()->ParallelProjectionOn(); - - vtkRenderWindowInteractor *anInteractor = vtkRenderWindowInteractor::New(); - anInteractor->SetRenderWindow(aWindow); - aWindow->Delete(); - - vtkInteractorStyle* aStyle = vtkInteractorStyleTrackballCamera::New(); - anInteractor->SetInteractorStyle(aStyle); - aStyle->Delete(); - - int aRet = thePrsBuilder.Publish(aRenderer); - - aWindow->Render(); - anInteractor->Start(); - - return aRet; -} - -//---------------------------------------------------------------------------- -int -main(int argc, char** argv) -{ - try{ - if (argc > 1) { - QFileInfo aFileInfo( argv[1] ); - if ( aFileInfo.isFile() ) { - QString anExtension = aFileInfo.suffix(); - if ( anExtension == "med" ) { - //TMeshBulder aBuilder( argv ); - TColoredPrsBulder aBuilder( argv ); - return RenderPresentation( aBuilder ); - } else if ( anExtension == "xls" || anExtension == "txt" ) - return RenderPresentation( TXLSSource( argv ) ); + if(allInit){ + + vtkRenderWindow *aWindow = vtkRenderWindow::New(); + vtkRenderer *aRenderer = vtkRenderer::New(); + + aWindow->AddRenderer(aRenderer); + aRenderer->GetActiveCamera()->ParallelProjectionOn(); + + vtkRenderWindowInteractor *anInteractor = vtkRenderWindowInteractor::New(); + anInteractor->SetRenderWindow(aWindow); + aWindow->Delete(); + + vtkInteractorStyle* aStyle = vtkInteractorStyleTrackballCamera::New(); + anInteractor->SetInteractorStyle(aStyle); + aStyle->Delete(); + + VISU_Convertor* aConvertor = CreateConvertor(aFileName); + aConvertor->BuildEntities(); + aConvertor->BuildGroups(); + aConvertor->BuildFields(); + aConvertor->BuildMinMax(); + const VISU::TMeshMap& aMeshMap = aConvertor->GetMeshMap(); + VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + if(aMeshMapIter == aMeshMap.end()) return 0; + //Iterate by meshes + for (;aMeshMapIter != aMeshMap.end();aMeshMapIter++) { + + const std::string& theMeshName = aMeshMapIter->first; + if( strcmp(aMeshName, theMeshName.c_str()) ) + continue; + else + isMeshOk = true; + + const VISU::PMesh aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; + + aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + //Iterate by meshes on entity + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++) { + const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; + const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); + + //Iterate by field + for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ + const VISU::PField aField = aFieldMapIter->second; + const std::string& theFieldName = aFieldMapIter->first; + + if( strcmp(aFieldName, theFieldName.c_str()) ) + continue; + else + isFieldOk = true; + + if(aComponentNumber > aField->myNbComp) + continue; + else + isComponentOk = true; + + const VISU::TValField& aValField = aField->myValField; + VISU::TValField::const_iterator aValFieldIter = aValField.find(aTimeStampNumber); + if(aValFieldIter == aValField.end()) + continue; + else + isTimeStampOk = true; + + int aTimeStamp = aValFieldIter->first; + + vtkActor* anActor = vtkActor::New(); + + if(anEntity != VISU::NODE_ENTITY){ + VISU::PUnstructuredGridIDMapper anUnstructuredGridIDMapper = + aConvertor->GetTimeStampOnMesh(theMeshName, + anEntity, + theFieldName, + aTimeStamp); + + vtkUnstructuredGrid* anUnstructuredGrid = anUnstructuredGridIDMapper->GetUnstructuredGridOutput(); + VISU::WriteToFile( anUnstructuredGrid, "/data/apo/elno_from_id_mapper.vtk" ); + + VISU_ElnoDisassembleFilter* aDisassembleFilter = VISU_ElnoDisassembleFilter::New(); + aDisassembleFilter->SetInput( anUnstructuredGrid ); + aDisassembleFilter->SetShrinkFactor( 0.999 ); + VISU::WriteToFile( aDisassembleFilter->GetOutput(), "/data/apo/elno_from_disassemble.vtk" ); + + vtkCutter *aCutter = vtkCutter::New(); + + vtkPointLocator* aPointLocator = vtkPointLocator::New(); + aCutter->SetLocator( aPointLocator ); + aPointLocator->Delete(); + + TPresent* aPresent = TPresent::New(); + aPresent->SetUnstructuredGridIDMapper( anUnstructuredGridIDMapper ); + //aPresent->SetOrientation( VISU_CutPlanesPL::ZX, 0.0, 0.0, 0 ); + aPresent->Update(); + + aPresent->GetMapper()->InterpolateScalarsBeforeMappingOn(); + anActor->SetMapper( aPresent->GetMapper() ); + + vtkScalarBarActor* aScalarBar = vtkScalarBarActor::New(); + //aScalarBar->SetLookupTable( aMapperTable ); + aScalarBar->SetLookupTable( aPresent->GetBarTable() ); + + + vtkScalarBarWidget* aWidget = vtkScalarBarWidget::New(); + aWidget->SetScalarBarActor( aScalarBar ); + aWidget->SetInteractor( anInteractor ); + aWidget->SetEnabled( true ); + + aRenderer->AddActor(anActor); + aRenderer->AddActor2D(aScalarBar); + }else{ + continue; + } + + aWindow->Render(); + aRenderer->ResetCamera(); + + anInteractor->Start(); + return 0; + } + } } } + else{ + PrintMissing(); + return 1; + } + + if(!isMeshOk) { + PrintErr(); + MESSAGE("Can not find mesh with name `"<SetInput(myExtractor->GetOutput()); GetMapperHolder()->SetLookupTable(GetMapperTable()); - GetMapper()->SetUseLookupTableScalarRange(true); + //GetMapper()->InterpolateScalarsBeforeMappingOn(); + GetMapper()->SetUseLookupTableScalarRange( true ); GetMapper()->SetColorModeToMapScalars(); GetMapper()->ScalarVisibilityOn(); } diff --git a/src/PIPELINE/VISU_CutLinesPL.cxx b/src/PIPELINE/VISU_CutLinesPL.cxx index 3bad32d1..dbd2243a 100644 --- a/src/PIPELINE/VISU_CutLinesPL.cxx +++ b/src/PIPELINE/VISU_CutLinesPL.cxx @@ -100,6 +100,12 @@ VISU_CutLinesPL Modified(); } +vtkDataSet* +VISU_CutLinesPL +::InsertCustomPL() +{ + return myAppendPolyData->GetOutput(); +} //---------------------------------------------------------------------------- vtkFloatingPointType diff --git a/src/PIPELINE/VISU_CutLinesPL.hxx b/src/PIPELINE/VISU_CutLinesPL.hxx index 58116834..7ed0ecd8 100644 --- a/src/PIPELINE/VISU_CutLinesPL.hxx +++ b/src/PIPELINE/VISU_CutLinesPL.hxx @@ -64,6 +64,9 @@ public: void Init(); + vtkDataSet* + InsertCustomPL(); + virtual void Update(); diff --git a/src/PIPELINE/VISU_CutPlanesPL.cxx b/src/PIPELINE/VISU_CutPlanesPL.cxx index 22493a10..a8776eaf 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.cxx +++ b/src/PIPELINE/VISU_CutPlanesPL.cxx @@ -29,13 +29,23 @@ #include "VISU_FieldTransform.hxx" #include "VISU_PipeLineUtils.hxx" #include "VTKViewer_GeometryFilter.h" +#include "VISU_MapperHolder.hxx" +#include "VISU_DeformationPL.hxx" #include #include #include +//#include + static vtkFloatingPointType EPS = 1.0E-3; +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + //---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_CutPlanesPL); @@ -43,10 +53,15 @@ vtkStandardNewMacro(VISU_CutPlanesPL); //---------------------------------------------------------------------------- VISU_CutPlanesPL -::VISU_CutPlanesPL() +::VISU_CutPlanesPL(): + VISU_OptionalDeformationPL() { + if(MYDEBUG) MESSAGE("VISU_CutPlanesPL()::VISU_CutPlanesPL() - "<Delete(); myAppendPolyData = NULL; } @@ -76,7 +93,11 @@ VISU_CutPlanesPL ::GetMTime() { unsigned long int aTime = Superclass::GetMTime(); - + + if(IsDeformed()) { + aTime = std::max(aTime, VISU_OptionalDeformationPL::GetMTime()); + } + aTime = std::max(aTime, myAppendPolyData->GetMTime()); return aTime; @@ -113,11 +134,11 @@ VISU_CutPlanesPL ::Init() { Superclass::Init(); - SetNbParts(10); myBasePlane[0] = YZ; myDisplacement[0] = 0.5; myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0; + SetScale(VISU_DeformationPL::GetDefaultScaleFactor(this)); } @@ -126,7 +147,7 @@ vtkDataSet* VISU_CutPlanesPL ::InsertCustomPL() { - return myAppendPolyData->GetOutput(); + return GetWarpVectorOutput(); } @@ -137,18 +158,32 @@ VISU_CutPlanesPL { ClearAppendPolyData(myAppendPolyData); - SetPartPosition(); + if(!myVectorialField || !IsDeformed()){ + SetMergeFilterInput(GetMergedInput(),GetMergedInput()); + } + + + if(VISU::IsDataOnCells(GetMergedInput())) + GetMapper()->SetScalarModeToUseCellData(); + else + GetMapper()->SetScalarModeToUsePointData(); + + SetPartPosition(); + vtkFloatingPointType aDir[3]; GetDir(aDir, myAng[0], myBasePlane[0]); - + vtkFloatingPointType aBounds[6]; - GetMergedInput()->GetBounds(aBounds); + + vtkDataSet* aFilterOutput = GetMergeFilterOutput(); + + aFilterOutput->GetBounds(aBounds); CutWithPlanes(myAppendPolyData, - GetMergedInput(), + aFilterOutput, myNbParts, aDir, aBounds, @@ -156,6 +191,9 @@ VISU_CutPlanesPL myPartCondition, myDisplacement[0]); + + + SetWarpVectorInput(myAppendPolyData->GetOutput()); Superclass::Update(); } @@ -412,7 +450,11 @@ VISU_CutPlanesPL vtkFloatingPointType aPosition = myPartPosition[thePartNumber]; if(myPartCondition[thePartNumber]){ vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3]; - GetMergedInput()->GetBounds(aBounds); + if(!IsDeformed()) + GetMergedInput()->GetBounds(aBounds); + else + GetMergeFilterOutput()->GetBounds(aBounds); + GetDir(aDir, myAng[theNum], @@ -564,3 +606,33 @@ VISU_CutPlanesPL //---------------------------------------------------------------------------- +void +VISU_CutPlanesPL::SetVectorialField(VISU::PUnstructuredGridIDMapper theMapper) +{ + if(myVectorialField == theMapper) + return; + + if(CheckCanDeformate(theMapper->GetOutput())){ + myVectorialField = theMapper; + + SetMergeFilterInput(GetMergedInput(),theMapper->GetOutput()); + } + else + UseDeformation(false); + + Modified(); +} + +//---------------------------------------------------------------------------- +VISU::PUnstructuredGridIDMapper VISU_CutPlanesPL:: +getVectorialField() +{ + return myVectorialField; +} + +//---------------------------------------------------------------------------- +void VISU_CutPlanesPL::SetMapScale(vtkFloatingPointType theMapScale){ + Superclass::SetMapScale(theMapScale); + if(IsDeformed()) + VISU_OptionalDeformationPL::SetMapScale(theMapScale); +} diff --git a/src/PIPELINE/VISU_CutPlanesPL.hxx b/src/PIPELINE/VISU_CutPlanesPL.hxx index 27d377fd..054b8761 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.hxx +++ b/src/PIPELINE/VISU_CutPlanesPL.hxx @@ -29,6 +29,8 @@ #include "VISUPipeline.hxx" #include "VISU_ScalarMapPL.hxx" +#include "VISU_OptionalDeformationPL.hxx" +#include "VISU_MapperHolder.hxx" #include @@ -36,7 +38,8 @@ class vtkAppendPolyData; //---------------------------------------------------------------------------- -class VISU_PIPELINE_EXPORT VISU_CutPlanesPL : public VISU_ScalarMapPL +class VISU_PIPELINE_EXPORT VISU_CutPlanesPL : public VISU_ScalarMapPL, + public VISU_OptionalDeformationPL { public: vtkTypeMacro(VISU_CutPlanesPL, VISU_ScalarMapPL); @@ -182,6 +185,14 @@ public: const std::vector& thePlaneCondition, vtkFloatingPointType theDisplacement); + virtual void SetVectorialField(VISU::PUnstructuredGridIDMapper); + VISU::PUnstructuredGridIDMapper getVectorialField(); + + virtual + void + SetMapScale(vtkFloatingPointType theMapScale = 1.0); + + protected: VISU_CutPlanesPL(); diff --git a/src/PIPELINE/VISU_DataSetMapperHolder.cxx b/src/PIPELINE/VISU_DataSetMapperHolder.cxx index 313c6d68..4a9adf0a 100644 --- a/src/PIPELINE/VISU_DataSetMapperHolder.cxx +++ b/src/PIPELINE/VISU_DataSetMapperHolder.cxx @@ -28,6 +28,7 @@ #include "VISU_DataSetMapperHolder.hxx" #include "SALOME_ExtractGeometry.h" +#include "VISU_ElnoDisassembleFilter.hxx" #include "VISU_LookupTable.hxx" #include "VISU_PipeLineUtils.hxx" @@ -41,6 +42,8 @@ #include #include +#include + #ifdef _DEBUG_ static int MYDEBUG = 0; #else @@ -55,10 +58,13 @@ vtkStandardNewMacro(VISU_DataSetMapperHolder); //---------------------------------------------------------------------------- VISU_DataSetMapperHolder ::VISU_DataSetMapperHolder(): - myExtractGeometry(SALOME_ExtractGeometry::New()) + myElnoDisassembleFilter( VISU_ElnoDisassembleFilter::New() ), + myExtractGeometry( SALOME_ExtractGeometry::New() ) { if(MYDEBUG) MESSAGE("VISU_DataSetMapperHolder::VISU_DataSetMapperHolder - "<Delete(); + // Clipping functionality myExtractGeometry->Delete(); myExtractGeometry->SetStoreMapping(true); @@ -96,6 +102,19 @@ VISU_DataSetMapperHolder } +//---------------------------------------------------------------------------- +void +VISU_DataSetMapperHolder +::SetElnoDisassembleState( bool theIsShrunk ) +{ + vtkFloatingPointType aShrinkFactor = std::abs( myElnoDisassembleFilter->GetShrinkFactor() ); + if ( theIsShrunk ) + myElnoDisassembleFilter->SetShrinkFactor( aShrinkFactor ); + else + myElnoDisassembleFilter->SetShrinkFactor( -aShrinkFactor ); +} + + //---------------------------------------------------------------------------- unsigned long int VISU_DataSetMapperHolder @@ -116,9 +135,10 @@ void VISU_DataSetMapperHolder ::SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper) { - myExtractGeometry->SetInput(theIDMapper->GetUnstructuredGridOutput()); + myElnoDisassembleFilter->SetInput( theIDMapper->GetUnstructuredGridOutput() ); + myExtractGeometry->SetInput( myElnoDisassembleFilter->GetOutput() ); myUnstructuredGridIDMapper = theIDMapper; - SetIDMapper(theIDMapper); + SetIDMapper( theIDMapper ); } diff --git a/src/PIPELINE/VISU_DataSetMapperHolder.hxx b/src/PIPELINE/VISU_DataSetMapperHolder.hxx index 45fa07fe..6588abd9 100644 --- a/src/PIPELINE/VISU_DataSetMapperHolder.hxx +++ b/src/PIPELINE/VISU_DataSetMapperHolder.hxx @@ -32,6 +32,7 @@ class vtkDataSetMapper; class vtkUnstructuredGrid; class SALOME_ExtractGeometry; +class VISU_ElnoDisassembleFilter; //---------------------------------------------------------------------------- @@ -50,6 +51,9 @@ public: ShallowCopy(VISU_MapperHolder *theMapperHolder, bool theIsCopyInput); + void + SetElnoDisassembleState( bool theIsShrunk ); + //! Gets memory size used by the instance (bytes). virtual unsigned long int @@ -158,8 +162,9 @@ protected: private: //---------------------------------------------------------------------------- VISU::PUnstructuredGridIDMapper myUnstructuredGridIDMapper; - vtkSmartPointer myDataSetMapper; - vtkSmartPointer myExtractGeometry; //!< Clipping + vtkSmartPointer< VISU_ElnoDisassembleFilter > myElnoDisassembleFilter; //!< Handling ELNO data + vtkSmartPointer< SALOME_ExtractGeometry > myExtractGeometry; //!< Clipping + vtkSmartPointer< vtkDataSetMapper > myDataSetMapper; }; #endif diff --git a/src/PIPELINE/VISU_DeformationPL.cxx b/src/PIPELINE/VISU_DeformationPL.cxx new file mode 100755 index 00000000..2189b228 --- /dev/null +++ b/src/PIPELINE/VISU_DeformationPL.cxx @@ -0,0 +1,163 @@ +// Copyright (C) 2008 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: VISU_ScalarMapPL.cxx +// Author: Roman NIKOLAEV +// Module : VISU + +//Salome includes +#include "VISU_DeformationPL.hxx" +#include "VISU_MergeFilter.hxx" +#include "VISU_DeformedShapePL.hxx" +#include "VISU_PipeLineUtils.hxx" + +//VTK includes +#include +#include +#include +#include +#include +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + + +//---------------------------------------------------------------------------- +VISU_DeformationPL::VISU_DeformationPL(): + myScaleFactor(1.0), + myMapScaleFactor(1.0) +{ + if(MYDEBUG) MESSAGE("VISU_DeformationPL()::VISU_DeformationPL() - "<SetScaleFactor(myScaleFactor); + + myVectorMergeFilter = VISU_MergeFilter::New(); + myVectorMergeFilter->SetMergingInputs(true); + myInputPassFilter = vtkPassThroughFilter::New(); + myOutputPassFiler = vtkPassThroughFilter::New(); + myCellDataToPointData = vtkCellDataToPointData::New(); + myCellDataToPointData->PassCellDataOn(); + + myInputPassFilter->SetInput(vtkUnstructuredGrid::New()); + + myCellDataToPointData->SetInput(myInputPassFilter->GetOutput()); + + myWarpVector->SetInput(myCellDataToPointData->GetOutput()); + + myOutputPassFiler->SetInput(myWarpVector->GetOutput()); +} + +//---------------------------------------------------------------------------- +VISU_DeformationPL::~VISU_DeformationPL() +{ + if(MYDEBUG) MESSAGE("VISU_DeformationPL()::~VISU_DeformationPL() - "<Delete(); + myVectorMergeFilter->Delete(); + myInputPassFilter->Delete(); + myOutputPassFiler->Delete(); + myCellDataToPointData->Delete(); +} + + +//---------------------------------------------------------------------------- +unsigned long int +VISU_DeformationPL::GetMTime(){ + unsigned long int aTime = std::max(myWarpVector->GetMTime(), + myVectorMergeFilter->GetMTime()); + + aTime = std::max(aTime,myInputPassFilter->GetMTime()); + aTime = std::max(aTime,myOutputPassFiler->GetMTime()); + aTime = std::max(aTime,myCellDataToPointData->GetMTime()); +} + +//---------------------------------------------------------------------------- +void VISU_DeformationPL::SetScale(vtkFloatingPointType theScaleFactor) +{ + if(myScaleFactor == theScaleFactor) + return; + myScaleFactor = theScaleFactor; + myWarpVector->SetScaleFactor(myScaleFactor*myMapScaleFactor); +} + +void VISU_DeformationPL::SetMapScale(vtkFloatingPointType theMapScaleFactor) +{ + if(myMapScaleFactor == theMapScaleFactor) + return; + myMapScaleFactor = theMapScaleFactor; + + myWarpVector->SetScaleFactor(myScaleFactor*myMapScaleFactor); +} + + +vtkFloatingPointType VISU_DeformationPL::GetScale() +{ + return myScaleFactor; +} + +//---------------------------------------------------------------------------- +void VISU_DeformationPL::SetWarpVectorInput(vtkDataSet *theInput) +{ + myInputPassFilter->SetInput(theInput); +} + +//---------------------------------------------------------------------------- +vtkDataSet* VISU_DeformationPL::GetWarpVectorOutput() +{ + return myOutputPassFiler->GetOutput(); +} + +//---------------------------------------------------------------------------- +void VISU_DeformationPL::SetMergeFilterInput(vtkDataSet* ScalarInput, + vtkDataSet* VectorialInput) +{ + myVectorMergeFilter->SetScalars(ScalarInput); + myVectorMergeFilter->AddField("VISU_CELLS_MAPPER",ScalarInput); + myVectorMergeFilter->AddField("VISU_POINTS_MAPPER",ScalarInput); + + myVectorMergeFilter->SetGeometry(VectorialInput); + myVectorMergeFilter->SetVectors(VectorialInput); +} + +//---------------------------------------------------------------------------- +vtkDataSet* VISU_DeformationPL::GetMergeFilterOutput(){ + return myVectorMergeFilter->GetOutput(); +} + +//---------------------------------------------------------------------------- +vtkFloatingPointType VISU_DeformationPL::GetDefaultScaleFactor(VISU_DeformationPL *thePipeLine) +{ + if(!thePipeLine || !thePipeLine->GetMergeFilterOutput()) + return 0.0; + + vtkFloatingPointType aSourceRange[2]; + thePipeLine->GetMergeFilterOutput()->GetScalarRange(aSourceRange); + + static vtkFloatingPointType EPS = 1.0 / VTK_LARGE_FLOAT; + if(fabs(aSourceRange[1]) > EPS){ + vtkDataSet* aDataSet = thePipeLine->GetMergeFilterOutput(); + vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor(aDataSet); + return aScaleFactor / aSourceRange[1]; + } + return 0.0; +} + diff --git a/src/PIPELINE/VISU_DeformationPL.hxx b/src/PIPELINE/VISU_DeformationPL.hxx new file mode 100755 index 00000000..e18f43e3 --- /dev/null +++ b/src/PIPELINE/VISU_DeformationPL.hxx @@ -0,0 +1,87 @@ +// Copyright (C) 2008 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 : VISU_DeformationPL.hxx +// Author : +// Module : SALOME + +#ifndef VISU_DeformationPL_HeaderFile +#define VISU_DeformationPL_HeaderFile + +#include "VISUPipeline.hxx" +#include "VISU_MapperHolder.hxx" +#include + +class vtkDataSet; +class VISU_MergeFilter; +class vtkPassThroughFilter; +class vtkWarpVector; +class vtkCellDataToPointData; + +class VISU_PIPELINE_EXPORT VISU_DeformationPL { + +public: + VISU_DeformationPL(); + virtual ~VISU_DeformationPL(); + + //----------------------------------------------------------- + virtual void SetScale(vtkFloatingPointType theScaleFactor); + virtual void SetMapScale(vtkFloatingPointType theMapScaleFactor); + virtual vtkFloatingPointType GetScale(); + + //----------------------------------------------------------- + virtual void SetVectorialField(VISU::PUnstructuredGridIDMapper theIdMapper) = 0; + virtual VISU::PUnstructuredGridIDMapper getVectorialField() = 0; + + + //----------------------------------------------------------- + virtual + unsigned + long int + GetMTime(); + + static vtkFloatingPointType GetDefaultScaleFactor(VISU_DeformationPL *thePipeLine); + + void SetWarpVectorInput(vtkDataSet *theInput); + vtkDataSet* GetWarpVectorOutput(); + + //----------------------------------------------------------- + void SetMergeFilterInput(vtkDataSet* ScalarInput, + vtkDataSet* VectorialInput); + + vtkDataSet* GetMergeFilterOutput(); + +protected: + + VISU::PUnstructuredGridIDMapper myVectorialField; + vtkWarpVector *myWarpVector; + vtkSmartPointer myVectorMergeFilter; + vtkPassThroughFilter *myInputPassFilter; + vtkPassThroughFilter *myOutputPassFiler; + vtkCellDataToPointData *myCellDataToPointData; + +private: + vtkFloatingPointType myScaleFactor; + vtkFloatingPointType myMapScaleFactor; + +}; + +#endif diff --git a/src/PIPELINE/VISU_DeformedGridPL.cxx b/src/PIPELINE/VISU_DeformedGridPL.cxx index e9068b9a..72f40c58 100644 --- a/src/PIPELINE/VISU_DeformedGridPL.cxx +++ b/src/PIPELINE/VISU_DeformedGridPL.cxx @@ -46,7 +46,8 @@ VISU_DeformedGridPL myContourFilter(vtkContourFilter::New()), myWarpScalar(vtkWarpScalar::New()), myIsContour(false), - myScaleFactor(1.0) + myScaleFactor(1.0), + myMapScaleFactor(1.0) { SetIsShrinkable(false); SetNumberOfContours(32); @@ -180,8 +181,9 @@ VISU_DeformedGridPL { if ( VISU::CheckIsSameValue( myWarpScalar->GetScaleFactor(), theScaleFactor ) ) return; + myScaleFactor = theScaleFactor; - myWarpScalar->SetScaleFactor(theScaleFactor); + myWarpScalar->SetScaleFactor(theScaleFactor*myMapScaleFactor); } @@ -222,6 +224,7 @@ VISU_DeformedGridPL ::SetMapScale(vtkFloatingPointType theMapScale) { Superclass::SetMapScale(theMapScale); + myMapScaleFactor = theMapScale; if ( myIsContour ) { vtkFloatingPointType aSourceRange[2]; diff --git a/src/PIPELINE/VISU_DeformedGridPL.hxx b/src/PIPELINE/VISU_DeformedGridPL.hxx index 840059a7..4f325949 100644 --- a/src/PIPELINE/VISU_DeformedGridPL.hxx +++ b/src/PIPELINE/VISU_DeformedGridPL.hxx @@ -108,6 +108,7 @@ private: void operator=(const VISU_DeformedGridPL&); // Not implemented. vtkFloatingPointType myScaleFactor; + vtkFloatingPointType myMapScaleFactor; vtkContourFilter* myContourFilter; vtkWarpScalar *myWarpScalar; bool myIsContour; diff --git a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx new file mode 100644 index 00000000..b807671e --- /dev/null +++ b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx @@ -0,0 +1,372 @@ +// VISU DeformedShapeAndScalarMapPL +// +// 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: VISU_DeformedShapeAndScalarMapPL.cxx +// Author: Eugeny Nikolaev +// Module : VISU + +#include "VISU_DeformedShapeAndScalarMapPL.hxx" +#include "VISU_FieldTransform.hxx" +#include "VISU_Extractor.hxx" +#include "VISU_LookupTable.hxx" +#include "VISU_DeformedShapePL.hxx" +#include "VTKViewer_TransformFilter.h" +#include "VTKViewer_Transform.h" +#include "VISU_MergeFilter.hxx" +#include "VISU_ElnoDisassembleFilter.hxx" +#include "VISU_PipeLineUtils.hxx" + +#include +#include +#include +#include + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(VISU_DeformedShapeAndScalarMapPL) + +//---------------------------------------------------------------------------- +/*! + * Constructor. Creating new instances of vtkWarpVector,vtkMergeFilter,vtkUnstructuredGrid + * Where: + * \li myDeformVectors is vtkWarpVector - deformation vectors data + * \li myScalarsMergeFilter is vtkMergeFilter - merge filter. + * Merge filter which unify the deformation and scalars + * \li myScalars is vtk shared pointer to vtkUnstructuredGrid - scalars data +*/ +VISU_DeformedShapeAndScalarMapPL +::VISU_DeformedShapeAndScalarMapPL(): + myScaleFactor(1.0), + myMapScaleFactor(1.0) +{ + myWarpVector = vtkWarpVector::New(); + + myScalarsMergeFilter = VISU_MergeFilter::New(); + myScalarsMergeFilter->SetMergingInputs(true); + + myScalarsExtractor = VISU_Extractor::New(); + + myScalarsFieldTransform = VISU_FieldTransform::New(); + + myCellDataToPointData = vtkCellDataToPointData::New(); + myScalarsElnoDisassembleFilter = VISU_ElnoDisassembleFilter::New(); +} + +//---------------------------------------------------------------------------- +/*! + * Destructor. + * Delete all fields. +*/ +VISU_DeformedShapeAndScalarMapPL +::~VISU_DeformedShapeAndScalarMapPL() +{ + myWarpVector->Delete(); + + myScalarsMergeFilter->Delete(); + + myScalarsExtractor->Delete(); + + myScalarsFieldTransform->Delete(); + + myCellDataToPointData->Delete(); +} + +//---------------------------------------------------------------------------- +/*! + * Initial method + */ +void +VISU_DeformedShapeAndScalarMapPL +::Init() +{ + Superclass::Init(); + + SetScale(VISU_DeformedShapePL::GetDefaultScale(this)); +} + +//---------------------------------------------------------------------------- +/*! + * Build method + * Building of deformation and puts result to merge filter. + */ +void +VISU_DeformedShapeAndScalarMapPL +::Build() +{ + Superclass::Build(); +} + + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_DeformedShapeAndScalarMapPL +::InsertCustomPL() +{ + GetMapper()->SetColorModeToMapScalars(); + GetMapper()->ScalarVisibilityOn(); + + VISU::CellDataToPoint(myWarpVector, + myCellDataToPointData, + GetMergedInput()); + + myScalars = GetMergedInput(); + + UpdateScalars(); + + myScalarsFieldTransform->SetInput(myScalarsExtractor->GetOutput()); + + // Sets geometry for merge filter + myScalarsMergeFilter->SetGeometry(myWarpVector->GetUnstructuredGridOutput()); + + vtkDataSet* aScalarsDataSet = myScalarsFieldTransform->GetOutput(); + myScalarsMergeFilter->SetScalars(aScalarsDataSet); + myScalarsMergeFilter->AddField("VISU_CELLS_MAPPER", aScalarsDataSet); + myScalarsMergeFilter->AddField("VISU_POINTS_MAPPER", aScalarsDataSet); + + return myScalarsMergeFilter->GetOutput(); +} + + +//---------------------------------------------------------------------------- +/*! + * Update method + */ +void +VISU_DeformedShapeAndScalarMapPL +::Update() +{ + Superclass::Update(); + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myScalarsExtractor.vtk"; + // VISU::WriteToFile(myScalarsExtractor->GetUnstructuredGridOutput(), aFileName); + //} + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myWarpVector.vtk"; + // VISU::WriteToFile(myWarpVector->GetUnstructuredGridOutput(), aFileName); + //} + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myScalarsMergeFilter.vtk"; + // VISU::WriteToFile(myScalarsMergeFilter->GetUnstructuredGridOutput(), aFileName); + //} +} + +//---------------------------------------------------------------------------- +unsigned long int +VISU_DeformedShapeAndScalarMapPL +::GetMemorySize() +{ + unsigned long int aSize = Superclass::GetMemorySize(); + + if(vtkDataSet* aDataSet = myWarpVector->GetOutput()) + aSize += aDataSet->GetActualMemorySize() * 1024; + + if(vtkDataSet* aDataSet = myScalarsExtractor->GetOutput()) + aSize += aDataSet->GetActualMemorySize() * 1024; + + if(vtkDataSet* aDataSet = myScalarsMergeFilter->GetOutput()) + aSize += aDataSet->GetActualMemorySize() * 1024; + + if(myCellDataToPointData->GetInput()) + if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput()) + aSize += aDataSet->GetActualMemorySize() * 1024; + + return aSize; +} + +//---------------------------------------------------------------------------- +/*! + * Update scalars method. + * Put scalars to merge filter. + */ +void +VISU_DeformedShapeAndScalarMapPL +::UpdateScalars() +{ + vtkDataSet* aScalars = GetScalars(); + myScalarsElnoDisassembleFilter->SetInput(aScalars); + myScalarsExtractor->SetInput(myScalarsElnoDisassembleFilter->GetOutput()); + + if(VISU::IsDataOnCells(myScalarsElnoDisassembleFilter->GetOutput())) + GetMapper()->SetScalarModeToUseCellData(); + else + GetMapper()->SetScalarModeToUsePointData(); +} + +//---------------------------------------------------------------------------- +/*! + * Copy information about pipline. + * Copy scale and scalars. + */ +void +VISU_DeformedShapeAndScalarMapPL +::DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput) +{ + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); + + if(VISU_DeformedShapeAndScalarMapPL *aPipeLine = dynamic_cast(thePipeLine)){ + SetScale(aPipeLine->GetScale()); + SetScalars(aPipeLine->GetScalars()); + } +} + +//---------------------------------------------------------------------------- +/*! + * Set scalars. + * Sets vtkDataSet with scalars values to VISU_Extractor filter for scalars extraction. + */ +void +VISU_DeformedShapeAndScalarMapPL +::SetScalars(vtkDataSet *theScalars) +{ + if(GetScalars() == theScalars) + return; + + myScalars = theScalars; + UpdateScalars(); +} + +//---------------------------------------------------------------------------- +/*! + * Get pointer to input scalars. + */ +vtkDataSet* +VISU_DeformedShapeAndScalarMapPL +::GetScalars() +{ + return myScalars.GetPointer(); +} + +//---------------------------------------------------------------------------- +/*! + * Sets scale for deformed shape + */ +void +VISU_DeformedShapeAndScalarMapPL +::SetScale(vtkFloatingPointType theScale) +{ + if(VISU::CheckIsSameValue(myScaleFactor, theScale)) + return; + + myScaleFactor = theScale; + myWarpVector->SetScaleFactor(theScale*myMapScaleFactor); +} + +//---------------------------------------------------------------------------- +/*! + * Gets scale of deformed shape. + */ +vtkFloatingPointType +VISU_DeformedShapeAndScalarMapPL +::GetScale() +{ + return myScaleFactor; +} + +//---------------------------------------------------------------------------- +/*! + * Set scale factor of deformation. + */ +void +VISU_DeformedShapeAndScalarMapPL +::SetMapScale(vtkFloatingPointType theMapScale) +{ + myMapScaleFactor = theMapScale; + Superclass::SetMapScale(theMapScale); + myWarpVector->SetScaleFactor(myScaleFactor*theMapScale); +} + +//---------------------------------------------------------------------------- +/*! + * Gets scalar mode. + */ +int +VISU_DeformedShapeAndScalarMapPL +::GetScalarMode() +{ + return myScalarsExtractor->GetScalarMode(); +} + +//---------------------------------------------------------------------------- +/*! + * Sets scalar mode. + */ +void +VISU_DeformedShapeAndScalarMapPL +::SetScalarMode(int theScalarMode) +{ + VISU_ScalarMapPL::SetScalarMode(theScalarMode, GetScalars(), myScalarsExtractor); +} + +//---------------------------------------------------------------------------- +void +VISU_DeformedShapeAndScalarMapPL +::SetScaling(int theScaling) +{ + if(GetScaling() == theScaling) + return; + + GetBarTable()->SetScale(theScaling); + + if(theScaling == VTK_SCALE_LOG10) + myScalarsFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10)); + else + myScalarsFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Ident)); +} + + +//---------------------------------------------------------------------------- +void +VISU_DeformedShapeAndScalarMapPL +::SetScalarRange(vtkFloatingPointType theRange[2]) +{ + if(VISU::CheckIsSameRange(theRange, GetScalarRange())) + return; + + myScalarsFieldTransform->SetScalarRange(theRange); + GetBarTable()->SetRange(theRange); +} + + +//---------------------------------------------------------------------------- +vtkFloatingPointType* +VISU_DeformedShapeAndScalarMapPL +::GetScalarRange() +{ + return myScalarsFieldTransform->GetScalarRange(); +} + + +//---------------------------------------------------------------------------- +/*! + * Gets ranges of extracted scalars + * \param theRange[2] - output values + * \li theRange[0] - minimum value + * \li theRange[1] - maximum value + */ +void +VISU_DeformedShapeAndScalarMapPL +::GetSourceRange(vtkFloatingPointType theRange[2]) +{ + myScalarsExtractor->Update(); + myScalarsExtractor->GetUnstructuredGridOutput()->GetScalarRange(theRange); +} diff --git a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx new file mode 100644 index 00000000..b3d454a2 --- /dev/null +++ b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx @@ -0,0 +1,149 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: VISU_DeformedShapeAndScalarMapPL.hxx +// Author: Eugeny Nikolaev +// Module : VISU + +#ifndef VISU_DeformedShapeAndScalarMapPL_HeaderFile +#define VISU_DeformedShapeAndScalarMapPL_HeaderFile + +#include "VISUPipeline.hxx" +#include "VISU_ScalarMapPL.hxx" + +class VISU_MergeFilter; +class vtkWarpVector; +class vtkUnstructuredGrid; +class vtkCellDataToPointData; +class vtkPointDataToCellData; +class VISU_ElnoDisassembleFilter; + + +//---------------------------------------------------------------------------- +class VISU_PIPELINE_EXPORT VISU_DeformedShapeAndScalarMapPL : public VISU_ScalarMapPL +{ +public: + vtkTypeMacro(VISU_DeformedShapeAndScalarMapPL, VISU_ScalarMapPL); + + static + VISU_DeformedShapeAndScalarMapPL* + New(); + + virtual + void + SetScale(vtkFloatingPointType theScale); + + virtual + vtkFloatingPointType + GetScale(); + + virtual + int + GetScalarMode(); + + virtual + void + SetScalarMode(int theScalarMode = 0); + + virtual + void + SetScaling(int theScaling); + + virtual + void + SetScalarRange(vtkFloatingPointType theRange[2]); + + virtual + vtkFloatingPointType* + GetScalarRange(); + + virtual + void + GetSourceRange(vtkFloatingPointType theRange[2]); + + virtual + void + SetScalars(vtkDataSet *theScalars); + + virtual + vtkDataSet* + 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(); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + //! Update scalars. + void + UpdateScalars(); + + virtual + void + SetMapScale(vtkFloatingPointType theMapScale = 1.0); + +protected: + VISU_DeformedShapeAndScalarMapPL(); + + virtual + ~VISU_DeformedShapeAndScalarMapPL(); + + virtual + vtkDataSet* + InsertCustomPL(); + + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput); + +private: + VISU_DeformedShapeAndScalarMapPL(const VISU_DeformedShapeAndScalarMapPL&); + + vtkFloatingPointType myScaleFactor; + vtkFloatingPointType myMapScaleFactor; + vtkWarpVector *myWarpVector; + VISU_MergeFilter *myScalarsMergeFilter; + vtkSmartPointer myScalars; + vtkCellDataToPointData* myCellDataToPointData; + VISU_FieldTransform* myScalarsFieldTransform; + VISU_Extractor* myScalarsExtractor; + VISU_ElnoDisassembleFilter* myScalarsElnoDisassembleFilter; +}; + +#endif diff --git a/src/PIPELINE/VISU_DeformedShapePL.cxx b/src/PIPELINE/VISU_DeformedShapePL.cxx index 6631af08..2a7f2c6a 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.cxx +++ b/src/PIPELINE/VISU_DeformedShapePL.cxx @@ -39,7 +39,8 @@ vtkStandardNewMacro(VISU_DeformedShapePL); //---------------------------------------------------------------------------- VISU_DeformedShapePL ::VISU_DeformedShapePL(): - myScaleFactor(0.0) + myScaleFactor(0.0), + myMapScaleFactor(1.0) { SetIsShrinkable(true); @@ -139,8 +140,8 @@ VISU_DeformedShapePL { if(VISU::CheckIsSameValue(myWarpVector->GetScaleFactor(), theScale)) return; - - myWarpVector->SetScaleFactor(theScale); + + myWarpVector->SetScaleFactor(theScale*myMapScaleFactor); myScaleFactor = theScale; } @@ -215,9 +216,14 @@ void VISU_DeformedShapePL ::SetMapScale(vtkFloatingPointType theMapScale) { + myMapScaleFactor = theMapScale; Superclass::SetMapScale(theMapScale); - myWarpVector->SetScaleFactor(myScaleFactor*theMapScale); + vtkFloatingPointType aMapScale = myScaleFactor * theMapScale; + if(VISU::CheckIsSameValue(myWarpVector->GetScaleFactor(), aMapScale)) + return; + + myWarpVector->SetScaleFactor( aMapScale ); } diff --git a/src/PIPELINE/VISU_DeformedShapePL.hxx b/src/PIPELINE/VISU_DeformedShapePL.hxx index 6011e501..b3283bea 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.hxx +++ b/src/PIPELINE/VISU_DeformedShapePL.hxx @@ -99,6 +99,7 @@ protected: bool theIsCopyInput); vtkFloatingPointType myScaleFactor; + vtkFloatingPointType myMapScaleFactor; vtkWarpVector *myWarpVector; vtkCellDataToPointData* myCellDataToPointData; diff --git a/src/PIPELINE/VISU_ElnoAssembleFilter.cxx b/src/PIPELINE/VISU_ElnoAssembleFilter.cxx new file mode 100644 index 00000000..be843ed3 --- /dev/null +++ b/src/PIPELINE/VISU_ElnoAssembleFilter.cxx @@ -0,0 +1,171 @@ +// 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 + +#include "VISU_ElnoAssembleFilter.hxx" +#include "VISU_PipeLineUtils.hxx" +#include "VISU_ElnoMeshValue.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro( VISU_ElnoAssembleFilter ); + + +//---------------------------------------------------------------------------- +VISU_ElnoAssembleFilter::VISU_ElnoAssembleFilter() +{ + this->SetInputArrayToProcess( 0, // idx + 0, // port + 0, // connection + vtkDataObject::FIELD_ASSOCIATION_POINTS, // field association + "ELNO_POINT_COORDS" ); // name + + this->myIsRestorePoints = false; +} + + +//---------------------------------------------------------------------------- +VISU_ElnoAssembleFilter::~VISU_ElnoAssembleFilter() +{} + + +//---------------------------------------------------------------------------- +void VISU_ElnoAssembleFilter::SetElnoAssembleState( bool theIsRestorePoints ) +{ + if ( myIsRestorePoints == theIsRestorePoints ) + return; + + myIsRestorePoints = theIsRestorePoints; + this->Modified(); +} + +//---------------------------------------------------------------------------- +namespace +{ + //---------------------------------------------------------------------------- + template < int points_type, int elno_type > + int Execute2( vtkPointSet *theInput, + vtkPointSet *theOutput, + vtkDataArray *theElnoPointCoords ) + { + theOutput->CopyStructure( theInput ); + + vtkCellData *aCellData = theOutput->GetCellData(); + aCellData->PassData( theInput->GetCellData() ); + + vtkPointData *aPointData = theOutput->GetPointData(); + aPointData->PassData( theInput->GetPointData() ); + + vtkPoints *anInputPoints = theInput->GetPoints(); + vtkPoints *aPoints = anInputPoints->New( elno_type ); + vtkIdType aNbPoints = theInput->GetNumberOfPoints(); + aPoints->SetNumberOfPoints( aNbPoints ); + + typedef typename VISU::TL::TEnum2VTKArrayType< elno_type >::TResult TPointsDataArray; + typedef typename VISU::TL::TEnum2VTKBasicType< elno_type >::TResult TPointsDataType; + TPointsDataArray* anOutputPointsArray = TPointsDataArray::SafeDownCast( aPoints->GetData() ); + + TPointsDataArray* anElnoPointCoords = TPointsDataArray::SafeDownCast( theElnoPointCoords ); + + for ( vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++ ) { + TPointsDataType aCoords[ 3 ]; + anElnoPointCoords->GetTupleValue( aPointId, aCoords ); + anOutputPointsArray->SetTupleValue( aPointId, aCoords ); + } + + theOutput->SetPoints( aPoints ); + + return 1; + } + + + //---------------------------------------------------------------------------- + template < int points_type > + int Execute( vtkPointSet *theInput, + vtkPointSet *theOutput, + vtkDataArray *theElnoPointCoords ) + { + switch( theElnoPointCoords->GetDataType() ){ + case VTK_DOUBLE: + return Execute2< points_type, VTK_DOUBLE >( theInput, theOutput, theElnoPointCoords ); + case VTK_FLOAT: + return Execute2< points_type, VTK_FLOAT >( theInput, theOutput, theElnoPointCoords ); + case VTK_INT: + return Execute2< points_type, VTK_INT >( theInput, theOutput, theElnoPointCoords ); + case VTK_LONG: + return Execute2< points_type, VTK_LONG >( theInput, theOutput, theElnoPointCoords ); + default: + break; + } + + return 0; + } + + + //---------------------------------------------------------------------------- +} + + +//---------------------------------------------------------------------------- +int VISU_ElnoAssembleFilter::RequestData( vtkInformation *vtkNotUsed(request), + vtkInformationVector **inputVector, + vtkInformationVector *outputVector ) +{ + // get the info objects + vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); + vtkInformation *outInfo = outputVector->GetInformationObject(0); + + // get the input and ouptut + vtkPointSet *anInput = vtkPointSet::SafeDownCast( inInfo->Get( vtkDataObject::DATA_OBJECT() ) ); + vtkPointSet *anOutput = vtkPointSet::SafeDownCast( outInfo->Get( vtkDataObject::DATA_OBJECT() ) ); + + vtkDataArray *anElnoPointCoords = this->GetInputArrayToProcess( 0, inputVector ); + + if ( !myIsRestorePoints || !anElnoPointCoords ) { + anOutput->ShallowCopy( anInput ); + return 1; + } + + vtkPoints *aPoints = anInput->GetPoints(); + switch( aPoints->GetDataType() ){ + case VTK_DOUBLE: + return ::Execute< VTK_DOUBLE >( anInput, anOutput, anElnoPointCoords ); + case VTK_FLOAT: + return ::Execute< VTK_FLOAT >( anInput, anOutput, anElnoPointCoords ); + case VTK_INT: + return ::Execute< VTK_INT >( anInput, anOutput, anElnoPointCoords ); + case VTK_LONG: + return ::Execute< VTK_LONG >( anInput, anOutput, anElnoPointCoords ); + default: + break; + } + + return 0; +} + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_ElnoAssembleFilter.hxx b/src/PIPELINE/VISU_ElnoAssembleFilter.hxx new file mode 100644 index 00000000..8f586c66 --- /dev/null +++ b/src/PIPELINE/VISU_ElnoAssembleFilter.hxx @@ -0,0 +1,47 @@ +// 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 + +#ifndef VISU_ElnoAssembleFilter_H +#define VISU_ElnoAssembleFilter_H + +#include + +class VISU_ElnoAssembleFilter : public vtkPointSetAlgorithm +{ +public: + typedef vtkPointSetAlgorithm Superclass; + + static VISU_ElnoAssembleFilter *New(); + + void SetElnoAssembleState( bool theIsRestorePoints ); + +protected: + VISU_ElnoAssembleFilter(); + ~VISU_ElnoAssembleFilter(); + + int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); + + bool myIsRestorePoints; + +private: + VISU_ElnoAssembleFilter(const VISU_ElnoAssembleFilter&); // Not implemented. + void operator=(const VISU_ElnoAssembleFilter&); // Not implemented. +}; + +#endif diff --git a/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx b/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx new file mode 100644 index 00000000..eb84ca41 --- /dev/null +++ b/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx @@ -0,0 +1,400 @@ +// 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 + +#include "VISU_ElnoDisassembleFilter.hxx" +#include "VISU_PipeLineUtils.hxx" +#include "VISU_ElnoMeshValue.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro( VISU_ElnoDisassembleFilter ); + + +//---------------------------------------------------------------------------- +VISU_ElnoDisassembleFilter::VISU_ElnoDisassembleFilter() +{ + this->SetInputArrayToProcess( 0, // idx + 0, // port + 0, // connection + vtkDataObject::FIELD_ASSOCIATION_CELLS, // field association + "ELNO_FIELD" ); // name + + this->SetInputArrayToProcess( 1, // idx + 0, // port + 0, // connection + vtkDataObject::FIELD_ASSOCIATION_CELLS, // field association + "ELNO_COMPONENT_MAPPER" ); // name + + this->myShrinkFactor = -0.999; +} + + +//---------------------------------------------------------------------------- +VISU_ElnoDisassembleFilter::~VISU_ElnoDisassembleFilter() +{} + + +//---------------------------------------------------------------------------- +void VISU_ElnoDisassembleFilter::SetShrinkFactor( vtkFloatingPointType theValue ) +{ + if ( VISU::CheckIsSameValue( theValue, myShrinkFactor ) ) + return; + + myShrinkFactor = theValue; + this->Modified(); +} + + +//---------------------------------------------------------------------------- +vtkFloatingPointType VISU_ElnoDisassembleFilter::GetShrinkFactor() +{ + return myShrinkFactor; +} + + +//---------------------------------------------------------------------------- +namespace +{ + //---------------------------------------------------------------------------- + template < int points_type, int elno_type > + struct TExecute2 + { + vtkUnstructuredGrid *myInput; + vtkUnstructuredGrid *myOutput; + vtkDataArray *myElnoDataArray; + vtkDataArray *myElnoDataMapper; + vtkFloatingPointType myShrinkFactor; + + typedef typename VISU::TL::TEnum2VTKArrayType< points_type >::TResult TPointsDataArray; + typedef typename VISU::TL::TEnum2VTKBasicType< points_type >::TResult TPointsDataType; + + typedef typename VISU::TL::TEnum2VTKArrayType< elno_type >::TResult TElnoDataArray; + typedef typename VISU::TL::TEnum2VTKBasicType< elno_type >::TResult TElnoDataType; + + VISU::TGetElnoNodeData< elno_type > myGetElnoNodeData; + vtkCellArray *myConnectivity; + vtkPointData *myInputPointData; + vtkPointData *myOutputPointData; + TPointsDataArray *myInputPointsArray; + TPointsDataArray *myOutputPointsArray; + TElnoDataArray* myElnoFullDataArray; + TElnoDataArray* myElnoPartialDataArray; + TPointsDataArray *myElnoPointCoords; + vtkIntArray* myInputPointsMapper; + vtkIntArray* myOutputPointsMapper; + + //---------------------------------------------------------------------------- + TExecute2( vtkUnstructuredGrid *theInput, + vtkUnstructuredGrid *theOutput, + vtkDataArray *theElnoDataArray, + vtkDataArray *theElnoDataMapper, + vtkFloatingPointType theShrinkFactor ) + : myGetElnoNodeData( theElnoDataArray, theElnoDataMapper ) + , myInput( theInput ) + , myOutput( theOutput ) + , myElnoDataArray( theElnoDataArray ) + , myElnoDataMapper( theElnoDataMapper ) + , myShrinkFactor( theShrinkFactor ) + { + myConnectivity = vtkCellArray::New(); + myConnectivity->DeepCopy( theInput->GetCells() ); + + vtkPoints *anInputPoints = theInput->GetPoints(); + vtkPoints *aPoints = anInputPoints->New( anInputPoints->GetDataType() ); + vtkIdType aNbCells = myConnectivity->GetNumberOfCells(); + vtkIdType aNbPoints = myConnectivity->GetNumberOfConnectivityEntries() - aNbCells; + aPoints->Allocate( aNbPoints ); + + myInputPointsArray = TPointsDataArray::SafeDownCast( anInputPoints->GetData() ); + myOutputPointsArray = TPointsDataArray::SafeDownCast( aPoints->GetData() ); + + myInputPointData = theInput->GetPointData(); + myOutputPointData = theOutput->GetPointData(); + myOutputPointData->Allocate( aNbPoints ); + + vtkCellData *anInputCellData = theInput->GetCellData(); + + // To create a new copy of initial data for output + myElnoFullDataArray = TElnoDataArray::New(); + myElnoFullDataArray->SetName( "VISU_FIELD" ); + myElnoFullDataArray->SetNumberOfComponents( myGetElnoNodeData.getNbComp() ); + myElnoFullDataArray->SetNumberOfTuples( aNbPoints ); + + // To create a new copy of partial initial data for output + myElnoPartialDataArray = TElnoDataArray::New(); + // This partial data can be represented as in terms of vectors as scalars + if ( anInputCellData->GetVectors() != NULL ) + myElnoPartialDataArray->SetNumberOfComponents( 3 ); + else + myElnoPartialDataArray->SetNumberOfComponents( 1 ); + myElnoPartialDataArray->SetNumberOfTuples( aNbPoints ); + + myElnoPointCoords = TPointsDataArray::New(); + myElnoPointCoords->SetName( "ELNO_POINT_COORDS" ); + myElnoPointCoords->SetNumberOfComponents( 3 ); + myElnoPointCoords->SetNumberOfTuples( aNbPoints ); + + vtkDataArray* anArray = myInputPointData->GetArray( "VISU_POINTS_MAPPER" ); + myInputPointsMapper = vtkIntArray::SafeDownCast( anArray ); + + myOutputPointsMapper = vtkIntArray::New(); + myOutputPointsMapper->SetName( myInputPointsMapper->GetName() ); + myOutputPointsMapper->SetNumberOfComponents( myInputPointsMapper->GetNumberOfComponents() ); + myOutputPointsMapper->SetNumberOfTuples( aNbPoints ); + + if ( theShrinkFactor > 0.0 ) + this->ShrinkExecute(); + else + this->SimpleExecute(); + + theOutput->SetPoints( aPoints ); + + theOutput->SetCells( theInput->GetCellTypesArray(), + theInput->GetCellLocationsArray(), + myConnectivity ); + + myConnectivity->Delete(); + + vtkCellData *anOutputCellData = theOutput->GetCellData(); + anOutputCellData->PassData( anInputCellData ); + + anOutputCellData->RemoveArray( "ELNO_COMPONENT_MAPPER" ); + anOutputCellData->RemoveArray( "ELNO_FIELD" ); + anOutputCellData->RemoveArray( "VISU_FIELD" ); + anOutputCellData->SetVectors( NULL ); + + //anOutputPointData->PassData( anInputPointData ); + + myOutputPointData->AddArray( myElnoFullDataArray ); + myElnoFullDataArray->Delete(); + + if ( anInputCellData->GetVectors() != NULL ) + myOutputPointData->SetVectors( myElnoPartialDataArray ); + else + myOutputPointData->SetScalars( myElnoPartialDataArray ); + myElnoPartialDataArray->Delete(); + + myOutputPointData->AddArray( myElnoPointCoords ); + myElnoPointCoords->Delete(); + + myOutputPointData->AddArray( myOutputPointsMapper ); + myOutputPointsMapper->Delete(); + } + + //---------------------------------------------------------------------------- + void SimpleExecute() + { + // To reserve a temproary value holder + vtkIdType aNbComp = std::max( 3, myGetElnoNodeData.getNbComp() ); + std::vector< TElnoDataType > anElnoDataValues( aNbComp ); + + std::vector< int > anPointsMapperValues( myInputPointsMapper->GetNumberOfComponents() ); + + myConnectivity->InitTraversal(); + vtkIdType aNbPts = 0, *aPts = 0; + for ( vtkIdType aCellId = 0; myConnectivity->GetNextCell( aNbPts, aPts ); aCellId++ ) { + for ( vtkIdType aPntId = 0; aPntId < aNbPts; aPntId++ ) { + TPointsDataType aCoords[ 3 ]; + vtkIdType aCurrentPntId = aPts[ aPntId ]; + myInputPointsArray->GetTupleValue( aCurrentPntId, aCoords ); + + aPts[ aPntId ] = myOutputPointsArray->InsertNextTupleValue( aCoords ); + vtkIdType aNewPntId = aPts[ aPntId ]; + + myElnoPointCoords->SetTupleValue( aNewPntId, aCoords ); + + myOutputPointData->CopyData( myInputPointData, aCurrentPntId, aNewPntId ); + + TElnoDataType* anElnoData = myGetElnoNodeData( aCellId, aPntId ); + myElnoFullDataArray->SetTupleValue( aNewPntId, anElnoData ); + + myElnoFullDataArray->GetTupleValue( aNewPntId, &anElnoDataValues[ 0 ] ); + myElnoPartialDataArray->SetTupleValue( aNewPntId, &anElnoDataValues[ 0 ] ); + + myInputPointsMapper->GetTupleValue( aCurrentPntId, &anPointsMapperValues[ 0 ] ); + myOutputPointsMapper->SetTupleValue( aNewPntId, &anPointsMapperValues[ 0 ] ); + } + } + } + + //---------------------------------------------------------------------------- + void ShrinkExecute() + { + // To reserve a temproary value holder + vtkIdType aNbComp = std::max( 3, myGetElnoNodeData.getNbComp() ); + std::vector< TElnoDataType > anElnoDataValues( aNbComp ); + + std::vector< int > anPointsMapperValues( myInputPointsMapper->GetNumberOfComponents() ); + + myConnectivity->InitTraversal(); + vtkIdType aNbPts = 0, *aPts = 0; + for ( vtkIdType aCellId = 0; myConnectivity->GetNextCell( aNbPts, aPts ); aCellId++ ) { + + TPointsDataType aCenter[ 3 ] = { TPointsDataType(), TPointsDataType(), TPointsDataType() }; + + for ( vtkIdType aPntId = 0; aPntId < aNbPts; aPntId++ ) { + TPointsDataType aCoords[ 3 ]; + myInputPointsArray->GetTupleValue( aPts[ aPntId ], aCoords ); + + aCenter[ 0 ] += aCoords[ 0 ]; + aCenter[ 1 ] += aCoords[ 1 ]; + aCenter[ 2 ] += aCoords[ 2 ]; + } + + aCenter[ 0 ] /= aNbPts; + aCenter[ 1 ] /= aNbPts; + aCenter[ 2 ] /= aNbPts; + + for ( vtkIdType aPntId = 0; aPntId < aNbPts; aPntId++ ) { + TPointsDataType aCoords[ 3 ]; + vtkIdType aCurrentPntId = aPts[ aPntId ]; + myInputPointsArray->GetTupleValue( aCurrentPntId, aCoords ); + + TPointsDataType aNewCoords[ 3 ]; + + aNewCoords[ 0 ] = aCenter[ 0 ] + + TPointsDataType( myShrinkFactor * ( aCoords[ 0 ] - aCenter[ 0 ] ) ); + aNewCoords[ 1 ] = aCenter[ 1 ] + + TPointsDataType( myShrinkFactor * ( aCoords[ 1 ] - aCenter[ 1 ] ) ); + aNewCoords[ 2 ] = aCenter[ 2 ] + + TPointsDataType( myShrinkFactor * ( aCoords[ 2 ] - aCenter[ 2 ] ) ); + + aPts[ aPntId ] = myOutputPointsArray->InsertNextTupleValue( aNewCoords ); + vtkIdType aNewPntId = aPts[ aPntId ]; + + myElnoPointCoords->SetTupleValue( aNewPntId, aCoords ); + + myOutputPointData->CopyData( myInputPointData, aCurrentPntId, aNewPntId ); + + TElnoDataType* anElnoData = myGetElnoNodeData( aCellId, aPntId ); + myElnoFullDataArray->SetTupleValue( aNewPntId, anElnoData ); + + myElnoFullDataArray->GetTupleValue( aNewPntId, &anElnoDataValues[ 0 ] ); + myElnoPartialDataArray->SetTupleValue( aNewPntId, &anElnoDataValues[ 0 ] ); + + myInputPointsMapper->GetTupleValue( aCurrentPntId, &anPointsMapperValues[ 0 ] ); + myOutputPointsMapper->SetTupleValue( aNewPntId, &anPointsMapperValues[ 0 ] ); + } + } + } + }; + + + //---------------------------------------------------------------------------- + template < int points_type, int elno_type > + int Execute2( vtkUnstructuredGrid *theInput, + vtkUnstructuredGrid *theOutput, + vtkDataArray *theElnoDataArray, + vtkDataArray *theElnoDataMapper, + vtkFloatingPointType theShrinkFactor ) + { + TExecute2< points_type, elno_type >( theInput, + theOutput, + theElnoDataArray, + theElnoDataMapper, + theShrinkFactor ); + + return 1; + } + + + //---------------------------------------------------------------------------- + template < int points_type > + int Execute( vtkUnstructuredGrid *theInput, + vtkUnstructuredGrid *theOutput, + vtkDataArray *theElnoDataArray, + vtkDataArray *theElnoDataMapper, + vtkFloatingPointType theShrinkFactor ) + { + switch( theElnoDataArray->GetDataType() ){ + case VTK_DOUBLE: + return Execute2< points_type, VTK_DOUBLE > + ( theInput, theOutput, theElnoDataArray, theElnoDataMapper, theShrinkFactor ); + case VTK_FLOAT: + return Execute2< points_type, VTK_FLOAT > + ( theInput, theOutput, theElnoDataArray, theElnoDataMapper, theShrinkFactor ); + case VTK_INT: + return Execute2< points_type, VTK_INT > + ( theInput, theOutput, theElnoDataArray, theElnoDataMapper, theShrinkFactor ); + case VTK_LONG: + return Execute2< points_type, VTK_LONG > + ( theInput, theOutput, theElnoDataArray, theElnoDataMapper, theShrinkFactor ); + default: + break; + } + + return 0; + } + + + //---------------------------------------------------------------------------- +} + + +//---------------------------------------------------------------------------- +int VISU_ElnoDisassembleFilter::RequestData( vtkInformation *vtkNotUsed(request), + vtkInformationVector **inputVector, + vtkInformationVector *outputVector ) +{ + // get the info objects + vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); + vtkInformation *outInfo = outputVector->GetInformationObject(0); + + // get the input and ouptut + vtkUnstructuredGrid *anInput = + vtkUnstructuredGrid::SafeDownCast( inInfo->Get( vtkDataObject::DATA_OBJECT() ) ); + vtkUnstructuredGrid *anOutput = + vtkUnstructuredGrid::SafeDownCast( outInfo->Get( vtkDataObject::DATA_OBJECT() ) ); + + vtkDataArray *anElnoDataArray = this->GetInputArrayToProcess( 0, inputVector ); + vtkDataArray *anElnoDataMapper = this->GetInputArrayToProcess( 1, inputVector ); + + if ( !anElnoDataArray ) { + anOutput->ShallowCopy( anInput ); + return 1; + } + + vtkPoints *aPoints = anInput->GetPoints(); + switch( aPoints->GetDataType() ){ + case VTK_DOUBLE: + return ::Execute< VTK_DOUBLE >( anInput, anOutput, anElnoDataArray, anElnoDataMapper, myShrinkFactor ); + case VTK_FLOAT: + return ::Execute< VTK_FLOAT >( anInput, anOutput, anElnoDataArray, anElnoDataMapper, myShrinkFactor ); + case VTK_INT: + return ::Execute< VTK_INT >( anInput, anOutput, anElnoDataArray, anElnoDataMapper, myShrinkFactor ); + case VTK_LONG: + return ::Execute< VTK_LONG >( anInput, anOutput, anElnoDataArray, anElnoDataMapper, myShrinkFactor ); + default: + break; + } + + return 0; +} + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_ElnoDisassembleFilter.hxx b/src/PIPELINE/VISU_ElnoDisassembleFilter.hxx new file mode 100644 index 00000000..0053c13e --- /dev/null +++ b/src/PIPELINE/VISU_ElnoDisassembleFilter.hxx @@ -0,0 +1,48 @@ +// 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 + +#ifndef VISU_ElnoDisassembleFilter_H +#define VISU_ElnoDisassembleFilter_H + +#include + +class VISU_ElnoDisassembleFilter : public vtkUnstructuredGridAlgorithm +{ +public: + typedef vtkUnstructuredGridAlgorithm Superclass; + + static VISU_ElnoDisassembleFilter *New(); + + void SetShrinkFactor( vtkFloatingPointType theValue ); + vtkFloatingPointType GetShrinkFactor(); + +protected: + VISU_ElnoDisassembleFilter(); + ~VISU_ElnoDisassembleFilter(); + + int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); + + vtkFloatingPointType myShrinkFactor; + +private: + VISU_ElnoDisassembleFilter(const VISU_ElnoDisassembleFilter&); // Not implemented. + void operator=(const VISU_ElnoDisassembleFilter&); // Not implemented. +}; + +#endif diff --git a/src/PIPELINE/VISU_Extractor.cxx b/src/PIPELINE/VISU_Extractor.cxx index e44145e3..eb078e3a 100644 --- a/src/PIPELINE/VISU_Extractor.cxx +++ b/src/PIPELINE/VISU_Extractor.cxx @@ -168,27 +168,27 @@ VISU_Extractor vtkInformationVector **theInputVector, vtkInformationVector *theOutputVector) { - vtkDataSet *anInput = VISU::GetInput(theInputVector, 0); - vtkDataSet *anOutput = VISU::GetOutput(theOutputVector); + vtkDataSet *anInput = VISU::GetInput( theInputVector, 0 ); + vtkDataSet *anOutput = VISU::GetOutput( theOutputVector ); - anOutput->CopyStructure(anInput); + anOutput->CopyStructure( anInput ); vtkPointData *anInputPointData = anInput->GetPointData(); vtkPointData *anOutputPointData = anOutput->GetPointData(); - anOutputPointData->PassData(anInputPointData); - if(VISU::IsDataOnPoints(anInput)){ + anOutputPointData->PassData( anInputPointData ); + if ( VISU::IsDataOnPoints( anInput ) ) { int aNbElems = anInput->GetNumberOfPoints(); - if(anInputPointData->GetAttribute(vtkDataSetAttributes::VECTORS)) - ExecuteScalars(aNbElems, myScalarMode, anInputPointData, anOutputPointData); + if ( anInputPointData->GetAttribute( vtkDataSetAttributes::VECTORS ) ) + ExecuteScalars( aNbElems, myScalarMode, anInputPointData, anOutputPointData ); } vtkCellData *anInputCellData = anInput->GetCellData(); vtkCellData *anOutputCellData = anOutput->GetCellData(); - anOutputCellData->PassData(anInputCellData); - if(VISU::IsDataOnCells(anInput)){ + anOutputCellData->PassData( anInputCellData ); + if ( VISU::IsDataOnCells( anInput ) ) { int aNbElems = anInput->GetNumberOfCells(); - if(anInputCellData->GetAttribute(vtkDataSetAttributes::VECTORS)) - ExecuteScalars(aNbElems, myScalarMode, anInputCellData, anOutputCellData); + if ( anInputCellData->GetAttribute( vtkDataSetAttributes::VECTORS ) ) + ExecuteScalars( aNbElems, myScalarMode, anInputCellData, anOutputCellData ); } return 1; diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.cxx b/src/PIPELINE/VISU_IsoSurfacesPL.cxx index bea9854f..88359963 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.cxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.cxx @@ -30,10 +30,12 @@ #include "VISU_LookupTable.hxx" #include "VISU_PipeLineUtils.hxx" +#include "VISU_LabelPointsFilter.hxx" #include + //---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_IsoSurfacesPL); @@ -44,6 +46,8 @@ VISU_IsoSurfacesPL { SetIsShrinkable(false); + SetElnoDisassembleState( true ); + myContourFilter = vtkContourFilter::New(); myCellDataToPointData = vtkCellDataToPointData::New(); @@ -100,6 +104,14 @@ VISU_IsoSurfacesPL return myContourFilter->GetNumberOfContours(); } +//---------------------------------------------------------------------------- +vtkFloatingPointType +VISU_IsoSurfacesPL +::GetValue(int i) +{ + return myContourFilter->GetValue(i); +} + //---------------------------------------------------------------------------- void @@ -181,6 +193,7 @@ VISU_IsoSurfacesPL VISU::CellDataToPoint(myContourFilter, myCellDataToPointData, GetMergedInput()); + } diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.hxx b/src/PIPELINE/VISU_IsoSurfacesPL.hxx index 83a646dd..73aec61e 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.hxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.hxx @@ -53,6 +53,8 @@ public: int GetNbParts(); + virtual vtkFloatingPointType GetValue(int i); + virtual void SetNbParts(int theNb = 10); diff --git a/src/PIPELINE/VISU_LabelPointsFilter.cxx b/src/PIPELINE/VISU_LabelPointsFilter.cxx new file mode 100644 index 00000000..040d6a23 --- /dev/null +++ b/src/PIPELINE/VISU_LabelPointsFilter.cxx @@ -0,0 +1,296 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File: VISU_LabelPointsFilter.cxx +// Author: Vitaly Smetannikov +// Module : VISU + + + +#include "VISU_LabelPointsFilter.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +#define CONTAINS(SET, PT) (SET.find(PT) != SET.end()) + +struct ltIdType +{ + bool operator()(const vtkIdType a1, const vtkIdType a2) const + { + return a1 < a2; + } +}; + + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(VISU_LabelPointsFilter); + + +//---------------------------------------------------------------------------- +void VISU_LabelPointsFilter::SetPointsNb(int theNb) +{ + if (myPointsNb == theNb) return; + myPointsNb = (theNb < 1)? 1:theNb; + Modified(); +} + +//---------------------------------------------------------------------------- +VISU_LabelPointsFilter::VISU_LabelPointsFilter(): + vtkPolyDataAlgorithm(), + myPointsNb(3) +{ +} + +//---------------------------------------------------------------------------- +VISU_LabelPointsFilter::~VISU_LabelPointsFilter() +{} + + + +//---------------------------------------------------------------------------- +int VISU_LabelPointsFilter::RequestData(vtkInformation* vtkNotUsed(request), + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) +{ + // get the info objects + vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); + vtkInformation* outInfo = outputVector->GetInformationObject(0); + + // get the input and ouptut + vtkPolyData* input = vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); + + GetRegions(input, output); + + return 1; +} + +int VISU_LabelPointsFilter::RequestUpdateExtent(vtkInformation* vtkNotUsed(request), + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) +{ + // get the info objects + vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); + vtkInformation *outInfo = outputVector->GetInformationObject(0); + + vtkPolyData* input = vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); + + GetRegions(input, output); + return 1; +} + + + +int VISU_LabelPointsFilter::GetRegions(vtkPolyData* theInput, + vtkPolyData* theOutput) +{ + vtkIdType cellId, i; + vtkIdType numPts, numCells; + vtkPoints *inPts; + + vtkPointData *aInpPD=theInput->GetPointData(), *aOutPD=theOutput->GetPointData(); + vtkCellData *aInpCD=theInput->GetCellData(), *aOutCD=theOutput->GetCellData(); + + // Check input/allocate storage + // + inPts = theInput->GetPoints(); + + if (inPts == NULL) + return 1; + + numPts = inPts->GetNumberOfPoints(); + numCells = theInput->GetNumberOfCells(); + + if ( numPts < 1 || numCells < 1 ) + return 1; + + // Build cell structure + // + vtkPolyData* aMesh = vtkPolyData::New(); + aMesh->CopyStructure(theInput); + aMesh->BuildLinks(); + + // Initialize. Keep track of points and cells visited. + // + vtkIdTypeArray* aRegionSizes = vtkIdTypeArray::New(); + int* aVisited = new int[numCells]; + for ( i=0; i < numCells; i++ ) + aVisited[i] = -1; + + vtkIdType* aPointMap = new vtkIdType[numPts]; + for ( i=0; i < numPts; i++ ) + aPointMap[i] = -1; + + vtkPoints* newPts = vtkPoints::New(); + newPts->Allocate(numPts); + + // Traverse all cells marking those visited. Each new search + // starts a new connected region. Connected region grows + // using a connected wave propagation. + // + vtkIdList* aWave = vtkIdList::New(); + aWave->Allocate(numPts/4+1,numPts); + vtkIdList* aWave2 = vtkIdList::New(); + aWave2->Allocate(numPts/4+1,numPts); + + vtkIdType aPointNumber = 0; + int aRegionNumber = 0; + + vtkIdList* aCellIds = vtkIdList::New(); + aCellIds->Allocate(8, VTK_CELL_SIZE); + vtkIdList* aPointIds = vtkIdList::New(); + aPointIds->Allocate(8, VTK_CELL_SIZE); + + // vtkIdType aNumCellsInRegion; + + aOutPD->CopyAllocate(aInpPD); + aOutCD->CopyAllocate(aInpCD); + + //visit all cells marking with region number + for (cellId=0; cellId < numCells; cellId++) { + if ( aVisited[cellId] < 0 ) { + aWave->InsertNextId(cellId); + aPointNumber = 0; + TraverseAndMark(aWave, aWave2, aVisited, aPointMap, + aRegionNumber, aPointNumber, aMesh); + + if (aPointNumber >= myPointsNb) { + std::set aIdxSet; + for (i=0; i < numPts; i++) { + if ( aPointMap[i] > -1 ) { + aIdxSet.insert(i); + aPointMap[i] = -1; + } + } + std::vector aIdx(aIdxSet.begin(), aIdxSet.end()); + int aActualPts = aIdx.size(); + int aNewId; + if (myPointsNb > 2) { + int k = aActualPts/(myPointsNb - 1); + int count; + for (i=0, count = 0; i < aActualPts; i+=k, count++) { + aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[i])); + aOutPD->CopyData(aInpPD, aIdx[i], aNewId); + } + if (count < myPointsNb) { + aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[aActualPts - 1])); + aOutPD->CopyData(aInpPD, aIdx[aActualPts - 1], aNewId); + } + } else { + aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[0])); + aOutPD->CopyData(aInpPD, aIdx[0], aNewId); + if (myPointsNb == 2) { + aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[aActualPts - 1])); + aOutPD->CopyData(aInpPD, aIdx[aActualPts - 1], aNewId); + } + } + } + aWave->Reset(); + aWave2->Reset(); + } + } + + aWave->Delete(); + aWave2->Delete(); + + theOutput->SetPoints(newPts); + newPts->Delete(); + + + delete [] aVisited; + delete [] aPointMap; + aMesh->Delete(); + theOutput->Squeeze(); + aCellIds->Delete(); + aPointIds->Delete(); + + return aRegionSizes->GetMaxId() + 1; +} + + +// Mark current cell as visited and assign region number. Note: +// traversal occurs across shared vertices. +// +void VISU_LabelPointsFilter::TraverseAndMark (vtkIdList* theWave, + vtkIdList* theWave2, + int* theVisited, + vtkIdType* thePointMap, + int& theRegionNumber, + vtkIdType& thePointNumber, + vtkPolyData* theMesh) +{ + vtkIdType cellId, ptId, numIds, i; + int j, k; + vtkIdType *pts, *cells, npts; + vtkIdList *tmpWave; + unsigned short ncells; + vtkIdList* aNeighborCellPointIds = vtkIdList::New(); + + + while ( (numIds=theWave->GetNumberOfIds()) > 0 ) { + for ( i=0; i < numIds; i++ ) { + cellId = theWave->GetId(i); + if ( theVisited[cellId] < 0 ) { + theVisited[cellId] = theRegionNumber; + theMesh->GetCellPoints(cellId, npts, pts); + + for (j=0; j < npts; j++) { + if ( thePointMap[ptId=pts[j]] < 0 ) { + thePointMap[ptId] = thePointNumber++; + } + theMesh->GetPointCells(ptId,ncells,cells); + + // check connectivity criterion (geometric + scalar) + for (k=0; k < ncells; k++) { + cellId = cells[k]; + theWave2->InsertNextId(cellId); + // } + }//for all cells using this point + }//for all points of this cell + }//if cell not yet visited + }//for all cells in this wave + + tmpWave = theWave; + theWave = theWave2; + theWave2 = tmpWave; + tmpWave->Reset(); + } //while wave is not empty +} diff --git a/src/PIPELINE/VISU_LabelPointsFilter.hxx b/src/PIPELINE/VISU_LabelPointsFilter.hxx new file mode 100644 index 00000000..46fa1c44 --- /dev/null +++ b/src/PIPELINE/VISU_LabelPointsFilter.hxx @@ -0,0 +1,76 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: VISU_LabelPointsFilter.hxx +// Author: Vitaly Smetannikov +// Module : VISU + +#ifndef VISU_LabelPointsFilter_HeaderFile +#define VISU_LabelPointsFilter_HeaderFile + +#include "VISUPipeline.hxx" +#include + +class vtkPolyData; + +class VISU_PIPELINE_EXPORT VISU_LabelPointsFilter : public vtkPolyDataAlgorithm +{ +public: + vtkTypeMacro(VISU_LabelPointsFilter, vtkPolyDataAlgorithm); + + static VISU_LabelPointsFilter* New(); + + void SetPointsNb(int theNb); + + int GetPointsNb() const { return myPointsNb; } + +protected: + VISU_LabelPointsFilter(); + + virtual ~VISU_LabelPointsFilter(); + + virtual int RequestData(vtkInformation* request, + vtkInformationVector** inputVector, + vtkInformationVector* outputVector); + + virtual int RequestUpdateExtent(vtkInformation*, + vtkInformationVector**, + vtkInformationVector*); + + + void TraverseAndMark (vtkIdList* theWave, + vtkIdList* theWave2, + int* theVisited, + vtkIdType* thePointMap, + int& theRegionNumber, + vtkIdType& thePointNumber, + vtkPolyData* theMesh); + + int GetRegions(vtkPolyData* theInput, + vtkPolyData* theOutput); + + int myPointsNb; + +}; + + +#endif diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx index 85184e78..8713339f 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx @@ -49,6 +49,8 @@ #include #include +#include "utilities.h" + #ifndef WNT # ifndef GLX_GLXEXT_LEGACY # define GLX_GLXEXT_LEGACY @@ -557,11 +559,10 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act) { #ifdef _DEBUG_RENDERING_PERFORMANCE_ // To control when the mapper is recalculated - cout<<"VISU_OpenGLPointSpriteMapper::RenderPiece - " - <<(this->GetMTime() > this->BuildTime)<<"; " - <<(input->GetMTime() > this->BuildTime)<<"; " - <<(act->GetProperty()->GetMTime() > this->BuildTime)<<"; " - <GetMTime() > this->BuildTime)<<"; " + <<(input->GetMTime() > this->BuildTime)<<"; " + <<(act->GetProperty()->GetMTime() > this->BuildTime)<<"; "); #endif // sets this->Colors as side effect this->MapScalars( act->GetProperty()->GetOpacity() ); diff --git a/src/PIPELINE/VISU_OptionalDeformationPL.cxx b/src/PIPELINE/VISU_OptionalDeformationPL.cxx new file mode 100755 index 00000000..a4bc4555 --- /dev/null +++ b/src/PIPELINE/VISU_OptionalDeformationPL.cxx @@ -0,0 +1,101 @@ +// Copyright (C) 2008 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: VISU_ScalarMapPL.cxx +// Author: Roman NIKOLAEV +// Module : VISU + +//Salome includes +#include "VISU_OptionalDeformationPL.hxx" +#include "VISU_PipeLineUtils.hxx" + +//VTK includes +#include +#include +#include +#include +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +//---------------------------------------------------------------------------- +VISU_OptionalDeformationPL::VISU_OptionalDeformationPL(): + VISU_DeformationPL(), + myIsDeformed(true) +{ + if(MYDEBUG) MESSAGE("VISU_OptionalDeformationPL()::VISU_OptionalDeformationPL() - "<SetInput(myInputPassFilter->GetOutput()); + myWarpVector->SetInput(myCellDataToPointData->GetOutput()); + myOutputPassFiler->SetInput(myWarpVector->GetOutput()); +} + +//---------------------------------------------------------------------------- +void VISU_OptionalDeformationPL::OffDeformation(){ + myOutputPassFiler->SetInput(myInputPassFilter->GetOutput()); +} + + + +bool VISU_OptionalDeformationPL::CheckCanDeformate(vtkDataSet* theInput){ + if(theInput) { + if(VISU::IsDataOnCells(theInput)) + return theInput->GetCellData()->GetVectors() != NULL; + else if(VISU::IsDataOnPoints(theInput)) + return theInput->GetPointData()->GetVectors() != NULL; + } + return false; +} diff --git a/src/PIPELINE/VISU_OptionalDeformationPL.hxx b/src/PIPELINE/VISU_OptionalDeformationPL.hxx new file mode 100755 index 00000000..333da0cc --- /dev/null +++ b/src/PIPELINE/VISU_OptionalDeformationPL.hxx @@ -0,0 +1,59 @@ +// Copyright (C) 2008 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 : VISU_OptionalDeformationPL.hxx +// Author : +// Module : SALOME + +#ifndef VISU_OptionalDeformationPL_HeaderFile +#define VISU_OptionalDeformationPL_HeaderFile + +#include "VISUPipeline.hxx" +#include "VISU_DeformationPL.hxx" + +class VISU_PIPELINE_EXPORT VISU_OptionalDeformationPL: public VISU_DeformationPL +{ +public: + VISU_OptionalDeformationPL(); + virtual ~VISU_OptionalDeformationPL(); + + typedef VISU_DeformationPL Superclass; + + void UseDeformation(bool flag); + bool IsDeformed(); + + virtual + unsigned + long int + GetMTime(); + +protected: + bool CheckCanDeformate(vtkDataSet* theInput); + +private: + void OnDeformation(); + void OffDeformation(); + +private: + bool myIsDeformed; +}; + +#endif diff --git a/src/PIPELINE/VISU_PipeLineUtils.cxx b/src/PIPELINE/VISU_PipeLineUtils.cxx index 6c31a356..26e7290e 100644 --- a/src/PIPELINE/VISU_PipeLineUtils.cxx +++ b/src/PIPELINE/VISU_PipeLineUtils.cxx @@ -95,6 +95,7 @@ namespace VISU theTarget->SetScalarMode(theSource->GetScalarMode()); theTarget->SetImmediateModeRendering(theSource->GetImmediateModeRendering()); theTarget->SetUseLookupTableScalarRange(theSource->GetUseLookupTableScalarRange()); + theTarget->SetInterpolateScalarsBeforeMapping(theSource->GetInterpolateScalarsBeforeMapping()); if(theSource->GetArrayAccessMode() == VTK_GET_ARRAY_BY_ID) theTarget->ColorByArrayComponent(theSource->GetArrayId(), theSource->GetArrayComponent()); else diff --git a/src/PIPELINE/VISU_Plot3DPL.cxx b/src/PIPELINE/VISU_Plot3DPL.cxx index c53afe9d..ed3750fc 100644 --- a/src/PIPELINE/VISU_Plot3DPL.cxx +++ b/src/PIPELINE/VISU_Plot3DPL.cxx @@ -56,7 +56,8 @@ VISU_Plot3DPL myIsRelative(true), myIsContour(false), myPosition(0.5), - myScaleFactor(1.0) + myScaleFactor(1.0), + myMapScaleFactor(1.0) { SetIsShrinkable(false); @@ -315,7 +316,7 @@ VISU_Plot3DPL ::SetScaleFactor(vtkFloatingPointType theScaleFactor) { myScaleFactor = theScaleFactor; - myWarpScalar->SetScaleFactor(theScaleFactor); + myWarpScalar->SetScaleFactor(theScaleFactor*myMapScaleFactor); } @@ -524,6 +525,7 @@ void VISU_Plot3DPL ::SetMapScale(vtkFloatingPointType theMapScale) { + myMapScaleFactor = theMapScale; Superclass::SetMapScale(theMapScale); if ( myIsContour ) { diff --git a/src/PIPELINE/VISU_Plot3DPL.hxx b/src/PIPELINE/VISU_Plot3DPL.hxx index 8585fb8b..7ec96d88 100644 --- a/src/PIPELINE/VISU_Plot3DPL.hxx +++ b/src/PIPELINE/VISU_Plot3DPL.hxx @@ -146,7 +146,7 @@ protected: vtkFloatingPointType myAngle[3]; bool myIsRelative, myIsContour; - vtkFloatingPointType myPosition, myScaleFactor; + vtkFloatingPointType myPosition, myScaleFactor, myMapScaleFactor; VISU_CutPlanesPL::PlaneOrientation myOrientation; vtkSmartPointer myCellDataToPointData; diff --git a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx deleted file mode 100644 index 54ff4f87..00000000 --- a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx +++ /dev/null @@ -1,368 +0,0 @@ -// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// -// File: VISU_ScalarMapOnDeformedShapePL.cxx -// Author: Eugeny Nikolaev -// Module : VISU - -#include "VISU_ScalarMapOnDeformedShapePL.hxx" -#include "VISU_FieldTransform.hxx" -#include "VISU_Extractor.hxx" -#include "VISU_LookupTable.hxx" -#include "VISU_DeformedShapePL.hxx" -#include "VTKViewer_TransformFilter.h" -#include "VTKViewer_Transform.h" -#include "VISU_MergeFilter.hxx" - -#include "VISU_PipeLineUtils.hxx" - -#include -#include -#include -#include - - -//---------------------------------------------------------------------------- -vtkStandardNewMacro(VISU_ScalarMapOnDeformedShapePL) - -//---------------------------------------------------------------------------- -/*! - * Constructor. Creating new instances of vtkWarpVector,vtkMergeFilter,vtkUnstructuredGrid - * Where: - * \li myDeformVectors is vtkWarpVector - deformation vectors data - * \li myScalarsMergeFilter 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(): - myScaleFactor(0.0) -{ - myWarpVector = vtkWarpVector::New(); - - myScalarsMergeFilter = VISU_MergeFilter::New(); - myScalarsMergeFilter->SetMergingInputs(true); - - myScalarsExtractor = VISU_Extractor::New(); - - myScalarsFieldTransform = VISU_FieldTransform::New(); - - myCellDataToPointData = vtkCellDataToPointData::New(); -} - -//---------------------------------------------------------------------------- -/*! - * Destructor. - * Delete all fields. -*/ -VISU_ScalarMapOnDeformedShapePL -::~VISU_ScalarMapOnDeformedShapePL() -{ - myWarpVector->Delete(); - - myScalarsMergeFilter->Delete(); - - myScalarsExtractor->Delete(); - - myScalarsFieldTransform->Delete(); - - myCellDataToPointData->Delete(); -} - -//---------------------------------------------------------------------------- -/*! - * Initial method - */ -void -VISU_ScalarMapOnDeformedShapePL -::Init() -{ - Superclass::Init(); - - SetScale(VISU_DeformedShapePL::GetDefaultScale(this)); -} - -//---------------------------------------------------------------------------- -/*! - * Build method - * Building of deformation and puts result to merge filter. - */ -void -VISU_ScalarMapOnDeformedShapePL -::Build() -{ - Superclass::Build(); -} - - -//---------------------------------------------------------------------------- -vtkDataSet* -VISU_ScalarMapOnDeformedShapePL -::InsertCustomPL() -{ - GetMapper()->SetColorModeToMapScalars(); - GetMapper()->ScalarVisibilityOn(); - - VISU::CellDataToPoint(myWarpVector, - myCellDataToPointData, - GetMergedInput()); - - myScalars = GetMergedInput(); - - UpdateScalars(); - - myScalarsFieldTransform->SetInput(myScalarsExtractor->GetOutput()); - - // Sets geometry for merge filter - myScalarsMergeFilter->SetGeometry(myWarpVector->GetUnstructuredGridOutput()); - - vtkDataSet* aScalarsDataSet = myScalarsFieldTransform->GetOutput(); - myScalarsMergeFilter->SetScalars(aScalarsDataSet); - myScalarsMergeFilter->AddField("VISU_CELLS_MAPPER", aScalarsDataSet); - myScalarsMergeFilter->AddField("VISU_POINTS_MAPPER", aScalarsDataSet); - - return myScalarsMergeFilter->GetOutput(); -} - - -//---------------------------------------------------------------------------- -/*! - * Update method - */ -void -VISU_ScalarMapOnDeformedShapePL -::Update() -{ - Superclass::Update(); - //{ - // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myScalarsExtractor.vtk"; - // VISU::WriteToFile(myScalarsExtractor->GetUnstructuredGridOutput(), aFileName); - //} - //{ - // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myWarpVector.vtk"; - // VISU::WriteToFile(myWarpVector->GetUnstructuredGridOutput(), aFileName); - //} - //{ - // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myScalarsMergeFilter.vtk"; - // VISU::WriteToFile(myScalarsMergeFilter->GetUnstructuredGridOutput(), aFileName); - //} -} - -//---------------------------------------------------------------------------- -unsigned long int -VISU_ScalarMapOnDeformedShapePL -::GetMemorySize() -{ - unsigned long int aSize = Superclass::GetMemorySize(); - - if(vtkDataSet* aDataSet = myWarpVector->GetOutput()) - aSize += aDataSet->GetActualMemorySize() * 1024; - - if(vtkDataSet* aDataSet = myScalarsExtractor->GetOutput()) - aSize += aDataSet->GetActualMemorySize() * 1024; - - if(vtkDataSet* aDataSet = myScalarsMergeFilter->GetOutput()) - aSize += aDataSet->GetActualMemorySize() * 1024; - - if(myCellDataToPointData->GetInput()) - if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput()) - aSize += aDataSet->GetActualMemorySize() * 1024; - - return aSize; -} - -//---------------------------------------------------------------------------- -/*! - * Update scalars method. - * Put scalars to merge filter. - */ -void -VISU_ScalarMapOnDeformedShapePL -::UpdateScalars() -{ - vtkDataSet* aScalars = GetScalars(); - myScalarsExtractor->SetInput(aScalars); - - if(VISU::IsDataOnCells(aScalars)) - GetMapper()->SetScalarModeToUseCellData(); - else - GetMapper()->SetScalarModeToUsePointData(); -} - -//---------------------------------------------------------------------------- -/*! - * Copy information about pipline. - * Copy scale and scalars. - */ -void -VISU_ScalarMapOnDeformedShapePL -::DoShallowCopy(VISU_PipeLine *thePipeLine, - bool theIsCopyInput) -{ - Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); - - if(VISU_ScalarMapOnDeformedShapePL *aPipeLine = dynamic_cast(thePipeLine)){ - SetScale(aPipeLine->GetScale()); - SetScalars(aPipeLine->GetScalars()); - } -} - -//---------------------------------------------------------------------------- -/*! - * Set scalars. - * Sets vtkDataSet with scalars values to VISU_Extractor filter for scalars extraction. - */ -void -VISU_ScalarMapOnDeformedShapePL -::SetScalars(vtkDataSet *theScalars) -{ - if(GetScalars() == theScalars) - return; - - myScalars = theScalars; - UpdateScalars(); -} - -//---------------------------------------------------------------------------- -/*! - * Get pointer to input scalars. - */ -vtkDataSet* -VISU_ScalarMapOnDeformedShapePL -::GetScalars() -{ - return myScalars.GetPointer(); -} - -//---------------------------------------------------------------------------- -/*! - * Sets scale for deformed shape - */ -void -VISU_ScalarMapOnDeformedShapePL -::SetScale(vtkFloatingPointType theScale) -{ - if(VISU::CheckIsSameValue(myScaleFactor, theScale)) - return; - - myWarpVector->SetScaleFactor(theScale); - myScaleFactor = theScale; -} - -//---------------------------------------------------------------------------- -/*! - * Gets scale of deformed shape. - */ -vtkFloatingPointType -VISU_ScalarMapOnDeformedShapePL -::GetScale() -{ - return myWarpVector->GetScaleFactor(); -} - -//---------------------------------------------------------------------------- -/*! - * Set scale factor of deformation. - */ -void -VISU_ScalarMapOnDeformedShapePL -::SetMapScale(vtkFloatingPointType theMapScale) -{ - Superclass::SetMapScale(theMapScale); - myWarpVector->SetScaleFactor(myScaleFactor*theMapScale); -} - -//---------------------------------------------------------------------------- -/*! - * Gets scalar mode. - */ -int -VISU_ScalarMapOnDeformedShapePL -::GetScalarMode() -{ - return myScalarsExtractor->GetScalarMode(); -} - -//---------------------------------------------------------------------------- -/*! - * Sets scalar mode. - */ -void -VISU_ScalarMapOnDeformedShapePL -::SetScalarMode(int theScalarMode) -{ - VISU_ScalarMapPL::SetScalarMode(theScalarMode, GetScalars(), myScalarsExtractor); -} - -//---------------------------------------------------------------------------- -void -VISU_ScalarMapOnDeformedShapePL -::SetScaling(int theScaling) -{ - if(GetScaling() == theScaling) - return; - - GetBarTable()->SetScale(theScaling); - - if(theScaling == VTK_SCALE_LOG10) - myScalarsFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10)); - else - myScalarsFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Ident)); -} - - -//---------------------------------------------------------------------------- -void -VISU_ScalarMapOnDeformedShapePL -::SetScalarRange(vtkFloatingPointType theRange[2]) -{ - if(VISU::CheckIsSameRange(theRange, GetScalarRange())) - return; - - myScalarsFieldTransform->SetScalarRange(theRange); - GetBarTable()->SetRange(theRange); -} - - -//---------------------------------------------------------------------------- -vtkFloatingPointType* -VISU_ScalarMapOnDeformedShapePL -::GetScalarRange() -{ - return myScalarsFieldTransform->GetScalarRange(); -} - - -//---------------------------------------------------------------------------- -/*! - * Gets ranges of extracted scalars - * \param theRange[2] - output values - * \li theRange[0] - minimum value - * \li theRange[1] - maximum value - */ -void -VISU_ScalarMapOnDeformedShapePL -::GetSourceRange(vtkFloatingPointType theRange[2]) -{ - myScalarsExtractor->Update(); - myScalarsExtractor->GetUnstructuredGridOutput()->GetScalarRange(theRange); -} diff --git a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx deleted file mode 100644 index 041a37d2..00000000 --- a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx +++ /dev/null @@ -1,146 +0,0 @@ -// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// -// File: VISU_ScalarMapOnDeformedShapePL.hxx -// Author: Eugeny Nikolaev -// Module : VISU - -#ifndef VISU_ScalarMapOnDeformedShapePL_HeaderFile -#define VISU_ScalarMapOnDeformedShapePL_HeaderFile - -#include "VISUPipeline.hxx" -#include "VISU_ScalarMapPL.hxx" - -class VISU_MergeFilter; -class vtkWarpVector; -class vtkUnstructuredGrid; -class vtkCellDataToPointData; -class vtkPointDataToCellData; - - -//---------------------------------------------------------------------------- -class VISU_PIPELINE_EXPORT VISU_ScalarMapOnDeformedShapePL : public VISU_ScalarMapPL -{ -public: - vtkTypeMacro(VISU_ScalarMapOnDeformedShapePL, VISU_ScalarMapPL); - - static - VISU_ScalarMapOnDeformedShapePL* - New(); - - virtual - void - SetScale(vtkFloatingPointType theScale); - - virtual - vtkFloatingPointType - GetScale(); - - virtual - int - GetScalarMode(); - - virtual - void - SetScalarMode(int theScalarMode = 0); - - virtual - void - SetScaling(int theScaling); - - virtual - void - SetScalarRange(vtkFloatingPointType theRange[2]); - - virtual - vtkFloatingPointType* - GetScalarRange(); - - virtual - void - GetSourceRange(vtkFloatingPointType theRange[2]); - - virtual - void - SetScalars(vtkDataSet *theScalars); - - virtual - vtkDataSet* - 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(); - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - - //! Update scalars. - void - UpdateScalars(); - - virtual - void - SetMapScale(vtkFloatingPointType theMapScale = 1.0); - -protected: - VISU_ScalarMapOnDeformedShapePL(); - - virtual - ~VISU_ScalarMapOnDeformedShapePL(); - - virtual - vtkDataSet* - InsertCustomPL(); - - virtual - void - DoShallowCopy(VISU_PipeLine *thePipeLine, - bool theIsCopyInput); - -private: - VISU_ScalarMapOnDeformedShapePL(const VISU_ScalarMapOnDeformedShapePL&); - - vtkFloatingPointType myScaleFactor; - vtkWarpVector *myWarpVector; - VISU_MergeFilter *myScalarsMergeFilter; - vtkSmartPointer myScalars; - vtkCellDataToPointData* myCellDataToPointData; - VISU_FieldTransform* myScalarsFieldTransform; - VISU_Extractor* myScalarsExtractor; -}; - -#endif diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index d7149129..ad739773 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -28,6 +28,7 @@ #include "VISU_ScalarMapPL.hxx" #include "VISU_DataSetMapperHolder.hxx" +#include "VISU_ElnoAssembleFilter.hxx" #include "VISU_FieldTransform.hxx" #include "VISU_AppendFilter.hxx" @@ -50,11 +51,16 @@ vtkStandardNewMacro(VISU_ScalarMapPL); VISU_ScalarMapPL ::VISU_ScalarMapPL(): VISU_UnstructuredGridPL(this), + myElnoAssembleFilter( VISU_ElnoAssembleFilter::New() ), myAppendFilter(VISU_AppendFilter::New()), myMergeFilter(VISU_MergeFilter::New()) { SetIsShrinkable(true); + SetElnoDisassembleState( false ); + + myElnoAssembleFilter->Delete(); + myAppendFilter->SetMergingInputs(true); myAppendFilter->Delete(); @@ -111,8 +117,11 @@ VISU_ScalarMapPL myMergeFilter->AddField("VISU_FIELD", aDataSet); myMergeFilter->AddField("VISU_CELLS_MAPPER", aDataSet); myMergeFilter->AddField("VISU_POINTS_MAPPER", aDataSet); + myMergeFilter->AddField("ELNO_POINT_COORDS", aDataSet); + + myElnoAssembleFilter->SetInput( InsertCustomPL() ); - GetDataSetMapper()->SetInput(InsertCustomPL()); + GetDataSetMapper()->SetInput( myElnoAssembleFilter->GetOutput() ); } @@ -148,6 +157,15 @@ VISU_ScalarMapPL } +//---------------------------------------------------------------------------- +void +VISU_ScalarMapPL +::SetElnoDisassembleState( bool theIsShrunk ) +{ + GetDataSetMapperHolder()->SetElnoDisassembleState( theIsShrunk ); + myElnoAssembleFilter->SetElnoAssembleState( theIsShrunk ); +} + //---------------------------------------------------------------------------- void VISU_ScalarMapPL diff --git a/src/PIPELINE/VISU_ScalarMapPL.hxx b/src/PIPELINE/VISU_ScalarMapPL.hxx index dff91d39..fdb4ef94 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.hxx +++ b/src/PIPELINE/VISU_ScalarMapPL.hxx @@ -34,6 +34,7 @@ #include "VISU_UnstructuredGridPL.hxx" class VISU_DataSetMapperHolder; +class VISU_ElnoAssembleFilter; class VISU_AppendFilter; class VISU_MergeFilter; @@ -111,12 +112,16 @@ protected: DoShallowCopy(VISU_PipeLine *thePipeLine, bool theIsCopyInput); + void + SetElnoDisassembleState( bool theIsShrunk ); + private: VISU_ScalarMapPL(const VISU_ScalarMapPL&); // Not implemented. void operator=(const VISU_ScalarMapPL&); // Not implemented. - vtkSmartPointer myAppendFilter; - vtkSmartPointer myMergeFilter; + vtkSmartPointer< VISU_ElnoAssembleFilter > myElnoAssembleFilter; + vtkSmartPointer< VISU_AppendFilter > myAppendFilter; + vtkSmartPointer< VISU_MergeFilter > myMergeFilter; }; #endif diff --git a/src/PIPELINE/VISU_VectorsPL.cxx b/src/PIPELINE/VISU_VectorsPL.cxx index 5192eefb..1c3257b9 100644 --- a/src/PIPELINE/VISU_VectorsPL.cxx +++ b/src/PIPELINE/VISU_VectorsPL.cxx @@ -44,18 +44,18 @@ vtkStandardNewMacro(VISU_VectorsPL); //---------------------------------------------------------------------------- template -void ToCellCenters(TOutputFilter *theOutputFilter, - vtkCellCenters *theCellCenters, - vtkDataSet* theDataSet, - VISU_UsedPointsFilter* theUsedPointsFilter) +void ToCellCenters( TOutputFilter *theOutputFilter, + vtkCellCenters *theCellCenters, + vtkDataSet* theDataSet, + VISU_UsedPointsFilter* theUsedPointsFilter ) { - if(VISU::IsDataOnCells(theDataSet)){ - theCellCenters->SetInput(theDataSet); + if ( VISU::IsDataOnCells( theDataSet ) ) { + theCellCenters->SetInput( theDataSet ); theCellCenters->VertexCellsOn(); - theOutputFilter->SetInput(theCellCenters->GetOutput()); + theOutputFilter->SetInput( theCellCenters->GetOutput() ); }else { - theUsedPointsFilter->SetInput(theDataSet); - theOutputFilter->SetInput(theUsedPointsFilter->GetOutput()); + theUsedPointsFilter->SetInput( theDataSet ); + theOutputFilter->SetInput( theUsedPointsFilter->GetOutput() ); } } @@ -63,10 +63,9 @@ void ToCellCenters(TOutputFilter *theOutputFilter, VISU_VectorsPL ::VISU_VectorsPL() { - SetIsShrinkable(false); + SetIsShrinkable( false ); - myBaseGlyph = vtkGlyph3D::New(); - myTransformedGlyph = vtkGlyph3D::New(); + myGlyph = vtkGlyph3D::New(); myGlyphSource = vtkGlyphSource2D::New(); myConeSource = vtkConeSource::New(); @@ -83,8 +82,7 @@ VISU_VectorsPL VISU_VectorsPL ::~VISU_VectorsPL() { - myBaseGlyph->Delete(); - myTransformedGlyph->Delete(); + myGlyph->Delete(); myCenters->Delete(); @@ -107,8 +105,7 @@ VISU_VectorsPL { unsigned long int aTime = Superclass::GetMTime(); - aTime = std::max(aTime, myBaseGlyph->GetMTime()); - aTime = std::max(aTime, myTransformedGlyph->GetMTime()); + aTime = std::max(aTime, myGlyph->GetMTime()); aTime = std::max(aTime, myCenters->GetMTime()); aTime = std::max(aTime, myGlyphSource->GetMTime()); aTime = std::max(aTime, myConeSource->GetMTime()); @@ -137,10 +134,9 @@ VISU_VectorsPL //---------------------------------------------------------------------------- void VISU_VectorsPL -::SetTransform(VTKViewer_Transform* theTransform) +::SetTransform( VTKViewer_Transform* theTransform ) { - GetFieldTransformFilter()->SetSpaceTransform(theTransform); - myTransformFilter->SetTransform(theTransform); + myTransformFilter->SetTransform( theTransform ); myTransformFilter->Modified(); } @@ -150,7 +146,7 @@ VTKViewer_Transform* VISU_VectorsPL ::GetTransform() { - return GetFieldTransformFilter()->GetSpaceTransform(); + return static_cast< VTKViewer_Transform* >( myTransformFilter->GetTransform() ); } @@ -159,13 +155,12 @@ void VISU_VectorsPL ::SetScale(vtkFloatingPointType theScale) { - if(myScaleFactor == theScale) + if ( VISU::CheckIsSameValue( myScaleFactor, theScale ) ) return; - myScaleFactor = theScale; + myGlyph->SetScaleFactor( theScale ); - myBaseGlyph->SetScaleFactor(myScaleFactor); - myTransformedGlyph->SetScaleFactor(myScaleFactor); + myScaleFactor = theScale; Modified(); } @@ -176,7 +171,7 @@ vtkFloatingPointType VISU_VectorsPL ::GetScale() { - return myTransformedGlyph->GetScaleFactor(); + return myGlyph->GetScaleFactor(); } @@ -243,22 +238,15 @@ VISU_VectorsPL { Superclass::Build(); - ToCellCenters(myBaseGlyph, - myCenters, - GetMergedInput(), - myUsedPointsFilter); - myBaseGlyph->SetVectorModeToUseVector(); - myBaseGlyph->SetScaleModeToScaleByVector(); - myBaseGlyph->SetColorModeToColorByScalar(); - - ToCellCenters(myTransformFilter, - myCenters, - GetMergedInput(), - myUsedPointsFilter); - myTransformedGlyph->SetInput(myTransformFilter->GetOutput()); - myTransformedGlyph->SetVectorModeToUseVector(); - myTransformedGlyph->SetScaleModeToScaleByVector(); - myTransformedGlyph->SetColorModeToColorByScalar(); + ToCellCenters( myTransformFilter, + myCenters, + GetMergedInput(), + myUsedPointsFilter ); + + myGlyph->SetInput( myTransformFilter->GetOutput() ); + myGlyph->SetVectorModeToUseVector(); + myGlyph->SetScaleModeToScaleByVector(); + myGlyph->SetColorModeToColorByScalar(); } @@ -267,7 +255,7 @@ vtkDataSet* VISU_VectorsPL ::InsertCustomPL() { - return myTransformedGlyph->GetOutput(); + return myGlyph->GetOutput(); } @@ -290,8 +278,7 @@ VISU_VectorsPL case CENTER: myGlyphSource->SetCenter(0.0, 0.0, 0.0); } - myBaseGlyph->SetSource(myGlyphSource->GetOutput()); - myTransformedGlyph->SetSource(myGlyphSource->GetOutput()); + myGlyph->SetSource(myGlyphSource->GetOutput()); } break; case CONE2: @@ -313,14 +300,12 @@ VISU_VectorsPL case CENTER: myConeSource->SetCenter(0.0, 0.0, 0.0); } - myBaseGlyph->SetSource(myConeSource->GetOutput()); - myTransformedGlyph->SetSource(myConeSource->GetOutput()); + myGlyph->SetSource(myConeSource->GetOutput()); } break; case NONE: default: { - myBaseGlyph->SetSource(myLineSource->GetOutput()); - myTransformedGlyph->SetSource(myLineSource->GetOutput()); + myGlyph->SetSource(myLineSource->GetOutput()); } } @@ -335,19 +320,12 @@ VISU_VectorsPL { unsigned long int aSize = Superclass::GetMemorySize(); - if(vtkDataSet* aDataSet = myBaseGlyph->GetOutput()) - aSize += aDataSet->GetActualMemorySize() * 1024; - - if(vtkDataSet* aDataSet = myTransformedGlyph->GetOutput()) + if(vtkDataSet* aDataSet = myGlyph->GetOutput()) aSize += aDataSet->GetActualMemorySize() * 1024; if(vtkDataSet* aDataSet = myCenters->GetOutput()) aSize += aDataSet->GetActualMemorySize() * 1024; - if(myCellDataToPointData->GetInput()) - if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput()) - aSize += aDataSet->GetActualMemorySize() * 1024; - return aSize; } @@ -357,8 +335,9 @@ vtkDataSet* VISU_VectorsPL ::GetOutput() { - myBaseGlyph->Update(); - return myBaseGlyph->GetOutput(); + myGlyph->Update(); + + return myGlyph->GetOutput(); } @@ -368,9 +347,9 @@ VISU_VectorsPL ::SetMapScale(vtkFloatingPointType theMapScale) { VISU_ScalarMapPL::SetMapScale(theMapScale); + myMapScaleFactor = theMapScale; - myBaseGlyph->SetScaleFactor(myScaleFactor*theMapScale); - myTransformedGlyph->SetScaleFactor(myScaleFactor*theMapScale); + myGlyph->SetScaleFactor( myScaleFactor*theMapScale ); Modified(); } diff --git a/src/PIPELINE/VISU_VectorsPL.hxx b/src/PIPELINE/VISU_VectorsPL.hxx index 09fe54cb..0befbd6e 100644 --- a/src/PIPELINE/VISU_VectorsPL.hxx +++ b/src/PIPELINE/VISU_VectorsPL.hxx @@ -135,8 +135,7 @@ protected: GlyphType myTypeGlyph; GlyphPos myPosGlyph; - vtkGlyph3D *myBaseGlyph; - vtkGlyph3D *myTransformedGlyph; + vtkGlyph3D *myGlyph; vtkGlyphSource2D *myGlyphSource; vtkLineSource *myLineSource; diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index 1f20a5b4..e3a86336 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -63,7 +63,7 @@ dist_libVISU_la_SOURCES= \ VisuGUI_StreamLinesDlg.cxx \ VisuGUI_VectorsDlg.cxx \ VisuGUI_Displayer.cxx \ - VisuGUI_ScalarMapOnDeformedShapeDlg.cxx \ + VisuGUI_DeformedShapeAndScalarMapDlg.cxx \ VisuGUI_SetupPlot2dDlg.cxx \ VisuGUI_BuildProgressDlg.cxx \ VisuGUI_Table3dDlg.cxx \ @@ -97,7 +97,7 @@ MOC_FILES= \ VisuGUI_CutPlanesDlg_moc.cxx \ VisuGUI_StreamLinesDlg_moc.cxx \ VisuGUI_VectorsDlg_moc.cxx \ - VisuGUI_ScalarMapOnDeformedShapeDlg_moc.cxx \ + VisuGUI_DeformedShapeAndScalarMapDlg_moc.cxx \ VisuGUI_SetupPlot2dDlg_moc.cxx \ VisuGUI_BuildProgressDlg_moc.cxx \ VisuGUI_Table3dDlg_moc.cxx \ diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 2125dcc0..b24996d2 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -397,6 +397,26 @@ Do you want to enlarge the cache? VISU_BAR_HEIGHT Bar height (%): + + VISU_AUTOMATIC_FIT_ALL + Automatic Fit All + + + VISU_DEFORMED_SHAPE_AND_SCALAR_MAP + Def. Shape and Scalar Map + + + VISU_FLOATING_POINT_PRECISION + Floating Point Precision + + + VISU_REALLY_DELETE + Do you really want to delete this %1 object(s): %2 + + + WRN_NO_APPROPRIATE_SELECTION + No appropriate objects selected + VVTK_MainWindow @@ -1105,8 +1125,8 @@ Please, refer to the documentation. Scalar Map - MEN_SCALAR_MAP_ON_DEFORMED_SHAPE - Scalar Map on Deformed Shape + MEN_DEFORMED_SHAPE_AND_SCALAR_MAP + Deformed Shape and Scalar Map MEN_SCALING @@ -1208,6 +1228,26 @@ Please, refer to the documentation. MEN_FILE_INFO MED File information + + ERR_ERROR_IN_THE_FILE + Error in the file + + + ERR_FILE_NOT_EXISTS + File does not exist + + + IMPORT_ERRORS + Import operation has finished with errors: + + + TLT_IMPORT_TABLE + Import table + + + UNKNOWN_IMPORT_ERROR + Unknown error + VisuGUI_AxisWg @@ -1664,6 +1704,18 @@ Please, provide non-empty resulting presentation. TXT_ORIENTATION Orientation + + LBL_DEFORMATION + Deformation + + + LBL_DEFROMATION_SCALE + Scale Factor : + + + LBL_DEFROMATION_VECT + Vectors : + VisuGUI_DeformedShapeDlg @@ -1980,6 +2032,18 @@ Please, provide non-empty resulting presentation. NB_SURFACES Number of surfaces: + + MAGNITUDE_COLORING_CHK + Magnitude coloring + + + SEL_COLOR_BTN + Select Color + + + SHOW_VALUES_CHK + Show values (nb per surface) + VisuGUI_IsoSurfacesDlg @@ -2717,7 +2781,7 @@ Please, provide non-empty resulting presentation. - VisuGUI_ScalarMapOnDeformedShapeDlg + VisuGUI_DeformedShapeAndScalarMapDlg &Cancel @@ -2728,7 +2792,7 @@ Please, provide non-empty resulting presentation. DLG_TITLE - Scalar Map on Deformed Shape + Deformed Shape and Scalar Map FIELD_ITEM @@ -2743,8 +2807,8 @@ Please, provide non-empty resulting presentation. Scalar Bar - SCALAR_MAP_ON_DEFORMED_SHAPE_TAB - Scalar Map on Deformed Shape + DEFORMED_SHAPE_AND_SCALAR_MAP_TAB + Deformed Shape and Scalar Map SCALE_FACTOR diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 810aeb27..109c8242 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -56,6 +56,7 @@ #include "SUIT_ViewManager.h" #include "SUIT_Desktop.h" #include "SUIT_DataBrowser.h" +#include "SUIT_OverrideCursor.h" #include "CAM_Module.h" @@ -122,8 +123,8 @@ #include "VISU_DeformedShape_i.hh" #include "VisuGUI_DeformedShapeDlg.h" -#include "VISU_ScalarMapOnDeformedShape_i.hh" -#include "VisuGUI_ScalarMapOnDeformedShapeDlg.h" +#include "VISU_DeformedShapeAndScalarMap_i.hh" +#include "VisuGUI_DeformedShapeAndScalarMapDlg.h" #include "VISU_IsoSurfaces_i.hh" #include "VisuGUI_IsoSurfacesDlg.h" @@ -193,7 +194,7 @@ VisuGUI SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); - // Get file name + // Get file name(s) QStringList aFilter; aFilter.append( tr( "FLT_MED_FILES" ) ); aFilter.append( tr( "FLT_DISTRIBUTED_MED_FILES" ) ); @@ -201,57 +202,85 @@ VisuGUI bool toUseBuildProgress = aResourceMgr->booleanValue("VISU", "use_build_progress", false); - SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( GetDesktop(this), true, tr("USE_BUILD_PROGRESS") ); - fd->setWindowTitle( tr( "IMPORT_FROM_FILE" ) ); - fd->setFilters( aFilter ); - fd->SetChecked( toUseBuildProgress ); - if( !fd->exec() ) - return; + SalomeApp_CheckFileDlg fd( GetDesktop(this), true, tr("USE_BUILD_PROGRESS") ); + fd.setWindowTitle( tr( "IMPORT_FROM_FILE" ) ); + fd.setFileMode( SalomeApp_CheckFileDlg::ExistingFiles ); + fd.setFilters( aFilter ); + fd.SetChecked( toUseBuildProgress ); + if ( SalomeApp_CheckFileDlg::getLastVisitedPath().isEmpty() ) + fd.setDirectory( QDir::currentPath() ); - QFileInfo aFileInfo( fd->selectedFile() ); - toUseBuildProgress = fd->IsChecked(); - delete fd; + QStringList fileNames; + if ( !fd.exec() ) + return; // cancelled, return - // Check the file name - if ( !aFileInfo.exists() ) - return; + fileNames = fd.selectedFiles(); + toUseBuildProgress = fd.IsChecked(); - if ( !toUseBuildProgress ) - { - bool toBuildFields = aResourceMgr->booleanValue( "VISU", "build_fields", true ); - bool toBuildMinMax = aResourceMgr->booleanValue( "VISU", "build_min_max", true ); - bool toBuildGroups = aResourceMgr->booleanValue( "VISU", "build_groups", true ); - bool toBuildAll = aResourceMgr->booleanValue( "VISU", "full_med_loading", false ); - bool toBuildAtOnce = aResourceMgr->booleanValue( "VISU", "build_at_once", false ); - - QString anInfo("Importing From File " + aFileInfo.absoluteFilePath() + "..." ); - application()->putInfo( anInfo ); - - QApplication::setOverrideCursor(Qt::WaitCursor); - VISU::Result_var aResult = GetVisuGen(this)->CreateResult( aFileInfo.filePath().toLatin1().data() ); - - if (CORBA::is_nil(aResult.in())) { - SUIT_MessageBox::warning(GetDesktop(this), - tr("WRN_VISU"), - VisuGUI_BuildProgressDlg::tr("ERR_ERROR_IN_THE_FILE") ); - QApplication::restoreOverrideCursor(); - }else{ - aResult->SetBuildFields( toBuildFields, toBuildMinMax ); - aResult->SetBuildGroups( toBuildGroups ); - aResult->Build( toBuildAll, toBuildAtOnce ); - - UpdateObjBrowser(this); - application()->putInfo( anInfo + tr("INF_DONE")); - QApplication::restoreOverrideCursor(); - } - } - else - { - VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) ); - aBuildProgressDlg->setFileName( aFileInfo.filePath() ); - aBuildProgressDlg->setGenerator( GetVisuGen(this) ); - aBuildProgressDlg->show(); + if ( fileNames.count() == 0 ) + return; // nothing selected, return + + SUIT_OverrideCursor wc; + QStringList errors; + + for ( QStringList::ConstIterator it = fileNames.begin(); it != fileNames.end(); ++it ) { + QFileInfo aFileInfo( *it ); + + if ( !aFileInfo.exists() ) { + // file not exist + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). + arg( tr( "ERR_FILE_NOT_EXISTS" ) ) ); } + else { + try { + if ( !toUseBuildProgress ) { + // build progress is not used, use build flags from settings + bool toBuildFields = aResourceMgr->booleanValue( "VISU", "build_fields", true ); + bool toBuildMinMax = aResourceMgr->booleanValue( "VISU", "build_min_max", true ); + bool toBuildGroups = aResourceMgr->booleanValue( "VISU", "build_groups", true ); + bool toBuildAll = aResourceMgr->booleanValue( "VISU", "full_med_loading", false ); + bool toBuildAtOnce = aResourceMgr->booleanValue( "VISU", "build_at_once", false ); + + QString anInfo( tr( "IMPORT_FROM_FILE" ) + " " + aFileInfo.filePath() + " ... " ); + application()->putInfo( anInfo ); + + VISU::Result_var aResult = GetVisuGen( this )->CreateResult( aFileInfo.filePath().toLatin1().constData() ); + + if ( CORBA::is_nil( aResult.in() ) ) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). + arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) ); + } + else { + aResult->SetBuildFields( toBuildFields, toBuildMinMax ); + aResult->SetBuildGroups( toBuildGroups ); + aResult->Build( toBuildAll, toBuildAtOnce ); + application()->putInfo( anInfo + tr("INF_DONE") ); + } + } // if ( !toUseBuildProgress ) + else { + // use build progress + wc.suspend(); + VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) ); + aBuildProgressDlg->setFileName( aFileInfo.filePath() ); + aBuildProgressDlg->setGenerator( GetVisuGen(this) ); + aBuildProgressDlg->exec(); + wc.resume(); + } + } // try + catch(...) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) ); + } + } // else // if ( !aFileInfo.exists() ) + } // for (...) + + if ( errors.count() > 0 ) { + SUIT_MessageBox::critical( GetDesktop(this), + tr("ERR_ERROR"), + tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); + } + else { + UpdateObjBrowser(this); + } } void @@ -266,26 +295,54 @@ VisuGUI aFilter.append( tr("FLT_TABLE_FILES") ); aFilter.append( tr("FLT_ALL_FILES") ); - QFileInfo aFileInfo = - SUIT_FileDlg::getFileName(GetDesktop(this), - "", - aFilter, - tr("MEN_IMPORT_TABLE"), - true); - if (aFileInfo.exists()) { - application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.absoluteFilePath() + " ..." ); - - CORBA::Object_var anObject = GetVisuGen(this)->ImportTables((const char*)aFileInfo.absoluteFilePath().toLatin1()); - - if (CORBA::is_nil(anObject.in())) { - SUIT_MessageBox::warning( GetDesktop(this), - tr("WRN_VISU"), - tr("ERR_ERROR_IN_THE_FILE") ); - } else { - application()->putInfo(aFileInfo.absoluteFilePath()+tr("INF_DONE")); - UpdateObjBrowser(this); + QString anInitialPath = ""; + if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() ) + anInitialPath = QDir::currentPath(); + + QStringList aFiles = SUIT_FileDlg::getOpenFileNames(GetDesktop(this), + anInitialPath, + aFilter, + tr("TLT_IMPORT_TABLE")); + if ( aFiles.count() == 0 ) + return; // nothing selected + + QStringList errors; + for ( QStringList::ConstIterator it = aFiles.begin(); it != aFiles.end(); ++it ) { + QFileInfo aFileInfo( *it ); + + if ( !aFileInfo.exists() ) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). + arg( tr( "ERR_FILE_NOT_EXISTS" ) ) ); + } + else { + try { + QString anInfo( tr("TLT_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." ); + application()->putInfo( anInfo ); + + CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath().toLatin1().constData()); + + if (CORBA::is_nil(anObject.in())) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). + arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) ); + } + else { + application()->putInfo( anInfo + tr("INF_DONE") ); + } + } + catch(...) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) ); + } } } + + if ( errors.count() > 0 ) { + SUIT_MessageBox::critical( GetDesktop(this), + tr("ERR_ERROR"), + tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); + } + else { + UpdateObjBrowser(this); + } } void @@ -667,15 +724,14 @@ void VisuGUI ::OnCreateDeformedShape() { - // CreatePrs3d(this); - VisuGUI_DeformedShapeDlg::CreatePrs3d(this); + CreatePrs3d(this); } void VisuGUI -::OnCreateScalarMapOnDeformedShape() +::OnCreateDeformedShapeAndScalarMap() { - CreatePrs3d(this); + CreatePrs3d(this); } void @@ -776,7 +832,8 @@ VisuGUI aViewWindow->getRenderer()->ResetCameraClippingRange(); aViewWindow->Repaint(); } - }} + } + } } } @@ -880,11 +937,11 @@ VisuGUI //---------------------------------------------------------------------------- void VisuGUI -::OnEditScalarMapOnDeformedShape() +::OnEditDeformedShapeAndScalarMap() { Handle(SALOME_InteractiveObject) anIO; if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO)) - EditPrs3d(this, anIO, aPrs3d); + EditPrs3d(this, anIO, aPrs3d); } //---------------------------------------------------------------------------- @@ -1142,12 +1199,6 @@ void VisuGUI ::OnChangeOpacity() { - VISU_Actor* anActor = NULL; - VISU::Prs3d_i* aPrs3d = NULL; - SVTK_ViewWindow* aViewWindow = NULL; - if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor)) - return; - VisuGUI_TransparencyDlg* aDialog = new VisuGUI_TransparencyDlg( this ); aDialog->show(); } @@ -1158,10 +1209,24 @@ VisuGUI ::OnChangeLines() { VISU_Actor* anActor = NULL; + VISU_ActorBase* anActorBase = NULL; VISU::Prs3d_i* aPrs3d = NULL; SVTK_ViewWindow* aViewWindow = NULL; - if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor)) - return; + float oldlwid; + bool isPrs3d = false; + + if (GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor)) { + isPrs3d = true; + } + else { + aViewWindow = GetActiveViewWindow(this); + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + VISU::PointMap3d_i* aTable = dynamic_cast(aSelectionItem.myObjectInfo.myBase); + anActorBase = VISU::FindActorBase(aViewWindow, aTable); + oldlwid = anActorBase->GetLineWidth(); + } + VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg (GetDesktop(this), (const char*)tr("DLG_LINEWIDTH_TITLE").toLatin1(), TRUE); @@ -1172,7 +1237,6 @@ VisuGUI CursorDlg->SpinBox1->setMinimum(1); CursorDlg->SpinBox1->setMaximum(10); - float oldlwid = anActor->GetLineWidth(); int intlwid = int(oldlwid); CursorDlg->SpinBox1->setValue(intlwid); @@ -1180,7 +1244,10 @@ VisuGUI if (ret == 1) { intlwid = CursorDlg->SpinBox1->value(); float newlwid = intlwid; - anActor->SetLineWidth(newlwid); + if (isPrs3d) + anActor->SetLineWidth(newlwid); + else + anActorBase->SetLineWidth(newlwid); } delete CursorDlg; } @@ -1272,15 +1339,30 @@ VisuGUI int i = 0, nbSelected = aList.Extent(); if (nbSelected < 1) return; - std::vector anEntries(nbSelected); + std::vector anEntries (nbSelected); + QString aNameList; Handle(SALOME_InteractiveObject) anIO; for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) { anIO = it.Value(); - if (anIO->hasEntry()) - anEntries[i++] = anIO->getEntry(); + aNameList.append("\n - "); + aNameList.append(anIO->getName()); + if (anIO->hasEntry()) { + if (IsRemovable(anIO->getEntry(), this)) + anEntries[i++] = anIO->getEntry(); + } } nbSelected = i; - if (nbSelected < 1) return; + if (nbSelected < 1) { + SUIT_MessageBox::warning(GetDesktop(this), + QObject::tr("WRN_VISU"), + QObject::tr("WRN_NO_APPROPRIATE_SELECTION")); + } + + if ( SUIT_MessageBox::question( GetDesktop(this), + QObject::tr( "WRN_VISU" ), + QObject::tr( "VISU_REALLY_DELETE" ).arg( nbSelected ).arg( aNameList ), + SUIT_MessageBox::Yes | SUIT_MessageBox::No ) != SUIT_MessageBox::Yes ) + return; // There is a transaction _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder(); @@ -1313,7 +1395,8 @@ VisuGUI } } } - }else{ + } + else{ DeleteSObject(this, aCStudy, aSObject); UpdateObjBrowser(this, true, aSObject); } @@ -1621,68 +1704,97 @@ VisuGUI return; VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); - if(aSelectionInfo.empty()) + if (aSelectionInfo.empty()) return; - VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); - _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject; - if(!aSObject) - return; + VisuGUI_Selection aSel (this); + aSel.init("", getApp()->selectionMgr()); + if (aSel.count() < 1) return; - //TEST DU PARENT == VISU - _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder(); - _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObject, "AttributeName"); - if (anAttr) { - _PTR(AttributeName) aName (anAttr); - QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() ); - if (!Name.isEmpty()) { - QApplication::setOverrideCursor(Qt::WaitCursor); - - // rename specific objects - if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){ - switch(aBase->GetType()){ - case VISU::TCURVE: { // Curve object - if(VISU::Curve_i* aCurve = dynamic_cast(aBase)) - aCurve->SetName((const char*)Name.toLatin1(), true); - break; - } - case VISU::TTABLE: { // Table object - if(VISU::Table_i* aTable = dynamic_cast(aBase)) - aTable->SetName((const char*)Name.toLatin1(), true); - break; - } - case VISU::TCONTAINER: { // Container object - if(VISU::Container_i* aContainer = dynamic_cast(aBase)) - aContainer->SetName((const char*)Name.toLatin1(), true); - break; - } - default: { - }} - } - } + bool isAny = false; // is there any appropriate object selected + for (int i = 0; i < aSelectionInfo.size(); i++) { + VISU::TSelectionItem aSelectionItem = aSelectionInfo[i]; + VISU::TObjectInfo anObjectInfo = aSelectionItem.myObjectInfo; - if (!Name.isEmpty()) { - // rename the study object - Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO; - aName->SetValue((const char*)Name.toLatin1()); // rename the SObject - anIO->setName((const char*)Name.toLatin1()); // rename the InteractiveObject - - ViewManagerList aViewManagerList; - ViewManagerList::Iterator anIt; - getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList); - anIt = aViewManagerList.begin(); - for(; anIt != aViewManagerList.end(); anIt++ ) - { - if(Plot2d_ViewManager* aManager = dynamic_cast(*anIt)){ - if(SPlot2d_Viewer* aViewer = dynamic_cast(aManager->getViewModel())) - aViewer->renameAll( anIO, (const char*)Name.toLatin1() ); - } - } + _PTR(SObject) aSObject = anObjectInfo.mySObject; + if (!aSObject) + continue; - UpdateObjBrowser(this, false); + // Check, if the selected object can be renamed + QString aStr = aSel.parameter(i, "type" ).toString(); + if (aStr == "VISU::TSCALARMAP" || aStr == "VISU::TISOSURFACES" || + aStr == "VISU::TDEFORMEDSHAPE" || aStr == "VISU::TCUTPLANES" || + aStr == "VISU::TCUTLINES" || aStr == "VISU::TVECTORS" || + aStr == "VISU::TSTREAMLINES" || aStr == "VISU::TPLOT3D" || + aStr == "VISU::TSCALARMAPONDEFORMEDSHAPE" || aStr == "VISU::TCOLOREDPRS3DHOLDER" || + aStr == "VISU::TTABLE" || aStr == "VISU::TCURVE" || aStr == "VISU::TCONTAINER" || + aStr == "VISU::POINTMAP3D" || aStr == "VISU::TVIEW3D" || + aStr == "VISU::TMESH" || aStr == "VISU::TPOINTMAP3D") + { + _PTR(GenericAttribute) anAttr; + if (aSObject->FindAttribute(anAttr, "AttributeName")) { + isAny = true; + _PTR(AttributeName) aName (anAttr); + QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() ); + if (!Name.isEmpty()) { + QApplication::setOverrideCursor(Qt::WaitCursor); + + // rename specific objects + if (VISU::Base_i* aBase = anObjectInfo.myBase) { + switch (aBase->GetType()) { + case VISU::TCURVE: { // Curve object + if (VISU::Curve_i* aCurve = dynamic_cast(aBase)) + aCurve->SetName(Name.toLatin1().constData(), true); + break; + } + case VISU::TTABLE: { // Table object + if (VISU::Table_i* aTable = dynamic_cast(aBase)) + aTable->SetName(Name.toLatin1().constData(), true); + break; + } + case VISU::TPOINTMAP3D: { // Table object + if (VISU::PointMap3d_i* aTable3d = dynamic_cast(aBase)) { + aTable3d->SetTitle(Name.toLatin1().constData()); + aTable3d->UpdateActors(); + } + break; + } + case VISU::TCONTAINER: { // Container object + if (VISU::Container_i* aContainer = dynamic_cast(aBase)) + aContainer->SetName(Name.toLatin1().constData(), true); + break; + } + default: { + }} + } + + // rename the study object + Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO; + aName->SetValue(Name.toLatin1().constData()); // rename the SObject + anIO->setName(Name.toLatin1().constData()); // rename the InteractiveObject + + ViewManagerList aViewManagerList; + getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList); + SUIT_ViewManager* aViewManager; + foreach( aViewManager, aViewManagerList ) { + if (Plot2d_ViewManager* aManager = dynamic_cast(aViewManager)) { + if (SPlot2d_Viewer* aViewer = dynamic_cast(aManager->getViewModel())) + aViewer->renameAll( anIO, Name.toLatin1().constData() ); + } + } + + UpdateObjBrowser(this, false); + + QApplication::restoreOverrideCursor(); + } + } } + } // for - QApplication::restoreOverrideCursor(); + if (!isAny) { + SUIT_MessageBox::warning(GetDesktop(this), + QObject::tr("WRN_VISU"), + QObject::tr("WRN_NO_APPROPRIATE_SELECTION")); } } @@ -1748,6 +1860,7 @@ VisuGUI aScalarMap->SetMapScale(aPercents); aScalarMap->UpdateActor(anActor); aViewWindow->getRenderWindow()->Render(); + aViewWindow->Repaint(); usleep(aTemp); } catch (std::exception& exc) { INFOS("Follow exception was occured :\n" << exc.what()); @@ -1869,7 +1982,8 @@ VisuGUI TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false); break; case VISU::TSCALARMAPONDEFORMEDSHAPE: - TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false); + case VISU::TDEFORMEDSHAPEANDSCALARMAP: + TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false); break; case VISU::TCUTPLANES: TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false); @@ -2014,26 +2128,7 @@ VisuGUI { if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs"); VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this); - - LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); - SALOME_ListIO aListIO; - aSelectionMgr->selectedObjects(aListIO); - - SalomeApp_Study* aStudy = GetAppStudy(this); - SALOME_ListIteratorOfListIO anIter(aListIO); - for (; anIter.More(); anIter.Next()) { - Handle(SALOME_InteractiveObject) anIO = anIter.Value(); - if (anIO->hasEntry()) { - QString anEntry(anIO->getEntry()); - VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, (const char*)anEntry.toLatin1()); - if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)) - aDlg->addPresentation(aPrsObject); - } - } - if (aDlg->getPrsCount() > 0) - aDlg->show(); - else - delete aDlg; + aDlg->exec(); } void @@ -2069,9 +2164,6 @@ VisuGUI SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); // Create actions - //createAction( VISU_IMPORT_FROM_FILE, "", QIcon(), - // tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false, - // this, SLOT(OnImportFromFile())); aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_IMPORT_MED")); createAction( VISU_IMPORT_FROM_FILE, tr("IMPORT_FROM_FILE"), QIcon(aPixmap), @@ -2093,9 +2185,9 @@ VisuGUI 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"), QIcon(aPixmap), - tr("MEN_SCALAR_MAP_ON_DEFORMED_SHAPE"), "", 0, aParent, false, - this, SLOT(OnCreateScalarMapOnDeformedShape())); + createAction( VISU_DEFORMED_SHAPE_AND_SCALAR_MAP, tr("MEN_DEFORMED_SHAPE_AND_SCALAR_MAP"), QIcon(aPixmap), + tr("MEN_DEFORMED_SHAPE_AND_SCALAR_MAP"), "", 0, aParent, false, + this, SLOT(OnCreateDeformedShapeAndScalarMap())); aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS")); createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIcon(aPixmap), @@ -2140,7 +2232,7 @@ VisuGUI tr("MEN_SHOW_TABLE"), "", 0, aParent, false, this, SLOT(OnShowTable())); - createAction( VISU_SHOW_TABLE_PLOT, tr("MEN_EDIT_PRS"), QIcon(), + createAction( VISU_EDIT_POINTMAP3D, tr("MEN_EDIT_PRS"), QIcon(), tr("MEN_EDIT_PRS"), "", 0, aParent, false, this, SLOT(OnShowTablePlot())); @@ -2331,10 +2423,9 @@ VisuGUI tr("MEN_EDIT_PRS"), "", 0, aParent, false, this, SLOT(OnEditPlot3D())); - createAction( VISU_EDIT_SCALARMAPONDEFORMEDSHAPE, tr("MEN_EDIT_PRS"), QIcon(), + createAction( VISU_EDIT_DEFORMEDSHAPEANDSCALARMAP, tr("MEN_EDIT_PRS"), QIcon(), tr("MEN_EDIT_PRS"), "", 0, aParent, false, - this, SLOT(OnEditScalarMapOnDeformedShape())); - + this, SLOT(OnEditDeformedShapeAndScalarMap())); createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIcon(), tr("MEN_CREATE_TABLE"), "", 0, aParent, false, @@ -2438,7 +2529,7 @@ VisuGUI 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 + createMenu( VISU_DEFORMED_SHAPE_AND_SCALAR_MAP, aMenuId, 10 ); // scalar map on deformed shape aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 ); createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info @@ -2470,7 +2561,7 @@ VisuGUI createTool( VISU_CUT_LINES, aToolId ); createTool( VISU_STREAM_LINES, aToolId ); createTool( VISU_PLOT_3D, aToolId ); - createTool( VISU_SCALAR_MAP_ON_DEFORMED_SHAPE, aToolId ); + createTool( VISU_DEFORMED_SHAPE_AND_SCALAR_MAP, aToolId ); aToolId = createTool(tr("TOOL_REPRESENTATION")); createTool( VISU_POINTS, aToolId ); @@ -2504,7 +2595,7 @@ VisuGUI 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_DEFORMED_SHAPE_AND_SCALAR_MAP ), -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 @@ -2520,8 +2611,9 @@ VisuGUI 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_DEFORMEDSHAPEANDSCALARMAP ), -1, -1, -1 ); mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 ); + mgr->insert( action( VISU_EDIT_POINTMAP3D ), -1, -1, -1 ); // rename mgr->insert( action( VISU_RENAME ), -1, -1, -1 ); @@ -2533,9 +2625,9 @@ VisuGUI mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 ); // table commands - //mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table - //mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves - //mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table + mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table + mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves + mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table mgr->insert( separator(), -1, -1, -1 ); @@ -2602,7 +2694,7 @@ VisuGUI QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' " - "'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TCOLOREDPRS3DHOLDER'"); + "'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TCOLOREDPRS3DHOLDER'"); // VISU root commands QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'"; @@ -2621,24 +2713,24 @@ VisuGUI mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule ); mgr->setRule( action( VISU_VECTORS ), aRule ); mgr->setRule( action( VISU_STREAM_LINES ), aRule ); - mgr->setRule( action( VISU_SCALAR_MAP_ON_DEFORMED_SHAPE ), aRule ); + mgr->setRule( action( VISU_DEFORMED_SHAPE_AND_SCALAR_MAP ), aRule ); // display/erase commands QString andInvisible = " and (((not isVisible) and isActiveView) or (not isActiveView))"; QString aTableOrCont = "(type='VISU::TTABLE' and nbChildren>0) or type='VISU::TCONTAINER'"; QString orCurveVisible = "or (type='VISU::TCURVE' and isVisible)"; QString orCurveInvisible = "or (type='VISU::TCURVE'" + andInvisible + ")"; - QString aPrsVisible = "(($type in {'VISU::TMESH' " + aPrsAll + "}) and isVisible)"; - QString aPrsInvisible = "(($type in {'VISU::TMESH' " + aPrsAll + "})" + andInvisible + ")"; + QString aPrsVisible = "(($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D'" + aPrsAll + "}) and isVisible)"; + QString aPrsInvisible = "(($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D'" + aPrsAll + "})" + andInvisible + ")"; QString aComponent = "( selcount=1 and canBeDisplayed and isVisuComponent )"; QString anEraseRule = "( selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsVisible + " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveVisible + "))) ) or " + aComponent; QString aDisplayRule = "( selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsInvisible + - " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveInvisible + "))) ) or" + aComponent; + " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveInvisible + "))) ) or " + aComponent; - QString aDOnlyRule = "( selcount>0 and ({true} in $canBeDisplayed) and (($type in {'VISU::TMESH' " + aPrsAll + "})" + QString aDOnlyRule = "( selcount>0 and ({true} in $canBeDisplayed) and (($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D'" + aPrsAll + "})" " or (client='ObjectBrowser' and ((type='VISU::TTABLE' and nbChildren>0) or" " ($type in {'VISU::TCURVE' 'VISU::TCONTAINER'})))) ) or" + aComponent; @@ -2646,7 +2738,7 @@ VisuGUI mgr->setRule( action( VISU_DISPLAY ), aDisplayRule ); mgr->setRule( action( VISU_DISPLAY_ONLY ), aDOnlyRule ); - aRule = "selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "}"; + aRule = "selcount>0 and $type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "}"; mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule ); aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}"; @@ -2663,14 +2755,15 @@ VisuGUI mgr->setRule( action( VISU_ARRANGE_ACTORS ), "$client in {'VTKViewer' 'VVTK'} and selcount=0" ); // 3D presentations commands - QString aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}"; - QString anInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}"; - QString aSurfFrameType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP''VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}"; + QString aPrsType = " and $type in {'VISU::TMESH'" + 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 aSurfType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " - " 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}"; - QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}"; + " 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TPOINTMAP3D'}"; + QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TPOINTMAP3D'}"; QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' " - "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' }"; + "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TPOINTMAP3D'}"; aRule = "selcount=1"; mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType ); @@ -2683,7 +2776,7 @@ VisuGUI QString aNotSurffr = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}"; mgr->setRule( action( VISU_POINTS ) , aRule + aPrsType + aNotPoints ); - mgr->setRule( action( VISU_WIREFRAME ) , aRule + aPrsType + aNotWirefr ); + mgr->setRule( action( VISU_WIREFRAME ) , aRule + aPrsType2 + aNotWirefr ); mgr->setRule( action( VISU_SURFACE ) , aRule + aSurfType + aNotSurfac ); mgr->setRule( action( VISU_INSIDEFRAME ) , aRule + anInsideType + aNotInside ); mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfFrameType + aNotSurffr ); @@ -2704,19 +2797,25 @@ VisuGUI mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1" ); // rename command - QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'"; + QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER' 'VISU::POINTMAP3D'"; - aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TMESH' " + aCurveAll + " " + aPrsAll + "})"; + aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TMESH' 'VISU::TPOINTMAP3D' " + aCurveAll + " " + aPrsAll + "})"; mgr->setRule( action( VISU_RENAME ), aRule ); // copy presentation command aRule = "selcount=1 and ($type in {" + aPrsAll + "})"; mgr->setRule( action( VISU_COPY_PRS ), aRule ); - // curve commands + // Curve commands aRule = "selcount=1 and type='VISU::TCURVE'"; mgr->setRule( action( VISU_CURVE_PROPS ), aRule ); + // Table Commands + aRule = "selcount=1 and ( type='VISU::TPOINTMAP3D' or type='VISU::TTABLE')"; + mgr->setRule( action( VISU_SHOW_TABLE ), aRule ); + mgr->setRule( action( VISU_CREATE_CURVES ), aRule ); + mgr->setRule( action( VISU_EXPORT_TABLE ), aRule ); + // curve container commands aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TCONTAINER'"; mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule ); @@ -2726,8 +2825,8 @@ VisuGUI "selcount=1 and type='VISU::TSCALARMAP'" ); mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ), "selcount=1 and type='VISU::TDEFORMEDSHAPE'" ); - mgr->setRule( action( VISU_EDIT_SCALARMAPONDEFORMEDSHAPE ), - "selcount=1 and type='VISU::TSCALARMAPONDEFORMEDSHAPE'" ); + mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPEANDSCALARMAP ), + "selcount=1 and $type in {'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP'}" ); mgr->setRule( action( VISU_EDIT_CUTPLANES ), "selcount=1 and type='VISU::TCUTPLANES'" ); mgr->setRule( action( VISU_EDIT_CUTLINES ), @@ -2740,6 +2839,8 @@ VisuGUI "selcount=1 and type='VISU::TSTREAMLINES'" ); mgr->setRule( action( VISU_EDIT_PLOT3D ), "selcount=1 and type='VISU::TPLOT3D'" ); + mgr->setRule( action( VISU_EDIT_POINTMAP3D ), + "selcount=1 and type='VISU::TPOINTMAP3D'" ); aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0"; mgr->setRule( action( VISU_CREATE_TABLE ), aRule ); @@ -2820,6 +2921,14 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QMenu* theMenu, QStrin _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry()); if ( !aSObject ) continue; + + if ( !isOBClient ) { + QString aName = QString( aSObject->GetName().c_str() ); + while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of popup + aName.remove( (aName.length() - 1), 1 ); + theTitle = aName; + } + CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject); if (CORBA::is_nil(aCORBAObject)) { VISU::VISUType aType = VISU::Storable::SObject2Type( aSObject ); @@ -2916,21 +3025,11 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QMenu* theMenu, QStrin theMenu->addAction( action( VISU_SHOW_ANIMATION ) ); } else if (isOBClient) { if (IsSObjectTable(aSObject)) { - theMenu->removeAction( action( VISU_DELETE_OBJS ) ); - if (aType == VISU::TPOINTMAP3D) { - theMenu->addAction( action( VISU_SHOW_TABLE_PLOT ) ); - theMenu->addSeparator(); - theMenu->addAction( action( VISU_ERASE ) ); - theMenu->addAction( action( myEraseAll ) ); - theMenu->addAction( action( VISU_DISPLAY ) ); - theMenu->addAction( action( VISU_DISPLAY_ONLY ) ); - theMenu->addSeparator(); - } - theMenu->addAction( action( VISU_SHOW_TABLE ) ); + /* action( VISU_SHOW_TABLE )->addTo(theMenu); theMenu->addAction( action( VISU_CREATE_CURVES ) ); theMenu->addAction( action( VISU_EXPORT_TABLE ) ); theMenu->addSeparator(); - theMenu->addAction( action( VISU_DELETE_OBJS ) ); + action( VISU_DELETE_OBJS )->addTo(theMenu);*/// dmv - code was moved up } else { if (!CORBA::is_nil(anObject)) { SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject); @@ -2952,17 +3051,6 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QMenu* theMenu, QStrin } } } - } else { - if (aType == VISU::TPOINTMAP3D) { - theMenu->removeAction( action( myEraseAll ) ); - theMenu->addAction( action( VISU_SHOW_TABLE_PLOT ) ); - theMenu->addSeparator(); - theMenu->addAction( action( VISU_ERASE ) ); - theMenu->addAction( action( myEraseAll ) ); - theMenu->addAction( action( VISU_DISPLAY ) ); - theMenu->addAction( action( VISU_DISPLAY_ONLY ) ); - theMenu->addSeparator(); - } } } @@ -3015,6 +3103,9 @@ VisuGUI shortcuts.append( QKeySequence(Qt::CTRL + Qt::Key_I) ); action(VISU_IMPORT_FROM_FILE)->setShortcuts(shortcuts); + action(VISU_DELETE_OBJS)->setEnabled(true); // Delete: Key_Delete + action(VISU_RENAME )->setEnabled(true); // Rename: Key_F2 + return true; } @@ -3027,7 +3118,10 @@ VisuGUI setToolShown( false ); // Unset actions accelerator keys - action(VISU_IMPORT_FROM_FILE)->setShortcuts(QKeySequence::UnknownKey); + action(VISU_IMPORT_FROM_FILE)->setShortcuts(QKeySequence::UnknownKey); // Import: CTRL + Key_I + + action(VISU_DELETE_OBJS)->setEnabled(false); // Delete: Key_Delete + action(VISU_RENAME )->setEnabled(false); // Rename: Key_F2 SalomeApp_Module::deactivateModule( theStudy ); return true; @@ -3452,17 +3546,28 @@ void VisuGUI::createPreferences() setPreferenceProperty( sp, "hstretch", 0 ); setPreferenceProperty( sp, "vstretch", 0 ); - int scalar_def_represent = addPreference( tr( "VISU_SCALAR_MAP_ON_DEFORMED_SHAPE" ), representGr, LightApp_Preferences::Selector, "VISU", "scalar_def_represent" ); + int scalar_def_represent = addPreference( tr( "VISU_DEFORMED_SHAPE_AND_SCALAR_MAP" ), representGr, LightApp_Preferences::Selector, "VISU", "scalar_def_represent" ); setPreferenceProperty( scalar_def_represent, "strings", modes1 ); setPreferenceProperty( scalar_def_represent, "indexes", indices1 ); addPreference( tr( "VISU_SHRINK" ), representGr, LightApp_Preferences::Bool, "VISU", "scalar_def_shrink" ); + int point_precision = addPreference( tr( "VISU_FLOATING_POINT_PRECISION" ), representGr, + LightApp_Preferences::IntSpin, "VISU", "floating_point_precision" ); + setPreferenceProperty( point_precision, "min", 1 ); + setPreferenceProperty( point_precision, "max", 16 ); + setPreferenceProperty( point_precision, "step", 1 ); + addPreference( "", representGr, LightApp_Preferences::Space ); + addPreference( tr( "VISU_USE_SHADING" ), representGr, LightApp_Preferences::Bool, "VISU", "represent_shading" ); sp = addPreference( "", representGr, LightApp_Preferences::Space ); setPreferenceProperty( sp, "hstretch", 0 ); setPreferenceProperty( sp, "vstretch", 0 ); addPreference( tr( "VISU_DISP_ONLY" ), representGr, LightApp_Preferences::Bool, "VISU", "display_only" ); + addPreference( "", representGr, LightApp_Preferences::Space ); + + addPreference( tr( "VISU_AUTOMATIC_FIT_ALL" ), representGr, + LightApp_Preferences::Bool, "VISU", "automatic_fit_all" ); // TAB: 3D Cache ; group: "Cache properties" int cacheTab = addPreference( tr( "3D Cache" ) ); diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index a4f00aac..f2d18169 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -106,7 +106,7 @@ protected slots: void OnCreatePlot3D(); void OnCreateManyMesh(); void OnCreatePlot2dView(); - void OnCreateScalarMapOnDeformedShape(); + void OnCreateDeformedShapeAndScalarMap(); void OnEditScalarMap(); void OnEditDeformedShape(); @@ -116,7 +116,7 @@ protected slots: void OnEditVectors(); void OnEditStreamLines(); void OnEditPlot3D(); - void OnEditScalarMapOnDeformedShape(); + void OnEditDeformedShapeAndScalarMap(); virtual void OnDisplayPrs(); virtual void OnDisplayOnlyPrs(); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index aab3df54..5c1083fa 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -39,13 +39,13 @@ #define VISU_CUT_LINES 4017 #define VISU_PLOT2D 4018 #define VISU_PLOT_3D 4019 -#define VISU_SCALAR_MAP_ON_DEFORMED_SHAPE 40110 +#define VISU_DEFORMED_SHAPE_AND_SCALAR_MAP 40110 //#define VISU_DELETE 4021 #define VISU_DELETE_OBJS 4022 #define VISU_SHOW_TABLE 4023 -#define VISU_SHOW_TABLE_PLOT 4029 +#define VISU_EDIT_POINTMAP3D 4029 #define VISU_CREATE_CURVES 4024 #define VISU_EXPORT_TABLE 4025 @@ -92,7 +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_DEFORMEDSHAPEANDSCALARMAP 40628 #define VISU_EDIT_PRS 4062 #define VISU_CREATE_TABLE 4063 diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index e99b70e5..6eef1a49 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -37,6 +37,7 @@ #include "VISU_ColoredPrs3dFactory.hh" #include "VISU_CutPlanes_i.hh" +#include "VISU_Result_i.hh" #include "VISU_CutPlanesPL.hxx" //#include "OB_Browser.h" @@ -70,11 +71,13 @@ #include #include #include +#include #include #include #include #include +#include using namespace std; @@ -166,6 +169,34 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent) QLabel* aPosLbl = new QLabel(tr( "LBL_POS" ), this); myPosSpn = new QtxDoubleSpinBox( 0, 1, 0.1, this ); + GDeformation = new QGroupBox(tr("LBL_DEFORMATION"), this); + GDeformation->setCheckable(true); + GDeformation->setChecked(false); + QGridLayout* GDeformationLayout = new QGridLayout( GDeformation ); + GDeformationLayout->setSpacing( 6 ); + GDeformationLayout->setMargin( 11 ); + connect(GDeformation, SIGNAL(toggled(bool)), this, SLOT(onDeformationCheck(bool))); + + QLabel* LabelDeformation1 = new QLabel (tr("LBL_DEFROMATION_VECT"), GDeformation); + GDeformationLayout->addWidget( LabelDeformation1, 0, 0 ); + + myVectorialFieldCombo = new QComboBox (GDeformation); + GDeformationLayout->addWidget( myVectorialFieldCombo, 0, 1 ); + + QLabel* LabelDeformation2 = new QLabel (tr("LBL_DEFROMATION_SCALE"), GDeformation); + GDeformationLayout->addWidget( LabelDeformation2, 1, 0 ); + myScaleSpn = new QtxDoubleSpinBox (0.0, 1.0E+38, 0.1, GDeformation); + myScaleSpn->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + GDeformationLayout->addWidget( myScaleSpn, 1, 1 ); + connect(myVectorialFieldCombo, SIGNAL(activated(int)), this, SLOT(onVectorialFieldChanged(int))); + connect(myScaleSpn, SIGNAL(valueChanged(double)), this, SLOT(onScaleFactorChanged(double))); + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 ); + + myScaleSpn->setDecimals( aPrecision*(-1) ); + myScaleSpn->setValue(0.1); + myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), this); myPreviewCheck->setChecked(false); connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) ); @@ -178,7 +209,8 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent) TopLayout->setRowStretch ( 3, 3 ); TopLayout->addWidget(aPosLbl, 4, 0 ); TopLayout->addWidget(myPosSpn, 4, 1 ); - TopLayout->addWidget( myPreviewCheck, 5, 0, 1, 2 ); + TopLayout->addWidget( GDeformation, 5, 0, 1, 2 ); + TopLayout->addWidget( myPreviewCheck, 6, 0, 1, 2 ); // signals and slots connections connect( SelPlane, SIGNAL( buttonClicked( int )), this, SLOT( orientationChanged( int ) ) ); @@ -208,6 +240,24 @@ void VisuGUI_CutPlanesPane::initFromPrsObject (VISU::CutPlanes_i* thePrs) setRotation(thePrs->GetRotateX()*180./PI, thePrs->GetRotateY()*180./PI); setPlanePos(thePrs->GetOrientationType()); myPosSpn->setValue(thePrs->GetDisplacement()); + InitEntity2VectorialFieldsMap(thePrs); + InsertAllVectorialFields(); + setScaleFactor(thePrs->GetScale()); + if(myEntity2VectorialFields.size() < 1) + GDeformation->setDisabled(true); + else{ + if(thePrs->IsDeformed()){ + GDeformation->setChecked(true); + int idx = myVectorialFieldCombo->findText(thePrs->GetVectorialFieldName()); + if (idx >= 0) + myVectorialFieldCombo->setCurrentIndex(idx); + else { + myVectorialFieldCombo->addItem(thePrs->GetVectorialFieldName()); + myVectorialFieldCombo->setCurrentIndex(myVectorialFieldCombo->count()-1); + } + } + } + hasInit = true; // init table myCutPlanes = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); @@ -220,19 +270,76 @@ void VisuGUI_CutPlanesPane::initFromPrsObject (VISU::CutPlanes_i* thePrs) } } +void VisuGUI_CutPlanesPane::InitEntity2VectorialFieldsMap(VISU::ColoredPrs3d_i* thePrs){ + + VISU::Result_var theResult = thePrs->GetResultObject(); + VISU::Result_i* aResult = dynamic_cast(GetServant(theResult).in()); + VISU::Result::Entities_var aEntities = aResult->GetEntities(thePrs->GetMeshName()); + VISU::Result::TimeStampNumbers_var aScalarTimeStamp = aResult->GetTimeStampNumbers(thePrs->GetMeshName(), + thePrs->GetEntity(), + thePrs->GetFieldName()); + CORBA::Long aTimeStampNumber = aScalarTimeStamp->length(); + + for(size_t iEntity = 0; iEntity < aEntities->length(); iEntity++){ + VISU::Entity aEntity = aEntities[iEntity]; + VISU::Result::EntityNames_var aFields = aResult->GetFields(thePrs->GetMeshName(),aEntity); + for(size_t iField = 0; iField < aFields->length(); iField++){ + + TVectorialFieldsList aVectorialFields; + VISU::Result::TimeStampNumbers_var aTimeStamps = aResult->GetTimeStampNumbers(thePrs->GetMeshName(),aEntity,aFields[iField] ); + + if((aResult->GetNumberOfComponents(thePrs->GetMeshName(),aEntity,aFields[iField] ) > 1) && + (aTimeStamps->length() >= aTimeStampNumber)){ + aVectorialFields.push_back(QString(aFields[iField].in())); + } + if(aVectorialFields.size() > 0){ + myEntity2VectorialFields.insert(TEntVectPair(aEntity,aVectorialFields)); + } + } + } +} + +void VisuGUI_CutPlanesPane::InsertAllVectorialFields(){ + TEntity2VectorialFields::const_iterator aFieldIter = myEntity2VectorialFields.begin(); + for( ;aFieldIter != myEntity2VectorialFields.end();aFieldIter++ ){ + TVectorialFieldsList aVectorialFields = aFieldIter->second; + for(size_t iField = 0;iField < aVectorialFields.size(); iField++) + myVectorialFieldCombo->addItem(aVectorialFields[iField]); + } +} + +double VisuGUI_CutPlanesPane::getScaleFactor(){ + return myScaleSpn->value(); +} + +void VisuGUI_CutPlanesPane::setScaleFactor(double theFactor){ + double i=0.1; + while (1) { // Calculate Step & Precission + if ( int (theFactor/i) >= 0) + break; + else { + i = i*0.1; + } + } + + myScaleSpn->setSingleStep(i); + myScaleSpn->setValue(theFactor); + +} + void VisuGUI_CutPlanesPane::createPlanes() { if (VISU::GetActiveViewWindow() == NULL) return; if (!myCutPlanes) return; if (myPreviewActor != 0) return; - vtkAppendPolyData* aPolyData = myCutPlanes->GetSpecificPL()->GetAppendPolyData(); - if (!aPolyData->GetOutput()->GetNumberOfCells()) { + vtkDataSet* aDataSet = myCutPlanes->GetSpecificPL()->GetWarpVectorOutput(); + if (!aDataSet->GetNumberOfCells()) { onPreviewCheck(false); return; } vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New(); - aPlaneMapper->SetInput(aPolyData->GetOutput()); + aPlaneMapper->SetInput(aDataSet); aPlaneMapper->ScalarVisibilityOff(); myPreviewActor = SALOME_Actor::New(); @@ -256,6 +363,31 @@ int VisuGUI_CutPlanesPane::storeToPrsObject (VISU::CutPlanes_i* thePrs) else thePrs->SetDefault(i); } + + thePrs->UseDeformation(GDeformation->isChecked()); + + if(GDeformation->isChecked()){ + TEntity2VectorialFields::const_iterator anIter = myEntity2VectorialFields.begin(); + VISU::Entity anEntity; + QString aFieldName; + bool isInited = false; + for(;anIter != myEntity2VectorialFields.end();anIter++){ + TVectorialFieldsList aFields = anIter->second; + for(int it = 0;it < aFields.size();it++) + if(!QString::compare(aFields[it], myVectorialFieldCombo->currentText ())){ + anEntity = anIter->first; + aFieldName = aFields[it]; + isInited = true; + break; + } + if(isInited) + break; + } + if(isInited) + thePrs->SetVectorialField(anEntity,aFieldName.toLatin1().constData()); + + thePrs->SetScale(myScaleSpn->value()); + } return 1; } @@ -324,6 +456,45 @@ void VisuGUI_CutPlanesPane::setRotation (const double r1, const double r2) Rot2->setValue( r2 ); } +void VisuGUI_CutPlanesPane::onScaleFactorChanged(double theFactor){ + DrawTable(); +} + +void VisuGUI_CutPlanesPane::onVectorialFieldChanged(int pos){ + InitVectorialField(); + DrawTable(); +} + +void VisuGUI_CutPlanesPane::onDeformationCheck(bool Flag){ + if(!myCutPlanes || !hasInit) return; + myCutPlanes->UseDeformation(Flag); + InitVectorialField(); + DrawTable(); +} + +void VisuGUI_CutPlanesPane::InitVectorialField(){ + if(myCutPlanes->IsDeformed()){ + TEntity2VectorialFields::const_iterator anIter = myEntity2VectorialFields.begin(); + VISU::Entity anEntity; + QString aFieldName; + bool isInited = false; + for(;anIter != myEntity2VectorialFields.end();anIter++){ + TVectorialFieldsList aFields = anIter->second; + for(int it = 0;it < aFields.size();it++) + if(!QString::compare(aFields[it], myVectorialFieldCombo->currentText ())){ + anEntity = anIter->first; + aFieldName = aFields[it]; + isInited = true; + break; + } + if(isInited) + break; + } + if(isInited) + myCutPlanes->SetVectorialField(anEntity,aFieldName.toLatin1().constData()); + } +} + /*! Draw the table of planes positions */ @@ -338,6 +509,7 @@ void VisuGUI_CutPlanesPane::DrawTable() myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.); myCutPlanes->SetNbPlanes(aNbPlanes); myCutPlanes->SetDisplacement(myPosSpn->value()); + myCutPlanes->SetScale(getScaleFactor()); if (aNbRows>0) for (int i = 0; i < aNbRows; ++i) { QTableWidgetItem* aItem = myPosTable->item( i, 1 ); @@ -571,7 +743,9 @@ void VisuGUI_CutPlanesPane::onPreviewCheck (bool thePreview) storeToPrsObject(myCutPlanes); myCutPlanes->GetPipeLine()->Update(); createPlanes(); - vf->onFitAll(); + if(VISU::GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)) { + vf->onFitAll(); + } } else { deletePlanes(); vf->Repaint(); diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.h b/src/VISUGUI/VisuGUI_CutPlanesDlg.h index 064a457d..a3b0b7e5 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.h +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.h @@ -42,15 +42,18 @@ class QRadioButton; class QTabWidget; class QTableWidget; class QCheckBox; - - +class QComboBox; #include "SALOMEconfig.h" #include CORBA_CLIENT_HEADER(VISU_Gen) +#include +#include + namespace VISU { class CutPlanes_i; + class Result_i; }; class SUIT_ViewWindow; @@ -74,15 +77,28 @@ public: double getRotation1() {return Rot1->value();} double getRotation2() {return Rot2->value();} - void initFromPrsObject(VISU::CutPlanes_i* thePrs); - int storeToPrsObject(VISU::CutPlanes_i* thePrs); + double getScaleFactor(); + void setScaleFactor(double factor); + + void initFromPrsObject(VISU::CutPlanes_i* thePrs); + int storeToPrsObject(VISU::CutPlanes_i* thePrs); private: + typedef std::vector TVectorialFieldsList; + typedef std::map TEntity2VectorialFields; + typedef std::pair TEntVectPair; + TEntity2VectorialFields myEntity2VectorialFields; + void createPlanes(); void deletePlanes(); + void InitEntity2VectorialFieldsMap(VISU::ColoredPrs3d_i* thePrs); + void InsertAllVectorialFields(); + void InitVectorialField(); + QLabel* LabelRot1; QLabel* LabelRot2; + QGroupBox* GDeformation; QSpinBox* nbPlan; QtxDoubleSpinBox* Rot1; QtxDoubleSpinBox* Rot2; @@ -93,6 +109,8 @@ private: QTableWidget* myPosTable; SALOME::GenericObjPtr myCutPlanes; QCheckBox* myPreviewCheck; + QComboBox* myVectorialFieldCombo; + QtxDoubleSpinBox* myScaleSpn; double X1, X2; double Y1, Y2; double Z1, Z2; @@ -107,6 +125,9 @@ private slots: void onValueChanged(int theRow, int theCol); void onRotation(double theValue); void onPreviewCheck(bool thePreview); + void onScaleFactorChanged(double); + void onDeformationCheck(bool); + void onVectorialFieldChanged(int); }; diff --git a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx new file mode 100644 index 00000000..67c3871d --- /dev/null +++ b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx @@ -0,0 +1,495 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VisuGUI_DeformedShapeAndScalarMapDlg.cxx +// Author : Eugeny Nikolaev +// Module : VISU + +#include "VisuGUI_DeformedShapeAndScalarMapDlg.h" + +#include "VisuGUI_Tools.h" +#include "VisuGUI_InputPane.h" + +#include "VISU_Result_i.hh" +#include "VISU_DeformedShapeAndScalarMap_i.hh" +#include "VISU_ColoredPrs3dFactory.hh" + +#include "VISU_ScalarMapPL.hxx" +#include "VISU_DeformedShapeAndScalarMapPL.hxx" + +#include "VISU_Convertor.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define MYDEBUG 0 + +/*! + * Constructor + */ +VisuGUI_DeformedShapeAndScalarMapDlg::VisuGUI_DeformedShapeAndScalarMapDlg (SalomeApp_Module* theModule) + : VisuGUI_ScalarBarBaseDlg(theModule), + myIsAnimation(false), + myUpdateScalars(true), + myVisuGUI(theModule) +{ + setWindowTitle(tr("DLG_TITLE")); + setSizeGripEnabled(true); + + QVBoxLayout* TopLayout = new QVBoxLayout (this); + TopLayout->setSpacing(6); + TopLayout->setMargin(11); + + myTabBox = new QTabWidget (this); + + // Scalar Map on Deformed shape pane + QWidget* aBox = new QWidget (this); + QVBoxLayout* aVBLay = new QVBoxLayout( aBox ); + aVBLay->setMargin(11); + QFrame* TopGroup = new QFrame (aBox); + aVBLay->addWidget(TopGroup); + TopGroup->setFrameStyle(QFrame::Box | QFrame::Sunken); + TopGroup->setLineWidth(1); + QGridLayout* TopGroupLayout = new QGridLayout (TopGroup); + TopGroupLayout->setSpacing(6); + TopGroupLayout->setMargin(11); + + // Scale factor + QLabel* ScaleLabel = new QLabel (tr("SCALE_FACTOR"), TopGroup); + TopGroupLayout->addWidget(ScaleLabel, 0, 0); + + ScalFact = new QtxDoubleSpinBox (0.0, 1.0E+38, 0.1, TopGroup); + ScalFact->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 ); + + ScalFact->setDecimals( aPrecision*(-1) ); + ScalFact->setValue(0.1); + TopGroupLayout->addWidget(ScalFact, 0, 1); + + // Fields combo box + QLabel* FieldLabel = new QLabel (tr("FIELD_ITEM"), TopGroup); + myFieldsCombo = new QComboBox (TopGroup); + + TopGroupLayout->addWidget(FieldLabel, 1, 0); + TopGroupLayout->addWidget(myFieldsCombo,1,1); + + // TimeStamps combo box + QLabel* TimeStampLabel = new QLabel (tr("TIMESTAMP_ITEM"), TopGroup); + myTimeStampsCombo = new QComboBox (TopGroup); + + TopGroupLayout->addWidget(TimeStampLabel, 2, 0); + TopGroupLayout->addWidget(myTimeStampsCombo,2,1); + TopGroupLayout->setRowStretch(3,5); + + // + myTabBox->addTab(aBox, tr("DEFORMED_SHAPE_AND_SCALAR_MAP_TAB")); + + // Scalar bar pane + myInputPane = new VisuGUI_InputPane(VISU::TDEFORMEDSHAPEANDSCALARMAP, theModule, this); + + myTabBox->addTab(GetScalarPane(), tr("SCALAR_BAR_TAB")); + myTabBox->addTab(myInputPane, tr("INPUT_TAB")); + + // Buttons + QGroupBox* GroupButtons = new QGroupBox (this); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + + QPushButton* buttonOk = new QPushButton (tr("&OK"), GroupButtons); + buttonOk->setAutoDefault(true); + buttonOk->setDefault(true); + QPushButton* buttonCancel = new QPushButton (tr("&Cancel") , GroupButtons); + buttonCancel->setAutoDefault(true); + QPushButton* buttonHelp = new QPushButton (tr("&Help") , GroupButtons); + buttonHelp->setAutoDefault(true); + + GroupButtonsLayout->addWidget(buttonOk); + GroupButtonsLayout->addSpacing(10); + GroupButtonsLayout->addStretch(); + GroupButtonsLayout->addWidget(buttonCancel); + GroupButtonsLayout->addWidget(buttonHelp); + + // Add Tab box and Buttons to the top layout + TopLayout->addWidget(myTabBox); + TopLayout->addWidget(GroupButtons); + + // signals and slots connections + connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); + connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())); + connect(myFieldsCombo, SIGNAL(activated(int)), this, SLOT(onFieldChanged(int))); + connect(myTimeStampsCombo, SIGNAL(activated(int)), this, SLOT(onTimeStampChanged(int))); +} + +VisuGUI_DeformedShapeAndScalarMapDlg::~VisuGUI_DeformedShapeAndScalarMapDlg() +{ +} + +void VisuGUI_DeformedShapeAndScalarMapDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, + bool theInit ) +{ + if( theInit ) + myPrsCopy = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); + setFactor(myPrsCopy->GetScale()); + myTimeStampsCombo->setDisabled(myIsAnimation); + + CORBA::String_var aFieldName(myPrsCopy->GetScalarFieldName()); + QString aIteration = GetFloatValueOfTimeStamp(myPrsCopy->GetScalarEntity(), + aFieldName.in(), + myPrsCopy->GetScalarTimeStampNumber()); + if (myEntity2Fields.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()); + VISU::VISUType aType = VISU::Storable::SObject2Type( aSObject ); + switch(aType){ + case VISU::TTIMESTAMP: { + aSObject = aSObject->GetFather(); + aSObject = aSObject->GetFather(); + break; + } + case VISU::TFIELD: { + _PTR(SObject) newSObject; + if(aSObject->ReferencedObject(newSObject)) aSObject = newSObject; + aSObject = aSObject->GetFather(); + break; + } + case VISU::TANIMATION: { + _PTR(ChildIterator) aTmpIter = aActiveStudy->NewChildIterator(aSObject); + for (aTmpIter->InitEx(true); aTmpIter->More(); aTmpIter->Next()) { + _PTR(SObject) aTmpChildSObj = aTmpIter->Value(); + _PTR(SObject) newSObject; + if(aTmpChildSObj->ReferencedObject(newSObject)){ + aSObject = newSObject; + aSObject->GetFather(); + break; + } + } + break; + }} + + aSObject = aSObject->GetFather(); + aSObject = aSObject->GetFather(); + + mySelectionObj = aSObject; + CORBA::Object_var anObject = VISU::ClientSObjectToObject(mySelectionObj); + if (CORBA::is_nil(anObject)) { + mySelectionObj = mySelectionObj->GetFather(); + } + } + } + + if (mySelectionObj) { + _PTR(ChildIterator) aIter = aActiveStudy->NewChildIterator(mySelectionObj); + + for (aIter->InitEx(true); aIter->More(); aIter->Next()) { + _PTR(SObject) aChildSObj = aIter->Value(); + VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aChildSObj); + if (!aRestoringMap.empty()) { + VISU::VISUType aType = VISU::Storable::RestoringMap2Type(aRestoringMap); + if (aType == VISU::TTIMESTAMP) { + QString aMeshName = aRestoringMap["myMeshName"]; + CORBA::String_var aName = myPrsCopy->GetMeshName(); + if (aMeshName != aName.in()) + continue; + QString aFieldName = aRestoringMap["myFieldName"]; + QString aTimeIter = aRestoringMap["myTimeStampId"]; + QString aEntity = aRestoringMap["myEntityId"]; + VISU::Entity anEntity; + switch (aEntity.toInt()) { + case 0: anEntity = VISU::NODE; break; + case 1: anEntity = VISU::EDGE; break; + case 2: anEntity = VISU::FACE; break; + case 3: anEntity = VISU::CELL; break; + } + TFieldName2TimeStamps& aFieldName2TimeStamps = myEntity2Fields[anEntity]; + TTimeStampNumber2Time& aTimeStampNumber2Time = aFieldName2TimeStamps[aFieldName]; + aTimeStampNumber2Time[aTimeIter.toInt()] = + GetFloatValueOfTimeStamp(anEntity, + aFieldName.toLatin1().constData(), + aTimeIter.toInt()); + } + } + } + } + AddAllFieldNames(); + } + int idx = myFieldsCombo->findText(aFieldName.in()); + if (idx >= 0) + myFieldsCombo->setCurrentIndex(idx); + else { + myFieldsCombo->addItem(aFieldName.in()); + myFieldsCombo->setCurrentIndex(myFieldsCombo->count()-1); + } + AddAllTimes(myFieldsCombo->currentText()); + idx = myTimeStampsCombo->findText(aIteration); + if (idx >= 0) + myTimeStampsCombo->setCurrentIndex(idx); + else { + myTimeStampsCombo->addItem(aIteration); + myTimeStampsCombo->setCurrentIndex(myTimeStampsCombo->count()-1); + } + SetScalarField( false ); + + VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit); + + if( !theInit ) + return; + + myInputPane->initFromPrsObject( myPrsCopy ); + myTabBox->setCurrentIndex( 0 ); +} + +double VisuGUI_DeformedShapeAndScalarMapDlg::getFactor() const +{ + return ScalFact->value(); +} + +void VisuGUI_DeformedShapeAndScalarMapDlg::setFactor(double theFactor) +{ + double i=0.1; + while (1) { // Calculate Step & Precission + if ( int (theFactor/i) > 0) + break; + else { + i = i*0.1; + } + } + + ScalFact->setSingleStep(i); + + ScalFact->setValue(theFactor); +} + +int +VisuGUI_DeformedShapeAndScalarMapDlg +::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) +{ + if(!myInputPane->check() || !GetScalarPane()->check()) + return 0; + + int anIsOk = myInputPane->storeToPrsObject( myPrsCopy ); + anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy ); + + myPrsCopy->SetScale(getFactor()); + + myPrsCopy->SetScalarField(myPrsCopy->GetScalarEntity(), + getCurrentScalarFieldName().toLatin1().constData(), + myTimeStampID[ myTimeStampsCombo->currentIndex() ]); + + if(myUpdateScalars) + SetScalarField( false ); + + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); + + return anIsOk; +} + +int VisuGUI_DeformedShapeAndScalarMapDlg::getCurrentScalarFieldNamePos(){ + return myFieldsCombo->currentIndex(); +} + +QString VisuGUI_DeformedShapeAndScalarMapDlg::getCurrentScalarFieldName(){ + return myFieldsCombo->currentText(); +} + +int VisuGUI_DeformedShapeAndScalarMapDlg::getCurrentScalarNbIterations(){ + return myTimeStampsCombo->count(); +} + +VISU::Entity +VisuGUI_DeformedShapeAndScalarMapDlg +::getCurrentScalarEntity() +{ + VISU::Entity anEntity = VISU::Entity(-1); + TEntity2Fields::const_iterator anIter = myEntity2Fields.begin(); + for(; anIter != myEntity2Fields.end(); anIter++){ + const TFieldName2TimeStamps& aFieldName2TimeStamps = anIter->second; + TFieldName2TimeStamps::const_iterator aFieldIter = aFieldName2TimeStamps.begin(); + for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){ + const QString& aFieldName = aFieldIter->first; + if (aFieldName == myFieldsCombo->currentText()) { + anEntity = anIter->first; + break; + } + } + } + return anEntity; +} + +void VisuGUI_DeformedShapeAndScalarMapDlg::SetScalarField( const bool save_scalar_pane ){ + SetScalarField( myTimeStampID[ myTimeStampsCombo->currentIndex() ], "", save_scalar_pane ); +} + +void +VisuGUI_DeformedShapeAndScalarMapDlg +::SetScalarField(int theIter, + QString theFieldName, + const bool save_scalar_pane ) +{ + QApplication::setOverrideCursor(Qt::WaitCursor); + + if( save_scalar_pane ) + GetScalarPane()->storeToPrsObject(myPrsCopy); + + QString aFieldName; + + if(theFieldName.isEmpty()) + aFieldName = myFieldsCombo->currentText(); + else + aFieldName = theFieldName; + + VISU::Entity anEntity = getCurrentScalarEntity(); + + myPrsCopy->SetScalarField(anEntity, + aFieldName.toLatin1().constData(), + theIter); + + if( save_scalar_pane ) + UpdateScalarField(); + + QApplication::restoreOverrideCursor(); +} + +void VisuGUI_DeformedShapeAndScalarMapDlg::accept() +{ + VisuGUI_ScalarBarBaseDlg::accept(); +} + +void VisuGUI_DeformedShapeAndScalarMapDlg::reject() +{ + VisuGUI_ScalarBarBaseDlg::reject(); +} + +QString VisuGUI_DeformedShapeAndScalarMapDlg::GetContextHelpFilePath() +{ + return "scalar_map_on_deformed_shape_page.html"; +} + +void VisuGUI_DeformedShapeAndScalarMapDlg::AddAllFieldNames(){ + TEntity2Fields::const_iterator anIter = myEntity2Fields.begin(); + for(; anIter != myEntity2Fields.end(); anIter++){ + const TFieldName2TimeStamps& aFieldName2TimeStamps = anIter->second; + TFieldName2TimeStamps::const_iterator aFieldIter = aFieldName2TimeStamps.begin(); + for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){ + const QString& aFieldName = aFieldIter->first; + myFieldsCombo->addItem(aFieldName); + } + } +} + +void VisuGUI_DeformedShapeAndScalarMapDlg::AddAllTimes(const QString& theFieldName){ + TEntity2Fields::const_iterator anIter = myEntity2Fields.begin(); + for(; anIter != myEntity2Fields.end(); anIter++){ + const TFieldName2TimeStamps& aFieldName2TimeStamps = anIter->second; + TFieldName2TimeStamps::const_iterator aFieldIter = aFieldName2TimeStamps.begin(); + for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){ + const QString& aFieldName = aFieldIter->first; + if(theFieldName != aFieldName) + continue; + + myTimeStampID.clear(); + myTimeStampsCombo->clear(); + + const TTimeStampNumber2Time& aTimeStampNumber2Time = aFieldIter->second; + TTimeStampNumber2Time::const_iterator aTimeStampIter = aTimeStampNumber2Time.begin(); + for(; aTimeStampIter != aTimeStampNumber2Time.end(); aTimeStampIter++){ + int aTimeStampNumber = aTimeStampIter->first; + myTimeStampID.push_back(aTimeStampNumber); + + QString aTimeStampTime = aTimeStampIter->second; + myTimeStampsCombo->addItem(aTimeStampTime); + } + return; + } + } +} + +void VisuGUI_DeformedShapeAndScalarMapDlg::onFieldChanged(int){ + AddAllTimes(myFieldsCombo->currentText()); + SetScalarField(); + UpdateScalarField(); +} + +void VisuGUI_DeformedShapeAndScalarMapDlg::onTimeStampChanged(int){ + SetScalarField(); + UpdateScalarField(); +} + +void VisuGUI_DeformedShapeAndScalarMapDlg::UpdateScalarField(){ + GetScalarPane()->initFromPrsObject(myPrsCopy); +} + +QString +VisuGUI_DeformedShapeAndScalarMapDlg +::GetFloatValueOfTimeStamp(VISU::Entity theEntity, + const std::string& theFieldName, + int theTimeStampNumber) +{ + QString aTime(""); + VISU::TEntity anEntity = VISU::TEntity(theEntity); + VISU::Result_i* theResult = myPrsCopy->GetCResult(); + VISU::Result_i::PInput anInput = theResult->GetInput(); + VISU::PField aField = anInput->GetField(myPrsCopy->GetCMeshName(), + anEntity, + theFieldName); + if(!aField) + return aTime; + + VISU::TValField& aValField = aField->myValField; + VISU::TValField::const_iterator aIter = aValField.find(theTimeStampNumber); + if(aIter != aValField.end()){ + VISU::PValForTime aValForTime = aIter->second; + aTime = VISU_Convertor::GenerateName(aValForTime->myTime).c_str(); + } + return aTime; +} diff --git a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.h b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.h new file mode 100644 index 00000000..9daf4a58 --- /dev/null +++ b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.h @@ -0,0 +1,116 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VisuGUI_DeformedShapeAndScalarMapDlg.h +// Author : Eugeny Nikolaev +// Module : VISU + +#ifndef VISUGUI_DEFORMEDSHAPEANDSCALARMAPDLS_H +#define VISUGUI_DEFORMEDSHAPEANDSCALARMAPDLS_H + +#include "VisuGUI_Prs3dDlg.h" + +#include "VISUConfig.hh" + +#include + +#include +#include + +class SalomeApp_Module; +class VisuGUI_InputPane; +class QtxDoubleSpinBox; +class QComboBox; +class QTabWidget; + +namespace VISU +{ + class DeformedShapeAndScalarMap_i; +} + +class VisuGUI_DeformedShapeAndScalarMapDlg : public VisuGUI_ScalarBarBaseDlg +{ + Q_OBJECT + +public: + VisuGUI_DeformedShapeAndScalarMapDlg (SalomeApp_Module* theModule); + ~VisuGUI_DeformedShapeAndScalarMapDlg(); + + double getFactor() const; + void setFactor(double theFactor); + + virtual void initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, + bool theInit ); + + virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); + + int getCurrentScalarFieldNamePos(); + QString getCurrentScalarFieldName(); + int getCurrentScalarNbIterations(); + VISU::Entity getCurrentScalarEntity(); + void SetScalarField(int theIter,QString theFieldName=QString(""), const bool = true ); + +protected: + virtual QString GetContextHelpFilePath(); + +protected slots: + void accept(); + void reject(); + +private slots: + void onFieldChanged(int i=0); + void onTimeStampChanged(int i=0); + +private: + QtxDoubleSpinBox* ScalFact; + QTabWidget* myTabBox; + VisuGUI_ScalarBarPane* myScalarPane; + VisuGUI_InputPane* myInputPane; + QComboBox *myFieldsCombo; + QComboBox *myTimeStampsCombo; + + typedef std::map TTimeStampNumber2Time; // Times map definition (iteration time, real value of time) + typedef std::map TFieldName2TimeStamps; // Field name and enity to Times + typedef std::map TEntity2Fields; // Mesh to fields map + + TEntity2Fields myEntity2Fields; + int myCurrScalarIter; + bool myIsAnimation; + bool myUpdateScalars; + std::vector myTimeStampID; + + _PTR(SObject) mySelectionObj; + SALOME::GenericObjPtr myPrsCopy; + SalomeApp_Module* myVisuGUI; + +protected: + void UpdateScalarField(); + void SetScalarField( const bool = true ); + void AddAllFieldNames(); + void AddAllTimes(const QString& theFieldName); + QString GetFloatValueOfTimeStamp(VISU::Entity theEntity, + const std::string& theFieldName, + int theTimeStampNumber); +}; + +#endif // VISUGUI_DEFORMEDSHAPEDLS_H diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx index e9b26850..6e677fc8 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx @@ -91,7 +91,11 @@ VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule) ScalFact = new QtxDoubleSpinBox (0.0, 1.0E+38, 0.1, TopGroup); ScalFact->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - ScalFact->setDecimals(38); + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 ); + + ScalFact->setDecimals( aPrecision*(-1) ); // ScalFact->setDecimals(38); ScalFact->setValue(0.1); TopGroupLayout->addWidget(ScalFact, 0, 1); @@ -119,7 +123,7 @@ VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule) GroupButtonsLayout->setSpacing(6); GroupButtonsLayout->setMargin(11); - QPushButton* buttonOk = new QPushButton (tr("BUT_OK"), GroupButtons); + QPushButton* buttonOk = new QPushButton (tr("A&pply and Close"), GroupButtons); buttonOk->setAutoDefault(TRUE); buttonOk->setDefault(TRUE); GroupButtonsLayout->addWidget(buttonOk, 0, 0); @@ -169,6 +173,22 @@ void VisuGUI_DeformedShapeDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, myTabBox->setCurrentIndex(0); } +void VisuGUI_DeformedShapeDlg::setFactor(double theFactor) +{ + double i=0.1; + while (1) { // Calculate Step & Precission + if ( int (theFactor/i) > 0) + break; + else { + i = i*0.1; + } + } + + ScalFact->setSingleStep(i); + + ScalFact->setValue(theFactor); +} + int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { if( !isValid() ) @@ -191,7 +211,8 @@ void VisuGUI_DeformedShapeDlg::updatePrsCopy() VisuGUI* aVisuGUI = dynamic_cast (myModule); if ( myPrsCopy->GetNumberOfActors() == 0 ) { PublishInView(aVisuGUI, myPrsCopy, aViewWindow); - aViewWindow->onFitAll(); + if(VISU::GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)) + aViewWindow->onFitAll(); int aPos = VISU::GetFreePositionOfDefaultScalarBar(aVisuGUI, aViewWindow); VISU::AddScalarBarPosition(aVisuGUI, aViewWindow, myPrsCopy, aPos); } else { @@ -270,26 +291,29 @@ void VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule) aFieldName.toLatin1().data(), aTimeStampId.toInt(), aPublishInStudyMode); - - VisuGUI_DeformedShapeDlg* aDlg = new VisuGUI_DeformedShapeDlg (theModule); - aDlg->initFromPrsObject(aPrs3d, true); - aDlg->UseMagn->setChecked(true); - VisuGUI_DialogRunner r(aDlg); - int dlgResult = r.run( false ); - - if ( dlgResult == 0 ) - aPrs3d->RemoveFromStudy(); - else { - aDlg->storeToPrsObject( aPrs3d ); - SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(); - PublishInView(theModule, aPrs3d, aViewWindow); - aViewWindow->onFitAll(); - int aPos = VISU::GetFreePositionOfDefaultScalarBar(theModule, aViewWindow); - VISU::AddScalarBarPosition(theModule, aViewWindow, aPrs3d, aPos); + + if (aPrs3d) { + VisuGUI_DeformedShapeDlg* aDlg = new VisuGUI_DeformedShapeDlg (theModule); + aDlg->initFromPrsObject(aPrs3d, true); + aDlg->UseMagn->setChecked(true); + VisuGUI_DialogRunner r(aDlg); + int dlgResult = r.run( false ); + + if ( dlgResult == 0 ) + DeletePrs3d(theModule,aPrs3d); + else { + aDlg->storeToPrsObject( aPrs3d ); + SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(); + PublishInView(theModule, aPrs3d, aViewWindow); + if(VISU::GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)) + aViewWindow->onFitAll(); + int aPos = VISU::GetFreePositionOfDefaultScalarBar(theModule, aViewWindow); + VISU::AddScalarBarPosition(theModule, aViewWindow, aPrs3d, aPos); + } + + VISU::UpdateObjBrowser(theModule, true, aTimeStamp); + delete aDlg; } - - VISU::UpdateObjBrowser(theModule, true, aTimeStamp); - delete aDlg; } } } diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.h b/src/VISUGUI/VisuGUI_DeformedShapeDlg.h index 099fc006..1449af50 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.h +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.h @@ -60,8 +60,7 @@ public: double getFactor() { return ScalFact->value(); } - void setFactor(double theFactor) - { ScalFact->setValue(theFactor); } + void setFactor(double theFactor); bool isColored() { return UseMagn->isChecked(); } diff --git a/src/VISUGUI/VisuGUI_Displayer.cxx b/src/VISUGUI/VisuGUI_Displayer.cxx index 7b8daf94..62e7f6c7 100644 --- a/src/VISUGUI/VisuGUI_Displayer.cxx +++ b/src/VISUGUI/VisuGUI_Displayer.cxx @@ -94,11 +94,19 @@ SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& theEntry, SALOM aPrs3d = dynamic_cast(VISU::GetServant(aColoredPrs3d).in()); }else if (aType == VISU::TPOINTMAP3D) { VISU::PointMap3d_i* aTable3d = dynamic_cast(aBaseServant); - VISU_PointMap3dActor* aPointMap3dActor = aTable3d->CreateActor(); - if (aPointMap3dActor) { - aViewWindow->AddActor(aPointMap3dActor); + VISU_ActorBase* anActorBase = VISU::FindActorBase(aViewWindow, aTable3d); + if (anActorBase) { + anActorBase->SetVisibility(true); aViewWindow->Repaint(); } + else { + VISU_PointMap3dActor* aPointMap3dActor = aTable3d->CreateActor(); + if (aPointMap3dActor) { + aViewWindow->AddActor(aPointMap3dActor); + aPointMap3dActor->SetVisibility(true); + aViewWindow->Repaint(); + } + } } else aPrs3d = dynamic_cast(aBaseServant); @@ -283,6 +291,9 @@ bool VisuGUI_Displayer::canBeDisplayed( const QString& entry, const QString& vie if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER) return true; + if(aBase->GetType() == VISU::TPOINTMAP3D) + return dynamic_cast(aBase); + return dynamic_cast(aBase); } else if( viewer_type==SPlot2d_Viewer::Type() ) diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index c8fa4f7e..14826a2f 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -43,6 +43,7 @@ #include "LightApp_Application.h" #include "SalomeApp_Module.h" +#include "LightApp_SelectionMgr.h" #include "SUIT_Desktop.h" #include "SUIT_ResourceMgr.h" #include "SUIT_Session.h" @@ -551,7 +552,7 @@ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs, myTextDlg->setTitleText(QString(thePrs->GetTitle())); vtkFloatingPointType R, G, B; - thePrs->GetTitleColor(&R, &G, &B); + thePrs->GetTitleColor(R, G, B); myBarDlg->setLabelsFormat(thePrs->GetLabelsFormat()); myBarDlg->setUnitsVisible(thePrs->IsUnitsVisible()); @@ -563,7 +564,7 @@ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs, thePrs->IsShadowTitle()); // "Labels" - thePrs->GetLabelColor(&R, &G, &B); + thePrs->GetLabelColor(R, G, B); myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), thePrs->GetLblFontType(), @@ -772,6 +773,7 @@ void VisuGUI_GaussScalarBarPane::onBarPref() * Constructor */ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule): + myModule(theModule), VisuGUI_Prs3dDlg(theModule) { //setName("VisuGUI_GaussPointsDlg"); @@ -844,6 +846,7 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule): // Input pane myInputPane = new VisuGUI_InputPane(VISU::TGAUSSPOINTS, theModule, this); + myInputPane->SetRestoreInitialSelection(false); connect( myResultsButton, SIGNAL( clicked() ), mySizeBox, SLOT( onToggleResults() ) ); connect( myResultsButton, SIGNAL( toggled( bool ) ), myScalarPane, SLOT( setEnabled( bool ) ) ); @@ -979,8 +982,22 @@ int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) myPrsCopy->SetMagnification( mySizeBox->getMagnification() ); myPrsCopy->SetMagnificationIncrement( mySizeBox->getIncrement() ); - VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); - + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); + + //Set created Gauss points presentation selected, + //Issue 0019874(EDF 746 VISU: Picking alphanumeric Gauss) + if(thePrs){ + SALOME_ListIO aListIO; + LightApp_SelectionMgr* aSelectionMgr = VISU::GetSelectionMgr(myModule); + Handle(SALOME_InteractiveObject) anIO = thePrs->GetIO(); + if(anIO && anIO->hasEntry()) { + aListIO.Append(anIO); + VISU::UpdateObjBrowser(myModule,true); + aSelectionMgr->setSelectedObjects(aListIO); + } + else + myInputPane->SetRestoreInitialSelection(true); + } return anIsOk; } diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.h b/src/VISUGUI/VisuGUI_GaussPointsDlg.h index 756e2dec..e23b9a1e 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.h +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.h @@ -165,6 +165,7 @@ private: QtxDoubleSpinBox* myScaleSpinBox; SALOME::GenericObjPtr myPrsCopy; + SalomeApp_Module* myModule; }; #endif // VISUGUI_GAUSSPOINTSDLS_H diff --git a/src/VISUGUI/VisuGUI_InputPane.cxx b/src/VISUGUI/VisuGUI_InputPane.cxx index d1aafe52..21bab673 100644 --- a/src/VISUGUI/VisuGUI_InputPane.cxx +++ b/src/VISUGUI/VisuGUI_InputPane.cxx @@ -82,7 +82,8 @@ VisuGUI_InputPane::VisuGUI_InputPane( VISU::VISUType theType, QGroupBox( theDialog ), myModule( theModule ), myDialog( theDialog ), - myPrs( NULL ) + myPrs( NULL ), + isRestoreInitialSelection(true) { //setFrameStyle( QFrame::NoFrame ); @@ -243,9 +244,17 @@ VisuGUI_InputPane::~VisuGUI_InputPane() } // Restore initial selection - aSelectionMgr->setSelectedObjects(mySavedSelection); + if(isRestoreInitialSelection) + aSelectionMgr->setSelectedObjects(mySavedSelection); } +void VisuGUI_InputPane::SetRestoreInitialSelection(bool on){ + isRestoreInitialSelection = on; +} + +bool VisuGUI_InputPane::GetRestoreInitialSelection(){ + return isRestoreInitialSelection; +} //--------------------------------------------------------------- /*! diff --git a/src/VISUGUI/VisuGUI_InputPane.h b/src/VISUGUI/VisuGUI_InputPane.h index 9190dde8..408d257b 100644 --- a/src/VISUGUI/VisuGUI_InputPane.h +++ b/src/VISUGUI/VisuGUI_InputPane.h @@ -71,6 +71,8 @@ public: int storeToPrsObject( VISU::ColoredPrs3d_i* ); bool eventFilter (QObject* object, QEvent* event); + void SetRestoreInitialSelection(bool on); + bool GetRestoreInitialSelection(); public slots: virtual void onSelectionChanged(); @@ -104,6 +106,7 @@ private: VISU::Result_var myResult; int myEntity; + bool isRestoreInitialSelection; VisuGUI_FieldFilter* myFieldFilter; SALOME_ListIO mySavedSelection; diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx index f0ebd544..fe3d30ba 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx @@ -53,12 +53,10 @@ #include #include #include - - +#include using namespace std; - VisuGUI_IsoSurfPane::VisuGUI_IsoSurfPane (QWidget* parent, VisuGUI_ScalarBarPane* theScalarPane) : QWidget(parent), @@ -105,8 +103,32 @@ VisuGUI_IsoSurfPane::VisuGUI_IsoSurfPane (QWidget* parent, LabelMax->setBuddy(MaxIso); TopGroupLayout->addWidget( MaxIso, 2, 1 ); + myUseMagnitude = new QCheckBox(tr("MAGNITUDE_COLORING_CHK"), TopGroup); + myUseMagnitude->setChecked(true); + TopGroupLayout->addWidget( myUseMagnitude, 3, 0 ); + mySelColor = new QPushButton(tr("SEL_COLOR_BTN"), TopGroup); + QPalette pal = mySelColor->palette(); + pal.setColor(mySelColor->backgroundRole(), Qt::black); + pal.setColor(mySelColor->foregroundRole(), Qt::gray); + mySelColor->setPalette(pal); + mySelColor->setDisabled(true); + TopGroupLayout->addWidget( mySelColor, 3, 1 ); + connect( mySelColor, SIGNAL( clicked() ), this, SLOT( setColor() ) ); + connect( myUseMagnitude, SIGNAL( toggled(bool) ), mySelColor, SLOT( setDisabled(bool) ) ); + + myUseLabels = new QCheckBox(tr("SHOW_VALUES_CHK"), TopGroup); + myUseLabels->setChecked(false); + TopGroupLayout->addWidget( myUseLabels, 4, 0 ); + myNbLabels = new QSpinBox( TopGroup ); + myNbLabels->setMinimum(1); + myNbLabels->setMaximum(100); + myNbLabels->setSingleStep(1); + myNbLabels->setEnabled(false); + TopGroupLayout->addWidget( myNbLabels, 4, 1 ); + connect( myUseLabels, SIGNAL( toggled(bool) ), myNbLabels, SLOT( setEnabled(bool) ) ); + QPushButton* aUpdateBtn = new QPushButton( "Update scalar bar range with these values", TopGroup); - TopGroupLayout->addWidget( aUpdateBtn, 3, 0, 1, 2); + TopGroupLayout->addWidget( aUpdateBtn, 5, 0, 1, 2); connect( aUpdateBtn, SIGNAL( clicked() ), this, SLOT(onCBUpdate() ) ); } @@ -115,12 +137,29 @@ void VisuGUI_IsoSurfPane::initFromPrsObject (VISU::IsoSurfaces_i* thePrs) NbrIso->setValue(thePrs->GetNbSurfaces()); MinIso->setText(QString::number(thePrs->GetSubMin())); MaxIso->setText(QString::number(thePrs->GetSubMax())); + myUseMagnitude->setChecked(thePrs->IsColored()); + SALOMEDS::Color anOldColor = thePrs->GetColor(); + QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B)); + setColor(aColor); + + myUseLabels->setChecked(thePrs->IsLabeled()); + myNbLabels->setValue(thePrs->GetNbLabels()); } int VisuGUI_IsoSurfPane::storeToPrsObject (VISU::IsoSurfaces_i* thePrs) { thePrs->SetNbSurfaces(NbrIso->value()); thePrs->SetSubRange(MinIso->text().toDouble(), MaxIso->text().toDouble()); + thePrs->ShowLabels(myUseLabels->isChecked(), myNbLabels->value()); + thePrs->ShowColored(myUseMagnitude->isChecked()); + if(!thePrs->IsColored()){ + QColor aQColor = color(); + SALOMEDS::Color aColor; + aColor.R = aQColor.red()/255.; + aColor.G = aQColor.green()/255.; + aColor.B = aQColor.blue()/255.; + thePrs->SetColor(aColor); + } return 1; } @@ -141,8 +180,24 @@ bool VisuGUI_IsoSurfPane::check() return true; } +void VisuGUI_IsoSurfPane::setColor() +{ + QColor cnew = QColorDialog::getColor( color(), this ); + if ( cnew.isValid() ) + setColor(cnew); +} +void VisuGUI_IsoSurfPane::setColor(const QColor& theColor) +{ + QPalette pal = mySelColor->palette(); + pal.setColor(mySelColor->backgroundRole(), theColor); + mySelColor->setPalette(pal); +} +QColor VisuGUI_IsoSurfPane::color() const +{ + return mySelColor->palette().color(mySelColor->backgroundRole()); +} /*! diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h index 94dc47e3..4410e819 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h @@ -47,7 +47,7 @@ class VisuGUI_IsoSurfPane : public QWidget { Q_OBJECT; - public: +public: VisuGUI_IsoSurfPane (QWidget* parent, VisuGUI_ScalarBarPane* theScalarPane); ~VisuGUI_IsoSurfPane() {}; @@ -57,13 +57,21 @@ class VisuGUI_IsoSurfPane : public QWidget bool check(); - protected slots: - void onCBUpdate(); + void setColor(const QColor& theColor); + QColor color() const; - private: - QLineEdit* MinIso; - QLineEdit* MaxIso; - QSpinBox* NbrIso; +protected slots: + void onCBUpdate(); + void setColor(); + +private: + QLineEdit* MinIso; + QLineEdit* MaxIso; + QSpinBox* NbrIso; + QCheckBox* myUseMagnitude; + QPushButton* mySelColor; + QCheckBox* myUseLabels; + QSpinBox* myNbLabels; VisuGUI_ScalarBarPane* myScalarPane; }; @@ -72,7 +80,7 @@ class VisuGUI_IsoSurfacesDlg : public VisuGUI_ScalarBarBaseDlg { Q_OBJECT; - public: +public: VisuGUI_IsoSurfacesDlg (SalomeApp_Module* theModule); ~VisuGUI_IsoSurfacesDlg(); @@ -81,13 +89,13 @@ class VisuGUI_IsoSurfacesDlg : public VisuGUI_ScalarBarBaseDlg virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); - protected: +protected: virtual QString GetContextHelpFilePath(); protected slots: void accept(); - private: +private: QTabWidget* myTabBox; VisuGUI_IsoSurfPane* myIsoPane; VisuGUI_InputPane* myInputPane; diff --git a/src/VISUGUI/VisuGUI_OffsetDlg.cxx b/src/VISUGUI/VisuGUI_OffsetDlg.cxx index 04928275..b40b30d1 100644 --- a/src/VISUGUI/VisuGUI_OffsetDlg.cxx +++ b/src/VISUGUI/VisuGUI_OffsetDlg.cxx @@ -27,6 +27,8 @@ #include "VISU_Actor.h" #include "LightApp_Application.h" +#include "LightApp_SelectionMgr.h" +#include "SALOME_ListIteratorOfListIO.hxx" #include "SalomeApp_Application.h" #include "SVTK_ViewWindow.h" #include "SVTK_ViewModel.h" @@ -55,9 +57,11 @@ VisuGUI_OffsetDlg::VisuGUI_OffsetDlg (VisuGUI* theModule) : QDialog(VISU::GetDesktop(theModule), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), - myModule(theModule) + myModule(theModule), + mySelectionMgr(VISU::GetSelectionMgr(theModule)) { //myPrsList.setAutoDelete(false); + //myPointMapList.setAutoDelete(false); setWindowTitle(tr("TIT_OFFSETDLG")); setSizeGripEnabled(TRUE); @@ -132,6 +136,50 @@ VisuGUI_OffsetDlg::VisuGUI_OffsetDlg (VisuGUI* theModule) connect(buttonApply, SIGNAL(clicked()), this, SLOT(onApply())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); + + onSelectionChanged(); + show(); +} + +void VisuGUI_OffsetDlg::setVisible(bool show){ + if ( show && getPrsCount() > 0 ) + QDialog::setVisible( show ); + else + QDialog::setVisible( show ); +} + +void VisuGUI_OffsetDlg::onSelectionChanged(){ + if(!mySelectionMgr) + return; + + //Clear old selection + clearPresentations(); + + SALOME_ListIO aListIO; + mySelectionMgr->selectedObjects(aListIO); + + SalomeApp_Study* aStudy = VISU::GetAppStudy(myModule); + SALOME_ListIteratorOfListIO anIter(aListIO); + for (; anIter.More(); anIter.Next()) { + Handle(SALOME_InteractiveObject) anIO = anIter.Value(); + if (anIO->hasEntry()) { + QString anEntry(anIO->getEntry()); + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anEntry.toLatin1().constData()); + if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)) + addPresentation(aPrsObject); + else if (VISU::PointMap3d_i* aPrs = dynamic_cast(anObjectInfo.myBase)) { + addPointMapPresentation(aPrs); + } + } + } +} + +void VisuGUI_OffsetDlg::clearPresentations(){ + myPrsList.clear(); + myPointMapList.clear(); + myOldOffsets.clear(); + myOldPointMapOffsets.clear(); } void VisuGUI_OffsetDlg::addPresentation (VISU::Prs3d_i* thePrs) @@ -149,6 +197,22 @@ void VisuGUI_OffsetDlg::addPresentation (VISU::Prs3d_i* thePrs) } } +void VisuGUI_OffsetDlg::addPointMapPresentation (VISU::PointMap3d_i* thePrs) +{ + myPointMapList.append(thePrs); + + CORBA::Float anOffset[3]; + thePrs->GetOffset(anOffset[0],anOffset[1],anOffset[2]); + OffsetStruct anOffs(anOffset[0],anOffset[1],anOffset[2]); + myOldPointMapOffsets.append(anOffs); + if (myPointMapList.count() == 1) { + setOffset(anOffs.myOffset); + } else if (myPointMapList.count() == 2) { + OffsetStruct anOffs; + setOffset(anOffs.myOffset); + } +} + void VisuGUI_OffsetDlg::setOffset (const vtkFloatingPointType* theOffset) { myDxEdt->setValue(theOffset[0]); @@ -183,8 +247,11 @@ void VisuGUI_OffsetDlg::updateOffset (VISU::Prs3d_i* thePrs, vtkFloatingPointTyp if (myPrsList.count() == 0) return; - if (isToSave()) + if (isToSave()) { thePrs->SetOffset(theOffset[0],theOffset[1],theOffset[2]); + thePrs->UpdateActors(); + return; + } ViewManagerList aViewManagerList; SalomeApp_Application* anApp = myModule->getApp(); @@ -195,8 +262,38 @@ void VisuGUI_OffsetDlg::updateOffset (VISU::Prs3d_i* thePrs, vtkFloatingPointTyp for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) { if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) { if (SVTK_ViewWindow* vw = dynamic_cast(aViewWindow)) { - vw->onAdjustTrihedron(); if (VISU_Actor* anActor = VISU::FindActor(vw, thePrs)) { + anActor->SetPosition(theOffset); + vw->onAdjustTrihedron(); + vw->getRenderer()->ResetCameraClippingRange(); + vw->Repaint(); + } + } + } + } + } +} + +void VisuGUI_OffsetDlg::updatePointMapOffset (VISU::PointMap3d_i* thePrs, vtkFloatingPointType* theOffset) +{ + if (myPointMapList.count() == 0) + return; + + if (isToSave()) + thePrs->SetOffset(theOffset[0],theOffset[1],theOffset[2]); + + ViewManagerList aViewManagerList; + SalomeApp_Application* anApp = myModule->getApp(); + anApp->viewManagers(aViewManagerList); + SUIT_ViewManager* aViewManager; + foreach( aViewManager, aViewManagerList ) { + QVector aViews = aViewManager->getViews(); + for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) { + if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) { + if (SVTK_ViewWindow* vw = dynamic_cast(aViewWindow)) { + vw->onAdjustTrihedron(); + + if (VISU_ActorBase* anActor = VISU::FindActorBase(vw, thePrs)) { anActor->SetPosition(theOffset); vw->highlight(thePrs->GetIO(), 1); vw->getRenderer()->ResetCameraClippingRange(); @@ -215,6 +312,9 @@ void VisuGUI_OffsetDlg::accept() for (int i = 0; i < myPrsList.count(); i++) { updateOffset(myPrsList.at(i), anOffset); } + for (int i = 0; i < myPointMapList.count(); i++) { + updatePointMapOffset(myPointMapList.at(i), anOffset); + } QDialog::accept(); } @@ -223,6 +323,9 @@ void VisuGUI_OffsetDlg::reject() for (int i = 0; i < myPrsList.count(); i++) { updateOffset(myPrsList.at(i), myOldOffsets[i].myOffset); } + for (int i = 0; i < myPointMapList.count(); i++) { + updatePointMapOffset(myPointMapList.at(i), myOldOffsets[i].myOffset); + } QDialog::reject(); } @@ -230,9 +333,13 @@ void VisuGUI_OffsetDlg::onApply() { vtkFloatingPointType anOffset[3]; getOffset(anOffset); + for (int i = 0; i < myPrsList.count(); i++) { updateOffset(myPrsList.at(i), anOffset); } + for (int i = 0; i < myPointMapList.count(); i++) { + updatePointMapOffset(myPointMapList.at(i), anOffset); + } } void VisuGUI_OffsetDlg::onHelp() diff --git a/src/VISUGUI/VisuGUI_OffsetDlg.h b/src/VISUGUI/VisuGUI_OffsetDlg.h index 217c8399..f8dc7eec 100644 --- a/src/VISUGUI/VisuGUI_OffsetDlg.h +++ b/src/VISUGUI/VisuGUI_OffsetDlg.h @@ -23,6 +23,7 @@ #include "VTKViewer.h" #include "VISU_Prs3d_i.hh" +#include "VISU_PointMap3d_i.hh" // QT Includes #include @@ -31,6 +32,7 @@ class QCheckBox; class QtxDoubleSpinBox; class VisuGUI; +class LightApp_SelectionMgr; struct OffsetStruct { @@ -58,8 +60,12 @@ class VisuGUI_OffsetDlg: public QDialog VisuGUI_OffsetDlg (VisuGUI* theModule); ~VisuGUI_OffsetDlg() {}; + virtual void setVisible(bool); + void addPresentation (VISU::Prs3d_i* thePrs); - int getPrsCount() const { return myPrsList.count(); } + void addPointMapPresentation (VISU::PointMap3d_i* thePrs); + int getPrsCount() const { return myPrsList.count() + myPointMapList.count(); } + void clearPresentations(); void setOffset (const vtkFloatingPointType* theOffset); void getOffset (vtkFloatingPointType* theOffset) const; @@ -76,11 +82,14 @@ class VisuGUI_OffsetDlg: public QDialog virtual void reject(); void onApply(); void onHelp(); + void onSelectionChanged(); private: void updateOffset (VISU::Prs3d_i* thePrs, vtkFloatingPointType* theOffset); + void updatePointMapOffset (VISU::PointMap3d_i* thePrs, vtkFloatingPointType* theOffset); VisuGUI * myModule; + LightApp_SelectionMgr* mySelectionMgr; QtxDoubleSpinBox * myDxEdt; QtxDoubleSpinBox * myDyEdt; @@ -89,6 +98,9 @@ class VisuGUI_OffsetDlg: public QDialog QList myPrsList; QList myOldOffsets; + + QList myPointMapList; + QList myOldPointMapOffsets; }; #endif // DIALOGBOX_OFFSET_H diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx index a4fcd799..263b40de 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx @@ -81,7 +81,7 @@ using namespace std; static void renderViewFrame (SVTK_ViewWindow* vw) { if (vw) { - vw->getRenderer()->ResetCameraClippingRange(); +// vw->getRenderer()->ResetCameraClippingRange(); vw->Repaint(); } } @@ -425,7 +425,7 @@ void VisuGUI_Plot3DPane::updatePreview() renderViewFrame(myViewWindow); - if (fitall) { + if (fitall && VISU::GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)) { myPreviewActor->SetInfinitive(false); myViewWindow->onFitAll(); myPreviewActor->SetInfinitive(true); diff --git a/src/VISUGUI/VisuGUI_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx index 26105e76..9fd9793d 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ b/src/VISUGUI/VisuGUI_PopupTools.cxx @@ -111,12 +111,14 @@ QString VisuGUI_Selection::type( const int ind ) const ENUM2STRING( aResStr, VISU::TISOSURFACES ); ENUM2STRING( aResStr, VISU::TDEFORMEDSHAPE ); ENUM2STRING( aResStr, VISU::TSCALARMAPONDEFORMEDSHAPE ); + ENUM2STRING( aResStr, VISU::TDEFORMEDSHAPEANDSCALARMAP ); ENUM2STRING( aResStr, VISU::TCUTPLANES ); ENUM2STRING( aResStr, VISU::TCUTLINES ); ENUM2STRING( aResStr, VISU::TVECTORS ); ENUM2STRING( aResStr, VISU::TSTREAMLINES ); ENUM2STRING( aResStr, VISU::TPLOT3D ); ENUM2STRING( aResStr, VISU::TANIMATION ); + ENUM2STRING( aResStr, VISU::TPOINTMAP3D ); } } @@ -381,11 +383,21 @@ struct TViewFunctor { VISU_Actor* anActor = NULL; VISU::Prs3d_i* aPrs3d = NULL; + VISU_ActorBase* anActorBase = NULL; + VISU::PointMap3d_i* aPointMap3d = NULL; SVTK_ViewWindow* aViewWindow = NULL; - if(!GetPrs3dSelectionInfo(theModule, theEntry, aPrs3d, aViewWindow, anActor)) - return QString(); - - return get(aPrs3d, aViewWindow, anActor); + if(GetPrs3dSelectionInfo(theModule, theEntry, aPrs3d, aViewWindow, anActor)) { + return get(aPrs3d, aViewWindow, anActor); + } else { + aViewWindow = GetActiveViewWindow(theModule); + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule); + if ( aSelectionInfo.empty() ) + return QString(); + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + aPointMap3d = dynamic_cast(aSelectionItem.myObjectInfo.myBase); + anActorBase = VISU::FindActorBase(aViewWindow, aPointMap3d); + return getPointMap(aPointMap3d, aViewWindow, anActorBase); + } } QString @@ -396,6 +408,15 @@ struct TViewFunctor { return QString(); } + + QString + virtual + getPointMap(VISU::PointMap3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_ActorBase* theActor) + { + return QString(); + } }; @@ -418,6 +439,22 @@ struct TGetRepesentationFunctor: TViewFunctor } return aResStr; } + + QString + virtual + getPointMap(VISU::PointMap3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_ActorBase* theActorBase) + { + QString aResStr = ""; + if (theActorBase) { + switch (theActorBase->GetRepresentation()) { + ENUM2STRING( aResStr, VISU::WIREFRAME ); // = 1 + ENUM2STRING( aResStr, VISU::SHADED ); // = 2 + } + } + return aResStr; + } }; QString VisuGUI_Selection::representation( const int ind ) const @@ -501,6 +538,17 @@ struct TIsShrunkFunctor: TViewFunctor { return theActor->IsShrunk() ? "1" : "0"; } + + QString + virtual + getPointMap(VISU::PointMap3d_i* thePointMap, + SVTK_ViewWindow* theViewWindow, + VISU_ActorBase* theActorBase) + { + if (theActorBase) + return theActorBase->IsShrunk() ? "1" : "0"; + else return "0"; + } }; QString VisuGUI_Selection::isShrunk( const int ind ) const diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx index 3dcc4386..d8110578 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx @@ -1046,9 +1046,6 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs) myTextDlg->setTitleText(aTitle.in()); myTitle = aTitle.in(); - vtkFloatingPointType R, G, B; - myScalarMap->GetTitleColor(&R, &G, &B); - setPosAndSize( myScalarMap->GetPosX(), myScalarMap->GetPosY(), myScalarMap->GetWidth(), @@ -1076,16 +1073,23 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs) myBarDlg->setLabelsFormat(myScalarMap->GetLabelsFormat()); myBarDlg->setUnitsVisible(myScalarMap->IsUnitsVisible()); - myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), + vtkFloatingPointType R, G, B; + myScalarMap->GetTitleColor(R, G, B); + + QColor aTextColor = QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)); + + myTextDlg->myTitleFont->SetData(aTextColor, myScalarMap->GetTitFontType(), myScalarMap->IsBoldTitle(), myScalarMap->IsItalicTitle(), myScalarMap->IsShadowTitle()); // "Labels" - myScalarMap->GetLabelColor(&R, &G, &B); + myScalarMap->GetLabelColor(R, G, B); + + QColor aLabelColor = QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)); - myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), + myTextDlg->myLabelFont->SetData(aLabelColor, myScalarMap->GetLblFontType(), myScalarMap->IsBoldLabel(), myScalarMap->IsItalicLabel(), diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index 570a96e0..f33d496d 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -264,7 +264,9 @@ namespace VISU // Display created presentation. if (aViewWindow) { PublishInView(theModule, aPrs3d, aViewWindow); - aViewWindow->onFitAll(); + if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){ + aViewWindow->onFitAll(); + } AddScalarBarPosition(theModule, aViewWindow, aPrs3d, aPos); } diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx deleted file mode 100644 index 069710ee..00000000 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx +++ /dev/null @@ -1,470 +0,0 @@ -// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// -// -// File : VisuGUI_ScalarMapOnDeformedShapeDlg.cxx -// Author : Eugeny Nikolaev -// Module : VISU - -#include "VisuGUI_ScalarMapOnDeformedShapeDlg.h" - -#include "VisuGUI_Tools.h" -#include "VisuGUI_InputPane.h" - -#include "VISU_Result_i.hh" -#include "VISU_ScalarMapOnDeformedShape_i.hh" -#include "VISU_ColoredPrs3dFactory.hh" - -#include "VISU_ScalarMapPL.hxx" -#include "VISU_ScalarMapOnDeformedShapePL.hxx" - -#include "VISU_Convertor.hxx" - -#include "SalomeApp_Module.h" -#include "LightApp_Application.h" -#include "LightApp_SelectionMgr.h" -#include "SUIT_Desktop.h" -#include "SUIT_ResourceMgr.h" -#include "SUIT_Session.h" -#include "SUIT_MessageBox.h" - -#include "SALOME_ListIO.hxx" - -#include "SALOMEDSClient_AttributeString.hxx" -#include "SALOMEDSClient_AttributeName.hxx" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -using namespace std; - -#define MYDEBUG 0 - -/*! - * Constructor - */ -VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (SalomeApp_Module* theModule) - : VisuGUI_ScalarBarBaseDlg(theModule), - myIsAnimation(false), - myUpdateScalars(true), - myVisuGUI(theModule) -{ - setWindowTitle(tr("DLG_TITLE")); - setSizeGripEnabled(TRUE); - - QVBoxLayout* TopLayout = new QVBoxLayout (this); - TopLayout->setSpacing(6); - TopLayout->setMargin(11); - - myTabBox = new QTabWidget (this); - - // Scalar Map on Deformed shape pane - QWidget* aBox = new QWidget (this); - QVBoxLayout* aVBLay = new QVBoxLayout( aBox ); - aVBLay->setMargin(11); - QFrame* TopGroup = new QFrame (aBox); - aVBLay->addWidget( 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); - TopGroupLayout->addWidget(ScaleLabel, 0, 0); - - ScalFact = new QtxDoubleSpinBox (0.0, 1.0E+38, 0.1, TopGroup); - ScalFact->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - ScalFact->setDecimals(38); - ScalFact->setValue(0.1); - TopGroupLayout->addWidget(ScalFact, 0, 1); - - // Fields combo box - QLabel* FieldLabel = new QLabel (tr("FIELD_ITEM"), TopGroup); - myFieldsCombo = new QComboBox (TopGroup ); - - TopGroupLayout->addWidget(FieldLabel, 1, 0); - TopGroupLayout->addWidget(myFieldsCombo,1,1); - - // TimeStamps combo box - QLabel* TimeStampLabel = new QLabel (tr("TIMESTAMP_ITEM"), TopGroup); - myTimeStampsCombo = new QComboBox (TopGroup); - - TopGroupLayout->addWidget(TimeStampLabel, 2, 0); - TopGroupLayout->addWidget(myTimeStampsCombo,2,1); - - // - myTabBox->addTab(aBox, tr("SCALAR_MAP_ON_DEFORMED_SHAPE_TAB")); - - // Scalar bar pane - myInputPane = new VisuGUI_InputPane(VISU::TSCALARMAPONDEFORMEDSHAPE, theModule, this); - - myTabBox->addTab(GetScalarPane(), tr("SCALAR_BAR_TAB")); - myTabBox->addTab(myInputPane, tr("INPUT_TAB")); - - // Buttons - QGroupBox* GroupButtons = new QGroupBox (this); - 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); - GroupButtonsLayout->setAlignment(Qt::AlignTop); - GroupButtonsLayout->setSpacing(6); - GroupButtonsLayout->setMargin(11); - - QPushButton* buttonOk = new QPushButton (tr("BUT_OK"), GroupButtons); - 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("BUT_CANCEL") , GroupButtons); - buttonCancel->setAutoDefault(TRUE); - GroupButtonsLayout->addWidget(buttonCancel, 0, 2); - - QPushButton* buttonHelp = new QPushButton (tr("BUT_HELP") , GroupButtons); - buttonHelp->setAutoDefault(TRUE); - GroupButtonsLayout->addWidget(buttonHelp, 0, 3); - - // Add Tab box and Buttons to the top layout - TopLayout->addWidget(myTabBox); - TopLayout->addWidget(GroupButtons); - - // signals and slots connections - connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); - connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())); - connect(myFieldsCombo, SIGNAL(activated(int)), this, SLOT(onFieldChanged(int))); - connect(myTimeStampsCombo, SIGNAL(activated(int)), this, SLOT(onTimeStampChanged(int))); -} - -VisuGUI_ScalarMapOnDeformedShapeDlg::~VisuGUI_ScalarMapOnDeformedShapeDlg() -{} - -void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, - bool theInit ) -{ - if( theInit ) - myPrsCopy = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); - - setFactor(myPrsCopy->GetScale()); - myTimeStampsCombo->setDisabled(myIsAnimation); - - CORBA::String_var aFieldName(myPrsCopy->GetScalarFieldName()); - QString aIteration = GetFloatValueOfTimeStamp(myPrsCopy->GetScalarEntity(), - aFieldName.in(), - myPrsCopy->GetScalarTimeStampNumber()); - if (myEntity2Fields.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()); - VISU::VISUType aType = VISU::Storable::SObject2Type( aSObject ); - switch(aType){ - case VISU::TTIMESTAMP: { - aSObject = aSObject->GetFather(); - aSObject = aSObject->GetFather(); - break; - } - case VISU::TFIELD: { - _PTR(SObject) newSObject; - if(aSObject->ReferencedObject(newSObject)) aSObject = newSObject; - aSObject = aSObject->GetFather(); - break; - } - case VISU::TANIMATION: { - _PTR(ChildIterator) aTmpIter = aActiveStudy->NewChildIterator(aSObject); - for (aTmpIter->InitEx(true); aTmpIter->More(); aTmpIter->Next()) { - _PTR(SObject) aTmpChildSObj = aTmpIter->Value(); - _PTR(SObject) newSObject; - if(aTmpChildSObj->ReferencedObject(newSObject)){ - aSObject = newSObject; - aSObject->GetFather(); - break; - } - } - break; - }} - - aSObject = aSObject->GetFather(); - aSObject = aSObject->GetFather(); - - mySelectionObj = aSObject; - CORBA::Object_var anObject = VISU::ClientSObjectToObject(mySelectionObj); - if (CORBA::is_nil(anObject)) { - mySelectionObj = mySelectionObj->GetFather(); - } - } - } - - if (mySelectionObj) { - _PTR(ChildIterator) aIter = aActiveStudy->NewChildIterator(mySelectionObj); - - for (aIter->InitEx(true); aIter->More(); aIter->Next()) { - _PTR(SObject) aChildSObj = aIter->Value(); - VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aChildSObj); - if (!aRestoringMap.empty()) { - VISU::VISUType aType = VISU::Storable::RestoringMap2Type(aRestoringMap); - if (aType == VISU::TTIMESTAMP) { - QString aMeshName = aRestoringMap["myMeshName"]; - CORBA::String_var aName = myPrsCopy->GetMeshName(); - if (aMeshName != aName.in()) - continue; - QString aFieldName = aRestoringMap["myFieldName"]; - QString aTimeIter = aRestoringMap["myTimeStampId"]; - QString aEntity = aRestoringMap["myEntityId"]; - VISU::Entity anEntity; - switch (aEntity.toInt()) { - case 0: anEntity = VISU::NODE; break; - case 1: anEntity = VISU::EDGE; break; - case 2: anEntity = VISU::FACE; break; - case 3: anEntity = VISU::CELL; break; - } - TFieldName2TimeStamps& aFieldName2TimeStamps = myEntity2Fields[anEntity]; - TTimeStampNumber2Time& aTimeStampNumber2Time = aFieldName2TimeStamps[aFieldName]; - aTimeStampNumber2Time[aTimeIter.toInt()] = - GetFloatValueOfTimeStamp(anEntity, - aFieldName.toLatin1().data(), - aTimeIter.toInt()); - } - } - } - } - AddAllFieldNames(); - } - myFieldsCombo->setCurrentIndex(myFieldsCombo->findText(aFieldName.in())); - AddAllTimes(myFieldsCombo->currentText()); - myTimeStampsCombo->setCurrentIndex(myTimeStampsCombo->findText(aIteration)); - SetScalarField( false ); - - VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit); - - if( !theInit ) - return; - - myInputPane->initFromPrsObject( myPrsCopy ); - myTabBox->setCurrentIndex( 0 ); -} - -int -VisuGUI_ScalarMapOnDeformedShapeDlg -::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) -{ - if(!myInputPane->check() || !GetScalarPane()->check()) - return 0; - - int anIsOk = myInputPane->storeToPrsObject( myPrsCopy ); - anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy ); - - myPrsCopy->SetScale(getFactor()); - - myPrsCopy->SetScalarField(myPrsCopy->GetScalarEntity(), - getCurrentScalarFieldName().toLatin1().data(), - myTimeStampID[ myTimeStampsCombo->currentIndex() ]); - - - if(myUpdateScalars) - SetScalarField( false ); - - VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); - - return anIsOk; -} - -int VisuGUI_ScalarMapOnDeformedShapeDlg::getCurrentScalarFieldNamePos(){ - return myFieldsCombo->currentIndex(); -} - -QString VisuGUI_ScalarMapOnDeformedShapeDlg::getCurrentScalarFieldName(){ - return myFieldsCombo->currentText(); -} - -int VisuGUI_ScalarMapOnDeformedShapeDlg::getCurrentScalarNbIterations(){ - return myTimeStampsCombo->count(); -} - -VISU::Entity -VisuGUI_ScalarMapOnDeformedShapeDlg -::getCurrentScalarEntity() -{ - VISU::Entity anEntity = VISU::Entity(-1); - TEntity2Fields::const_iterator anIter = myEntity2Fields.begin(); - for(; anIter != myEntity2Fields.end(); anIter++){ - const TFieldName2TimeStamps& aFieldName2TimeStamps = anIter->second; - TFieldName2TimeStamps::const_iterator aFieldIter = aFieldName2TimeStamps.begin(); - for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){ - const QString& aFieldName = aFieldIter->first; - if (aFieldName == myFieldsCombo->currentText()) { - anEntity = anIter->first; - break; - } - } - } - return anEntity; -} - -void VisuGUI_ScalarMapOnDeformedShapeDlg::SetScalarField( const bool save_scalar_pane ){ - SetScalarField( myTimeStampID[ myTimeStampsCombo->currentIndex() ], "", save_scalar_pane ); -} - -void -VisuGUI_ScalarMapOnDeformedShapeDlg -::SetScalarField(int theIter, - QString theFieldName, - const bool save_scalar_pane ) -{ - QApplication::setOverrideCursor(Qt::WaitCursor); - - if( save_scalar_pane ) - GetScalarPane()->storeToPrsObject(myPrsCopy); - - QString aFieldName; - - if(theFieldName.isEmpty()) - aFieldName = myFieldsCombo->currentText(); - else - aFieldName = theFieldName; - - VISU::Entity anEntity = getCurrentScalarEntity(); - - myPrsCopy->SetScalarField(anEntity, - aFieldName.toLatin1().data(), - theIter); - - if( save_scalar_pane ) - UpdateScalarField(); - - QApplication::restoreOverrideCursor(); -} - -void VisuGUI_ScalarMapOnDeformedShapeDlg::accept() -{ - VisuGUI_ScalarBarBaseDlg::accept(); -} - -void VisuGUI_ScalarMapOnDeformedShapeDlg::reject() -{ - VisuGUI_ScalarBarBaseDlg::reject(); -} - -QString VisuGUI_ScalarMapOnDeformedShapeDlg::GetContextHelpFilePath() -{ - return "scalar_map_on_deformed_shape_page.html"; -} - -void VisuGUI_ScalarMapOnDeformedShapeDlg::AddAllFieldNames(){ - TEntity2Fields::const_iterator anIter = myEntity2Fields.begin(); - for(; anIter != myEntity2Fields.end(); anIter++){ - const TFieldName2TimeStamps& aFieldName2TimeStamps = anIter->second; - TFieldName2TimeStamps::const_iterator aFieldIter = aFieldName2TimeStamps.begin(); - for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){ - const QString& aFieldName = aFieldIter->first; - myFieldsCombo->addItem(aFieldName); - } - } -} - -void VisuGUI_ScalarMapOnDeformedShapeDlg::AddAllTimes(const QString& theFieldName){ - TEntity2Fields::const_iterator anIter = myEntity2Fields.begin(); - for(; anIter != myEntity2Fields.end(); anIter++){ - const TFieldName2TimeStamps& aFieldName2TimeStamps = anIter->second; - TFieldName2TimeStamps::const_iterator aFieldIter = aFieldName2TimeStamps.begin(); - for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){ - const QString& aFieldName = aFieldIter->first; - if(theFieldName != aFieldName) - continue; - - myTimeStampID.clear(); - myTimeStampsCombo->clear(); - - const TTimeStampNumber2Time& aTimeStampNumber2Time = aFieldIter->second; - TTimeStampNumber2Time::const_iterator aTimeStampIter = aTimeStampNumber2Time.begin(); - for(; aTimeStampIter != aTimeStampNumber2Time.end(); aTimeStampIter++){ - int aTimeStampNumber = aTimeStampIter->first; - myTimeStampID.push_back(aTimeStampNumber); - - QString aTimeStampTime = aTimeStampIter->second; - myTimeStampsCombo->addItem(aTimeStampTime); - } - return; - } - } -} - -void VisuGUI_ScalarMapOnDeformedShapeDlg::onFieldChanged(int){ - AddAllTimes(myFieldsCombo->currentText()); - SetScalarField(); - UpdateScalarField(); -} - -void VisuGUI_ScalarMapOnDeformedShapeDlg::onTimeStampChanged(int){ - SetScalarField(); - UpdateScalarField(); -} - -void VisuGUI_ScalarMapOnDeformedShapeDlg::UpdateScalarField(){ - GetScalarPane()->initFromPrsObject(myPrsCopy); -} - -QString -VisuGUI_ScalarMapOnDeformedShapeDlg -::GetFloatValueOfTimeStamp(VISU::Entity theEntity, - const std::string& theFieldName, - int theTimeStampNumber) -{ - QString aTime(""); - VISU::TEntity anEntity = VISU::TEntity(theEntity); - VISU::Result_i* theResult = myPrsCopy->GetCResult(); - VISU::Result_i::PInput anInput = theResult->GetInput(); - VISU::PField aField = anInput->GetField(myPrsCopy->GetCMeshName(), - anEntity, - theFieldName); - if(!aField) - return aTime; - - VISU::TValField& aValField = aField->myValField; - VISU::TValField::const_iterator aIter = aValField.find(theTimeStampNumber); - if(aIter != aValField.end()){ - VISU::PValForTime aValForTime = aIter->second; - aTime = VISU_Convertor::GenerateName(aValForTime->myTime).c_str(); - } - return aTime; -} diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h deleted file mode 100644 index 6eec691a..00000000 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h +++ /dev/null @@ -1,118 +0,0 @@ -// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// -// -// File : VisuGUI_ScalarMapOnDeformedShapeDlg.h -// Author : Eugeny Nikolaev -// Module : VISU - -#ifndef VISUGUI_SCALARMAPONDEFORMEDSHAPEDLS_H -#define VISUGUI_SCALARMAPONDEFORMEDSHAPEDLS_H - -#include "VisuGUI_Prs3dDlg.h" - -#include "VISUConfig.hh" - -#include "QtxDoubleSpinBox.h" - -class QComboBox; -class QTabWidget; - -#include -#include - -class SalomeApp_Module; -class VisuGUI_InputPane; - -namespace VISU -{ - class ScalarMapOnDeformedShape_i; -} - -class VisuGUI_ScalarMapOnDeformedShapeDlg : public VisuGUI_ScalarBarBaseDlg -{ - Q_OBJECT - -public: - VisuGUI_ScalarMapOnDeformedShapeDlg (SalomeApp_Module* theModule); - ~VisuGUI_ScalarMapOnDeformedShapeDlg(); - - double getFactor() - { return ScalFact->value(); } - void setFactor(double theFactor) - { ScalFact->setValue(theFactor); } - - virtual void initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, - bool theInit ); - - virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); - - int getCurrentScalarFieldNamePos(); - QString getCurrentScalarFieldName(); - int getCurrentScalarNbIterations(); - VISU::Entity getCurrentScalarEntity(); - void SetScalarField(int theIter,QString theFieldName=QString(""), const bool = true ); - -protected: - virtual QString GetContextHelpFilePath(); - -protected slots: - void accept(); - void reject(); - -private slots: - void onFieldChanged(int i=0); - void onTimeStampChanged(int i=0); - -private: - QtxDoubleSpinBox* ScalFact; - QTabWidget* myTabBox; - VisuGUI_ScalarBarPane* myScalarPane; - VisuGUI_InputPane* myInputPane; - QComboBox *myFieldsCombo; - QComboBox *myTimeStampsCombo; - - typedef std::map TTimeStampNumber2Time; // Times map definition (iteration time, real value of time) - typedef std::map TFieldName2TimeStamps; // Field name and enity to Times - typedef std::map TEntity2Fields; // Mesh to fields map - - TEntity2Fields myEntity2Fields; - int myCurrScalarIter; - bool myIsAnimation; - bool myUpdateScalars; - std::vector myTimeStampID; - - _PTR(SObject) mySelectionObj; - SALOME::GenericObjPtr myPrsCopy; - SalomeApp_Module* myVisuGUI; - -protected: - void UpdateScalarField(); - void SetScalarField( const bool = true ); - void AddAllFieldNames(); - void AddAllTimes(const QString& theFieldName); - QString GetFloatValueOfTimeStamp(VISU::Entity theEntity, - const std::string& theFieldName, - int theTimeStampNumber); -}; - -#endif // VISUGUI_DEFORMEDSHAPEDLS_H diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 5d9bd5b4..c4b6d44e 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -55,6 +55,8 @@ #include "SVTK_ViewWindow.h" #include "SVTK_Selector.h" +#include "VISU_ConvertorUtils.hxx" + #include "utilities.h" // OCCT Includes @@ -499,21 +501,30 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { { int aVTKID = anVISUActor->GetNodeVTKID(anID); if(aVTKID >= 0){ + if ( aVTKID >= 0 ) { vtkFloatingPointType* aCoord = anVISUActor->GetNodeCoord(anID); myXValLbl->setText( QString::number( aCoord[0] ) ); myYValLbl->setText( QString::number( aCoord[1] ) ); myZValLbl->setText( QString::number( aCoord[2] ) ); - myIDValLbl->setText( QString::number(anID) ); - myScalarValLbl->setText(getValue(aPntData, aVTKID)); - myVectorValLbl->setText(getVector(aPntData, aVTKID)); + myIDValLbl->setText( QString::number( anID ) ); + + if ( !VISU::IsElnoData( aDataSet ) ) { + myScalarValLbl->setText( getValue( aPntData, aVTKID ) ); + myVectorValLbl->setText( getVector( aPntData, aVTKID ) ); + } else { + myScalarValLbl->setText( "< ELNO data >" ); + myVectorValLbl->setText( "< ELNO data >" ); + } + const VISU::PIDMapper& aMapper = aPrs3d->GetPipeLine()->GetIDMapper(); - VISU::TStructuredId aStructuredId = aMapper->GetIndexesOfNode(anID); + VISU::TStructuredId aStructuredId = aMapper->GetIndexesOfNode( anID ); myKValLbl->setText( GetNumber( aStructuredId, 2 ) ); myJValLbl->setText( GetNumber( aStructuredId, 1 ) ); myIValLbl->setText( GetNumber( aStructuredId, 0 ) ); - } + } } break; + } case 1: { vtkCellData* aCellData = aDataSet->GetCellData(); diff --git a/src/VISUGUI/VisuGUI_Table3dDlg.cxx b/src/VISUGUI/VisuGUI_Table3dDlg.cxx index d76db59b..6c961fbf 100644 --- a/src/VISUGUI/VisuGUI_Table3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Table3dDlg.cxx @@ -162,7 +162,10 @@ void VisuGUI_Table3DPane::initFromPrsObject( VISU::PointMap3d_i* thePrs ) myPrs = thePrs; // scale - ScaleSpn->setValue( thePrs->GetScaleFactor() ); + double aScale = thePrs->GetScaleFactor(); + if (aScale<0) + aScale = 0; + ScaleSpn->setValue( aScale ); // prs type int id = thePrs->GetIsContourPrs() ? CONTOUR_PRS_ID : SURFACE_PRS_ID; @@ -418,7 +421,7 @@ void VisuGUI_TableScalarBarPane::initFromPrsObject( VISU::PointMap3d_i* thePrs ) myTitle = aTitle.in(); vtkFloatingPointType R, G, B; - myBarPrs->GetTitleColor( &R, &G, &B ); + myBarPrs->GetTitleColor( R, G, B ); setPosAndSize( myBarPrs->GetPosX(), myBarPrs->GetPosY(), @@ -444,7 +447,7 @@ void VisuGUI_TableScalarBarPane::initFromPrsObject( VISU::PointMap3d_i* thePrs ) myBarPrs->IsShadowTitle() ); // "Labels" - myBarPrs->GetLabelColor( &R, &G, &B ); + myBarPrs->GetLabelColor( R, G, B ); myTextDlg->myLabelFont->SetData( QColor( (int)(R*255.), (int)(G*255.), (int)(B*255.) ), myBarPrs->GetLblFontType(), @@ -642,6 +645,47 @@ void VisuGUI_TableScalarBarPane::changeDefaults( int ) } } +//======================================================================= +//function : Check +//purpose : Called when button is clicked, validates data and closes dialog +//======================================================================= +bool VisuGUI_TableScalarBarPane::check() +{ + double minVal = MinEdit->text().toDouble(); + double maxVal = MaxEdit->text().toDouble(); + if ( RBIrange->isChecked() ) { + if (minVal >= maxVal) { + SUIT_MessageBox::warning( this,tr("WRN_VISU"), + tr("MSG_MINMAX_VALUES") ); + return false; + } + } + + // check if logarithmic mode is on and check imposed range to not contain negative values + if ( CBLog->isChecked() ) { + if ( minVal <= 0.0 ) { + if ( RBIrange->isChecked() ) { + SUIT_MessageBox::warning( this, + tr("WRN_VISU"), + tr("WRN_LOGARITHMIC_RANGE") ); + } else { + if ( minVal == 0) + SUIT_MessageBox::warning( this, + tr("WRN_VISU"), + tr("WRN_LOGARITHMIC_RANGE") ); + else + SUIT_MessageBox::warning( this, + tr("WRN_VISU"), + tr("WRN_LOGARITHMIC_FIELD_RANGE") ); + RBIrange->setChecked(true); + changeRange(1); + } + return false; + } + } + return true; +} + //======================================================================= //function : Constructor //purpose : @@ -650,7 +694,7 @@ VisuGUI_Table3DDlg::VisuGUI_Table3DDlg ( SalomeApp_Module* theModule ) : QDialog ( VISU::GetDesktop( theModule ) ) { setModal( false ); - setWindowTitle( tr( "TITLE" ) ); + setWindowTitle( tr( "Point Map 3D Definition" ) ); setSizeGripEnabled( true ); QVBoxLayout* TopLayout = new QVBoxLayout( this ); @@ -704,14 +748,26 @@ VisuGUI_Table3DDlg::~VisuGUI_Table3DDlg() { } +//======================================================================= +//function : accept +//purpose : +//======================================================================= +void VisuGUI_Table3DDlg::accept() +{ + if (myScalarBarPane->check()) + QDialog::accept(); +} + //======================================================================= //function : onApply //purpose : //======================================================================= void VisuGUI_Table3DDlg::onApply() { - storeToPrsObject( myPrsCopy ); - myPrsCopy->UpdateActors(); + if (myScalarBarPane->check()) { + storeToPrsObject( myPrsCopy ); + myPrsCopy->UpdateActors(); + } } //======================================================================= @@ -720,7 +776,24 @@ void VisuGUI_Table3DDlg::onApply() //======================================================================= void VisuGUI_Table3DDlg::onHelp() { - // "table_3d_page.html"; + QString aHelpFileName = "table_3d_page.html"; + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) { + VisuGUI* aVisuGUI = dynamic_cast( app->activeModule() ); + app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName); + } + else { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + SUIT_MessageBox::warning( this, QObject::tr("WRN_WARNING"), + tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) ); + } + } //======================================================================= @@ -745,4 +818,3 @@ void VisuGUI_Table3DDlg::initFromPrsObject( VISU::PointMap3d_i* thePrs ) myIsoPane->initFromPrsObject( thePrs ); myScalarBarPane->initFromPrsObject( thePrs ); } - diff --git a/src/VISUGUI/VisuGUI_Table3dDlg.h b/src/VISUGUI/VisuGUI_Table3dDlg.h index 3945fb33..2257b483 100644 --- a/src/VISUGUI/VisuGUI_Table3dDlg.h +++ b/src/VISUGUI/VisuGUI_Table3dDlg.h @@ -173,6 +173,7 @@ public: virtual int storeToPrsObject( VISU::PointMap3d_i* ); protected slots: + void accept(); void onHelp(); void onApply(); diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 26b7ca6f..86df91b6 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -34,7 +34,7 @@ #include "VisuGUI_VectorsDlg.h" #include "VisuGUI_IsoSurfacesDlg.h" #include "VisuGUI_StreamLinesDlg.h" -#include "VisuGUI_ScalarMapOnDeformedShapeDlg.h" +#include "VisuGUI_DeformedShapeAndScalarMapDlg.h" #include "VisuGUI_GaussPointsDlg.h" #include "VISU_TimeAnimation.h" @@ -47,7 +47,7 @@ #include "VISU_CutLines_i.hh" #include "VISU_Vectors_i.hh" #include "VISU_StreamLines_i.hh" -#include "VISU_ScalarMapOnDeformedShape_i.hh" +#include "VISU_DeformedShapeAndScalarMap_i.hh" #include "VISU_GaussPoints_i.hh" #include "VISU_ViewManager_i.hh" @@ -92,6 +92,42 @@ #define MAXVAL 1e10 #define VALPRECISION 8 +namespace { + void GeneratePresentations(int theFieldId, VISU_TimeAnimation* theAnimator) + { + theAnimator->generatePresentations(theFieldId); + FieldData& aFieldData = theAnimator->getFieldData(theFieldId); + + + int aRefFieldId = ( theAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) ? theFieldId : 0; + if(VISU::ColoredPrs3d_i* aInitialPrs3d = dynamic_cast(theAnimator->getFieldData(aRefFieldId).myPrs[0])){ + for (long aFrameId = 0; aFrameId < aFieldData.myNbFrames; aFrameId++) { + VISU::ColoredPrs3d_i* aColoredPrs3d = aFieldData.myPrs[aFrameId]; + + // Special case for DeformedShape And ScalarMap presentation + // Restore time stamp number for all presentations + VISU::DeformedShapeAndScalarMap_i* aDeformedAndScalPrs = dynamic_cast(aColoredPrs3d); + int aTimeStampNum = -1; + if(aDeformedAndScalPrs){ + aTimeStampNum = aDeformedAndScalPrs->GetScalarTimeStampNumber(); + } + aColoredPrs3d->SameAs(aInitialPrs3d); + + if(aDeformedAndScalPrs){ + aDeformedAndScalPrs->SetScalarField(aDeformedAndScalPrs->GetScalarEntity(), + aDeformedAndScalPrs->GetScalarFieldName(), + aTimeStampNum); + } + + std::string aTitle = aColoredPrs3d->GetCTitle(); + if ( aFrameId != 0 && theAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) { + aColoredPrs3d->SetTitle(aTitle.c_str()); + } + } + } + } +} + ArrangeDlg::ArrangeDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) : QDialog(theParent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), myAnimator(theAnimator), @@ -130,7 +166,7 @@ ArrangeDlg::ArrangeDlg(QWidget* theParent, vtkActorCollection *aCollection = myViewWindow->getRenderer()->GetActors(); aCollection->InitTraversal(); while(vtkActor* anActor = aCollection->GetNextActor()){ - if (VISU_Actor* anVISUActor = dynamic_cast(anActor)) + if (VISU_Actor* anVISUActor = dynamic_cast(anActor)) { if(anVISUActor->GetVisibility() != 0){ if (VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d()){ if(!myPrsMap.contains(aPrs)){ @@ -154,6 +190,31 @@ ArrangeDlg::ArrangeDlg(QWidget* theParent, } } } + } else { //if PointMap3d Actor + if (VISU_ActorBase* anActorBase = dynamic_cast(anActor)) + if(anActorBase->GetVisibility() != 0) + if (VISU::PointMap3d_i* aPrs = dynamic_cast(anActorBase->GetFactory())) { + if(!myPointMapPrsMap.contains(aPrs)){ + Handle(SALOME_InteractiveObject) anIO = aPrs->GetIO(); + if(!anIO->hasEntry()) + continue; + SalomeApp_Study* aStudy = VISU::GetAppStudy(theModule); + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anIO->getEntry()); + if(_PTR(SObject) aSObject = anObjectInfo.mySObject){ + _PTR(GenericAttribute) anAttr; + if (aSObject->FindAttribute(anAttr, "AttributeName")) { + _PTR(AttributeName) aName(anAttr); + QString strIn(aName->Value().c_str()); + aPrsNames.append(strIn); + myPointMapPrsMap[aPrs] = myOffsets.count(); + Offset aOffs; + anActorBase->GetPosition(aOffs.myOffset); + myOffsets.append(aOffs); + } + } + } + } + } } myFieldLst->addItems(aPrsNames); myFieldLst->setCurrentRow(0); @@ -345,7 +406,7 @@ void ArrangeDlg::acceptAnimation() QApplication::setOverrideCursor( Qt::WaitCursor ); FieldData& aData = myAnimator->getFieldData(myFieldLst->currentRow()); if (aData.myPrs.empty()) - myAnimator->generatePresentations(myFieldLst->currentRow()); + GeneratePresentations(myFieldLst->currentRow(),myAnimator); vtkFloatingPointType aBounds[6]; aData.myPrs[0]->GetBounds(aBounds); vtkFloatingPointType aDist = 0; @@ -409,14 +470,24 @@ void ArrangeDlg::acceptViewWindow() if (mySaveChk->isChecked()) aPrs->SetOffset(aOffs.myOffset[0],aOffs.myOffset[1],aOffs.myOffset[2]); } + QMap::Iterator itt; + for (itt = myPointMapPrsMap.begin(); itt != myPointMapPrsMap.end(); ++itt) { + VISU::PointMap3d_i* aPrs = itt.key(); + Offset& aOffs = myOffsets[itt.value()]; + if (VISU_ActorBase* anActor = VISU::FindActorBase(myViewWindow, aPrs)) + anActor->SetPosition(aOffs.myOffset); + if (mySaveChk) + if (mySaveChk->isChecked()) + aPrs->SetOffset(aOffs.myOffset[0],aOffs.myOffset[1],aOffs.myOffset[2]); + } } else { vtkFloatingPointType aDist = 0; vtkFloatingPointType aShift = 0; vtkFloatingPointType aPrevDist = 0; vtkFloatingPointType aPrevShift = 0; - int i; + int i = 0; QMap::Iterator it; - for (it = myPrsMap.begin(), i = 0; it != myPrsMap.end(); ++it, i++) { + for (it = myPrsMap.begin(); it != myPrsMap.end(); ++it, i++) { VISU::Prs3d_i* aPrs = it.key(); if (VISU_Actor* aActor = VISU::FindActor(myViewWindow, aPrs)) { int aAxis = getAxis(); @@ -489,7 +560,69 @@ void ArrangeDlg::acceptViewWindow() aPrevDist = aDist; aPrevShift = aShift; } - } + } // end of myPrsMap loop + // Loop in PointMap3D the same as previous loop + QMap::Iterator itt; + for (itt = myPointMapPrsMap.begin(); itt != myPointMapPrsMap.end(); ++itt, i++) { + VISU::PointMap3d_i* aPrs = itt.key(); + if (VISU_ActorBase* aActor = VISU::FindActorBase(myViewWindow, aPrs)) { + int aAxis = getAxis(); + + vtkFloatingPointType aZeroOffset[3]; + aZeroOffset[0] = aZeroOffset[1] = aZeroOffset[2] = 0; + aActor->SetPosition(aZeroOffset); + aActor->GetMapper()->Update(); + + vtkFloatingPointType aBounds[6]; + aActor->GetBounds(aBounds); + switch (aAxis) { + case XAxis: + aDist = fabs(aBounds[1] - aBounds[0]); + break; + case YAxis: + aDist = fabs(aBounds[3] - aBounds[2]); + break; + case ZAxis: + aDist = fabs(aBounds[5] - aBounds[4]); + } + vtkFloatingPointType aOffset[3]; + aOffset[0] = aOffset[1] = aOffset[2] = 0; + aOffset[aAxis] = + (aBounds[2*aAxis+1] < aBounds[2*aAxis]) ? -aBounds[2*aAxis+1] : -aBounds[2*aAxis]; + + if (i > 0) { + vtkFloatingPointType aCCDist = (aDist + aPrevDist) / 2.0; + + vtkFloatingPointType dx = fabs(aBounds[1] - aBounds[0]); + vtkFloatingPointType dy = fabs(aBounds[3] - aBounds[2]); + vtkFloatingPointType dz = fabs(aBounds[5] - aBounds[4]); + vtkFloatingPointType max = (dx > dy) ? dx : dy; + max = (dz > max) ? dz : max; + max /= 100.0; + + if (aCCDist < max) { + // set base distance between centers of bounding boxes + // to minimal (but big enough) size of current bounding box + if (dx < max) dx = FLT_MAX; + if (dy < max) dy = FLT_MAX; + if (dz < max) dz = FLT_MAX; + + aCCDist = (dx < dy) ? dx : dy; + aCCDist = (dz < aCCDist) ? dz : aCCDist; + } + aShift = aPrevShift + aPrevDist/2.0 + aCCDist*getDistance() - aDist/2.0; + } + + aOffset[aAxis] += aShift; + aActor->SetPosition(aOffset); + if (mySaveChk) + if (mySaveChk->isChecked()) + aPrs->SetOffset(aOffset[0],aOffset[1],aOffset[2]); + + aPrevDist = aDist; + aPrevShift = aShift; + } + } // end of myPointMapPrsMap loop } myViewWindow->getRenderer()->ResetCameraClippingRange(); myViewWindow->Repaint(); @@ -704,6 +837,8 @@ void SetupDlg::initialize() FieldData& aData = myAnimator->getFieldData( 0 ); _PTR(SObject) aField = aData.myField; + if(!aField) return; + _PTR(ChildIterator) anIter = aStudy->NewChildIterator(aField); anIter->Next(); // First is reference on support for(int index = 1; anIter->More(); anIter->Next(), index++) @@ -729,7 +864,7 @@ enum PrsComboItem { TVECTORS_ITEM = 6, // VISU::TVECTORS TSTREAMLINES_ITEM = 7, // VISU::TSTREAMLINES TGAUSSPOINTS_ITEM = 8, // VISU::TGAUSSPOINTS - TSCALARMAPONDEFORMEDSHAPE_ITEM = 9 // VISU::TSCALARMAPONDEFORMEDSHAPE + TDEFORMEDSHAPEANDSCALARMAP_ITEM = 9 // VISU::TDEFORMEDSHAPEANDSCALARMAP }; //------------------------------------------------------------------------ @@ -820,9 +955,9 @@ void SetupDlg::onFieldChange (int theIndex) myTypeId2ComboId[TSTREAMLINES_ITEM] = myComboId2TypeId.size(); myComboId2TypeId.push_back(TSTREAMLINES_ITEM);; - myTypeCombo->addItem("Scalar map on Deformed shape"); // item 9 - myTypeId2ComboId[TSCALARMAPONDEFORMEDSHAPE_ITEM] = myComboId2TypeId.size(); - myComboId2TypeId.push_back(TSCALARMAPONDEFORMEDSHAPE_ITEM);; + myTypeCombo->addItem("Deformed shape and Scalar map"); // item 9 + myTypeId2ComboId[TDEFORMEDSHAPEANDSCALARMAP_ITEM] = myComboId2TypeId.size(); + myComboId2TypeId.push_back(TDEFORMEDSHAPEANDSCALARMAP_ITEM);; } if(anEnableGP){ @@ -851,7 +986,8 @@ void SetupDlg::onFieldChange (int theIndex) myTypeCombo->setCurrentIndex(myTypeId2ComboId[TDEFORMEDSHAPE_ITEM]); break; case VISU::TSCALARMAPONDEFORMEDSHAPE: //Scalar Map on Deformed Shape - myTypeCombo->setCurrentIndex(myTypeId2ComboId[TSCALARMAPONDEFORMEDSHAPE_ITEM]); + case VISU::TDEFORMEDSHAPEANDSCALARMAP: + myTypeCombo->setCurrentIndex(myTypeId2ComboId[TDEFORMEDSHAPEANDSCALARMAP_ITEM]); break; case VISU::TVECTORS: //Vectors myTypeCombo->setCurrentIndex(myTypeId2ComboId[TVECTORS_ITEM]); @@ -895,8 +1031,8 @@ 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; + case TDEFORMEDSHAPEANDSCALARMAP_ITEM: //Scalar Map on Deformed Shape + aData.myPrsType = VISU::TDEFORMEDSHAPEANDSCALARMAP; break; case TVECTORS_ITEM: //Vectors aData.myPrsType = VISU::TVECTORS; @@ -971,7 +1107,7 @@ void SetupDlg::onPreferencesDlg() } } - if(!aData.myNbFrames || !aData.myPrs[0]){ + if(!aData.myNbFrames || aData.myPrs.empty() || !aData.myPrs[0]){ QApplication::restoreOverrideCursor(); SUIT_MessageBox::warning(this, tr("ERROR"), @@ -1006,18 +1142,43 @@ void SetupDlg::onPreferencesDlg() c.suspend(); EditPrs(myModule,aData,myAnimator); break; - case TSCALARMAPONDEFORMEDSHAPE_ITEM: //Scalar Map on Deformed Shape + case TDEFORMEDSHAPEANDSCALARMAP_ITEM: //Scalar Map on Deformed Shape c.suspend(); { - typedef VisuGUI_ScalarMapOnDeformedShapeDlg DLG; - typedef VISU::ScalarMapOnDeformedShape_i TYPE; + typedef VisuGUI_DeformedShapeAndScalarMapDlg DLG; + typedef VISU::DeformedShapeAndScalarMap_i TYPE; DLG* aDlg = new DLG (myModule); TYPE* aPrs3d = dynamic_cast(aData.myPrs[0]); aDlg->initFromPrsObject(aPrs3d, true); - if (aDlg->exec() && aDlg->storeToPrsObject(aData.myPrs[0])) { - for (int i = 1; i < aData.myNbFrames; i++){ - aData.myPrs[i]->SameAs(aData.myPrs[0]); - } + if (aDlg->exec() && aDlg->storeToPrsObject(aData.myPrs[0])) { + for (long aFrameId = 1; aFrameId < aData.myNbFrames; aFrameId++){ + TYPE* aDeformedPrs3d = dynamic_cast(aData.myPrs[aFrameId]); + //Set correct time stamp number + int aTimeStampNum = aDeformedPrs3d->GetScalarTimeStampNumber(); + aDeformedPrs3d->SameAs(aPrs3d); + aDeformedPrs3d->SetScalarField(aDeformedPrs3d->GetScalarEntity(), + aDeformedPrs3d->GetScalarFieldName(), + aTimeStampNum); + + } + + if ( myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) { + for (int aFieldId = 1; aFieldId < myAnimator->getNbFields(); aFieldId++) { + FieldData& aFieldData = myAnimator->getFieldData(aFieldId); + for (long aFrameId = 0; aFrameId < aFieldData.myNbFrames; aFrameId++) { + TYPE* aDeformedPrs3d = dynamic_cast(aFieldData.myPrs[aFrameId]); + std::string aTitle = aDeformedPrs3d->GetCTitle(); + //Set correct time stamp number + int aTimeStampNum = aDeformedPrs3d->GetScalarTimeStampNumber(); + aDeformedPrs3d->SameAs(aPrs3d); + aDeformedPrs3d->SetTitle(aTitle.c_str()); + aDeformedPrs3d->SetScalarField(aDeformedPrs3d->GetScalarEntity(), + aDeformedPrs3d->GetScalarFieldName(), + aTimeStampNum); + + } + } + } } delete aDlg; } @@ -1625,7 +1786,8 @@ void VisuGUI_TimeAnimationDlg::createFrames() FieldData& aFieldData = myAnimator->getFieldData(i); if( aFieldData.myPrs.empty() ) { - myAnimator->generatePresentations(i); + //myAnimator->generatePresentations(i); + GeneratePresentations(i,myAnimator); continue; } @@ -1634,6 +1796,8 @@ void VisuGUI_TimeAnimationDlg::createFrames() // when a range or a sequence of the animation has been changed if( isRegenerate ) { + GeneratePresentations(i,myAnimator); + /* VISU::ColoredPrs3d_i* aPrs3d = dynamic_cast(aFieldData.myPrs[0]); if( !aPrs3d ) continue; @@ -1649,6 +1813,7 @@ void VisuGUI_TimeAnimationDlg::createFrames() aColoredPrs3d->SetTitle(aTitle.c_str()); } } + */ } } if( isRegenerate ) diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.h b/src/VISUGUI/VisuGUI_TimeAnimation.h index d472288d..400f8513 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.h +++ b/src/VISUGUI/VisuGUI_TimeAnimation.h @@ -48,6 +48,7 @@ class VISU_TimeAnimation; namespace VISU { class Prs3d_i; + class PointMap3d_i; } class SVTK_ViewWindow; @@ -114,6 +115,7 @@ class ArrangeDlg: public QDialog int myCurrent; QMap myPrsMap; + QMap myPointMapPrsMap; }; diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index ef30aef2..6df04f65 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -381,6 +381,79 @@ namespace VISU theSelectionMgr->setSelectedObjects(aNewListIO); } + /*! + * \brief Check, if the object can be deleted + * + * \param theEntry - entry of the object to check + * \param theModule - is used to access Study and VISU_Gen + * \retval bool - returns TRUE if the object is removable + */ + bool + IsRemovable (const std::string theEntry, + const SalomeApp_Module* theModule) + { + // asv : if selected object is a Save Point object selected in object browser - return false + if ( QString( theEntry.c_str() ).startsWith( QObject::tr( "SAVE_POINT_DEF_NAME" ) ) ) + return false; + + _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule)); + + _PTR(SObject) aSObject = aStudy->FindObjectID(theEntry); + VISU::Storable::TRestoringMap pMap; + if (aSObject) { + CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject); + if (!CORBA::is_nil(aCORBAObject)) { + VISU::RemovableObject_var aRemovableObj = VISU::RemovableObject::_narrow(aCORBAObject); + if (CORBA::is_nil(aRemovableObj)) { + // Not removable CORBA object + return false; + } + } else { + // Can be removed, if lays directly under VISU + // (first sub-level) or is a child of such an object + string aNAME, aVisuNAME = GetVisuGen(theModule)->ComponentDataType(); + _PTR(GenericAttribute) anAttr; + _PTR(AttributeString) aComment; + + bool isUnderVISU = false; + _PTR(SObject) aFatherSObject = aSObject->GetFather(); + if (aFatherSObject->FindAttribute(anAttr, "AttributeName")) { + // mkr : 24.11.2006 : use AttributeName and module title for correct "Delete" + // popup item displaying in object browser popup + _PTR(AttributeName) aComment (anAttr); + aNAME = aComment->Value(); + QString aVisuTITLE = theModule->getApp()->moduleTitle(aVisuNAME.c_str()); + if (!aVisuTITLE.compare(aNAME.c_str())) { + isUnderVISU = true; + } + } + if (!isUnderVISU) { + // Not directly under VISU component, check father + aCORBAObject = VISU::ClientSObjectToObject(aFatherSObject); + if (!CORBA::is_nil(aCORBAObject)) { + // Father has IOR + return false; + } + + isUnderVISU = false; + aFatherSObject = aFatherSObject->GetFather(); + if (aFatherSObject->FindAttribute(anAttr, "AttributeString")) { + _PTR(AttributeString) aComment (anAttr); + aNAME = aComment->Value(); + if (aNAME == aVisuNAME) { + isUnderVISU = true; + } + } + if (!isUnderVISU) { + // Father is not directly under VISU component + return false; + } + } + } + } + return true; + } + /*! * \brief Check, if "Delete" popup-menu can be put on current selection * @@ -404,64 +477,8 @@ namespace VISU for (; anIter.More(); anIter.Next()) { Handle(SALOME_InteractiveObject) anIO = anIter.Value(); if (anIO->hasEntry()) { - - // asv : if selected object is a Save Point object selected in object browser - return false - if ( QString( anIO->getEntry() ).startsWith( QObject::tr( "SAVE_POINT_DEF_NAME" ) ) ) - return false; - - _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry()); - VISU::Storable::TRestoringMap pMap; - if (aSObject) { - CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject); - if (!CORBA::is_nil(aCORBAObject)) { - VISU::RemovableObject_var aRemovableObj = VISU::RemovableObject::_narrow(aCORBAObject); - if (CORBA::is_nil(aRemovableObj)) { - // Not removable CORBA object - return false; - } - } else { - // Can be removed, if lays directly under VISU - // (first sub-level) or is a child of such an object - string aNAME, aVisuNAME = GetVisuGen(theModule)->ComponentDataType(); - _PTR(GenericAttribute) anAttr; - _PTR(AttributeString) aComment; - - bool isUnderVISU = false; - _PTR(SObject) aFatherSObject = aSObject->GetFather(); - if (aFatherSObject->FindAttribute(anAttr, "AttributeName")) { - // mkr : 24.11.2006 : use AttributeName and module title for correct "Delete" - // popup item displaying in object browser popup - _PTR(AttributeName) aComment (anAttr); - aNAME = aComment->Value().c_str(); - QString aVisuTITLE = theModule->getApp()->moduleTitle(QString(aVisuNAME.c_str())); - if (!aVisuTITLE.compare(QString(aNAME.c_str()))) { - isUnderVISU = true; - } - } - if (!isUnderVISU) { - // Not directly under VISU component, check father - aCORBAObject = VISU::ClientSObjectToObject(aFatherSObject); - if (!CORBA::is_nil(aCORBAObject)) { - // Father has IOR - return false; - } - - isUnderVISU = false; - aFatherSObject = aFatherSObject->GetFather(); - if (aFatherSObject->FindAttribute(anAttr, "AttributeString")) { - _PTR(AttributeString) aComment (anAttr); - aNAME = aComment->Value(); - if (aNAME == aVisuNAME) { - isUnderVISU = true; - } - } - if (!isUnderVISU) { - // Father is not directly under VISU component - return false; - } - } - } - } + if (!IsRemovable(anIO->getEntry(), theModule)) + return false; } } return true; @@ -540,32 +557,58 @@ namespace VISU if(aSelectionInfo.empty()) return; + VISU::Prs3d_i* aPrs3d; + VISU::PointMap3d_i* aTable; + VISU_Actor* anActor; + VISU_ActorBase* anActorBase; + TSelectionItem aSelectionItem = aSelectionInfo.front(); - VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase); - if(!aPrs3d) - return; + aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase); + if(!aPrs3d) { + aTable = dynamic_cast(aSelectionItem.myObjectInfo.myBase); + if(!aTable) + return; + } SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(theModule); if(!aViewWindow) return; - VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d); - if(!anActor) - return; + if (aPrs3d) { + anActor = FindActor(aViewWindow, aPrs3d); + if(!anActor) + return; + } else { + anActorBase = VISU::FindActorBase(aViewWindow, aTable); + if(!anActorBase) + return; + } switch (theType) { case VISU::SHRINK: + if (aPrs3d) { if (anActor->IsShrunk()) anActor->UnShrink(); else anActor->SetShrink(); + } else if (aTable) { + if (anActorBase->IsShrunk()) + anActorBase->UnShrink(); + else + anActorBase->SetShrink(); + } break; default: - if (VISU::Mesh_i* aMesh = dynamic_cast(aPrs3d)) { - aMesh->SetPresentationType(theType); - RecreateActor(theModule, aMesh); - } else { - anActor->SetRepresentation(theType); + if (aPrs3d) { + if (VISU::Mesh_i* aMesh = dynamic_cast(aPrs3d)) { + aMesh->SetPresentationType(theType); + RecreateActor(theModule, aMesh); + } else { + anActor->SetRepresentation(theType); + } + } + else if (aTable) { + anActorBase->SetRepresentation(theType); } } aViewWindow->Repaint(); @@ -730,6 +773,17 @@ namespace VISU return FindActor(theViewWindow, aPrs3d); } + //------------------------------------------------------------ + VISU_ActorBase* + FindActorBase(const SalomeApp_Study* theStudy, + SVTK_ViewWindow* theViewWindow, + const QString& theEntry) + { + TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry.toLatin1().constData()); + VISU::PointMap3d_i* aTable = dynamic_cast(anObjectInfo.myBase); + return FindActorBase(theViewWindow, aTable); + } + //------------------------------------------------------------ void RecreateActor (const SalomeApp_Module* theModule, @@ -979,17 +1033,32 @@ namespace VISU aPlot->getCurves( clist ); SPlot2d_Curve* plotCurve = 0; SPlot2d_Curve* tmpCurve; - for (int i = 0; i < clist.count(); i++) { - tmpCurve = dynamic_cast(clist.at(i)); - if (tmpCurve && tmpCurve->hasIO() && - theCurve->GetEntry() != tmpCurve->getIO()->getEntry()) { - plotCurve = tmpCurve; - } else if (theDisplaying == VISU::eDisplayOnly) { - aPlot->eraseCurve(clist.at(i)); + if(theDisplaying == VISU::eErase) { + // 23.06.2008 skl for IPAL17672 + for (int i = 0; i < clist.count(); i++) { + tmpCurve = dynamic_cast(clist.at(i)); + if (tmpCurve && tmpCurve->hasIO() && + theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) { + plotCurve = tmpCurve; + aPlot->eraseCurve(clist.at(i)); + break; + } } + UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying); + } + else { + for (int i = 0; i < clist.count(); i++) { + tmpCurve = dynamic_cast(clist.at(i)); + if (tmpCurve && tmpCurve->hasIO() && + theCurve->GetEntry() != tmpCurve->getIO()->getEntry()) { + plotCurve = tmpCurve; + } + else if (theDisplaying == VISU::eDisplayOnly) { + aPlot->eraseCurve(clist.at(i)); + } + } + UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying); } - - UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying); aPlot->Repaint(); } @@ -1057,7 +1126,9 @@ namespace VISU } } aPlot->Repaint(); - aPlot->fitAll(); + if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){ + aPlot->fitAll(); + } qApp->processEvents(); } @@ -1169,7 +1240,9 @@ namespace VISU if(av)(const_cast(av))->OnEraseAll(); } PublishMeshInView(theModule, pPresent, theViewWindow); - SetFitAll(theViewWindow); + if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){ + SetFitAll(theViewWindow); + } #ifdef CHECKTIME timer.Stop(); MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH"); @@ -1228,6 +1301,7 @@ namespace VISU case VISU::TSTREAMLINES: case VISU::TPLOT3D: case VISU::TSCALARMAPONDEFORMEDSHAPE: + case VISU::TDEFORMEDSHAPEANDSCALARMAP: { PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject); if (aServant.in()) { diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index 8e69af3d..e5d8510b 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -127,6 +127,8 @@ namespace VISU void Remove(LightApp_SelectionMgr* theSelectionMgr, const Handle(SALOME_InteractiveObject)& theIO); + bool IsRemovable (const std::string theEntry, + const SalomeApp_Module* theModule); bool IsRemovableSelected(const SalomeApp_Module* theModule); void DeleteSObject(VisuGUI* theModule, @@ -168,6 +170,9 @@ namespace VISU VISU_Actor* FindActor(const SalomeApp_Study* theStudy, SVTK_ViewWindow* theViewWindow, const QString& theEntry); + VISU_ActorBase* FindActorBase(const SalomeApp_Study* theStudy, + SVTK_ViewWindow* theViewWindow, + const QString& theEntry); void RecreateActor(const SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs); diff --git a/src/VISUGUI/VisuGUI_TransparencyDlg.cxx b/src/VISUGUI/VisuGUI_TransparencyDlg.cxx index b470b5a0..ba83ec2d 100644 --- a/src/VISUGUI/VisuGUI_TransparencyDlg.cxx +++ b/src/VISUGUI/VisuGUI_TransparencyDlg.cxx @@ -217,6 +217,11 @@ void VisuGUI_TransparencyDlg::SetTransparency() VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), myViewWindow, anIO->getEntry()); if (anActor) anActor->SetOpacity(opacity); + else { + VISU_ActorBase* anActor = VISU::FindActorBase(VISU::GetAppStudy(myModule), myViewWindow, anIO->getEntry()); + if (anActor) + anActor->SetOpacity(opacity); + } } myViewWindow->Repaint(); } diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.cxx b/src/VISUGUI/VisuGUI_VectorsDlg.cxx index b0f4bdcc..ed7bcc57 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.cxx +++ b/src/VISUGUI/VisuGUI_VectorsDlg.cxx @@ -91,7 +91,11 @@ VisuGUI_VectorsDlg::VisuGUI_VectorsDlg (SalomeApp_Module* theModule) ScaleLabel = new QLabel (tr("LBL_SCALE_FACTOR"), TopGroup ); ScalFact = new QtxDoubleSpinBox( 1e-20, 1.0E+38, 0.1, TopGroup ); - ScalFact->setDecimals( 5 ); + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 ); + + ScalFact->setDecimals( aPrecision*(-1) ); // ScalFact->setDecimals( 5 ); ScalFact->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); ScalFact->setValue( 0.1 ); @@ -322,9 +326,20 @@ void VisuGUI_VectorsDlg::enableSetColor() /*! Sets Scale factor */ -void VisuGUI_VectorsDlg::setScaleFactor( double sf ) +void VisuGUI_VectorsDlg::setScaleFactor( double theFactor ) { - ScalFact->setValue( sf ); + double i=0.1; + while (1) { // Calculate Step & Precission + if ( int (theFactor/i) > 0) + break; + else { + i = i*0.1; + } + } + + ScalFact->setSingleStep(i); + + ScalFact->setValue( theFactor ); } /*! diff --git a/src/VISU_I/Makefile.am b/src/VISU_I/Makefile.am index a4ff436a..0bc6b6ac 100644 --- a/src/VISU_I/Makefile.am +++ b/src/VISU_I/Makefile.am @@ -50,10 +50,14 @@ salomeinclude_HEADERS = \ VISU_ViewManager_i.hh \ VISU_View_i.hh \ VISU_TimeAnimation.h \ - VISU_ScalarMapOnDeformedShape_i.hh \ + VISU_DeformedShapeAndScalarMap_i.hh \ VISU_ColoredPrs3dFactory.hh \ + VISU_MonoColorPrs_i.hh \ + VISU_Deformation_i.hh \ + VISU_OptionalDeformation_i.hh \ SALOME_GenericObjPointer.hh + libVISUEngineImpl_la_SOURCES = \ VISUConfig.cc \ VISU_Result_i.cc \ @@ -74,7 +78,7 @@ libVISUEngineImpl_la_SOURCES = \ VISU_CutLines_i.cc \ VISU_Vectors_i.cc \ VISU_StreamLines_i.cc \ - VISU_ScalarMapOnDeformedShape_i.cc \ + VISU_DeformedShapeAndScalarMap_i.cc \ VISU_ColoredPrs3dCache_i.cc \ VISU_ColoredPrs3dHolder_i.cc \ VISU_ColoredPrs3dFactory.cc \ @@ -85,6 +89,9 @@ libVISUEngineImpl_la_SOURCES = \ VISU_Table_i.cc \ VISU_PointMap3d_i.cc \ VISU_DumpPython.cc \ + VISU_MonoColorPrs_i.cc \ + VISU_Deformation_i.cc \ + VISU_OptionalDeformation_i.cc \ SALOME_GenericObjPointer.cc MOC_FILES = VISU_TimeAnimation_moc.cxx diff --git a/src/VISU_I/VISUConfig.cc b/src/VISU_I/VISUConfig.cc index 2ff2fd7f..073d07c8 100644 --- a/src/VISU_I/VISUConfig.cc +++ b/src/VISU_I/VISUConfig.cc @@ -214,8 +214,8 @@ namespace VISU return VISU::TISOSURFACES; if ( theComment == "DEFORMEDSHAPE" ) return VISU::TDEFORMEDSHAPE; - if ( theComment == "SCALARMAPONDEFORMEDSHAPE" ) - return VISU::TSCALARMAPONDEFORMEDSHAPE; + if ( theComment == "DEFORMEDSHAPEANDSCALARMAP" ) + return VISU::TDEFORMEDSHAPEANDSCALARMAP; if ( theComment == "GAUSSPOINTS" ) return VISU::TGAUSSPOINTS; if ( theComment == "PLOT3D" ) diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 76fee4fb..9e833c82 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -47,6 +47,8 @@ #include +#include "utilities.h" + #ifdef _DEBUG_ static int MYDEBUG = 0; #else @@ -390,7 +392,7 @@ VISU::ColoredPrs3dCache_i ::CreateHolder(VISU::VISUType theType, const VISU::ColoredPrs3dHolder::BasicInput& theInput) { - if(MYDEBUG) cout << "CreateHolder " << theType << endl; + if(MYDEBUG) MESSAGE ("CreateHolder "<GetEntry().c_str() << " " << aList.size() << endl; + if(MYDEBUG) MESSAGE("GetLastVisitedPrs " << theHolder->GetEntry().c_str() << " " << aList.size() ); if( !aList.empty() ) return aList.front(); return VISU::TPrs3dPtr(); @@ -622,7 +624,7 @@ VISU::ColoredPrs3dCache_i const VISU::ColoredPrs3dHolder::BasicInput& theInput, VISU::View3D_ptr theView3D) { - if(MYDEBUG) cout << "VISU::ColoredPrs3dCache_i::UpdateLastVisitedPrs" << endl; + if(MYDEBUG) MESSAGE( "VISU::ColoredPrs3dCache_i::UpdateLastVisitedPrs" ); TPrs3dPtr aPrs3d; try{ TPrs3dPtr aLastVisitedPrs3d = GetLastVisitedPrs(theHolder); @@ -633,12 +635,12 @@ VISU::ColoredPrs3dCache_i CORBA::Float aRequiredMemory = 0.0; if(aPrs3d = FindPrsByInput(aLastVisitedPrsList, theInput)){ aLastVisitedPrsList.push_front(aPrs3d); - if(MYDEBUG) cout << "FindPrsByInput " << aPrs3d << endl; + if(MYDEBUG) MESSAGE( "FindPrsByInput " << aPrs3d ); }else if(anIsCheckPossible && IsPossible(aPrsType, theInput, aRequiredMemory, aHolderEntry)){ if( aRequiredMemory > 1.0 / VTK_LARGE_FLOAT ) ClearMemory(aRequiredMemory, aHolderEntry); aPrs3d = CreatePrs(aPrsType, theInput, theHolder); - if(MYDEBUG) cout << "Created " << aPrs3d << endl; + if(MYDEBUG) MESSAGE( "Created " << aPrs3d ); }else{ aPrs3d = aLastVisitedPrsList.back(); aPrs3d->SetResultObject(theInput.myResult); @@ -648,12 +650,21 @@ VISU::ColoredPrs3dCache_i aPrs3d->SetTimeStampNumber(theInput.myTimeStampNumber); aLastVisitedPrsList.pop_back(); aLastVisitedPrsList.push_front(aPrs3d); - if(MYDEBUG) cout << "Move only " << aPrs3d << endl; + if(MYDEBUG) MESSAGE( "Move only " << aPrs3d ); } //if(MYDEBUG) PrintCache(); aPrs3d->SameAs(thePrs); - aPrs3d->UpdateActors(); + + // special case for deformed shape + VISU::DeformedShapeAndScalarMap_i* dShape = + dynamic_cast( aPrs3d.get() ); + if ( dShape && dShape->GetScalarTimeStampNumber() != theInput.myTimeStampNumber ) + { + dShape->SetScalarField( dShape->GetScalarEntity(), + dShape->GetScalarFieldName(), theInput.myTimeStampNumber ); + } + if(CORBA::is_nil(theView3D)) return false; @@ -697,6 +708,8 @@ VISU::ColoredPrs3dCache_i aPrs3d->SetActiveState(true); } + + aPrs3d->UpdateActors(); ProcessVoidEvent(new TRenderEvent(aViewWindow)); //aViewWindow->getRenderWindow()->Render(); return true; @@ -761,8 +774,8 @@ VISU::ColoredPrs3dCache_i { if(MYDEBUG) { - cout << "--------------CACHE-----------------" << endl; - cout << "Cache memory - " << GetMemorySize() << " Mb" << endl; + MESSAGE_BEGIN(std::endl << "--------------CACHE-----------------" ); + MESSAGE_ADD(std::endl << "Cache memory - " << GetMemorySize() << " Mb" ); TColoredPrs3dHolderMap::const_iterator aHolderIter = myHolderMap.begin(); TColoredPrs3dHolderMap::const_iterator aHolderIterEnd = myHolderMap.end(); for(; aHolderIter != aHolderIterEnd; aHolderIter++){ @@ -770,19 +783,18 @@ VISU::ColoredPrs3dCache_i TLastVisitedPrsList::const_iterator aPrsIter = aPrsList.begin(); TLastVisitedPrsList::const_iterator aPrsIterEnd = aPrsList.end(); - cout << "--------------------------" << endl; - cout << "Holder - " << aHolderIter->first.c_str() << endl; - cout << "Size - " << aPrsList.size() << endl; + MESSAGE_ADD(std::endl << "--------------------------" ); + MESSAGE_ADD(std::endl << "Holder - " << aHolderIter->first.c_str() ); + MESSAGE_ADD(std::endl << "Size - " << aPrsList.size() ); for(; aPrsIter != aPrsIterEnd; aPrsIter++) if(TPrs3dPtr aPrs3d = *aPrsIter) { - cout << aPrs3d << " (" << aPrs3d->GetMemorySize() << " Mb)"; + MESSAGE_ADD(std::endl << aPrs3d << " (" << aPrs3d->GetMemorySize() << " Mb)"); if(aPrsIter == aPrsList.begin()) - cout << " (device)"; - cout << endl; + MESSAGE_ADD( " (device)" ); } } - cout << "------------------------------------" << endl; + MESSAGE_END(std::endl << "------------------------------------" ); } } diff --git a/src/VISU_I/VISU_ColoredPrs3dFactory.cc b/src/VISU_I/VISU_ColoredPrs3dFactory.cc index cff778da..0aee75f2 100644 --- a/src/VISU_I/VISU_ColoredPrs3dFactory.cc +++ b/src/VISU_I/VISU_ColoredPrs3dFactory.cc @@ -97,7 +97,8 @@ namespace VISU case TDEFORMEDSHAPE: return VISU::CreatePrs3dByEnum(theStudy, thePublishInStudyMode); case TSCALARMAPONDEFORMEDSHAPE: - return VISU::CreatePrs3dByEnum(theStudy, thePublishInStudyMode); + case TDEFORMEDSHAPEANDSCALARMAP: + return VISU::CreatePrs3dByEnum(theStudy, thePublishInStudyMode); case TISOSURFACES: return VISU::CreatePrs3dByEnum(theStudy, thePublishInStudyMode); case TSTREAMLINES: @@ -201,7 +202,8 @@ namespace VISU aMemory = CheckIsPossible(theInput, theMemoryCheck); break; case TSCALARMAPONDEFORMEDSHAPE: - aMemory = CheckIsPossible(theInput, theMemoryCheck); + case TDEFORMEDSHAPEANDSCALARMAP: + aMemory = CheckIsPossible(theInput, theMemoryCheck); break; case TISOSURFACES: aMemory = CheckIsPossible(theInput, theMemoryCheck); diff --git a/src/VISU_I/VISU_ColoredPrs3dFactory.hh b/src/VISU_I/VISU_ColoredPrs3dFactory.hh index eae438dd..98ee08f2 100644 --- a/src/VISU_I/VISU_ColoredPrs3dFactory.hh +++ b/src/VISU_I/VISU_ColoredPrs3dFactory.hh @@ -33,7 +33,7 @@ #include "VISU_I.hxx" #include "SALOME_GenericObjPointer.hh" -#include "VISU_ScalarMapOnDeformedShape_i.hh" +#include "VISU_DeformedShapeAndScalarMap_i.hh" #include "VISU_Plot3D_i.hh" #include "VISU_GaussPoints_i.hh" #include "VISU_StreamLines_i.hh" @@ -52,7 +52,8 @@ namespace VISU namespace TL { //---------------------------------------------------------------------------- - typedef TList > > > > > > > > > + TNullType> > > > > > > > > > > TColoredPrs3dTypeList; typedef TList, + TList, TList, TList, TList, @@ -76,7 +78,7 @@ namespace VISU TList, TList, TList, - TNullType> > > > > > > > > > + TNullType> > > > > > > > > > > TColoredPrs3dEnumList; diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 2bdb127f..787eba58 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -170,6 +170,12 @@ VISU::ColoredPrs3d_i:: ColoredPrs3d_i(EPublishInStudyMode thePublishInStudyMode) : myPublishInStudyMode(thePublishInStudyMode), myIsTimeStampFixed(thePublishInStudyMode == EPublishUnderTimeStamp), + myEntity( VISU::Entity( -1 ) ), + myPreviousEntity( VISU::Entity( -1 ) ), + myTimeStampNumber( -1 ), + myPreviousTimeStampNumber( -1 ), + myIsUnits( true ), + myOrientation( VISU::ColoredPrs3dBase::HORIZONTAL ), myColoredPL(NULL), myIsFixedRange(false), myIsRestored(true) @@ -341,7 +347,7 @@ void VISU::ColoredPrs3d_i ::SetEntity(VISU::Entity theEntity) { - if(myEntity == theEntity) + if ( myEntity == theEntity ) return; VISU::TSetModified aModified(this); @@ -425,7 +431,7 @@ void VISU::ColoredPrs3d_i ::SetTimeStampNumber(CORBA::Long theTimeStampNumber) { - if(myTimeStampNumber == theTimeStampNumber) + if ( myTimeStampNumber == theTimeStampNumber ) return; VISU::TSetModified aModified(this); @@ -710,14 +716,14 @@ VISU::ColoredPrs3d_i SetShadowTitle(anOrigin->IsShadowTitle()); SetTitFontType(anOrigin->GetTitFontType()); vtkFloatingPointType r,g,b; - anOrigin->GetTitleColor(&r,&g,&b); + anOrigin->GetTitleColor(r,g,b); SetTitleColor(r,g,b); SetBoldLabel(anOrigin->IsBoldLabel()); SetItalicLabel(anOrigin->IsItalicLabel()); SetShadowLabel(anOrigin->IsShadowLabel()); SetLblFontType(anOrigin->GetLblFontType()); - anOrigin->GetLabelColor(&r,&g,&b); + anOrigin->GetLabelColor(r,g,b); SetLabelColor(r,g,b); myIsTimeStampFixed = anOrigin->IsTimeStampFixed(); @@ -931,7 +937,7 @@ void VISU::ColoredPrs3d_i ::SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theOrientation) { - if(myOrientation == theOrientation) + if ( myOrientation == theOrientation ) return; VISU::TSetModified aModified(this); @@ -1177,13 +1183,15 @@ VISU::ColoredPrs3d_i //---------------------------------------------------------------------------- void VISU::ColoredPrs3d_i -::SetUnitsVisible(CORBA::Boolean isVisible) +::SetUnitsVisible(CORBA::Boolean theIsVisible) { - if( myIsUnits != isVisible ){ - VISU::TSetModified aModified(this); - myIsUnits = isVisible; - myParamsTime.Modified(); - } + if ( myIsUnits == theIsVisible ) + return; + + VISU::TSetModified aModified( this ); + + myIsUnits = theIsVisible; + myParamsTime.Modified(); } //---------------------------------------------------------------------------- @@ -1293,13 +1301,13 @@ VISU::ColoredPrs3d_i //---------------------------------------------------------------------------- void VISU::ColoredPrs3d_i -::GetTitleColor(vtkFloatingPointType* theR, - vtkFloatingPointType* theG, - vtkFloatingPointType* theB) +::GetTitleColor(vtkFloatingPointType& theR, + vtkFloatingPointType& theG, + vtkFloatingPointType& theB) { - *theR = myTitleColor[0]; - *theG = myTitleColor[1]; - *theB = myTitleColor[2]; + theR = myTitleColor[0]; + theG = myTitleColor[1]; + theB = myTitleColor[2]; } //---------------------------------------------------------------------------- @@ -1414,13 +1422,13 @@ VISU::ColoredPrs3d_i //---------------------------------------------------------------------------- void VISU::ColoredPrs3d_i -::GetLabelColor(vtkFloatingPointType* theR, - vtkFloatingPointType* theG, - vtkFloatingPointType* theB) +::GetLabelColor(vtkFloatingPointType& theR, + vtkFloatingPointType& theG, + vtkFloatingPointType& theB) { - *theR = myLabelColor[0]; - *theG = myLabelColor[1]; - *theB = myLabelColor[2]; + theR = myLabelColor[0]; + theG = myLabelColor[1]; + theB = myLabelColor[2]; } //---------------------------------------------------------------------------- @@ -1593,9 +1601,11 @@ VISU::ColoredPrs3d_i QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) ); - myTitleColor[0] = aTextColor.red() / 255; - myTitleColor[1] = aTextColor.green() / 255; - myTitleColor[2] = aTextColor.blue() / 255; + SetTitleColor(aTextColor.red()/255., aTextColor.green()/255., aTextColor.blue()/255.); + + myTitleColor[0] = aTextColor.red() / 255.; + myTitleColor[1] = aTextColor.green() / 255.; + myTitleColor[2] = aTextColor.blue() / 255.; myIsBoldLabel = myIsItalicLabel = myIsShadowLabel = true; myLblFontType = VTK_ARIAL; @@ -1616,9 +1626,11 @@ VISU::ColoredPrs3d_i QColor aLabelColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) ); - myLabelColor[0] = aLabelColor.red() / 255; - myLabelColor[1] = aLabelColor.green() / 255; - myLabelColor[2] = aLabelColor.blue() / 255; + SetLabelColor(aLabelColor.red()/255., aLabelColor.green()/255., aLabelColor.blue()/255.); + + myLabelColor[0] = aLabelColor.red() / 255.; + myLabelColor[1] = aLabelColor.green() / 255.; + myLabelColor[2] = aLabelColor.blue() / 255.; return this; } diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 50177693..9046637c 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -483,9 +483,9 @@ namespace VISU virtual void - GetTitleColor(vtkFloatingPointType* theR, - vtkFloatingPointType* theG, - vtkFloatingPointType* theB); + GetTitleColor(vtkFloatingPointType& theR, + vtkFloatingPointType& theG, + vtkFloatingPointType& theB); virtual void @@ -527,9 +527,9 @@ namespace VISU virtual void - GetLabelColor(vtkFloatingPointType* theR, - vtkFloatingPointType* theG, - vtkFloatingPointType* theB); + GetLabelColor(vtkFloatingPointType& theR, + vtkFloatingPointType& theG, + vtkFloatingPointType& theB); virtual void diff --git a/src/VISU_I/VISU_CorbaMedConvertor.cxx b/src/VISU_I/VISU_CorbaMedConvertor.cxx index 385ca3f2..1bdcf0ae 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -37,6 +37,8 @@ #include "ReceiverFactory.hxx" #include "MED_SliceArray.hxx" +#include "utilities.h" + #define USER_INTERLACE MED_FULL_INTERLACE #ifdef _DEBUG_ @@ -588,13 +590,13 @@ namespace else aGeom2ProfileIds = aSupport->getNumberFromFile(aMGeom); int aLen = aGeom2ProfileIds->length(); - if(MYDEBUG) MESSAGE(" - aMGeom="<" << anId << endl; + if(MYDEBUG) MESSAGE_ADD(std::endl << "------------------------------->" << anId); } - if(MYDEBUG) cout << endl; + if(MYDEBUG) MESSAGE_END(" "); } catch(...) { continue; } diff --git a/src/VISU_I/VISU_CutLines_i.cc b/src/VISU_I/VISU_CutLines_i.cc index cdb55177..e329711c 100644 --- a/src/VISU_I/VISU_CutLines_i.cc +++ b/src/VISU_I/VISU_CutLines_i.cc @@ -102,6 +102,7 @@ VISU::CutLines_i:: CutLines_i(EPublishInStudyMode thePublishInStudyMode) : ColoredPrs3d_i(thePublishInStudyMode), ScalarMap_i(thePublishInStudyMode), + myUseAbsLength( false ), myCutLinesPL(NULL) {} @@ -551,7 +552,7 @@ void VISU::CutLines_i ::SetUseAbsoluteLength(CORBA::Boolean theAbsLength) { - if(myUseAbsLength == theAbsLength) + if ( myUseAbsLength == theAbsLength ) return; VISU::TSetModified aModified(this); diff --git a/src/VISU_I/VISU_CutPlanes_i.cc b/src/VISU_I/VISU_CutPlanes_i.cc index 55856310..4592dea6 100644 --- a/src/VISU_I/VISU_CutPlanes_i.cc +++ b/src/VISU_I/VISU_CutPlanes_i.cc @@ -25,6 +25,7 @@ // Module : VISU #include "VISU_CutPlanesPL.hxx" +#include "VISU_Convertor.hxx" #include "VISU_Prs3dUtils.hh" #include "VISU_CutPlanes_i.hh" @@ -41,6 +42,7 @@ static int MYDEBUG = 0; #endif + //---------------------------------------------------------------------------- size_t VISU::CutPlanes_i @@ -95,8 +97,12 @@ VISU::CutPlanes_i ::CutPlanes_i(EPublishInStudyMode thePublishInStudyMode): ColoredPrs3d_i(thePublishInStudyMode), ScalarMap_i(thePublishInStudyMode), - myCutPlanesPL(NULL) -{} + myCutPlanesPL(NULL), + Deformation_i(this), + OptionalDeformation_i(this) +{ + if(MYDEBUG) MESSAGE("CutPlanes_i::CutPlanes_i()"); +} //---------------------------------------------------------------------------- @@ -131,6 +137,8 @@ VISU::CutPlanes_i if(aCondList[i].toInt() == 0) SetPlanePosition(i,aPosList[i].toDouble()); + OptionalDeformation_i::RestoreDeformation(theSObject,theMap); + return this; } @@ -152,6 +160,7 @@ void VISU::CutPlanes_i::ToStream(std::ostringstream& theStr){ } Storable::DataToStream( theStr, "myPlanePosition", (const char*)aStrPos.toLatin1()); Storable::DataToStream( theStr, "myPlaneCondition", (const char*)aStrCon.toLatin1()); + OptionalDeformation_i::DeformationToStream(theStr); } @@ -321,6 +330,7 @@ VISU::CutPlanes_i }else myCutPlanesPL = dynamic_cast(thePipeLine); + InitDeformedPipeLine(myCutPlanesPL); TSuperClass::CreatePipeLine(myCutPlanesPL); } @@ -348,3 +358,10 @@ VISU::CutPlanes_i return NULL; } +void +VISU::CutPlanes_i:: +SameAs(const Prs3d_i* theOrigin){ + if(MYDEBUG) MESSAGE("CutPlanes_i::SameAs()"); + TSuperClass::SameAs(theOrigin); + OptionalDeformation_i::SameAsDeformation(dynamic_cast(theOrigin)); +} diff --git a/src/VISU_I/VISU_CutPlanes_i.hh b/src/VISU_I/VISU_CutPlanes_i.hh index 9386f9f3..8a5f9355 100644 --- a/src/VISU_I/VISU_CutPlanes_i.hh +++ b/src/VISU_I/VISU_CutPlanes_i.hh @@ -28,6 +28,7 @@ #define VISU_CutPlanes_i_HeaderFile #include "VISU_ScalarMap_i.hh" +#include "VISU_OptionalDeformation_i.hh" class VISU_CutPlanesPL; @@ -35,7 +36,8 @@ namespace VISU { //---------------------------------------------------------------------------- class VISU_I_EXPORT CutPlanes_i : public virtual POA_VISU::CutPlanes, - public virtual ScalarMap_i + public virtual ScalarMap_i, + public virtual OptionalDeformation_i { static int myNbPresent; CutPlanes_i(const CutPlanes_i&); @@ -157,6 +159,10 @@ namespace VISU Restore(SALOMEDS::SObject_ptr theSObject, const Storable::TRestoringMap& theMap); + virtual + void + SameAs(const Prs3d_i* theOrigin); + //! Redefines VISU_ColoredPrs3d_i::CreateActor virtual VISU_Actor* diff --git a/src/VISU_I/VISU_Deformation_i.cc b/src/VISU_I/VISU_Deformation_i.cc new file mode 100755 index 00000000..507a9476 --- /dev/null +++ b/src/VISU_I/VISU_Deformation_i.cc @@ -0,0 +1,166 @@ +// Copyright (C) 2008 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 : VISU_Deformation_i.cc +// Author : +// Module : VISU + +#include "VISU_Deformation_i.hh" +#include "VISU_Result_i.hh" +#include "VISU_Prs3dUtils.hh" + +#include "VISU_DeformationPL.hxx" +#include "VISU_Convertor.hxx" +#include "VISU_DeformationPL.hxx" +#include "VISUConfig.hh" + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +//--------------------------------------------------------------- +VISU::Deformation_i::Deformation_i(VISU::ColoredPrs3d_i *thePrs3d): + myColoredPrs3d(thePrs3d) +{ + if(MYDEBUG) MESSAGE("Deformation_i::Deformation_i()"); +} + +//--------------------------------------------------------------- +VISU::Deformation_i::~Deformation_i() +{ + if(MYDEBUG) MESSAGE("Deformation_i::~Deformation_i()"); +} + +//--------------------------------------------------------------- +void VISU::Deformation_i::SetScale(CORBA::Double theScale) +{ + if(MYDEBUG) MESSAGE("Deformation_i::SetScale()"); + + VISU::TSetModified aModified(GetColoredPrs3d()); + + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificDeformedPL(), &VISU_DeformationPL::SetScale, theScale)); +} + +//--------------------------------------------------------------- +void VISU::Deformation_i::InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine){ + + if(MYDEBUG) MESSAGE("Deformation_i::InitDeformedPipeLine()"); + myDeformationPL = theDeformedPipeLine; +} + +//--------------------------------------------------------------- +CORBA::Double +VISU::Deformation_i +::GetScale() +{ + if(MYDEBUG) MESSAGE("Deformation_i::GetScale()"); + return GetSpecificDeformedPL()->GetScale(); +} + +//--------------------------------------------------------------- +VISU::Entity VISU::Deformation_i::GetVectorialFieldEntity(){ + return myVectorialEntity; +} + +//--------------------------------------------------------------- +char* VISU::Deformation_i::GetVectorialFieldName(){ + return CORBA::string_dup(myVectorialFieldName.c_str()); +} + +//--------------------------------------------------------------- +void VISU::Deformation_i:: +DeformationToStream(std::ostringstream& theStr) +{ + Storable::DataToStream(theStr,"myScaleFactor", GetScale()); + Storable::DataToStream(theStr,"myVectorialField", GetVectorialFieldName()); + Storable::DataToStream(theStr,"myVectorialEntiry", GetVectorialFieldEntity()); + +} + +//--------------------------------------------------------------- +void +VISU::Deformation_i::RestoreDeformation(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap) +{ + SetScale(VISU::Storable::FindValue(theMap,"myScaleFactor").toDouble()); + VISU::Entity anEntity = VISU::Entity(VISU::Storable::FindValue(theMap, "myVectorialEntiry").toInt()); + + SetVectorialField(anEntity, + VISU::Storable::FindValue(theMap, "myVectorialField").toLatin1().constData()); +} + +//--------------------------------------------------------------- +void +VISU::Deformation_i::SameAsDeformation(const Deformation_i *aDeformedPrs){ + if(const Deformation_i* aPrs = dynamic_cast(aDeformedPrs)) { + Deformation_i* anOrigin = const_cast(aPrs); + + CORBA::String_var aVectorialFieldName = anOrigin->GetVectorialFieldName(); + VISU::Entity anEntity = anOrigin->GetVectorialFieldEntity(); + this->SetVectorialField(anEntity, + aVectorialFieldName); + this->SetScale(anOrigin->GetScale()); + } +} + +void VISU::Deformation_i::SetVectorialField(Entity theEntity, const char* theFieldName){ + if(MYDEBUG) MESSAGE("CutPlanes_i::SetVectorialField()"); + + bool anIsModified = false; + if(!anIsModified) + anIsModified |= GetVectorialFieldEntity() != theEntity; + + if(!anIsModified) + anIsModified |= GetVectorialFieldName() != theFieldName; + + if(!anIsModified) + return; + + ColoredPrs3d_i *aColoredPrs = GetColoredPrs3d(); + int aTimeStampNumber = aColoredPrs->GetTimeStampNumber(); + + VISU::TEntity aEntity = VISU::TEntity(theEntity); + + VISU::Result_i::PInput anInput = aColoredPrs->GetCResult()->GetInput(aColoredPrs->GetCMeshName(), + theEntity, + theFieldName, + aTimeStampNumber); + + PField aVectorialField = anInput->GetField(aColoredPrs->GetCMeshName(), aEntity, theFieldName); + + VISU::PUnstructuredGridIDMapper anIDMapper = + anInput->GetTimeStampOnMesh(aColoredPrs->GetCMeshName(), + aEntity, + theFieldName, + aTimeStampNumber); + if(GetSpecificDeformedPL() && anIDMapper) { + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificDeformedPL(), &VISU_DeformationPL::SetVectorialField, anIDMapper)); + + VISU::TSetModified aModified(GetColoredPrs3d()); + + myVectorialEntity = theEntity; + myVectorialFieldName = theFieldName; + myVectorialField = anIDMapper; + } +}; diff --git a/src/VISU_I/VISU_Deformation_i.hh b/src/VISU_I/VISU_Deformation_i.hh new file mode 100755 index 00000000..821b2735 --- /dev/null +++ b/src/VISU_I/VISU_Deformation_i.hh @@ -0,0 +1,103 @@ +// Copyright (C) 2008 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 : VISU_Deformation_i.hxx +// Author : +// Module : VISU + +#ifndef VISU_Deformation_i_HeaderFile +#define VISU_Deformation_i_HeaderFile + +#include "VISU_I.hxx" +#include "VISU_ColoredPrs3d_i.hh" +#include "VISU_DeformationPL.hxx" + + + +namespace VISU{ + + class VISU_I_EXPORT Deformation_i : public virtual POA_VISU::Deformation + { + Deformation_i(const Deformation_i&); + public: + typedef VISU::Deformation TInterface; + + Deformation_i(VISU::ColoredPrs3d_i* theColoredPrs3d); + virtual ~Deformation_i(); + + virtual + void + SetScale(CORBA::Double theScale); + + virtual + CORBA::Double + GetScale(); + + virtual + void + DeformationToStream(std::ostringstream& theStr); + + virtual + void + RestoreDeformation(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap); + + virtual + void + SameAsDeformation(const Deformation_i *aDeformedPrs); + + virtual + VISU::Entity + GetVectorialFieldEntity(); + + virtual + char* + GetVectorialFieldName(); + + virtual void SetVectorialField(Entity theEntity, const char* theFieldName); + + protected: + virtual + void + InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine); + + VISU_DeformationPL* + GetSpecificDeformedPL() const + { + return myDeformationPL; + } + + ColoredPrs3d_i* GetColoredPrs3d(){ + return myColoredPrs3d; + } + + + private: + VISU_DeformationPL *myDeformationPL; + + PField myVectorialField; + VISU::Entity myVectorialEntity; + std::string myVectorialFieldName; + ColoredPrs3d_i *myColoredPrs3d; + + }; +} + +#endif diff --git a/src/VISU_I/VISU_DeformedShapeAndScalarMap_i.cc b/src/VISU_I/VISU_DeformedShapeAndScalarMap_i.cc new file mode 100644 index 00000000..9667e0c3 --- /dev/null +++ b/src/VISU_I/VISU_DeformedShapeAndScalarMap_i.cc @@ -0,0 +1,404 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_DeformedShapeAndScalarMap_i.cc +// Author : Eugeny Nikolaev +// Module : VISU + +#include "VISU_DeformedShapeAndScalarMap_i.hh" +#include "VISU_Prs3dUtils.hh" +#include "VISU_Result_i.hh" + +#include "VISU_ScalarMapAct.h" +#include "VISU_DeformedShapeAndScalarMapPL.hxx" +#include "VISU_Convertor.hxx" + +#include "SUIT_ResourceMgr.h" +#include "SALOME_Event.h" + +#include +#include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +static int INCMEMORY = 4+12; + + +//--------------------------------------------------------------- +size_t +VISU::DeformedShapeAndScalarMap_i +::IsPossible(Result_i* theResult, + const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber, + bool theIsMemoryCheck) +{ + size_t aResult = 0; + try{ + aResult = TSuperClass::IsPossible(theResult, + theMeshName, + theEntity, + theFieldName, + theTimeStampNumber, + false); + if(theIsMemoryCheck && aResult){ + VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName, + theEntity, + theFieldName, + theTimeStampNumber); + VISU::PField aField = anInput->GetField(theMeshName, + (VISU::TEntity)theEntity, + theFieldName); + if(aField->myNbComp <= 1) + return 0; + + bool anIsEstimated = true; + size_t aSize = anInput->GetTimeStampOnMeshSize(theMeshName, + (VISU::TEntity)theEntity, + theFieldName, + theTimeStampNumber, + anIsEstimated); + if(anIsEstimated) + aSize *= INCMEMORY; + aResult = VISU_PipeLine::CheckAvailableMemory(aSize); + if(MYDEBUG) + MESSAGE("DeformedShapeAndScalarMap_i::IsPossible - CheckAvailableMemory = "<(theOrigin)){ + DeformedShapeAndScalarMap_i* anOrigin = const_cast(aPrs3d); + CORBA::String_var aFieldName = anOrigin->GetScalarFieldName(); + + SetScalarField(anOrigin->GetScalarEntity(), + aFieldName, + anOrigin->GetScalarTimeStampNumber()); + Update(); + } +} + + +//--------------------------------------------------------------- +void +VISU::DeformedShapeAndScalarMap_i +::SetScale(CORBA::Double theScale) +{ + VISU::TSetModified aModified(this); + + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificPL(), &VISU_DeformedShapeAndScalarMapPL::SetScale, theScale)); +} + + +//--------------------------------------------------------------- +CORBA::Double +VISU::DeformedShapeAndScalarMap_i +::GetScale() +{ + return myDeformedShapeAndScalarMapPL->GetScale(); +} + + +//--------------------------------------------------------------- +void +VISU::DeformedShapeAndScalarMap_i +::CreatePipeLine(VISU_PipeLine* thePipeLine) +{ + if(!thePipeLine){ + myDeformedShapeAndScalarMapPL = VISU_DeformedShapeAndScalarMapPL::New(); + }else + myDeformedShapeAndScalarMapPL = dynamic_cast(thePipeLine); + + myDeformedShapeAndScalarMapPL->GetMapper()->SetScalarVisibility(1); + + TSuperClass::CreatePipeLine(myDeformedShapeAndScalarMapPL); +} + + +//--------------------------------------------------------------- +bool +VISU::DeformedShapeAndScalarMap_i +::CheckIsPossible() +{ + return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true); +} + + +//--------------------------------------------------------------- +VISU_Actor* +VISU::DeformedShapeAndScalarMap_i +::CreateActor() +{ + VISU_Actor* anActor = TSuperClass::CreateActor(true); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aDispMode = aResourceMgr->integerValue("VISU", "scalar_def_represent", 2); + bool toShrink = aResourceMgr->booleanValue("VISU", "scalar_def_shrink", false); + anActor->SetRepresentation(aDispMode); + if (toShrink) + anActor->SetShrink(); + anActor->SetVTKMapping(false); + return anActor; +} + + +//--------------------------------------------------------------- +void +VISU::DeformedShapeAndScalarMap_i +::UpdateActor(VISU_Actor* theActor) +{ + if(VISU_ScalarMapAct* anActor = dynamic_cast(theActor)){ + anActor->SetBarVisibility(true); + GetPipeLine()->GetMapper()->SetScalarVisibility(1); + } + TSuperClass::UpdateActor(theActor); +} + + +//--------------------------------------------------------------- +void +VISU::DeformedShapeAndScalarMap_i +::SetField(VISU::PField theField) +{ + TSuperClass::SetField(theField); + + if(!myScalarField) + myScalarField = theField; +} + + +//--------------------------------------------------------------- +void +VISU::DeformedShapeAndScalarMap_i +::SetScalarField(VISU::Entity theEntity, + const char* theFieldName, + CORBA::Long theTimeStampNumber) +{ + bool anIsModified = false; + + if(!anIsModified) + anIsModified |= myScalarEntity != theEntity; + + if(!anIsModified) + anIsModified |= myScalarFieldName != theFieldName; + + if(!anIsModified) + anIsModified |= myScalarTimeStampNumber != theTimeStampNumber; + + if(!anIsModified) + return; + + VISU::TSetModified aModified(this); + + VISU::TEntity aEntity = VISU::TEntity(theEntity); + VISU::Result_i::PInput anInput = GetCResult()->GetInput(GetCMeshName(), + theEntity, + theFieldName, + theTimeStampNumber); + myScalarField = anInput->GetField(GetCMeshName(), aEntity, theFieldName); + + VISU::PUnstructuredGridIDMapper anIDMapper = + anInput->GetTimeStampOnMesh(GetCMeshName(), + aEntity, + theFieldName, + theTimeStampNumber); + + vtkUnstructuredGrid* anOutput = anIDMapper->GetUnstructuredGridOutput(); + if(myDeformedShapeAndScalarMapPL && anOutput) + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificPL(), &VISU_DeformedShapeAndScalarMapPL::SetScalars, anOutput)); + + myScalarEntity = theEntity; + myScalarFieldName = theFieldName; + myScalarTimeStampNumber = theTimeStampNumber; + + SetTitle(theFieldName); + SetScalarMode(GetScalarMode()); + if(!IsRangeFixed() && IsPipeLineExists()) + SetSourceRange(); + + myParamsTime.Modified(); +} + + +//--------------------------------------------------------------- +VISU::Entity +VISU::DeformedShapeAndScalarMap_i +::GetScalarEntity() +{ + return myScalarEntity; +} + + +//--------------------------------------------------------------- +char* +VISU::DeformedShapeAndScalarMap_i +::GetScalarFieldName() +{ + return CORBA::string_dup(myScalarFieldName.c_str()); +} + + +//--------------------------------------------------------------- +CORBA::Long +VISU::DeformedShapeAndScalarMap_i +::GetScalarTimeStampNumber() +{ + return myScalarTimeStampNumber; +} + + +//--------------------------------------------------------------- +VISU::PField +VISU::DeformedShapeAndScalarMap_i +::GetScalarField() +{ + return myScalarField; +} diff --git a/src/VISU_I/VISU_DeformedShapeAndScalarMap_i.hh b/src/VISU_I/VISU_DeformedShapeAndScalarMap_i.hh new file mode 100644 index 00000000..35827d1d --- /dev/null +++ b/src/VISU_I/VISU_DeformedShapeAndScalarMap_i.hh @@ -0,0 +1,179 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: VISU_DeformedShapeAndScalarMap_i.hh +// Author: Eugeny Nikolaev +// Module : VISU + +#ifndef VISU_DeformedShapeAndScalarMap_i_HeaderFile +#define VISU_DeformedShapeAndScalarMap_i_HeaderFile + +#include "VISU_ScalarMap_i.hh" + +class VISU_DeformedShapeAndScalarMapPL; + +namespace VISU +{ + //---------------------------------------------------------------------------- + //! Class of Scalar Map on Deformed Shape presentation. + class VISU_I_EXPORT DeformedShapeAndScalarMap_i : public virtual POA_VISU::DeformedShapeAndScalarMap, + public virtual ScalarMap_i + { + static int myNbPresent; + DeformedShapeAndScalarMap_i(const DeformedShapeAndScalarMap_i&); + + public: + //---------------------------------------------------------------------------- + typedef ScalarMap_i TSuperClass; + typedef VISU::DeformedShapeAndScalarMap TInterface; + + explicit + DeformedShapeAndScalarMap_i(EPublishInStudyMode thePublishInStudyModep); + + virtual + ~DeformedShapeAndScalarMap_i(); + + virtual + VISU::VISUType + GetType() + { + return VISU::TDEFORMEDSHAPEANDSCALARMAP; + } + + virtual + void + SetScale(CORBA::Double theScale); + + virtual + CORBA::Double + GetScale(); + + virtual + void + SameAs(const Prs3d_i* theOrigin); + + VISU_DeformedShapeAndScalarMapPL* + GetSpecificPL() + { + return myDeformedShapeAndScalarMapPL; + } + + protected: + //! Redefines VISU_ColoredPrs3d_i::SetField + virtual + void + SetField(VISU::PField theField); + + //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine + virtual + void + CreatePipeLine(VISU_PipeLine* thePipeLine); + + //! Redefines VISU_ColoredPrs3d_i::CheckIsPossible + virtual + bool + CheckIsPossible(); + + public: + //! Redefines VISU_ColoredPrs3d_i::IsPossible + static + size_t + IsPossible(Result_i* theResult, + const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber, + bool theIsMemoryCheck); + + //! Redefines VISU_ColoredPrs3d_i::IsPossible + virtual + Storable* + Create(const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber); + + //! Redefines VISU_ColoredPrs3d_i::ToStream + virtual + void + ToStream(std::ostringstream& theStr); + + //! Redefines VISU_ColoredPrs3d_i::Restore + virtual + Storable* + Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap); + + static const std::string myComment; + + virtual + const char* + GetComment() const; + + virtual + QString + GenerateName(); + + virtual + const char* + GetIconName(); + + virtual + VISU_Actor* + CreateActor(); + + virtual + void + UpdateActor(VISU_Actor* theActor) ; + + virtual + void + SetScalarField(VISU::Entity theEntity, + const char* theFieldName, + CORBA::Long theTimeStampNumber); + + virtual + VISU::Entity + GetScalarEntity(); + + virtual + char* + GetScalarFieldName(); + + virtual + CORBA::Long + GetScalarTimeStampNumber(); + + virtual + VISU::PField + GetScalarField(); + + private: + VISU_DeformedShapeAndScalarMapPL *myDeformedShapeAndScalarMapPL; + + PField myScalarField; + VISU::Entity myScalarEntity; + std::string myScalarFieldName; + CORBA::Long myScalarTimeStampNumber; + }; +} +#endif diff --git a/src/VISU_I/VISU_DeformedShape_i.cc b/src/VISU_I/VISU_DeformedShape_i.cc index de8f43cf..a4811982 100644 --- a/src/VISU_I/VISU_DeformedShape_i.cc +++ b/src/VISU_I/VISU_DeformedShape_i.cc @@ -123,6 +123,7 @@ VISU::DeformedShape_i ::DeformedShape_i(EPublishInStudyMode thePublishInStudyMode): ColoredPrs3d_i(thePublishInStudyMode), ScalarMap_i(thePublishInStudyMode), + MonoColorPrs_i(thePublishInStudyMode), myDeformedShapePL(NULL) { if(MYDEBUG) MESSAGE("DeformedShape_i::DeformedShape_i"); @@ -151,8 +152,6 @@ VISU::DeformedShape_i const std::string& theFieldName, CORBA::Long theTimeStampNumber) { - myIsColored = false; - myColor.R = myColor.G = myColor.B = 0.5; return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber); } @@ -167,10 +166,6 @@ VISU::DeformedShape_i return NULL; 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; } @@ -184,11 +179,6 @@ VISU::DeformedShape_i TSuperClass::ToStream(theStr); 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 ); } @@ -220,54 +210,6 @@ VISU::DeformedShape_i } -//--------------------------------------------------------------- -CORBA::Boolean -VISU::DeformedShape_i -::IsColored() -{ - return myIsColored; -} - - -//--------------------------------------------------------------- -void -VISU::DeformedShape_i -::ShowColored(CORBA::Boolean theColored) -{ - if(myIsColored == theColored) - return; - - myIsColored = theColored; - myParamsTime.Modified(); -} - -//--------------------------------------------------------------- -SALOMEDS::Color -VISU::DeformedShape_i -::GetColor() -{ - return myColor; -} - - -//--------------------------------------------------------------- -void -VISU::DeformedShape_i -::SetColor(const SALOMEDS::Color& theColor) -{ - bool anIsSameValue = VISU::CheckIsSameValue(myColor.R, theColor.R); - anIsSameValue &= VISU::CheckIsSameValue(myColor.G, theColor.G); - anIsSameValue &= VISU::CheckIsSameValue(myColor.B, theColor.B); - if(anIsSameValue) - return; - - VISU::TSetModified aModified(this); - - myColor = theColor; - myParamsTime.Modified(); -} - - //--------------------------------------------------------------- void VISU::DeformedShape_i @@ -321,34 +263,7 @@ VISU::DeformedShape_i bool toShrink = aResourceMgr->booleanValue("VISU", "deformed_shape_shrink", false); anActor->SetRepresentation(aDispMode); if (toShrink && !toSupressShrinking) anActor->SetShrink(); - anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B); return anActor; } -//--------------------------------------------------------------- -VISU_Actor* -VISU::DeformedShape_i -::CreateActor() -{ - return CreateActor(false); -} - - -//--------------------------------------------------------------- -void -VISU::DeformedShape_i -::UpdateActor(VISU_Actor* theActor) -{ - if(VISU_ScalarMapAct* anActor = dynamic_cast(theActor)){ - if(IsColored()){ - anActor->SetBarVisibility(true); - GetPipeLine()->GetMapper()->SetScalarVisibility(1); - }else{ - anActor->SetBarVisibility(false); - GetPipeLine()->GetMapper()->SetScalarVisibility(0); - anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B); - } - TSuperClass::UpdateActor(theActor); - } -} diff --git a/src/VISU_I/VISU_DeformedShape_i.hh b/src/VISU_I/VISU_DeformedShape_i.hh index 1f5d90c7..96487209 100644 --- a/src/VISU_I/VISU_DeformedShape_i.hh +++ b/src/VISU_I/VISU_DeformedShape_i.hh @@ -28,7 +28,7 @@ #define VISU_DeformedShape_i_HeaderFile #include -#include "VISU_ScalarMap_i.hh" +#include "VISU_MonoColorPrs_i.hh" class VISU_DeformedShapePL; @@ -36,14 +36,14 @@ namespace VISU { //---------------------------------------------------------------------------- class VISU_I_EXPORT DeformedShape_i : public virtual POA_VISU::DeformedShape, - public virtual ScalarMap_i + public virtual MonoColorPrs_i { static int myNbPresent; DeformedShape_i(const DeformedShape_i&); public: //---------------------------------------------------------------------------- - typedef ScalarMap_i TSuperClass; + typedef MonoColorPrs_i TSuperClass; typedef VISU::DeformedShape TInterface; explicit @@ -71,22 +71,6 @@ namespace VISU CORBA::Double GetScale(); - virtual - CORBA::Boolean - IsColored(); - - virtual - void - ShowColored(CORBA::Boolean theColored); - - virtual - SALOMEDS::Color - GetColor(); - - virtual - void - SetColor(const SALOMEDS::Color& theColor); - VISU_DeformedShapePL* GetSpecificPL() const { @@ -105,8 +89,6 @@ namespace VISU CheckIsPossible(); VISU_DeformedShapePL *myDeformedShapePL; - SALOMEDS::Color myColor; - bool myIsColored; public: static @@ -152,17 +134,10 @@ namespace VISU void SetMapScale(double theMapScale = 1.0); - virtual - VISU_Actor* - CreateActor(); - virtual VISU_Actor* CreateActor(bool toSupressShrinking); - virtual - void - UpdateActor(VISU_Actor* theActor) ; }; } diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index 8c4f613f..93da7d73 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -39,8 +39,9 @@ #include "VISU_StreamLines_i.hh" #include "VISU_Plot3D_i.hh" #include "VISU_Table_i.hh" +#include "VISU_PointMap3d_i.hh" #include "VISU_GaussPoints_i.hh" -#include "VISU_ScalarMapOnDeformedShape_i.hh" +#include "VISU_DeformedShapeAndScalarMap_i.hh" #include "VISU_ColoredPrs3dCache_i.hh" #include "VISU_ColoredPrs3dHolder_i.hh" @@ -415,6 +416,21 @@ namespace VISU return thePrefix; } + //--------------------------------------------------------------------------- + std::string + MonoColorPrsToPython(SALOMEDS::SObject_ptr theSObject, + VISU::MonoColorPrs_i* theServant, + std::ostream& theStr, + const std::string& theName, + TColoredPrs3dFactory& thePrsFactory, + std::string thePrefix) + { + thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix); + theStr<IsColored())<<")"<GetColor())<<")"<GetScale()<<")"<IsColored())<<")"<GetColor())<<")"<IsColored())<<")"<GetColor())<<")"<GetNbSurfaces()<<")"<IsLabeled()<<","<GetNbLabels()<<")"<GetPlanePosition(anId)<<")"<IsDeformed())<<")"<IsDeformed()){ + theStr<< thePrefix << theName << ".SetScale(" << theServant->GetScale()<<")"<GetVectorialFieldEntity(); + switch(anEntity){ + case NODE: + aStringEntity = "VISU.NODE"; + break; + case EDGE: + aStringEntity = "VISU.EDGE"; + break; + case FACE: + aStringEntity = "VISU.FACE"; + break; + case CELL: + aStringEntity = "VISU.CELL"; + break; + } + theStr<< thePrefix << theName << ".SetVectorialField("<GetVectorialFieldName() <<"')"<(GetServant(anObj).in())){ - TCreateFromResult aPrsFactory(theSObject, aServant, aName, "ScalarMapOnDeformedShapeOnField", theArgumentName); - thePrefix = ScalarMapOnDeformedShapeToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix); + case VISU::TDEFORMEDSHAPEANDSCALARMAP: + if(DeformedShapeAndScalarMap_i* aServant = dynamic_cast(GetServant(anObj).in())){ + TCreateFromResult aPrsFactory(theSObject, aServant, aName, "DeformedShapeAndScalarMapOnField", theArgumentName); + thePrefix = DeformedShapeAndScalarMapToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix); theStr<(GetServant(anObj).in())) { + CORBA::Short aTag = theSObject->Tag(); + theStr<GetScaleFactor()<<")"<GetIsContourPrs()<<")"<GetNbOfContours()<<")"<GetScaling()){ + case LINEAR: + aParam = "VISU.LINEAR"; + break; + case LOGARITHMIC: + aParam = "VISU.LOGARITHMIC"; + break; + } + theStr<GetNbColors()<<")"<GetLabels()<<")"<GetBarOrientation()){ + case ColoredPrs3dBase::HORIZONTAL: + aParam = "VISU.ColoredPrs3d.HORIZONTAL"; + break; + case ColoredPrs3dBase::VERTICAL: + aParam = "VISU.ColoredPrs3d.VERTICAL"; + break; + } + theStr<IsRangeFixed()) + theStr<GetMin()<<", "<GetMax()<<")"<GetPosX()<<", "<GetPosY()<<")"<GetWidth()<<", "<GetHeight()<<")"<GetOffset(dx, dy, dz); + theStr<(GetServant(anObj).in())){ TCreateFromResult aPrsFactory(theSObject, aServant, aName, "GaussPointsOnField", theArgumentName); @@ -1721,8 +1832,9 @@ namespace VISU break; } case VISU::TSCALARMAPONDEFORMEDSHAPE: - if(ScalarMapOnDeformedShape_i* aServant = dynamic_cast(aDevice)){ - ScalarMapOnDeformedShapeToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + case VISU::TDEFORMEDSHAPEANDSCALARMAP: + if(DeformedShapeAndScalarMap_i* aServant = dynamic_cast(aDevice)){ + DeformedShapeAndScalarMapToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); break; } case VISU::TVECTORS: diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index d8f465ce..cbb1fe7f 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -892,7 +892,7 @@ VISU::GaussPoints_i vtkTextProperty* aTitleProp = theScalarBar->GetTitleTextProperty(); aTitleProp->SetFontFamily(GetTitFontType()); - GetTitleColor(&anRGB[0],&anRGB[1],&anRGB[2]); + GetTitleColor(anRGB[0],anRGB[1],anRGB[2]); aTitleProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); IsBoldTitle()? aTitleProp->BoldOn() : aTitleProp->BoldOff(); @@ -902,7 +902,7 @@ VISU::GaussPoints_i vtkTextProperty* aLabelProp = theScalarBar->GetLabelTextProperty(); aLabelProp->SetFontFamily(GetLblFontType()); - GetLabelColor(&anRGB[0],&anRGB[1],&anRGB[2]); + GetLabelColor(anRGB[0],anRGB[1],anRGB[2]); aLabelProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); IsBoldLabel()? aLabelProp->BoldOn() : aLabelProp->BoldOff(); diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index f4ccad96..0732d558 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -210,7 +210,7 @@ namespace VISU Storable::RegistryStorableEngine(StreamLines_i::myComment.c_str(),&(StorableEngine)); Storable::RegistryStorableEngine(Plot3D_i::myComment.c_str(),&(StorableEngine)); Storable::RegistryStorableEngine(Vectors_i::myComment.c_str(),&(StorableEngine)); - Storable::RegistryStorableEngine(ScalarMapOnDeformedShape_i::myComment.c_str(),&(StorableEngine)); + Storable::RegistryStorableEngine(DeformedShapeAndScalarMap_i::myComment.c_str(),&(StorableEngine)); Storable::RegistryStorableEngine(ColoredPrs3dHolder_i::myComment.c_str(),&(ColoredPrs3dHolder_i::StorableEngine)); Storable::RegistryStorableEngine(ColoredPrs3dCache_i::myComment.c_str(),&(ColoredPrs3dCache_i::StorableEngine)); @@ -968,7 +968,7 @@ namespace VISU //--------------------------------------------------------------- - ScalarMapOnDeformedShape_ptr + DeformedShapeAndScalarMap_ptr VISU_Gen_i ::ScalarMapOnDeformedShapeOnField(Result_ptr theResult, const char* theMeshName, @@ -976,11 +976,28 @@ namespace VISU const char* theFieldName, CORBA::Long theIteration) { - return Prs3dOnField(theResult, - theMeshName, - theEntity, - theFieldName, - theIteration)._retn(); + return DeformedShapeAndScalarMapOnField(theResult, + theMeshName, + theEntity, + theFieldName, + theIteration); + } + + +//--------------------------------------------------------------- + DeformedShapeAndScalarMap_ptr + VISU_Gen_i + ::DeformedShapeAndScalarMapOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Long theIteration) + { + return Prs3dOnField(theResult, + theMeshName, + theEntity, + theFieldName, + theIteration)._retn(); } @@ -1150,7 +1167,9 @@ namespace VISU VISU_Gen_i ::CreateTable(const char* theTableEntry) { - if(myStudyDocument->GetProperties()->IsLocked()) + TCollection_AsciiString tmp( (char*)theTableEntry ); // 11.06.2008 IPAL18844 + if( myStudyDocument->GetProperties()->IsLocked() || + tmp.Length()==0 ) return Table::_nil(); return ProcessEvent(new CreateTableEvent(myStudyDocument, theTableEntry)); @@ -1375,12 +1394,11 @@ namespace VISU SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false); if(MYDEBUG) MESSAGE("Result_i::PasteInto - aListOfFileNames->length() = "<length()); - std::string aLocalPersistentID; + std::ostrstream aLocalPersistentID; { std::string aCopyPersist = aTmpDir + "copy_persistent"; - std::ifstream anInputFileStream(aCopyPersist.c_str()); - anInputFileStream>>aLocalPersistentID; - anInputFileStream.close(); + std::ifstream anInputFileStream( aCopyPersist.c_str() ); + anInputFileStream >> aLocalPersistentID.rdbuf(); } //Just for Result::Restore to find the Comment attribute :( @@ -1389,7 +1407,7 @@ namespace VISU std::string aFileName(aTmpDir); if(aListOfFileNames->length() > 1) aFileName += aListOfFileNames[1].in(); - Storable* aStorable = Storable::Create(aSObject, aLocalPersistentID, aFileName, false); + Storable* aStorable = Storable::Create(aSObject, aLocalPersistentID.str(), aFileName, false); SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames; aFilesToRemove->length(1); diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index 1f38e06e..1043ed2a 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -177,13 +177,23 @@ namespace VISU const char* theFieldName, CORBA::Long theIteration); + //This function is obsolete. Use DeformedShapeAndScalarMapOnField instead. virtual - ScalarMapOnDeformedShape_ptr + DeformedShapeAndScalarMap_ptr ScalarMapOnDeformedShapeOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, CORBA::Long theIteration); + + virtual + DeformedShapeAndScalarMap_ptr + DeformedShapeAndScalarMapOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Long theIteration); + virtual Vectors_ptr VectorsOnField(Result_ptr theResult, diff --git a/src/VISU_I/VISU_I.cxx b/src/VISU_I/VISU_I.cxx index 6c8c3973..27114c9f 100644 --- a/src/VISU_I/VISU_I.cxx +++ b/src/VISU_I/VISU_I.cxx @@ -43,7 +43,7 @@ #include "VISU_Vectors_i.hh" #include "VISU_StreamLines_i.hh" #include "VISU_GaussPoints_i.hh" -#include "VISU_ScalarMapOnDeformedShape_i.hh" +#include "VISU_DeformedShapeAndScalarMap_i.hh" #include "VISU_ViewManager_i.hh" #include "VISU_View_i.hh" #include "VISU_TimeAnimation.h" diff --git a/src/VISU_I/VISU_IsoSurfaces_i.cc b/src/VISU_I/VISU_IsoSurfaces_i.cc index 30b01592..90e3b18a 100644 --- a/src/VISU_I/VISU_IsoSurfaces_i.cc +++ b/src/VISU_I/VISU_IsoSurfaces_i.cc @@ -30,9 +30,12 @@ #include "VISU_IsoSurfacesPL.hxx" #include "VISU_Result_i.hh" #include "VISU_Actor.h" +#include "VISU_ScalarMapAct.h" +#include "VISU_IsoSurfActor.h" #include "SUIT_ResourceMgr.h" #include "SALOME_Event.h" +#include #ifdef _DEBUG_ static int MYDEBUG = 0; @@ -94,7 +97,10 @@ VISU::IsoSurfaces_i ::IsoSurfaces_i(EPublishInStudyMode thePublishInStudyMode) : ColoredPrs3d_i(thePublishInStudyMode), ScalarMap_i(thePublishInStudyMode), - myIsoSurfacesPL(NULL) + MonoColorPrs_i(thePublishInStudyMode), + myIsoSurfacesPL(NULL), + myIsLabeled(false), + myNbLabels(3) {} @@ -106,7 +112,12 @@ VISU::IsoSurfaces_i const std::string& theFieldName, CORBA::Long theTimeStampNumber) { - return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber); + VISU::Storable* aRes = TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber); + myIsColored = true; + myColor.R = myColor.G = myColor.B = 0.; + //myIsLabeled = false; + //myNbLabels = 3; + return aRes; } @@ -122,6 +133,8 @@ VISU::IsoSurfaces_i SetNbSurfaces(VISU::Storable::FindValue(theMap,"myNbSurface").toInt()); float aMin = VISU::Storable::FindValue(theMap,"myRange[0]").toDouble(); float aMax = VISU::Storable::FindValue(theMap,"myRange[1]").toDouble(); + myNbLabels = VISU::Storable::FindValue(theMap,"myNbLabels").toInt(); + myIsLabeled = VISU::Storable::FindValue(theMap,"myIsLabeled").toInt(); SetSubRange(aMin,aMax); return this; @@ -138,8 +151,22 @@ VISU::IsoSurfaces_i Storable::DataToStream( theStr, "myNbSurface", int(GetNbSurfaces()) ); Storable::DataToStream( theStr, "myRange[0]", GetSubMin() ); Storable::DataToStream( theStr, "myRange[1]", GetSubMax() ); + Storable::DataToStream( theStr, "myNbLabels", myNbLabels ); + Storable::DataToStream( theStr, "myIsLabeled", myIsLabeled ); } +//--------------------------------------------------------------- +void VISU::IsoSurfaces_i::SameAs(const Prs3d_i* theOrigin) +{ + TSuperClass::SameAs(theOrigin); + + if(const IsoSurfaces_i* aPrs3d = dynamic_cast(theOrigin)){ + IsoSurfaces_i* anOrigin = const_cast(aPrs3d); + ShowLabels(anOrigin->IsLabeled(), anOrigin->GetNbLabels()); + } +} + + //--------------------------------------------------------------- VISU::IsoSurfaces_i @@ -231,20 +258,33 @@ VISU::IsoSurfaces_i } //--------------------------------------------------------------- -VISU_Actor* -VISU::IsoSurfaces_i -::CreateActor() +VISU_Actor* VISU::IsoSurfaces_i::CreateActor() { - if(VISU_Actor* anActor = TSuperClass::CreateActor()){ + VISU_IsoSurfActor* anActor = VISU_IsoSurfActor::New(); + try{ + VISU::Prs3d_i::CreateActor(anActor); + anActor->SetBarVisibility(true); anActor->SetVTKMapping(true); SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); int aDispMode = aResourceMgr->integerValue("VISU" , "iso_surfaces_represent", 2); anActor->SetRepresentation(aDispMode); - return anActor; + UpdateActor(anActor); + }catch(...){ + anActor->Delete(); + throw ; } - return NULL; + + return anActor; } +//--------------------------------------------------------------- +void VISU::IsoSurfaces_i::UpdateActor(VISU_ActorBase* theActor) +{ + if(VISU_IsoSurfActor* anActor = dynamic_cast(theActor)){ + anActor->SetLinesLabeled(myIsLabeled, myNbLabels); + } + TSuperClass::UpdateActor(theActor); +} //--------------------------------------------------------------- void @@ -253,3 +293,26 @@ VISU::IsoSurfaces_i { myIsoSurfacesPL->SetMapScale(theMapScale); } + +//--------------------------------------------------------------- +CORBA::Boolean VISU::IsoSurfaces_i::IsLabeled() +{ + return myIsLabeled; +} + +//--------------------------------------------------------------- +void VISU::IsoSurfaces_i::ShowLabels(CORBA::Boolean theShow, CORBA::Long theNb) +{ + if ((myIsLabeled == theShow) && (myNbLabels == theNb)) return; + VISU::TSetModified aModified(this); + myIsLabeled = theShow; + myNbLabels = theNb; + myParamsTime.Modified(); +} + +//--------------------------------------------------------------- +CORBA::Long VISU::IsoSurfaces_i::GetNbLabels() +{ + return myNbLabels; +} + diff --git a/src/VISU_I/VISU_IsoSurfaces_i.hh b/src/VISU_I/VISU_IsoSurfaces_i.hh index 74cc1c3d..1e5b6dd4 100644 --- a/src/VISU_I/VISU_IsoSurfaces_i.hh +++ b/src/VISU_I/VISU_IsoSurfaces_i.hh @@ -28,7 +28,8 @@ #define VISU_IsoSurfaces_i_HeaderFile #include "VISU_I.hxx" -#include "VISU_ScalarMap_i.hh" +//#include "VISU_ScalarMap_i.hh" +#include "VISU_MonoColorPrs_i.hh" class VISU_IsoSurfacesPL; @@ -36,19 +37,21 @@ namespace VISU { //---------------------------------------------------------------------------- class VISU_I_EXPORT IsoSurfaces_i : public virtual POA_VISU::IsoSurfaces, - public virtual ScalarMap_i + public virtual MonoColorPrs_i { static int myNbPresent; IsoSurfaces_i(const IsoSurfaces_i&); public: //---------------------------------------------------------------------------- - typedef ScalarMap_i TSuperClass; + typedef MonoColorPrs_i TSuperClass; typedef VISU::IsoSurfaces TInterface; explicit IsoSurfaces_i(EPublishInStudyMode thePublishInStudyModep); + virtual void SameAs(const Prs3d_i* theOrigin); + virtual ~IsoSurfaces_i(); @@ -84,7 +87,14 @@ namespace VISU { return myIsoSurfacesPL; } + + + virtual CORBA::Boolean IsLabeled(); + virtual void ShowLabels(CORBA::Boolean theShow, CORBA::Long theNb); + + virtual CORBA::Long GetNbLabels(); + protected: //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine virtual @@ -103,6 +113,9 @@ namespace VISU VISU_IsoSurfacesPL* myIsoSurfacesPL; + bool myIsLabeled; + CORBA::Long myNbLabels; + public: static size_t @@ -150,6 +163,9 @@ namespace VISU virtual void SetMapScale(double theMapScale = 1.0); + + virtual void UpdateActor(VISU_ActorBase* theActor); + }; } diff --git a/src/VISU_I/VISU_MonoColorPrs_i.cc b/src/VISU_I/VISU_MonoColorPrs_i.cc new file mode 100644 index 00000000..28afbc8d --- /dev/null +++ b/src/VISU_I/VISU_MonoColorPrs_i.cc @@ -0,0 +1,186 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_MonoColorPrs_i.cxx +// Author : Vitaly Smetannikov +// Module : VISU + + +#include "VISU_MonoColorPrs_i.hh" +#include "VISU_Prs3dUtils.hh" +#include "VISU_PipeLineUtils.hxx" +#include "VISU_ScalarMapAct.h" + +#include "VISU_PipeLine.hxx" + +#include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +//--------------------------------------------------------------- +VISU::MonoColorPrs_i +::MonoColorPrs_i(EPublishInStudyMode thePublishInStudyMode): + ColoredPrs3d_i(thePublishInStudyMode), + ScalarMap_i(thePublishInStudyMode) +{ + if(MYDEBUG) MESSAGE("MonoColorPrs_i::MonoColorPrs_i"); +} + +//--------------------------------------------------------------- +void +VISU::MonoColorPrs_i +::SameAs(const Prs3d_i* theOrigin) +{ + TSuperClass::SameAs(theOrigin); + + if(const MonoColorPrs_i* aPrs3d = dynamic_cast(theOrigin)){ + MonoColorPrs_i* anOrigin = const_cast(aPrs3d); + SetColor(anOrigin->GetColor()); + ShowColored(anOrigin->IsColored()); + } +} + + +//--------------------------------------------------------------- +VISU::Storable* +VISU::MonoColorPrs_i +::Create(const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber) +{ + myIsColored = false; + myColor.R = myColor.G = myColor.B = 0.5; + return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber); +} + +//--------------------------------------------------------------- +VISU::Storable* +VISU::MonoColorPrs_i +::Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap) +{ + if(!TSuperClass::Restore(theSObject, theMap)) + return NULL; + + 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::MonoColorPrs_i +::ToStream(std::ostringstream& theStr) +{ + TSuperClass::ToStream(theStr); + + 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::MonoColorPrs_i::~MonoColorPrs_i() +{ + if(MYDEBUG) MESSAGE("MonoColorPrs_i::~MonoColorPrs_i()"); +} + +//--------------------------------------------------------------- +CORBA::Boolean VISU::MonoColorPrs_i::IsColored() +{ + return myIsColored; +} + + + +//--------------------------------------------------------------- +void +VISU::MonoColorPrs_i::ShowColored(CORBA::Boolean theColored) +{ + if(myIsColored == theColored) + return; + myIsColored = theColored; + myParamsTime.Modified(); +} + +//--------------------------------------------------------------- +SALOMEDS::Color VISU::MonoColorPrs_i::GetColor() +{ + return myColor; +} + +//--------------------------------------------------------------- +void VISU::MonoColorPrs_i::SetColor(const SALOMEDS::Color& theColor) +{ + bool anIsSameValue = VISU::CheckIsSameValue(myColor.R, theColor.R); + anIsSameValue &= VISU::CheckIsSameValue(myColor.G, theColor.G); + anIsSameValue &= VISU::CheckIsSameValue(myColor.B, theColor.B); + if(anIsSameValue) + return; + + VISU::TSetModified aModified(this); + + myColor = theColor; + myParamsTime.Modified(); +} + +//--------------------------------------------------------------- +VISU_Actor* VISU::MonoColorPrs_i::CreateActor(bool toSupressShrinking) +{ + VISU_Actor* anActor = TSuperClass::CreateActor(toSupressShrinking); + anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B); + return anActor; +} + +//--------------------------------------------------------------- +VISU_Actor* VISU::MonoColorPrs_i::CreateActor() +{ + return CreateActor(false); +} + +//--------------------------------------------------------------- +void VISU::MonoColorPrs_i::UpdateActor(VISU_ActorBase* theActor) +{ + if(VISU_ScalarMapAct* anActor = dynamic_cast(theActor)){ + if(IsColored()){ + anActor->SetBarVisibility(true); + GetPipeLine()->GetMapper()->SetScalarVisibility(1); + }else{ + anActor->SetBarVisibility(false); + GetPipeLine()->GetMapper()->SetScalarVisibility(0); + anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B); + } + TSuperClass::UpdateActor(theActor); + } +} + diff --git a/src/VISU_I/VISU_MonoColorPrs_i.hh b/src/VISU_I/VISU_MonoColorPrs_i.hh new file mode 100644 index 00000000..50fff308 --- /dev/null +++ b/src/VISU_I/VISU_MonoColorPrs_i.hh @@ -0,0 +1,83 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_MonoColorPrs_i.hxx +// Author : Vitaly Smetannikov +// Module : VISU + + +#ifndef VISU_MonoColorPrs_i_HeaderFile +#define VISU_MonoColorPrs_i_HeaderFile + +#include +#include "VISU_ScalarMap_i.hh" + +namespace VISU +{ + //---------------------------------------------------------------------------- + class VISU_I_EXPORT MonoColorPrs_i : public virtual POA_VISU::MonoColorPrs, + public virtual ScalarMap_i + { + MonoColorPrs_i(const MonoColorPrs_i&); + + public: + //---------------------------------------------------------------------------- + typedef ScalarMap_i TSuperClass; + typedef VISU::MonoColorPrs TInterface; + + explicit MonoColorPrs_i(EPublishInStudyMode thePublishInStudyModep); + + virtual void SameAs(const Prs3d_i* theOrigin); + + virtual ~MonoColorPrs_i(); + + virtual CORBA::Boolean IsColored(); + + virtual void ShowColored(CORBA::Boolean theColored); + + virtual SALOMEDS::Color GetColor(); + + virtual void SetColor(const SALOMEDS::Color& theColor); + + protected: + SALOMEDS::Color myColor; + bool myIsColored; + + public: + virtual Storable* Create(const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber); + + virtual void ToStream(std::ostringstream& theStr); + + virtual Storable* Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap); + + virtual VISU_Actor* CreateActor(); + + virtual VISU_Actor* CreateActor(bool toSupressShrinking); + + virtual void UpdateActor(VISU_ActorBase* theActor); + }; +}; +#endif diff --git a/src/VISU_I/VISU_OptionalDeformation_i.cc b/src/VISU_I/VISU_OptionalDeformation_i.cc new file mode 100755 index 00000000..77a12298 --- /dev/null +++ b/src/VISU_I/VISU_OptionalDeformation_i.cc @@ -0,0 +1,110 @@ +// Copyright (C) 2008 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 : VISU_OptionalDeformation_i.cc +// Author : +// Module : VISU + +#include "VISU_OptionalDeformation_i.hh" +#include "VISU_Result_i.hh" +#include "VISU_Prs3dUtils.hh" +#include "VISUConfig.hh" + +#include "VISU_OptionalDeformationPL.hxx" + + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +//--------------------------------------------------------------- +VISU::OptionalDeformation_i::OptionalDeformation_i(VISU::ColoredPrs3d_i *theColoredPrs3d): + Deformation_i(theColoredPrs3d) +{ + if(MYDEBUG) MESSAGE("OptionalDeformation_i::OptionalDeformation_i()"); +} + +//--------------------------------------------------------------- +VISU::OptionalDeformation_i::~OptionalDeformation_i() +{ + if(MYDEBUG) MESSAGE("OptionalDeformation_i::~OptionalDeformation_i()"); +} + +//--------------------------------------------------------------- +void VISU::OptionalDeformation_i::UseDeformation(CORBA::Boolean theFlag){ + if(MYDEBUG) MESSAGE("OptionalDeformation_i::UseDeformation()"); + + VISU::TSetModified aModified(GetColoredPrs3d()); + + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificDeformedPL(), &VISU_OptionalDeformationPL::UseDeformation, theFlag)); +} + +//--------------------------------------------------------------- +CORBA::Boolean VISU::OptionalDeformation_i::IsDeformed(){ + + if(MYDEBUG) MESSAGE("OptionalDeformation_i::IsDeformed()"); + return GetSpecificDeformedPL()->IsDeformed(); +} + + +void VISU::OptionalDeformation_i::InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine){ + + if(MYDEBUG) MESSAGE("OptionalDeformation_i::InitDeformedPipeLine()"); + myOptionalDeformationPL = dynamic_cast(theDeformedPipeLine); + + TSuperClass::InitDeformedPipeLine(myOptionalDeformationPL); +} + +//--------------------------------------------------------------- +void VISU::OptionalDeformation_i:: +DeformationToStream(std::ostringstream& theStr) +{ + Storable::DataToStream(theStr,"IsDeformed", IsDeformed()); + if(IsDeformed()) + TSuperClass::DeformationToStream(theStr); +} + +//--------------------------------------------------------------- +void +VISU::OptionalDeformation_i::RestoreDeformation(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap) +{ + UseDeformation(Storable::FindValue(theMap,"IsDeformed").toInt()); + if(IsDeformed()) + TSuperClass::RestoreDeformation(theSObject,theMap); +} + + + +void +VISU::OptionalDeformation_i::SameAsDeformation(const Deformation_i *aDeformedPrs){ + + if(const OptionalDeformation_i* aPrs3d = dynamic_cast(aDeformedPrs)){ + OptionalDeformation_i* anOrigin = const_cast(aPrs3d); + UseDeformation(anOrigin->IsDeformed()); + + if(anOrigin->IsDeformed()){ + TSuperClass::SameAsDeformation(aDeformedPrs); + } + } +} diff --git a/src/VISU_I/VISU_OptionalDeformation_i.hh b/src/VISU_I/VISU_OptionalDeformation_i.hh new file mode 100755 index 00000000..ac6a08ff --- /dev/null +++ b/src/VISU_I/VISU_OptionalDeformation_i.hh @@ -0,0 +1,76 @@ +// Copyright (C) 2008 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 : VISU_Deformation_i.hxx +// Author : +// Module : VISU + +#ifndef VISU_OptionalDeformation_i_HeaderFile +#define VISU_OptionalDeformation_i_HeaderFile + +#include "VISU_I.hxx" +#include "VISU_Deformation_i.hh" +#include "VISU_OptionalDeformationPL.hxx" + +namespace VISU { + class VISU_I_EXPORT OptionalDeformation_i : public virtual POA_VISU::OptionalDeformation, + public virtual Deformation_i + { + OptionalDeformation_i(const OptionalDeformation_i&); + public: + typedef VISU::OptionalDeformation TInterface; + typedef Deformation_i TSuperClass; + + OptionalDeformation_i(VISU::ColoredPrs3d_i* theModifiedEngine); + virtual ~OptionalDeformation_i(); + + virtual void UseDeformation(CORBA::Boolean theFlag); + virtual CORBA::Boolean IsDeformed(); + + + virtual + void + DeformationToStream(std::ostringstream& theStr); + + virtual + void + RestoreDeformation(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap); + + virtual + void + SameAsDeformation(const Deformation_i *aDeformedPrs); + + protected: + virtual + void InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine); + + VISU_OptionalDeformationPL* + GetSpecificDeformedPL() const + { + return myOptionalDeformationPL; + } + + private: + VISU_OptionalDeformationPL* myOptionalDeformationPL; + + }; +} +#endif diff --git a/src/VISU_I/VISU_PointMap3d_i.cc b/src/VISU_I/VISU_PointMap3d_i.cc index ed2c2c01..2885a351 100644 --- a/src/VISU_I/VISU_PointMap3d_i.cc +++ b/src/VISU_I/VISU_PointMap3d_i.cc @@ -21,7 +21,7 @@ // // // File : VISU_PointMap3d_i.cc -// Author : Vadim SANDLER +// Author : Dmitry Matveitchev // Module : VISU #include "VISU_PointMap3d_i.hh" @@ -82,7 +82,7 @@ VISU::PointMap3d_i::PointMap3d_i( SALOMEDS::Study_ptr theStudy, const char* theO myActorCollection(vtkActorCollection::New()), myIsActiveState(true) { - MESSAGE("PointMap3d_i::PointMap3d_i - "<booleanValue( "VISU", "scalar_bar_display_units", true ); SetUnitsVisible(isUnits); + SetSourceRange(); + + if( aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false) ) + SetScaling(VISU::LOGARITHMIC); + else + SetScaling(VISU::LINEAR); + + int aNumberOfColors = aResourceMgr->integerValue( "VISU", "scalar_bar_num_colors", 64 ); + SetNbColors(aNumberOfColors); + + int aRangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0); + UseFixedRange(aRangeType == 1); + if(aRangeType == 1){ + float aMin = aResourceMgr->doubleValue("VISU", "scalar_range_min", 0); + float aMax = aResourceMgr->doubleValue("VISU", "scalar_range_max", 0); + SetRange(aMin, aMax); + } + QString aLabelsFormat = aResourceMgr->stringValue( "VISU", "scalar_bar_label_format", "%-#6.3g" ); SetLabelsFormat(aLabelsFormat.toLatin1().constData()); @@ -338,6 +367,12 @@ VISU_PointMap3dActor* VISU::PointMap3d_i::CreateActor() anActor->SetPipeLine(myTablePL); anActor->SetFactory(this); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aDispMode = aResourceMgr->integerValue("VISU", "point_map_represent", 2); + bool toShrink = aResourceMgr->booleanValue("VISU", "scalar_map_shrink", false); + anActor->SetRepresentation(aDispMode); + if (toShrink) anActor->SetShrink(); + Handle (SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(GetEntry().c_str(), "VISU", GetName().c_str()); anActor->setIO(anIO); @@ -357,6 +392,7 @@ VISU_PointMap3dActor* VISU::PointMap3d_i::CreateActor() void VISU::PointMap3d_i::UpdateActor(VISU_ActorBase* theActor) { if(VISU_PointMap3dActor* anActor = dynamic_cast(theActor)){ + Update(); VISU_ScalarBarActor *aScalarBar = anActor->GetScalarBar(); aScalarBar->SetLookupTable(GetSpecificPL()->GetBarTable()); aScalarBar->SetTitle(GetTitle()); @@ -377,7 +413,7 @@ void VISU::PointMap3d_i::UpdateActor(VISU_ActorBase* theActor) vtkTextProperty* aTitleProp = aScalarBar->GetTitleTextProperty(); aTitleProp->SetFontFamily(GetTitFontType()); - GetTitleColor(&anRGB[0],&anRGB[1],&anRGB[2]); + GetTitleColor(anRGB[0],anRGB[1],anRGB[2]); aTitleProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); IsBoldTitle()? aTitleProp->BoldOn() : aTitleProp->BoldOff(); @@ -387,7 +423,7 @@ void VISU::PointMap3d_i::UpdateActor(VISU_ActorBase* theActor) vtkTextProperty* aLabelProp = aScalarBar->GetLabelTextProperty(); aLabelProp->SetFontFamily(GetLblFontType()); - GetLabelColor(&anRGB[0],&anRGB[1],&anRGB[2]); + GetLabelColor(anRGB[0],anRGB[1],anRGB[2]); aLabelProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); IsBoldLabel()? aLabelProp->BoldOn() : aLabelProp->BoldOff(); @@ -410,6 +446,38 @@ VISU::PointMap3d_i ProcessVoidEvent(new VISU::TInvokeSignalEvent(myUpdateActorsSignal)); } +//---------------------------------------------------------------------------- +void +VISU::PointMap3d_i +::Update() +{ + if(GetMTime() < myUpdateTime.GetMTime()) + return; + + if(MYDEBUG) MESSAGE("PointMap3d_i::Update - this = "< + (GetSpecificPL(), &VISU_PipeLine::Update)); + myUpdateTime.Modified(); + }catch(std::exception&){ + throw; + }catch(...){ + throw std::runtime_error("PointMap3d_i::Update >> unexpected exception was caught!!!"); + } +} + +//---------------------------------------------------------------------------- +unsigned long int +VISU::PointMap3d_i +::GetMTime() +{ + unsigned long int aTime = myParamsTime.GetMTime(); + if( GetSpecificPL() ) + aTime = std::max(aTime, GetSpecificPL()->GetMTime()); + return aTime; +} + /*! Builds presentation of table */ @@ -683,6 +751,40 @@ CORBA::Double VISU::PointMap3d_i::GetMin() return myTablePL->GetScalarRange()[0]; } +CORBA::Double VISU::PointMap3d_i::GetMinTableValue() +{ + SALOMEDS::GenericAttribute_var anAttr; + mySObj->FindAttribute(anAttr, "AttributeTableOfReal"); + SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr); + double aMin = aTableOfReal->GetValue(1, 1); + + for (int i=1; i<=aTableOfReal->GetNbColumns(); i++) + for (int j=1; j<=aTableOfReal->GetNbRows(); j++) { + double aVal = aTableOfReal->GetValue(j, i); + if (aVal < aMin) + aMin = aVal; + } + + return aMin; +} + +CORBA::Double VISU::PointMap3d_i::GetMaxTableValue() +{ + SALOMEDS::GenericAttribute_var anAttr; + mySObj->FindAttribute(anAttr, "AttributeTableOfReal"); + SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr); + double aMax = aTableOfReal->GetValue(1, 1); + + for (int i=1; i<=aTableOfReal->GetNbColumns(); i++) + for (int j=1; j<=aTableOfReal->GetNbRows(); j++) { + double aVal = aTableOfReal->GetValue(j, i); + if (aVal > aMax) + aMax = aVal; + } + + return aMax; +} + CORBA::Double VISU::PointMap3d_i::GetMax() { return myTablePL->GetScalarRange()[1]; @@ -702,8 +804,6 @@ CORBA::Double VISU::PointMap3d_i::GetSourceMin() vtkFloatingPointType aRange[2]; GetSpecificPL()->GetSourceRange(aRange); return aRange[0]; - - UseFixedRange(false); } CORBA::Double VISU::PointMap3d_i::GetSourceMax() @@ -718,6 +818,8 @@ void VISU::PointMap3d_i::SetSourceRange() GetSpecificPL()->SetSourceRange(); ProcessVoidEvent(new TVoidMemFunEvent (GetSpecificPL(), &VISU_DeformedGridPL::SetSourceRange)); + + UseFixedRange(false); } CORBA::Boolean VISU::PointMap3d_i::IsRangeFixed() @@ -825,6 +927,23 @@ VISU::Scaling VISU::PointMap3d_i::GetScaling() return VISU::Scaling(GetSpecificPL()->GetScaling()); } +//------------------- Check Table on Positive Values ------------ +bool VISU::PointMap3d_i::IsPositiveTable() +{ + SALOMEDS::GenericAttribute_var anAttr; + mySObj->FindAttribute(anAttr, "AttributeTableOfReal"); + SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr); + + for (int i=1; i<=aTableOfReal->GetNbColumns(); i++) + for (int j=1; j<=aTableOfReal->GetNbRows(); j++) { + double aVal = aTableOfReal->GetValue(j, i); + if (aVal < 0) + return false; + } + + return true; +} + //------------------- Plot3dBase Methods ------------------------ void VISU::PointMap3d_i::SetScaleFactor (CORBA::Double theScaleFactor) @@ -872,14 +991,6 @@ void VISU::PointMap3d_i::SetActiveState ( bool theState ) myIsActiveState = theState; } -unsigned long int VISU::PointMap3d_i::GetMTime () -{ - unsigned long int aTime = myParamsTime.GetMTime(); - if( GetSpecificPL() ) - aTime = std::max(aTime, GetSpecificPL()->GetMTime()); - return aTime; -} - void VISU::PointMap3d_i::RemoveActor (VISU_ActorBase* theActor) { myActorCollection->RemoveItem(theActor); @@ -957,13 +1068,13 @@ void VISU::PointMap3d_i::SetTitFontType(int theTitFontType) } //---------------------------------------------------------------------------- -void VISU::PointMap3d_i::GetTitleColor(vtkFloatingPointType* theR, - vtkFloatingPointType* theG, - vtkFloatingPointType* theB) +void VISU::PointMap3d_i::GetTitleColor(vtkFloatingPointType& theR, + vtkFloatingPointType& theG, + vtkFloatingPointType& theB) { - *theR = myTitleColor[0]; - *theG = myTitleColor[1]; - *theB = myTitleColor[2]; + theR = myTitleColor[0]; + theG = myTitleColor[1]; + theB = myTitleColor[2]; } //---------------------------------------------------------------------------- @@ -1048,13 +1159,13 @@ void VISU::PointMap3d_i::SetLblFontType(int theLblFontType) } //---------------------------------------------------------------------------- -void VISU::PointMap3d_i::GetLabelColor(vtkFloatingPointType* theR, - vtkFloatingPointType* theG, - vtkFloatingPointType* theB) +void VISU::PointMap3d_i::GetLabelColor(vtkFloatingPointType& theR, + vtkFloatingPointType& theG, + vtkFloatingPointType& theB) { - *theR = myLabelColor[0]; - *theG = myLabelColor[1]; - *theB = myLabelColor[2]; + theR = myLabelColor[0]; + theG = myLabelColor[1]; + theB = myLabelColor[2]; } //---------------------------------------------------------------------------- diff --git a/src/VISU_I/VISU_PointMap3d_i.hh b/src/VISU_I/VISU_PointMap3d_i.hh index dfe6d125..593721ec 100644 --- a/src/VISU_I/VISU_PointMap3d_i.hh +++ b/src/VISU_I/VISU_PointMap3d_i.hh @@ -65,6 +65,10 @@ namespace VISU virtual void UpdateActor(VISU_ActorBase* thePointMap3dActor); virtual void UpdateActors(); + virtual void Update(); + + virtual Handle(SALOME_InteractiveObject) GetIO(); + //----------- override Prs3d methods ----------------------------- //! Move the 3D presentation according to the given offset parameters @@ -80,6 +84,8 @@ namespace VISU virtual CORBA::Double GetMin(); virtual CORBA::Double GetMax(); + virtual CORBA::Double GetMinTableValue(); + virtual CORBA::Double GetMaxTableValue(); virtual void SetRange(CORBA::Double theMin, CORBA::Double theMax); virtual CORBA::Double GetSourceMin(); @@ -120,16 +126,18 @@ namespace VISU virtual VISU::Scaling GetScaling(); virtual void SetScaling(VISU::Scaling theScaling); + bool IsPositiveTable(); + // Plot3dBase methods void SetScaleFactor (CORBA::Double theScaleFactor); - double GetScaleFactor(); + CORBA::Double GetScaleFactor(); void SetContourPrs (CORBA::Boolean theIsContourPrs ); - bool GetIsContourPrs(); + CORBA::Boolean GetIsContourPrs(); void SetNbOfContours (CORBA::Long); - long GetNbOfContours(); + CORBA::Long GetNbOfContours(); VISU_DeformedGridPL* GetSpecificPL() const { return myTablePL; } @@ -157,9 +165,9 @@ namespace VISU virtual void SetShadowTitle(bool isShadow); virtual int GetTitFontType(); virtual void SetTitFontType(int theType); - virtual void GetTitleColor(vtkFloatingPointType* theR, - vtkFloatingPointType* theG, - vtkFloatingPointType* theB); + virtual void GetTitleColor(vtkFloatingPointType& theR, + vtkFloatingPointType& theG, + vtkFloatingPointType& theB); virtual void SetTitleColor(vtkFloatingPointType theR, vtkFloatingPointType theG, vtkFloatingPointType theB); @@ -172,9 +180,9 @@ namespace VISU virtual void SetShadowLabel(bool isShadow); virtual int GetLblFontType(); virtual void SetLblFontType(int theType); - virtual void GetLabelColor(vtkFloatingPointType* theR, - vtkFloatingPointType* theG, - vtkFloatingPointType* theB); + virtual void GetLabelColor(vtkFloatingPointType& theR, + vtkFloatingPointType& theG, + vtkFloatingPointType& theB); virtual void SetLabelColor(vtkFloatingPointType theR, vtkFloatingPointType theG, vtkFloatingPointType theB); @@ -212,6 +220,9 @@ namespace VISU CORBA::Float myOffset[3]; bool myIsActiveState; vtkTimeStamp myParamsTime; + vtkTimeStamp myUpdateTime; + + Handle(SALOME_InteractiveObject) myIO; //Font management diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 9951cbbe..55e2bd1d 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -41,7 +41,7 @@ #include #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; #else static int MYDEBUG = 0; #endif @@ -99,6 +99,7 @@ VISU::Prs3d_i::~Prs3d_i() { if(MYDEBUG) MESSAGE("Prs3d_i::~Prs3d_i - this = "<Destroy(); } @@ -157,8 +158,13 @@ VISU::Prs3d_i if(GetCResult() == theResult) return; - if(theResult) + if(theResult) { SetStudyDocument(theResult->GetStudyDocument()); + theResult->Register(); + } + if(myResult) { + myResult->Destroy(); + } VISU::TSetModified aModified(this); diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index f250318d..a43015d9 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -62,7 +62,7 @@ #include #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; #else static int MYDEBUG = 0; #endif @@ -162,6 +162,7 @@ VISU::Result_i myIsBuildParts(false), myIsPartsDone(false) { + if(MYDEBUG) MESSAGE("Result_i::Result_i - this = "<length(aMeshOnEntityMap.size()); - VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.end(); + VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.begin(); for(size_t anId = 0; anIter != aMeshOnEntityMap.end(); anIter++, anId++){ const VISU::TEntity& anEntity = anIter->first; anEntities[anId] = VISU::Entity(anEntity); @@ -1044,7 +1047,7 @@ VISU::Result_i { aResult->length(aFamilyMap.size()); - VISU::TFamilyMap::const_iterator anIter = aFamilyMap.end(); + VISU::TFamilyMap::const_iterator anIter = aFamilyMap.begin(); for(size_t anId = 0; anIter != aFamilyMap.end(); anIter++, anId++){ const std::string& aName = anIter->first; aResult[anId] = aName.c_str(); @@ -1077,7 +1080,7 @@ VISU::Result_i { aResult->length(aGroupMap.size()); - VISU::TGroupMap::const_iterator anIter = aGroupMap.end(); + VISU::TGroupMap::const_iterator anIter = aGroupMap.begin(); for(size_t anId = 0; anIter != aGroupMap.end(); anIter++, anId++){ const std::string& aName = anIter->first; aResult[anId] = aName.c_str(); @@ -1121,7 +1124,7 @@ VISU::Result_i { aResult->length(aFieldMap.size()); - VISU::TFieldMap::const_iterator anIter = aFieldMap.end(); + VISU::TFieldMap::const_iterator anIter = aFieldMap.begin(); for(size_t anId = 0; anIter != aFieldMap.end(); anIter++, anId++){ const std::string& aName = anIter->first; aResult[anId] = aName.c_str(); @@ -1178,7 +1181,7 @@ VISU::Result_i { aResult->length(aValField.size()); - VISU::TValField::const_iterator anIter = aValField.end(); + VISU::TValField::const_iterator anIter = aValField.begin(); for(size_t anId = 0; anIter != aValField.end(); anIter++, anId++){ const vtkIdType& aTimeStampNumber = anIter->first; aResult[anId] = aTimeStampNumber; @@ -1350,7 +1353,7 @@ std::string VISU::Result_i ::GetFileName() const { - if(GetSourceId() == eFile) + if(GetSourceId() == eRestoredFile) return VISU::MakeFileName(myFileName, this); return myFileName; diff --git a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc deleted file mode 100644 index 1a5d6388..00000000 --- a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc +++ /dev/null @@ -1,404 +0,0 @@ -// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// -// File : VISU_ScalarMapOnDeformedShape_i.cc -// Author : Eugeny Nikolaev -// Module : VISU - -#include "VISU_ScalarMapOnDeformedShape_i.hh" -#include "VISU_Prs3dUtils.hh" -#include "VISU_Result_i.hh" - -#include "VISU_ScalarMapAct.h" -#include "VISU_ScalarMapOnDeformedShapePL.hxx" -#include "VISU_Convertor.hxx" - -#include "SUIT_ResourceMgr.h" -#include "SALOME_Event.h" - -#include -#include -#include - -#ifdef _DEBUG_ -static int MYDEBUG = 0; -#else -static int MYDEBUG = 0; -#endif - -static int INCMEMORY = 4+12; - - -//--------------------------------------------------------------- -size_t -VISU::ScalarMapOnDeformedShape_i -::IsPossible(Result_i* theResult, - const std::string& theMeshName, - VISU::Entity theEntity, - const std::string& theFieldName, - CORBA::Long theTimeStampNumber, - bool theIsMemoryCheck) -{ - size_t aResult = 0; - try{ - aResult = TSuperClass::IsPossible(theResult, - theMeshName, - theEntity, - theFieldName, - theTimeStampNumber, - false); - if(theIsMemoryCheck && aResult){ - VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName, - theEntity, - theFieldName, - theTimeStampNumber); - VISU::PField aField = anInput->GetField(theMeshName, - (VISU::TEntity)theEntity, - theFieldName); - if(aField->myNbComp <= 1) - return 0; - - bool anIsEstimated = true; - size_t aSize = anInput->GetTimeStampOnMeshSize(theMeshName, - (VISU::TEntity)theEntity, - theFieldName, - theTimeStampNumber, - anIsEstimated); - if(anIsEstimated) - aSize *= INCMEMORY; - aResult = VISU_PipeLine::CheckAvailableMemory(aSize); - if(MYDEBUG) - MESSAGE("ScalarMapOnDeformedShape_i::IsPossible - CheckAvailableMemory = "<(theOrigin)){ - ScalarMapOnDeformedShape_i* anOrigin = const_cast(aPrs3d); - CORBA::String_var aFieldName = anOrigin->GetScalarFieldName(); - - SetScalarField(anOrigin->GetScalarEntity(), - aFieldName, - anOrigin->GetScalarTimeStampNumber()); - Update(); - } -} - - -//--------------------------------------------------------------- -void -VISU::ScalarMapOnDeformedShape_i -::SetScale(CORBA::Double theScale) -{ - VISU::TSetModified aModified(this); - - ProcessVoidEvent(new TVoidMemFun1ArgEvent - (GetSpecificPL(), &VISU_ScalarMapOnDeformedShapePL::SetScale, theScale)); -} - - -//--------------------------------------------------------------- -CORBA::Double -VISU::ScalarMapOnDeformedShape_i -::GetScale() -{ - return myScalarMapOnDeformedShapePL->GetScale(); -} - - -//--------------------------------------------------------------- -void -VISU::ScalarMapOnDeformedShape_i -::CreatePipeLine(VISU_PipeLine* thePipeLine) -{ - if(!thePipeLine){ - myScalarMapOnDeformedShapePL = VISU_ScalarMapOnDeformedShapePL::New(); - }else - myScalarMapOnDeformedShapePL = dynamic_cast(thePipeLine); - - myScalarMapOnDeformedShapePL->GetMapper()->SetScalarVisibility(1); - - TSuperClass::CreatePipeLine(myScalarMapOnDeformedShapePL); -} - - -//--------------------------------------------------------------- -bool -VISU::ScalarMapOnDeformedShape_i -::CheckIsPossible() -{ - return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true); -} - - -//--------------------------------------------------------------- -VISU_Actor* -VISU::ScalarMapOnDeformedShape_i -::CreateActor() -{ - VISU_Actor* anActor = TSuperClass::CreateActor(true); - SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - int aDispMode = aResourceMgr->integerValue("VISU", "scalar_def_represent", 2); - bool toShrink = aResourceMgr->booleanValue("VISU", "scalar_def_shrink", false); - anActor->SetRepresentation(aDispMode); - if (toShrink) - anActor->SetShrink(); - anActor->SetVTKMapping(false); - return anActor; -} - - -//--------------------------------------------------------------- -void -VISU::ScalarMapOnDeformedShape_i -::UpdateActor(VISU_Actor* theActor) -{ - if(VISU_ScalarMapAct* anActor = dynamic_cast(theActor)){ - anActor->SetBarVisibility(true); - GetPipeLine()->GetMapper()->SetScalarVisibility(1); - } - TSuperClass::UpdateActor(theActor); -} - - -//--------------------------------------------------------------- -void -VISU::ScalarMapOnDeformedShape_i -::SetField(VISU::PField theField) -{ - TSuperClass::SetField(theField); - - if(!myScalarField) - myScalarField = theField; -} - - -//--------------------------------------------------------------- -void -VISU::ScalarMapOnDeformedShape_i -::SetScalarField(VISU::Entity theEntity, - const char* theFieldName, - CORBA::Long theTimeStampNumber) -{ - bool anIsModified = false; - - if(!anIsModified) - anIsModified |= myScalarEntity != theEntity; - - if(!anIsModified) - anIsModified |= myScalarFieldName != theFieldName; - - if(!anIsModified) - anIsModified |= myScalarTimeStampNumber != theTimeStampNumber; - - if(!anIsModified) - return; - - VISU::TSetModified aModified(this); - - VISU::TEntity aEntity = VISU::TEntity(theEntity); - VISU::Result_i::PInput anInput = GetCResult()->GetInput(GetCMeshName(), - theEntity, - theFieldName, - theTimeStampNumber); - myScalarField = anInput->GetField(GetCMeshName(), aEntity, theFieldName); - - VISU::PUnstructuredGridIDMapper anIDMapper = - anInput->GetTimeStampOnMesh(GetCMeshName(), - aEntity, - theFieldName, - theTimeStampNumber); - - vtkUnstructuredGrid* anOutput = anIDMapper->GetUnstructuredGridOutput(); - if(myScalarMapOnDeformedShapePL && anOutput) - ProcessVoidEvent(new TVoidMemFun1ArgEvent - (GetSpecificPL(), &VISU_ScalarMapOnDeformedShapePL::SetScalars, anOutput)); - - myScalarEntity = theEntity; - myScalarFieldName = theFieldName; - myScalarTimeStampNumber = theTimeStampNumber; - - SetTitle(theFieldName); - SetScalarMode(GetScalarMode()); - if(!IsRangeFixed() && IsPipeLineExists()) - SetSourceRange(); - - myParamsTime.Modified(); -} - - -//--------------------------------------------------------------- -VISU::Entity -VISU::ScalarMapOnDeformedShape_i -::GetScalarEntity() -{ - return myScalarEntity; -} - - -//--------------------------------------------------------------- -char* -VISU::ScalarMapOnDeformedShape_i -::GetScalarFieldName() -{ - return CORBA::string_dup(myScalarFieldName.c_str()); -} - - -//--------------------------------------------------------------- -CORBA::Long -VISU::ScalarMapOnDeformedShape_i -::GetScalarTimeStampNumber() -{ - return myScalarTimeStampNumber; -} - - -//--------------------------------------------------------------- -VISU::PField -VISU::ScalarMapOnDeformedShape_i -::GetScalarField() -{ - return myScalarField; -} diff --git a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh deleted file mode 100644 index 83f2e64d..00000000 --- a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh +++ /dev/null @@ -1,179 +0,0 @@ -// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// -// 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 VISU_I_EXPORT ScalarMapOnDeformedShape_i : public virtual POA_VISU::ScalarMapOnDeformedShape, - public virtual ScalarMap_i - { - static int myNbPresent; - ScalarMapOnDeformedShape_i(const ScalarMapOnDeformedShape_i&); - - public: - //---------------------------------------------------------------------------- - typedef ScalarMap_i TSuperClass; - typedef VISU::ScalarMapOnDeformedShape TInterface; - - explicit - ScalarMapOnDeformedShape_i(EPublishInStudyMode thePublishInStudyModep); - - virtual - ~ScalarMapOnDeformedShape_i(); - - virtual - VISU::VISUType - GetType() - { - return VISU::TSCALARMAPONDEFORMEDSHAPE; - } - - virtual - void - SetScale(CORBA::Double theScale); - - virtual - CORBA::Double - GetScale(); - - virtual - void - SameAs(const Prs3d_i* theOrigin); - - VISU_ScalarMapOnDeformedShapePL* - GetSpecificPL() - { - return myScalarMapOnDeformedShapePL; - } - - protected: - //! Redefines VISU_ColoredPrs3d_i::SetField - virtual - void - SetField(VISU::PField theField); - - //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine - virtual - void - CreatePipeLine(VISU_PipeLine* thePipeLine); - - //! Redefines VISU_ColoredPrs3d_i::CheckIsPossible - virtual - bool - CheckIsPossible(); - - public: - //! Redefines VISU_ColoredPrs3d_i::IsPossible - static - size_t - IsPossible(Result_i* theResult, - const std::string& theMeshName, - VISU::Entity theEntity, - const std::string& theFieldName, - CORBA::Long theTimeStampNumber, - bool theIsMemoryCheck); - - //! Redefines VISU_ColoredPrs3d_i::IsPossible - virtual - Storable* - Create(const std::string& theMeshName, - VISU::Entity theEntity, - const std::string& theFieldName, - CORBA::Long theTimeStampNumber); - - //! Redefines VISU_ColoredPrs3d_i::ToStream - virtual - void - ToStream(std::ostringstream& theStr); - - //! Redefines VISU_ColoredPrs3d_i::Restore - virtual - Storable* - Restore(SALOMEDS::SObject_ptr theSObject, - const Storable::TRestoringMap& theMap); - - static const std::string myComment; - - virtual - const char* - GetComment() const; - - virtual - QString - GenerateName(); - - virtual - const char* - GetIconName(); - - virtual - VISU_Actor* - CreateActor(); - - virtual - void - UpdateActor(VISU_Actor* theActor) ; - - virtual - void - SetScalarField(VISU::Entity theEntity, - const char* theFieldName, - CORBA::Long theTimeStampNumber); - - virtual - VISU::Entity - GetScalarEntity(); - - virtual - char* - GetScalarFieldName(); - - virtual - CORBA::Long - GetScalarTimeStampNumber(); - - virtual - VISU::PField - GetScalarField(); - - private: - VISU_ScalarMapOnDeformedShapePL *myScalarMapOnDeformedShapePL; - - PField myScalarField; - VISU::Entity myScalarEntity; - std::string myScalarFieldName; - CORBA::Long myScalarTimeStampNumber; - }; -} -#endif diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index d974a484..61edb836 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -443,7 +443,7 @@ VISU::ScalarMap_i vtkTextProperty* aTitleProp = aScalarBar->GetTitleTextProperty(); aTitleProp->SetFontFamily(GetTitFontType()); - GetTitleColor(&anRGB[0],&anRGB[1],&anRGB[2]); + GetTitleColor(anRGB[0],anRGB[1],anRGB[2]); aTitleProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); IsBoldTitle()? aTitleProp->BoldOn() : aTitleProp->BoldOff(); @@ -453,7 +453,7 @@ VISU::ScalarMap_i vtkTextProperty* aLabelProp = aScalarBar->GetLabelTextProperty(); aLabelProp->SetFontFamily(GetLblFontType()); - GetLabelColor(&anRGB[0],&anRGB[1],&anRGB[2]); + GetLabelColor(anRGB[0],anRGB[1],anRGB[2]); aLabelProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); IsBoldLabel()? aLabelProp->BoldOn() : aLabelProp->BoldOff(); diff --git a/src/VISU_I/VISU_StreamLines_i.cc b/src/VISU_I/VISU_StreamLines_i.cc index 8919fc3e..01ebfa16 100644 --- a/src/VISU_I/VISU_StreamLines_i.cc +++ b/src/VISU_I/VISU_StreamLines_i.cc @@ -120,7 +120,7 @@ VISU::StreamLines_i ::StreamLines_i(EPublishInStudyMode thePublishInStudyMode) : ColoredPrs3d_i(thePublishInStudyMode), ScalarMap_i(thePublishInStudyMode), - DeformedShape_i(thePublishInStudyMode), + MonoColorPrs_i(thePublishInStudyMode), myStreamLinesPL(NULL), myAppendFilter(vtkAppendFilter::New()) {} diff --git a/src/VISU_I/VISU_StreamLines_i.hh b/src/VISU_I/VISU_StreamLines_i.hh index f0cee757..a1ccf3b9 100644 --- a/src/VISU_I/VISU_StreamLines_i.hh +++ b/src/VISU_I/VISU_StreamLines_i.hh @@ -27,7 +27,8 @@ #ifndef VISU_StreamLines_i_HeaderFile #define VISU_StreamLines_i_HeaderFile -#include "VISU_DeformedShape_i.hh" +//#include "VISU_DeformedShape_i.hh" +#include "VISU_MonoColorPrs_i.hh" class VISU_StreamLinesPL; class vtkAppendFilter; @@ -36,14 +37,15 @@ namespace VISU { //---------------------------------------------------------------------------- class VISU_I_EXPORT StreamLines_i : public virtual POA_VISU::StreamLines, - public virtual DeformedShape_i + public virtual MonoColorPrs_i + //public virtual DeformedShape_i { static int myNbPresent; StreamLines_i(const StreamLines_i&); public: //---------------------------------------------------------------------------- - typedef DeformedShape_i TSuperClass; + typedef MonoColorPrs_i TSuperClass; typedef VISU::StreamLines TInterface; explicit diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index 3abd1ecc..0910d8dc 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -36,6 +36,8 @@ #include "VISU_TableReader.hxx" #include "VISU_ConvertorUtils.hxx" +#include "utilities.h" + #ifdef _DEBUG_ static int MYDEBUG = 0; #else @@ -66,6 +68,7 @@ const char* VISU::Table_i::GetComment() const VISU::Table_i::Table_i( SALOMEDS::Study_ptr theStudy, const char* theObjectEntry ) : PrsObject_i(theStudy) { + MESSAGE("Table_i::Table_i - "<FindObjectID(theObjectEntry); myOrientation = VISU::Table::HORIZONTAL; } @@ -74,7 +77,7 @@ VISU::Table_i::Table_i( SALOMEDS::Study_ptr theStudy, const char* theObjectEntry */ VISU::Table_i::~Table_i() { - MESSAGE("Table_i::~Table_i"); + MESSAGE("Table_i::~Table_i - "<NewObject(aFileObject); anAttr = aStudyBuilder->FindOrCreateAttribute(aRealObject, "AttributeName"); aName = SALOMEDS::AttributeName::_narrow(anAttr); - if(MYDEBUG) cout<<"aTable2D.myTitle = "<SetValue(aTable2D.myTitle.c_str()); } else { @@ -1215,7 +1218,7 @@ VISU::ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy) int kEnd = aNewTable2D.myRows[0].myValues.size(); aTableOfReal->SetNbColumns(kEnd); for(int j = 0, jEnd = aNewTable2D.myRows.size(); j < jEnd; j++){ - if(MYDEBUG) cout<<"j = "<GetFather(); + aSObj = aSObj->GetFather(); + aSObj = aSObj->GetFather(); + CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObj); + if (CORBA::is_nil(anObject)) return false; + aNewData.myResult = dynamic_cast(VISU::GetServant(anObject).in()); + VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aNewData.myField); if(VISU::Storable::FindValue(aMap,"myComment") != "FIELD") return false; @@ -490,7 +499,12 @@ double getMaxFieldsValue( QList& theFieldsLst ) return aRes; } -void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { +void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) +{ + int nbf = myFieldsLst.size(); + if( theFieldNum<0 || theFieldNum>nbf-1 ) + return; + FieldData& aData = myFieldsLst[theFieldNum]; // Delete previous presentations @@ -596,13 +610,14 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { aSequence); break; case VISU::TSCALARMAPONDEFORMEDSHAPE: // Scalar map on deformed shape - GeneratePresentations(myStudy, - aData, - aResult, - isRangeDefined(), - myTimeMinVal, - myTimeMaxVal, - aSequence); + case VISU::TDEFORMEDSHAPEANDSCALARMAP: + GeneratePresentations(myStudy, + aData, + aResult, + isRangeDefined(), + myTimeMinVal, + myTimeMaxVal, + aSequence); break; default: MESSAGE("Not implemented for this presentation type: " << aData.myPrsType); @@ -618,7 +633,7 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { myFieldsAbsFrames.push_back(aData.myNbFrames); if (theFieldNum == getNbFields() - 1) { - if ( aData.myPrsType != VISU::TGAUSSPOINTS) { + if ( aData.myPrsType != VISU::TGAUSSPOINTS && aData.myPrsType != TDEFORMEDSHAPEANDSCALARMAP && aData.myPrsType != TSCALARMAPONDEFORMEDSHAPE) { // Initialize the MinMax controller VISU::PCompositeMinMaxController aMinMaxController(new VISU::TCompositeMinMaxController()); @@ -1369,11 +1384,17 @@ void VISU_TimeAnimation::saveImages( int theFieldId, if (myDumpFormat.compare("AVI") != 0) { QString aFile(myDumpPath); + int aFrameNb = myFrame; // parallel animation mode + if ( myAnimationMode == VISU::Animation::SUCCESSIVE ) // successive animation mode + aFrameNb = getRelativeFrameNumber(myFrame).second; + + int aMaxNb = myFieldsLst[theFieldId].myTiming.size(); + int nbDigits = QString("%1").arg(aMaxNb).length(); + QString aFormat = QString("%.%1d_").arg(nbDigits); + QString aName; - if ( myAnimationMode == VISU::Animation::PARALLEL ) // parallel animation mode - aName = QString("%1").arg(myFieldsLst[theFieldId].myTiming[myFrame]); - else // successive animation mode - aName = QString("%1").arg(myFieldsLst[theFieldId].myTiming[getRelativeFrameNumber(myFrame).second]); + aName.sprintf(aFormat.toLatin1().data(), aFrameNb); + aName += QString("%1").arg(myFieldsLst[theFieldId].myTiming[aFrameNb]); int aPos = -1; while ((aPos = aName.indexOf(".")) > -1 ) @@ -1678,7 +1699,8 @@ std::string GetPresentationComment (VISU::VISUType thePrsType) aPrsCmt = VISU::GaussPoints_i::myComment; break; case VISU::TSCALARMAPONDEFORMEDSHAPE: - aPrsCmt = VISU::ScalarMapOnDeformedShape_i::myComment; + case VISU::TDEFORMEDSHAPEANDSCALARMAP: + aPrsCmt = VISU::DeformedShapeAndScalarMap_i::myComment; break; default: aPrsCmt = "Unknown presentation"; @@ -1842,9 +1864,15 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField) for (anIter->Init(); anIter->More(); anIter->Next()) { _PTR(SObject) aRefObj = anIter->Value(); _PTR(SObject) aFieldObj; + if (!aRefObj->ReferencedObject(aFieldObj) ) continue; + int nbAttr = aFieldObj->GetAllAttributes().size(); + //std::string name1 = aFieldObj->GetName(); + if(nbAttr<1) + continue; + addField(aFieldObj); if ( isRangeDefined() || isSequenceDefined() ) myFieldsAbsFrames.pop_back(); @@ -1882,8 +1910,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 if (strName == VISU::DeformedShapeAndScalarMap_i::myComment.c_str()) + aData.myPrsType = VISU::TDEFORMEDSHAPEANDSCALARMAP; else continue; generatePresentations(getNbFields()-1); diff --git a/src/VISU_I/VISU_TimeAnimation.h b/src/VISU_I/VISU_TimeAnimation.h index 09221faa..d3ed8fa7 100644 --- a/src/VISU_I/VISU_TimeAnimation.h +++ b/src/VISU_I/VISU_TimeAnimation.h @@ -26,6 +26,9 @@ #include "VISUConfig.hh" +#include "VISU_Result_i.hh" +#include "SALOME_GenericObjPointer.hh" + #include #include @@ -37,7 +40,7 @@ class VISU_Actor; namespace VISU { - class Result_i; + //class Result_i; class ColoredPrs3d_i; class ExecutionState; } @@ -52,6 +55,8 @@ struct FieldData std::vector myActors; // Actors std::vector myTiming; // time values CORBA::Float myOffset[3]; + typedef SALOME::GenericObjPtr TResultPtr; + TResultPtr myResult; }; diff --git a/src/VISU_I/VISU_Vectors_i.cc b/src/VISU_I/VISU_Vectors_i.cc index 525ebc98..1ef9bab6 100644 --- a/src/VISU_I/VISU_Vectors_i.cc +++ b/src/VISU_I/VISU_Vectors_i.cc @@ -129,6 +129,7 @@ VISU::Vectors_i ::Vectors_i(EPublishInStudyMode thePublishInStudyMode) : ColoredPrs3d_i(thePublishInStudyMode), ScalarMap_i(thePublishInStudyMode), + MonoColorPrs_i(thePublishInStudyMode), DeformedShape_i(thePublishInStudyMode), myLineWidth(1.0), myVectorsPL(NULL) diff --git a/src/VISU_I/VISU_View_i.cc b/src/VISU_I/VISU_View_i.cc index 22f813cd..a7bd144f 100644 --- a/src/VISU_I/VISU_View_i.cc +++ b/src/VISU_I/VISU_View_i.cc @@ -2382,7 +2382,8 @@ namespace VISU { VISU::VISUType aType = myPrs->GetType(); if (aType != VISU::TSCALARMAP && aType != VISU::TDEFORMEDSHAPE && - aType != VISU::TSCALARMAPONDEFORMEDSHAPE) { + aType != VISU::TSCALARMAPONDEFORMEDSHAPE && + aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) { myResult = "Insideframe representation is not available for this type of presentations."; return; } diff --git a/src/VISU_SWIG/VISU_Example_01.py b/src/VISU_SWIG/VISU_Example_01.py index 159ebdf4..a9e97fc3 100644 --- a/src/VISU_SWIG/VISU_Example_01.py +++ b/src/VISU_SWIG/VISU_Example_01.py @@ -100,7 +100,7 @@ cutplanes.SetOrientation(VISU.CutPlanes.YZ, 0, 0) myView.DisplayOnly(cutplanes) print "Creating Scalar Map On Deformed Shape.......", -scalarmapondefshape = myVisu.ScalarMapOnDeformedShapeOnField(myResult,myMeshName,myNodeEntity,'vitesse',1); +scalarmapondefshape = myVisu.DeformedShapeAndScalarMapOnField(myResult,myMeshName,myNodeEntity,'vitesse',1); if scalarmapondefshape is None : print "Error" else : print "OK" scalarmapondefshape.SetScalarField(myCellEntity,'pression',2); @@ -158,7 +158,7 @@ cutplanes1.SetOrientation(VISU.CutPlanes.YZ, 0, 0) myView1.DisplayOnly(cutplanes1) print "Creating Scalar Map On Deformed Shape.......", -scalarmapondefshape1 = myVisu.ScalarMapOnDeformedShapeOnField(myResult1,myMeshName1,myCellEntity,'vectoriel field',1); +scalarmapondefshape1 = myVisu.DeformedShapeAndScalarMapOnField(myResult1,myMeshName1,myCellEntity,'vectoriel field',1); if scalarmapondefshape1 is None : print "Error" else : print "OK" myView1.DisplayOnly(scalarmapondefshape1) diff --git a/src/VISU_SWIG/VISU_Example_07.py b/src/VISU_SWIG/VISU_Example_07.py index c676ddf5..600f3225 100644 --- a/src/VISU_SWIG/VISU_Example_07.py +++ b/src/VISU_SWIG/VISU_Example_07.py @@ -144,7 +144,7 @@ scmap = myVisu.CutPlanesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1); ChangeRepresentation(scmap, VISU.SHADED, 1, 1, 0.5, 3) print "Creating Scalar Map On Deformed Shape.......", -scmap = myVisu.ScalarMapOnDeformedShapeOnField(myResult,myMeshName,VISU.NODE,myFieldName,1); +scmap = myVisu.DeformedShapeAndScalarMapOnField(myResult,myMeshName,VISU.NODE,myFieldName,1); ChangeRepresentation(scmap, VISU.SHADED, 1, 1, 0.5, 3) print "Creating Deformed Shape.......", diff --git a/src/VISU_SWIG/visu.py b/src/VISU_SWIG/visu.py index abc7e831..f9df3325 100644 --- a/src/VISU_SWIG/visu.py +++ b/src/VISU_SWIG/visu.py @@ -628,15 +628,15 @@ def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDi else : aVISUObjList.append(aPrsObj) - if HasValue(thePrsTypeList,VISU.TSCALARMAPONDEFORMEDSHAPE) : - print " Creating ScalarMapOnDeformedShapeOnField", - aPrsObj = theVisu.ScalarMapOnDeformedShapeOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId) + if HasValue(thePrsTypeList,VISU.TSCALARMAPONDEFORMEDSHAPE) or HasValue(thePrsTypeList,VISU.TDEFORMEDSHAPEANDSCALARMAP) : + print " Creating DeformedShapeAndScalarMapOnField", + aPrsObj = theVisu.DeformedShapeAndScalarMapOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId) if aPrsObj is None : print "Error" else : print ",OK" theView.DisplayOnly(aPrsObj) theView.FitAll() - aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSCALARMAPONDEFORMEDSHAPE." + thePictureExt + aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TDEFORMEDSHAPEANDSCALARMAP." + thePictureExt aPictureName = re.sub("\s+","_", aPictureName) theView.SavePicture(aPictureName) if theIsAutoDelete : diff --git a/src/VISU_SWIG/visu_cache.py b/src/VISU_SWIG/visu_cache.py index bdd01bde..d30ad9d5 100644 --- a/src/VISU_SWIG/visu_cache.py +++ b/src/VISU_SWIG/visu_cache.py @@ -56,6 +56,7 @@ PRS3D_TYPE_LIST.append(VISU.TDEFORMEDSHAPE) PRS3D_TYPE_LIST.append(VISU.TVECTORS) PRS3D_TYPE_LIST.append(VISU.TSTREAMLINES) PRS3D_TYPE_LIST.append(VISU.TSCALARMAPONDEFORMEDSHAPE) +PRS3D_TYPE_LIST.append(VISU.TDEFORMEDSHAPEANDSCALARMAP) #--------------------------------------------------------------- @@ -83,4 +84,4 @@ anInput.myEntity = VISU.CELL; anInput.myFieldName = "pression"; WalkTroughTimeStamps(VISU.TGAUSSPOINTS, anInput, aViewManager) -#execfile('/data/apo/a.py') \ No newline at end of file +#execfile('/data/apo/a.py') diff --git a/src/VISU_SWIG/visu_pointmap3d.py b/src/VISU_SWIG/visu_pointmap3d.py new file mode 100755 index 00000000..f16d6ee0 --- /dev/null +++ b/src/VISU_SWIG/visu_pointmap3d.py @@ -0,0 +1,57 @@ +import os +import VISU +from visu_gui import * + +aTableFile = os.getenv('DATA_DIR') + '/Tables/table_test.xls' + +aTableSObject = myVisu.ImportTables(aTableFile) + +aTable = None +if aTableSObject: + anIsFound, aSObject = aTableSObject.FindSubObject(1) + if anIsFound: + aTable = aSObject.GetObject() + +aViewManager = myVisu.GetViewManager(); +aView = aViewManager.Create3DView() +if aView is None : print "Creating View Error" +print aTable + +##########Get Values################ +aScaleFactor = aTable.GetScaleFactor(); +anIsContourPrs = aTable.GetIsContourPrs(); +aNbOfContours = aTable.GetNbOfContours(); +aScaling = aTable.GetScaling(); +aMin = aTable.GetMin(); +aMax = aTable.GetMax(); +aSourceMin = aTable.GetSourceMin(); +aSourceMax = aTable.GetSourceMax(); +aPosX = aTable.GetPosX(); +aPosY = aTable.GetPosY(); +aHeight = aTable.GetHeight(); +aWidth = aTable.GetWidth(); +aNbColors = aTable.GetNbColors(); +aLabels = aTable.GetLabels(); +aBarOrientation = aTable.GetBarOrientation(); + + +print "Get Values:" +print "aScaleFactor = ", aScaleFactor +print "anIsContourPrs = ", anIsContourPrs +print "aNbOfContours = ", aNbOfContours +print "aScaling = ", aScaling +print "===== SCALAR BAR =======" +print "aMin = ", aMin +print "aMax = ", aMax +print "aSourceMin = ", aSourceMin +print "aSourceMax = ", aSourceMax +print "aPosX = ", aPosX +print "aPosY = ", aPosY +print "aHeight = ", aHeight +print "aWidth = ", aWidth +print "aNbColors = ", aNbColors +print "aLabels = ", aLabels +print "aBarOrientation = ", aBarOrientation + +aView.DisplayOnly( aTable ) +aView.FitAll() \ No newline at end of file diff --git a/src/VVTK/VVTK_ImageWriter.cxx b/src/VVTK/VVTK_ImageWriter.cxx index 30853887..6177a068 100755 --- a/src/VVTK/VVTK_ImageWriter.cxx +++ b/src/VVTK/VVTK_ImageWriter.cxx @@ -30,6 +30,8 @@ #include +#include "utilities.h" + #include #include #include @@ -61,7 +63,7 @@ VVTK_ImageWriter VVTK_ImageWriter ::~VVTK_ImageWriter() { - if(MYDEBUG) cout<<"VVTK_ImageWriter::~VVTK_ImageWriter - this = "< #ifdef _DEBUG_ static int MYDEBUG = 0; @@ -49,9 +50,9 @@ VVTK_ImageWriterMgr int aMax = std::numeric_limits::max() / 2; mySemaphore = new QSemaphore(aMax); mySemaphore->acquire( aMax ); - if(MYDEBUG) cout<<"VVTK_ImageWriterMgr::VVTK_ImageWriterMgr "<< + if(MYDEBUG) MESSAGE("VVTK_ImageWriterMgr::VVTK_ImageWriterMgr "<< //"- total = "<total()<< - "; available = "<available()<setValue( aCursorSize ); - - aPyramidHeight = aResourceMgr->doubleValue( "VISU", "picking_pyramid_height", aPyramidHeight ); - myPyramidHeightSpinBox->setValue( aPyramidHeight ); - - aPointTolerance = aResourceMgr->doubleValue( "VISU", "picking_point_tolerance", aPointTolerance ); - myPointToleranceSpinBox->setValue( aPointTolerance ); - - aColor = aResourceMgr->colorValue( "VISU", "picking_selection_color", aColor ); - //QPalette aPalette( mySelectionColorButton->palette() ); - //aPalette.setColor( mySelectionColorButton->backgroundRole(), aColor ); - mySelectionColorButton->setColor( aColor ); - - anInfoWindowTransparency = aResourceMgr->integerValue( "VISU", "picking_transparency", anInfoWindowTransparency ); - myTransparencySpinBox->setValue( anInfoWindowTransparency ); - - anInfoWindowPosition = aResourceMgr->integerValue( "VISU", "picking_position", anInfoWindowPosition ); - myPositionComboBox->setCurrentIndex( anInfoWindowPosition ); - - aZoomFactor = aResourceMgr->doubleValue( "VISU", "picking_zoom_factor", aZoomFactor ); - myZoomFactorSpinBox->setValue( aZoomFactor ); - - aStepNumber = aResourceMgr->integerValue( "VISU", "picking_step_number", aStepNumber ); - myStepNumberSpinBox->setValue( aStepNumber ); - - aDisplayParentMesh = aResourceMgr->booleanValue( "VISU", "picking_display_parent_mesh", aDisplayParentMesh ); - myDisplayParentMeshCheckBox->setChecked( aDisplayParentMesh ); - + myCursorSizeSpinBox->setValue( myPickingSettings->GetCursorSize() ); + myPyramidHeightSpinBox->setValue( myPickingSettings->GetPyramidHeight() ); + myPointToleranceSpinBox->setValue( myPickingSettings->GetPointTolerance() ); + myTransparencySpinBox->setValue( int(myPickingSettings->GetInfoWindowTransparency() * 100.0) ); + myPositionComboBox->setCurrentIndex( myPickingSettings->GetInfoWindowPosition() ); + myZoomFactorSpinBox->setValue( myPickingSettings->GetZoomFactor() ); + myStepNumberSpinBox->setValue( myPickingSettings->GetStepNumber() ); + myDisplayParentMeshCheckBox->setChecked( myPickingSettings->GetDisplayParentMesh() ); + + vtkFloatingPointType* aColor = myPickingSettings->GetColor(); + mySelectionColorButton->setColor( QColor( ( int )( aColor[0] * 255.0 ), + ( int )( aColor[1] * 255.0 ), + ( int )( aColor[2] * 255.0 ) ) ); onClickApply(); } @@ -621,8 +566,6 @@ void VVTK_PickingDlg::KeyPressed() void VVTK_PickingDlg::onClickApply() { - myPickingSettings->SetInitial( false ); - myPickingSettings->SetCursorSize( myCursorSizeSpinBox->value() ); myPickingSettings->SetPyramidHeight( myPyramidHeightSpinBox->value() ); myPickingSettings->SetPointTolerance( myPointToleranceSpinBox->value() ); diff --git a/src/VVTK/VVTK_Recorder.cxx b/src/VVTK/VVTK_Recorder.cxx index 4208ca75..e9e173f7 100755 --- a/src/VVTK/VVTK_Recorder.cxx +++ b/src/VVTK/VVTK_Recorder.cxx @@ -320,7 +320,7 @@ VVTK_Recorder myPaused = myPaused ? 0 : 1; if(myPaused && !myFrameIndexes.empty()){ myFrameIndexes.back() *= -1; - if(MYDEBUG) cout<<"VVTK_Recorder::Pause - myFrameIndexes.back() = "<