From 7760b741863e8c011912617a654c5fafaae302b1 Mon Sep 17 00:00:00 2001 From: dmv Date: Tue, 8 Apr 2008 12:39:56 +0000 Subject: [PATCH] NPAL 13444 Generate from table Plot3D presentation --- idl/VISU_Gen.idl | 210 +++-- src/CONVERTOR/Makefile.am | 6 +- src/CONVERTOR/VISUConvertor.cxx | 48 +- src/CONVERTOR/VISU_Convertor_impl.cxx | 58 +- src/CONVERTOR/VISU_IDMapper.cxx | 82 +- src/CONVERTOR/VISU_IDMapper.hxx | 50 +- src/CONVERTOR/VISU_MedConvertor.cxx | 69 +- src/CONVERTOR/VISU_Structures_impl.cxx | 44 +- src/CONVERTOR/VISU_Structures_impl.hxx | 20 + src/CONVERTOR/VISU_TableReader.cxx | 400 ++++++++ src/CONVERTOR/VISU_TableReader.hxx | 110 +++ src/OBJECT/Makefile.am | 8 +- src/OBJECT/VISU_Actor.cxx | 14 +- src/OBJECT/VISU_Actor.h | 25 +- src/OBJECT/VISU_ActorBase.cxx | 82 ++ src/OBJECT/VISU_ActorBase.h | 78 ++ src/OBJECT/VISU_ActorFactory.h | 7 +- src/OBJECT/VISU_PointMap3dActor.cxx | 139 +++ src/OBJECT/VISU_PointMap3dActor.h | 95 ++ src/PIPELINE/Makefile.am | 8 + src/PIPELINE/VISUPipeLine.cxx | 344 ++++--- src/PIPELINE/VISU_ColoredPL.cxx | 9 - src/PIPELINE/VISU_ColoredPL.hxx | 30 - src/PIPELINE/VISU_DeformedGridPL.cxx | 235 +++++ src/PIPELINE/VISU_DeformedGridPL.hxx | 116 +++ src/PIPELINE/VISU_GaussPointsPL.cxx | 1 + src/PIPELINE/VISU_GaussPointsPL.hxx | 4 +- src/PIPELINE/VISU_MergedPL.cxx | 51 ++ src/PIPELINE/VISU_MergedPL.hxx | 75 ++ src/PIPELINE/VISU_MeshPL.cxx | 2 +- src/PIPELINE/VISU_Plot3DPL.cxx | 7 +- src/PIPELINE/VISU_Plot3DPL.hxx | 8 +- src/PIPELINE/VISU_PolyDataPL.cxx | 279 +----- src/PIPELINE/VISU_PolyDataPL.hxx | 105 +-- src/PIPELINE/VISU_ScalarMapPL.cxx | 1 + src/PIPELINE/VISU_ScalarMapPL.hxx | 4 +- src/VISUGUI/Makefile.am | 2 + src/VISUGUI/VISU_msg_en.po | 91 ++ src/VISUGUI/VisuGUI.cxx | 66 +- src/VISUGUI/VisuGUI.h | 1 + src/VISUGUI/VisuGUI_ActionsDef.h | 1 + src/VISUGUI/VisuGUI_ClippingDlg.cxx | 30 +- src/VISUGUI/VisuGUI_Displayer.cxx | 10 +- src/VISUGUI/VisuGUI_Displayer.h | 1 + src/VISUGUI/VisuGUI_GaussPointsDlg.cxx | 2 +- src/VISUGUI/VisuGUI_Prs3dDlg.cxx | 2 +- src/VISUGUI/VisuGUI_Selection.cxx | 52 +- src/VISUGUI/VisuGUI_Table3dDlg.cxx | 771 ++++++++++++++++ src/VISUGUI/VisuGUI_Table3dDlg.h | 187 ++++ src/VISUGUI/VisuGUI_ViewTools.cxx | 12 + src/VISUGUI/VisuGUI_ViewTools.h | 1 + src/VISU_I/Makefile.am | 2 + src/VISU_I/VISUConfig.cc | 2 + src/VISU_I/VISU_ColoredPrs3d_i.cc | 20 +- src/VISU_I/VISU_ColoredPrs3d_i.hh | 6 +- src/VISU_I/VISU_CutLines_i.hh | 2 +- src/VISU_I/VISU_DumpPython.cc | 4 +- src/VISU_I/VISU_GaussPoints_i.cc | 2 +- src/VISU_I/VISU_GaussPoints_i.hh | 2 +- src/VISU_I/VISU_Gen_i.cc | 50 +- src/VISU_I/VISU_Mesh_i.cc | 2 +- src/VISU_I/VISU_Mesh_i.hh | 2 +- src/VISU_I/VISU_PointMap3d_i.cc | 1166 ++++++++++++++++++++++++ src/VISU_I/VISU_PointMap3d_i.hh | 263 ++++++ src/VISU_I/VISU_Prs3d_i.cc | 12 +- src/VISU_I/VISU_Prs3d_i.hh | 5 +- src/VISU_I/VISU_Result_i.cc | 61 +- src/VISU_I/VISU_ScalarMap_i.cc | 2 +- src/VISU_I/VISU_ScalarMap_i.hh | 2 +- src/VISU_I/VISU_Table_i.cc | 229 +---- src/VISU_I/VISU_ViewManager_i.cc | 31 + src/VISU_I/VISU_ViewManager_i.hh | 3 + src/VISU_I/VISU_View_i.cc | 39 +- src/VVTK/VVTK_ViewModel.cxx | 6 +- 74 files changed, 4820 insertions(+), 1146 deletions(-) create mode 100644 src/CONVERTOR/VISU_TableReader.cxx create mode 100644 src/CONVERTOR/VISU_TableReader.hxx create mode 100644 src/OBJECT/VISU_ActorBase.cxx create mode 100644 src/OBJECT/VISU_ActorBase.h create mode 100644 src/OBJECT/VISU_PointMap3dActor.cxx create mode 100644 src/OBJECT/VISU_PointMap3dActor.h create mode 100644 src/PIPELINE/VISU_DeformedGridPL.cxx create mode 100644 src/PIPELINE/VISU_DeformedGridPL.hxx create mode 100644 src/PIPELINE/VISU_MergedPL.cxx create mode 100644 src/PIPELINE/VISU_MergedPL.hxx create mode 100644 src/VISUGUI/VisuGUI_Table3dDlg.cxx create mode 100644 src/VISUGUI/VisuGUI_Table3dDlg.h create mode 100644 src/VISU_I/VISU_PointMap3d_i.cc create mode 100644 src/VISU_I/VISU_PointMap3d_i.hh diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 9e1958f8..67d4485b 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -81,6 +81,7 @@ module VISU { TSCALARMAPONDEFORMEDSHAPE, /*!< Scalar map on deformed shape 3D presentation object */ TGAUSSPOINTS, /*!< Gauss Points 3D presentation object */ TPLOT3D, /*!< Plot3D 3D presentation object */ + TPOINTMAP3D, /*!< 3D presentation for table object */ TCUTPLANES, /*!< Cut planes 3D presentation object */ TCUTLINES, /*!< Cut lines 3D presentation object */ TVECTORS, /*!< Vectors 3D presentation object */ @@ -135,59 +136,6 @@ module VISU { interface PrsObject : RemovableObject { }; - //------------------------------------------------------- - /*! \brief %Table representation interface - * - * Presentation parameters of the %Table view. - */ - interface Table : PrsObject { - /*! - * Sets the title of the table. - * \param theTitle String parameter defining the title of this table. - */ - void SetTitle(in string theTitle); - - /*! - * Gets the title of the table. - * \return A string value containing the title of the table. - */ - string GetTitle(); - - /*! - * This enumeration contains a set of elements defining the orientation of the table. - */ - enum Orientation { - HORIZONTAL, /*!< Horizontal orientation of the table. */ - VERTIACAL /*!< Vertical orientation of the table. */ - }; - - /*! - * Sets orientation of the table. - * \param theOrientation This input parameter defines the orientation of the table. - * It is taken from the Orientation enumeration. - */ - void SetOrientation(in Orientation theOrientation); - - /*! - * Gets orientation of the table. - * \return Orientation of the table. The returned value will correspond - * to one of the elements the Orientation enumeration. - */ - Orientation GetOrientation(); - - /*! - * Gets the number of rows of the table. - * \return Long value corresponding to the number of rows of the table - */ - long GetNbRows(); - - /*! - * Gets the number of columns of the table. - * \return Long value corresponding to the number of columns of the table - */ - long GetNbColumns(); - }; - //------------------------------------------------------- /*! \brief Interface of curve representation. * @@ -412,16 +360,8 @@ module VISU { * bar is displayed along with each colored field presentation and serves for * consulting the correspondance between colors and data values. */ - interface ColoredPrs3d : Prs3d + interface ColoredPrs3dBase : Prs3d { - /*! Sets the method of coloring of the elements composing a 3D presentation. - */ - void SetScalarMode(in long theScalarMode); - - /*! Gets the method of coloring of the elements composing a 3D presentation. - */ - long GetScalarMode(); - /*! * Sets scalar range - min and max boundaries of the scalar bar. * \param theMin Min boundary of the scalar bar. @@ -447,7 +387,7 @@ module VISU { /*! * Gets the min boundary of the scalar bar from source data. */ - double GetSourceMin(); + double GetSourceMin(); /*! * Gets the max boundary of the scalar bar from source data. @@ -509,7 +449,6 @@ module VISU { * will be used for visualization of this presentable object. */ long GetNbColors(); - /*! * Sets the number of labels which will be used for indication of color gradation * of the scalar bar. @@ -524,17 +463,6 @@ module VISU { */ long GetLabels(); - /*! - * Sets the title of the scalar bar. By default - the name of the selected result is used. - * \param theName String parameter defining the name of the scalar bar. - */ - void SetTitle(in string theName); - - /*! - * Gets the title of the scalar bar. - */ - string GetTitle(); - /*! %Orientation of the scalar bar (to provide backward compatibility). */ enum Orientation { HORIZONTAL, /*!< Horizontal orientation of the scalar bar.*/ @@ -552,6 +480,32 @@ module VISU { * Gets the type of orientation of the scalar bar (to provide backward compatibility). */ Orientation GetBarOrientation(); + }; + + /*! \brief Additional Interface for the %Colored 3D Presentations + * + */ + + interface ColoredPrs3d : ColoredPrs3dBase + { + /*! + * Sets the title of the scalar bar. By default - the name of the selected result is used. + * \param theName String parameter defining the name of the scalar bar. + */ + void SetTitle(in string theName); + + /*! + * Gets the title of the scalar bar. + */ + string GetTitle(); + + /*! Sets the method of coloring of the elements composing a 3D presentation. + */ + void SetScalarMode(in long theScalarMode); + + /*! Gets the method of coloring of the elements composing a 3D presentation. + */ + long GetScalarMode(); /*! * Add group as geometry of presentation. @@ -560,7 +514,6 @@ module VISU { */ void AddMeshOnGroup(in string theGroupName); - /*! * PrsMerger method: * Remove all groups.(The scalar map will be placed on all mesh). @@ -702,7 +655,8 @@ module VISU { * bar is displayed along with each colored field presentation and serves for * consulting the correspondance between colors and data values. */ - interface ScalarMap : ColoredPrs3d { + + interface ScaledPrs3d { /*! * Sets the type of scaling of the values reflected by the scalar bar. * \param theScaling The value of this parameter is taken from the Scaling enumeration. @@ -713,6 +667,9 @@ module VISU { * Gets the type of scaling of the values reflected by this presentation. */ Scaling GetScaling(); + }; + + interface ScalarMap : ColoredPrs3d, ScaledPrs3d { }; @@ -961,7 +918,44 @@ module VISU { * consists of deforming initial planar mesh according to values assigned to the mesh elements. * If mesh not planar but volumic one, it is possible to generate intermediate planar mesh. */ - interface Plot3D : ScalarMap { + interface Plot3dBase { + /*! + * Sets the scale factor for scalar values + * (how much corresponding mesh elements should be translated). + * \param theScaleFactor The scaling factor. + */ + void SetScaleFactor (in double theScaleFactor); + + /*! + * Gets the scale factor for scalar values. + * (how much corresponding mesh elements is translated) + */ + double GetScaleFactor(); + + /*! + * Sets presentation type: contour or surface. + * \param theIsContourPrs Define, whether presentation type is contour. + */ + void SetContourPrs (in boolean theIsContourPrs ); + + /*! + * Returns true if presentation type is contour. + */ + boolean GetIsContourPrs(); + + /*! + * Sets the number of contours. + * \param theNb The number of contours. + */ + void SetNbOfContours (in long theNb); + + /*! + * Gets the number of contours. + */ + long GetNbOfContours(); + }; + + interface Plot3D : ScalarMap, Plot3dBase { /*! * This enumeration contains a set of elements defining * the type of orientation in 3D space of the cutting plane. @@ -1015,41 +1009,67 @@ module VISU { * Returns true if a position of cutting plane is relative */ boolean IsPositionRelative(); + }; + //------------------------------------------------------- + /*! \brief %Table representation interface + * + * Presentation parameters of the %Table view. + */ + interface Table : PrsObject { /*! - * Sets the scale factor for scalar values - * (how much corresponding mesh elements should be translated). - * \param theScaleFactor The scaling factor. + * Sets the title of the table. + * \param theTitle String parameter defining the title of this table. */ - void SetScaleFactor (in double theScaleFactor); + void SetTitle(in string theTitle); /*! - * Gets the scale factor for scalar values. - * (how much corresponding mesh elements is translated) + * Gets the title of the table. + * \return A string value containing the title of the table. + */ + string GetTitle(); + + /*! + * This enumeration contains a set of elements defining the orientation of the table. */ - double GetScaleFactor(); + enum Orientation { + HORIZONTAL, /*!< Horizontal orientation of the table. */ + VERTIACAL /*!< Vertical orientation of the table. */ + }; /*! - * Sets presentation type: contour or surface. - * \param theIsContourPrs Define, whether presentation type is contour. + * Sets orientation of the table. + * \param theOrientation This input parameter defines the orientation of the table. + * It is taken from the Orientation enumeration. */ - void SetContourPrs (in boolean theIsContourPrs ); + void SetOrientation(in Orientation theOrientation); /*! - * Returns true if presentation type is contour. + * Gets orientation of the table. + * \return Orientation of the table. The returned value will correspond + * to one of the elements the Orientation enumeration. */ - boolean GetIsContourPrs(); + Orientation GetOrientation(); /*! - * Sets the number of contours. - * \param theNb The number of contours. + * Gets the number of rows of the table. + * \return Long value corresponding to the number of rows of the table */ - void SetNbOfContours (in long theNb); + long GetNbRows(); /*! - * Gets the number of contours. + * Gets the number of columns of the table. + * \return Long value corresponding to the number of columns of the table */ - long GetNbOfContours(); + long GetNbColumns(); + }; + + //------------------------------------------------------- + /*! \brief %PointMap3d representation interface + * + * Presentation parameters of the %Table Point Map in 3d view. + */ + interface PointMap3d : ColoredPrs3dBase, ScaledPrs3d, Plot3dBase, Table { }; //------------------------------------------------------- diff --git a/src/CONVERTOR/Makefile.am b/src/CONVERTOR/Makefile.am index 9bfefbf3..448bbdca 100644 --- a/src/CONVERTOR/Makefile.am +++ b/src/CONVERTOR/Makefile.am @@ -46,7 +46,8 @@ salomeinclude_HEADERS= \ VISU_UsedPointsFilter.hxx \ VISU_CommonCellsFilter.hxx \ VISUConvertor.hxx \ - VISU_GaussMergeFilter.hxx + VISU_GaussMergeFilter.hxx \ + VISU_TableReader.hxx dist_libVisuConvertor_la_SOURCES= \ VISU_IDMapper.cxx \ @@ -66,7 +67,8 @@ dist_libVisuConvertor_la_SOURCES= \ VISU_MergeFilterUtilities.cxx \ VISU_UsedPointsFilter.cxx \ VISU_CommonCellsFilter.cxx \ - VISU_GaussMergeFilter.cxx + VISU_GaussMergeFilter.cxx \ + VISU_TableReader.cxx libVisuConvertor_la_CPPFLAGS= \ -ftemplate-depth-32 \ diff --git a/src/CONVERTOR/VISUConvertor.cxx b/src/CONVERTOR/VISUConvertor.cxx index d92e9d8c..df0b03f6 100644 --- a/src/CONVERTOR/VISUConvertor.cxx +++ b/src/CONVERTOR/VISUConvertor.cxx @@ -27,15 +27,17 @@ #include "VISU_Convertor.hxx" #include "VISU_ConvertorUtils.hxx" +#include "VISU_Convertor_impl.hxx" +#include "VISU_TableReader.hxx" + #include #include -#include #include #include #include #include -#include "VISU_Convertor_impl.hxx" +#include #include using namespace std; @@ -51,8 +53,8 @@ static int MYDEBUG = 0; typedef vtkUnstructuredGrid TOutput; -void parseFile(const char* theFileName) -{ +void ParseMEDFile(const char* theFileName) +{ #ifndef _DEXCEPT_ try{ #endif @@ -178,24 +180,38 @@ void parseFile(const char* theFileName) #endif } -int main(int argc, char** argv){ - if(argc > 1){ - QFileInfo fi(argv[1]); - for(int i = 0; i < 1; i++){ - if(fi.exists()){ - if(fi.isDir()){ - QDir aDir(fi.absFilePath()); - QStringList aStringList = aDir.entryList("*.med",QDir::Files); +void ParseXLSFile(const char* theFileName) +{ + VISU::TTableContainer aContainer; + VISU::ImportTables( theFileName, aContainer ); +} + +int +main( int argc, char** argv ) +{ + if ( argc > 1 ) { + QFileInfo aFileInfo( argv[1] ); + for ( int i = 0; i < 1; i++ ) { + if ( aFileInfo.exists() ) { + if ( aFileInfo.isDir() ) { + QDir aDir( aFileInfo.absFilePath() ); + QStringList aStringList = aDir.entryList( "*.med", QDir::Files ); int jEnd = aStringList.count(); - for(int j = 0; j < jEnd; j++){ - parseFile(aDir.filePath(aStringList[j]).latin1()); + for ( int j = 0; j < jEnd; j++ ) { + ParseMEDFile( aDir.filePath( aStringList[j] ).latin1() ); } - }else{ - parseFile(argv[1]); + } else { + QString anExtension = aFileInfo.extension(); + if ( anExtension == "med" ) + ParseMEDFile( argv[1] ); + else if ( anExtension == "xls" || anExtension == "txt" ) + ParseXLSFile( argv[1] ); } } } + return 0; } + return 1; } diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 750e3a7a..c8bdc2d1 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -666,17 +666,11 @@ VISU_Convertor_impl vtkIdType aVGeom = VISUGeom2VTK(aEGeom); VISU::PSubMeshImpl aSubMesh = anIter->second; - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - aSubMesh->myIsStructured = aMesh->myIsStructured; - aSubMesh->myType = aMesh->myType; - aSubMesh->myGrilleStructure = aMesh->myGrilleStructure; - aSubMesh->myObjID2StructureID = aMesh->myObjID2StructureID; - //ENK: 23.11.2006 - - const VISU::PUnstructuredGrid& aSource = aSubMesh->GetSource(); - aSource->ShallowCopy(aMesh->GetPointSet()); + aSubMesh->CopyStructure( aMesh ); aSubMesh->myStartID = aCellID; + + const VISU::PUnstructuredGrid& aSource = aSubMesh->GetSource(); GetCellsOnSubMesh(aSource, aMeshOnEntity, aSubMesh, aVGeom); anAppendFilter->AddInput(aSource.GetPointer()); @@ -688,14 +682,8 @@ VISU_Convertor_impl aSubMeshArr[anID] = aSubMesh; } - aMeshOnEntity->myNamedPointCoords = aMesh->myNamedPointCoords; - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - aMeshOnEntity->myIsStructured = aMesh->myIsStructured; - aMeshOnEntity->myType = aMesh->myType; - aMeshOnEntity->myGrilleStructure = aMesh->myGrilleStructure; - aMeshOnEntity->myObjID2StructureID = aMesh->myObjID2StructureID; - //ENK: 23.11.2006 + aMeshOnEntity->CopyStructure( aMesh ); aMeshOnEntity->myIsVTKDone = true; @@ -747,23 +735,16 @@ VISU_Convertor_impl #ifndef _DEXCEPT_ try{ #endif - if(!aFamily->myIsVTKDone){ - const VISU::PUnstructuredGrid& aSource = aFamily->GetSource(); - if(MYVTKDEBUG) aSource->DebugOn(); + if ( !aFamily->myIsVTKDone ) { + GetMeshOnEntity( theMeshName, theEntity ); - GetMeshOnEntity(theMeshName,theEntity); + LoadFamilyOnEntity( aMesh, aMeshOnEntity, aFamily ); - LoadFamilyOnEntity(aMesh,aMeshOnEntity,aFamily); - aSource->ShallowCopy(aMesh->GetPointSet()); - GetCellsOnFamily(aSource,aMeshOnEntity,aFamily); + aFamily->CopyStructure( aMesh ); + + const VISU::PUnstructuredGrid& aSource = aFamily->GetSource(); + GetCellsOnFamily( aSource, aMeshOnEntity, aFamily ); - aFamily->myNamedPointCoords = aMesh->myNamedPointCoords; - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - aFamily->myIsStructured = aMesh->myIsStructured; - aFamily->myType = aMesh->myType; - aFamily->myGrilleStructure = aMesh->myGrilleStructure; - aFamily->myObjID2StructureID = aMesh->myObjID2StructureID; - //ENK: 23.11.2006 aFamily->myIsVTKDone = true; if(MYDEBUGWITHFILES){ @@ -840,13 +821,9 @@ VISU_Convertor_impl } aFamilyArr[anID] = aFamily; } - aGroup->myNamedPointCoords = aMesh->myNamedPointCoords; - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - aGroup->myIsStructured = aMesh->myIsStructured; - aGroup->myType = aMesh->myType; - aGroup->myGrilleStructure = aMesh->myGrilleStructure; - aGroup->myObjID2StructureID = aMesh->myObjID2StructureID; - //ENK: 23.11.2006 + + aGroup->CopyStructure( aMesh ); + aGroup->myIsVTKDone = true; if(MYDEBUGWITHFILES){ @@ -994,12 +971,7 @@ VISU_Convertor_impl aVTKMeshOnEntity->myEntity); } - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - anUnstructuredGridIDMapper->myIsStructured = aMesh->myIsStructured; - anUnstructuredGridIDMapper->myType = aMesh->myType; - anUnstructuredGridIDMapper->myGrilleStructure = aMesh->myGrilleStructure; - anUnstructuredGridIDMapper->myObjID2StructureID = aMesh->myObjID2StructureID; - //ENK: 23.11.2006 + anUnstructuredGridIDMapper->CopyStructure( aMesh ); anUnstructuredGridIDMapper->myIsVTKDone = true; diff --git a/src/CONVERTOR/VISU_IDMapper.cxx b/src/CONVERTOR/VISU_IDMapper.cxx index 0fc47bb2..bf1e8fca 100644 --- a/src/CONVERTOR/VISU_IDMapper.cxx +++ b/src/CONVERTOR/VISU_IDMapper.cxx @@ -33,7 +33,47 @@ namespace VISU { //--------------------------------------------------------------- - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing + TStructuredId + ::TStructuredId() + { + myData[0] = myData[1] = myData[2] = -1; + } + + vtkIdType& + TStructuredId + ::operator [] ( size_t theId ) + { + return myData[ theId ]; + } + + const vtkIdType& + TStructuredId + ::operator [] ( size_t theId ) const + { + return myData[ theId ]; + } + + bool + TStructuredId + ::operator == ( const TStructuredId& theId ) const + { + return + theId[0] == myData[0] && + theId[1] == myData[1] && + theId[2] == myData[2]; + } + + //--------------------------------------------------------------- + void + TStructured + ::CopyStructure(PStructured theStructured) + { + myIsPolarType = theStructured->myIsPolarType; + myIsStructured = theStructured->myIsStructured; + myGrilleStructure = theStructured->myGrilleStructure; + myObj2StructuredId = theStructured->myObj2StructuredId; + } + bool TStructured ::IsStructured() const @@ -41,39 +81,49 @@ namespace VISU return myIsStructured; } - TIdTypeVector + TStructuredId TStructured ::GetStructure() { return myGrilleStructure; } - TIdTypeVector + vtkIdType + TStructured + ::GetStructureDim() + { + return + vtkIdType( myGrilleStructure[0] >= 0) + + vtkIdType( myGrilleStructure[1] >= 0) + + vtkIdType( myGrilleStructure[2] >= 0); + } + + TStructuredId TStructured ::GetIndexesOfNode(vtkIdType theNodeId) { - TIdTypeVector aNullVec; - if(!IsStructured()) - return aNullVec; - TObj2IdTypeVector::const_iterator aIter = myObjID2StructureID.find(theNodeId); - if(aIter!=myObjID2StructureID.end()) - return aIter->second; - else - return aNullVec; + if ( IsStructured() ) { + TObj2StructuredId::const_iterator aIter = myObj2StructuredId->find( theNodeId ); + if ( aIter != myObj2StructuredId->end() ) + return aIter->second; + } + + return TStructuredId(); } vtkIdType TStructured - ::GetObjectIDByIndexes(TIdTypeVector theVec) + ::GetObjectIDByIndexes(TStructuredId theVec) { - TObj2IdTypeVector::const_iterator aIter = myObjID2StructureID.begin(); - for(;aIter!=myObjID2StructureID.end();aIter++){ - if(theVec == aIter->second) + TObj2StructuredId::const_iterator aIter = myObj2StructuredId->begin(); + for (; aIter != myObj2StructuredId->end(); aIter++ ) { + if ( theVec == aIter->second ) return aIter->first; } + return -1; } - //ENK: 23.11.2006 + //--------------------------------------------------------------- vtkFloatingPointType* diff --git a/src/CONVERTOR/VISU_IDMapper.hxx b/src/CONVERTOR/VISU_IDMapper.hxx index 767def57..2657165c 100644 --- a/src/CONVERTOR/VISU_IDMapper.hxx +++ b/src/CONVERTOR/VISU_IDMapper.hxx @@ -51,18 +51,43 @@ namespace VISU using MED::SharedPtr; using MED::TVector; + + //--------------------------------------------------------------- + class TStructuredId + { + vtkIdType myData[3]; + + public: + TStructuredId(); + + vtkIdType& + operator [] ( size_t theId ); + + const vtkIdType& + operator [] ( size_t theId ) const; + + bool + operator == ( const TStructuredId& theId ) const; + }; + + typedef std::map TObj2StructuredId; + typedef MED::SharedPtr PObj2StructuredId; - typedef TVector TIdTypeVector; - typedef std::map TObj2IdTypeVector; + struct TStructured; + typedef MED::SharedPtr PStructured; struct VISU_CONVERTOR_EXPORT TStructured { TStructured(): myIsStructured(false), - myType(true) + myIsPolarType(true) {} + //! Copys all information which should be sinchronized between two instances virtual + void + CopyStructure(PStructured theStructured); + bool IsStructured() const; @@ -71,34 +96,35 @@ namespace VISU * see also MED::TGrilleInfo::GetGrilleStructure * see also MED::TGrilleInfo::GetNbIndexes */ - virtual TIdTypeVector + TStructuredId GetStructure(); + vtkIdType + GetStructureDim(); + /*! * Gets i,j,k by object id * return -1, if not found */ - virtual TIdTypeVector + TStructuredId GetIndexesOfNode(vtkIdType theNodeId); /*! * Gets object id by i,j,k * return -1, if not found */ - virtual vtkIdType - GetObjectIDByIndexes(TIdTypeVector theVec); + vtkIdType + GetObjectIDByIndexes(TStructuredId theVec); - public: bool myIsStructured; //!< To define mesh type (structured - true, non structured - false) - bool myType; //!< To define structured mesh is polair + bool myIsPolarType; //!< To define structured mesh is polair /*!provides grille structure for structured grid. * Example: {3,4,5}, 3 nodes in X axe, 4 nodes in Y axe, ... */ - TIdTypeVector myGrilleStructure; - - TObj2IdTypeVector myObjID2StructureID;//!< map of object id to i,j,k ids of structured grid nodes + TStructuredId myGrilleStructure; + PObj2StructuredId 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 bd4878e7..b10aa67e 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -621,51 +621,45 @@ namespace VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; MED::TEntityInfo::const_iterator anEntityIter = theEntityInfo.begin(); - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - int iMax,jMax,kMax; - iMax=jMax=kMax=0; - - MED::TIntVector aIntVec; - if(theGrilleInfo->GetGrilleType()!=MED::eGRILLE_STANDARD) - for(int i=0;imyDim;i++) - aIntVec.push_back(theGrilleInfo->GetNbIndexes(i)); - else - aIntVec = theGrilleInfo->GetGrilleStructure(); - - theMesh->myGrilleStructure = aIntVec; - - switch((theMesh->GetStructure()).size()){ - case 3: kMax=theMesh->GetStructure()[2]; - case 2: jMax=theMesh->GetStructure()[1]; - case 1: iMax=theMesh->GetStructure()[0]; + VISU::TStructuredId& aGrilleStructure = theMesh->myGrilleStructure; + if ( theGrilleInfo->GetGrilleType() != MED::eGRILLE_STANDARD ) + for ( int aDimId = 0; aDimId < theMesh->myDim; aDimId++ ) + aGrilleStructure[aDimId] = theGrilleInfo->GetNbIndexes(aDimId); + else { + MED::TIntVector aVector = theGrilleInfo->GetGrilleStructure(); + for ( int aDimId = 0; aDimId < aVector.size(); aDimId++ ) + aGrilleStructure[aDimId] = aVector[aDimId]; } + + int kMax = aGrilleStructure[2]; + int jMax = aGrilleStructure[1]; + int iMax = aGrilleStructure[0]; - int iii=0; - switch(theMesh->myDim){ + int iii = 0; + VISU::TObj2StructuredId& aObj2StructuredId = theMesh->myObj2StructuredId; + switch ( theMesh->myDim ) { case 1: - for(int i=1;i<=iMax;i++) - (theMesh->myObjID2StructureID[i-1]).push_back(i); + for ( int i = 1; i <= iMax; i++ ) + aObj2StructuredId[i-1][0] = i; break; case 2: - for(int j=1;j<=jMax;j++) - for(int i=1;i<=iMax;i++){ - (theMesh->myObjID2StructureID[iii]).push_back(i); - (theMesh->myObjID2StructureID[iii]).push_back(j); + for ( int j = 1; j <= jMax; j++ ) + for ( int i = 1; i <= iMax; i++ ) { + aObj2StructuredId[iii][0] = i; + aObj2StructuredId[iii][1] = j; iii++; } break; case 3: - for(int k=1;k<=kMax ;k++) - for(int j=1;j<=jMax;j++) - for(int i=1;i<=iMax;i++) - { - (theMesh->myObjID2StructureID[iii]).push_back(i); - (theMesh->myObjID2StructureID[iii]).push_back(j); - (theMesh->myObjID2StructureID[iii]).push_back(k); - iii++; - } + for ( int k = 1; k <= kMax; k++ ) + for ( int j = 1; j <= jMax; j++ ) + for ( int i = 1; i <= iMax; i++ ) { + aObj2StructuredId[iii][0] = i; + aObj2StructuredId[iii][1] = j; + aObj2StructuredId[iii][2] = k; + iii++; + } } - //ENK: 23.11.2006 for(; anEntityIter != theEntityInfo.end(); anEntityIter++){ const MED::EEntiteMaillage& aMEntity = anEntityIter->first; @@ -1437,10 +1431,9 @@ VISU_MedConvertor aMesh->myNbPoints = aGrilleInfo->GetNbNodes(); aMesh->myEntityInfo = anEntityInfo; - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing + + aMesh->myIsPolarType = (MED::eGRILLE_POLAIRE == aGrilleInfo->GetGrilleType()); aMesh->myIsStructured = true; - aMesh->myType = (MED::eGRILLE_POLAIRE == aGrilleInfo->GetGrilleType()); - //ENK: 23.11.2006 #ifndef _DEXCEPT_ try{ #endif diff --git a/src/CONVERTOR/VISU_Structures_impl.cxx b/src/CONVERTOR/VISU_Structures_impl.cxx index a00e8e90..7c269284 100644 --- a/src/CONVERTOR/VISU_Structures_impl.cxx +++ b/src/CONVERTOR/VISU_Structures_impl.cxx @@ -631,8 +631,6 @@ namespace VISU //--------------------------------------------------------------- - - TUnstructuredGridIDMapperImpl ::TUnstructuredGridIDMapperImpl(): myIsSpecialKey(false) @@ -1058,6 +1056,16 @@ namespace VISU myStartID(0) {} + void + TSubMeshImpl + ::CopyStructure( PStructured theStructured ) + { + TStructured::CopyStructure( theStructured ); + + if ( PMeshImpl aMesh = theStructured ) + GetSource()->ShallowCopy( aMesh->GetPointSet() ); + } + vtkIdType TSubMeshImpl ::GetElemObjID(vtkIdType theID) const @@ -1092,6 +1100,16 @@ namespace VISU anAppendFilter->SetMappingInputs(true); } + void + TMeshOnEntityImpl + ::CopyStructure( PStructured theStructured ) + { + TStructured::CopyStructure( theStructured ); + + if ( PMeshImpl aMesh = theStructured ) + myNamedPointCoords = aMesh->myNamedPointCoords; + } + vtkIdType TMeshOnEntityImpl ::GetNodeVTKID(vtkIdType theID) const @@ -1161,6 +1179,18 @@ namespace VISU } //--------------------------------------------------------------- + void + TFamilyImpl + ::CopyStructure( PStructured theStructured ) + { + TStructured::CopyStructure( theStructured ); + + if ( PMeshImpl aMesh = theStructured ) { + myNamedPointCoords = aMesh->myNamedPointCoords; + GetSource()->ShallowCopy( aMesh->GetPointSet() ); + } + } + vtkIdType TFamilyImpl ::GetElemVTKID(vtkIdType theID) const @@ -1223,6 +1253,16 @@ namespace VISU //--------------------------------------------------------------- + void + TGroupImpl + ::CopyStructure( PStructured theStructured ) + { + TStructured::CopyStructure( theStructured ); + + if ( PMeshImpl aMesh = theStructured ) + myNamedPointCoords = aMesh->myNamedPointCoords; + } + TNbASizeCells TGroupImpl ::GetNbASizeCells() const diff --git a/src/CONVERTOR/VISU_Structures_impl.hxx b/src/CONVERTOR/VISU_Structures_impl.hxx index 71b078b8..35bbc9e3 100644 --- a/src/CONVERTOR/VISU_Structures_impl.hxx +++ b/src/CONVERTOR/VISU_Structures_impl.hxx @@ -613,6 +613,11 @@ namespace VISU { TSubMeshImpl(); + //! Reimplements the TStructured::CopyStructure + virtual + void + CopyStructure( PStructured theStructured ); + //! To implement the TIDMapper::GetElemObjID virtual vtkIdType @@ -644,6 +649,11 @@ namespace VISU { TMeshOnEntityImpl(); + //! Reimplements the TStructured::CopyStructure + virtual + void + CopyStructure( PStructured theStructured ); + //! Reimplement the TIDMapper::GetNodeVTKID virtual vtkIdType @@ -699,6 +709,11 @@ namespace VISU struct VISU_CONVERTOR_EXPORT TFamilyImpl: virtual TFamily, virtual TUnstructuredGridHolder { + //! Reimplements the TStructured::CopyStructure + virtual + void + CopyStructure( PStructured theStructured ); + //! Reimplement the TIDMapper::GetNodeObjID vtkIdType GetNodeObjID(vtkIdType theID) const ; @@ -744,6 +759,11 @@ namespace VISU struct VISU_CONVERTOR_EXPORT TGroupImpl: virtual TGroup, virtual TAppendFilterHolder { + //! Reimplements the TStructured::CopyStructure + virtual + void + CopyStructure( PStructured theStructured ); + //! Calculate pair of values - number of cells and its size TNbASizeCells GetNbASizeCells() const; diff --git a/src/CONVERTOR/VISU_TableReader.cxx b/src/CONVERTOR/VISU_TableReader.cxx new file mode 100644 index 00000000..c130a575 --- /dev/null +++ b/src/CONVERTOR/VISU_TableReader.cxx @@ -0,0 +1,400 @@ +// 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: +// Author: +// Module : VISU + +#include "VISU_TableReader.hxx" + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + + +//--------------------------------------------------------------- +int +VISU::TTable2D +::Check() +{ + if ( myRows.empty() ) + return 0; + + int iEnd = myRows[0].myValues.size(); + if ( iEnd == 0 ) + return 0; + + if ( myColumnTitles.size() != iEnd ) + myColumnTitles.resize( iEnd ); + + if ( myColumnUnits.size() != iEnd ) + myColumnUnits.resize( iEnd ); + + int jEnd = myRows.size(); + for ( int j = 0; j < jEnd; j++ ) + if ( myRows[j].myValues.size() != iEnd ) + return 0; + + return 1; +} + + +//--------------------------------------------------------------- +void +VISU::TTable2D +::getColumns(VISU::TTable2D& theTable2D) const +{ + TRows& aRows = theTable2D.myRows; + aRows.clear(); + if ( myRows.empty() ) + return; + + int jEnd = myRows.size(); + + //Define Titles & Units + theTable2D.myColumnTitles.resize(jEnd); + theTable2D.myColumnUnits.resize(jEnd); + for ( int j = 0; j < jEnd; j++ ) { + theTable2D.myColumnTitles[j] = myRows[j].myTitle; + theTable2D.myColumnUnits[j] = myRows[j].myUnit; + } + + //Define Rows + int iEnd = myRows[0].myValues.size(); + for ( int i = 0; i < iEnd; i++ ) { + TRow aNewRow; + aNewRow.myTitle = myColumnTitles[i]; + aNewRow.myUnit = myColumnUnits[i]; + aNewRow.myValues.resize(jEnd); + for ( int j = 0; j < jEnd; j++ ) { + aNewRow.myValues[j] = myRows[j].myValues[i]; + } + aRows.push_back(aNewRow); + } +} + + +//--------------------------------------------------------------- +namespace +{ + int getLine( std::ifstream& theStmIn, QString& theString ) + { + char tmp; + std::ostrstream aStrOut; + + while ( theStmIn.get( tmp ) ) { + aStrOut<= 0 ) { + data = aTmp.left( index ).stripWhiteSpace(); + cmt = aTmp.mid( index+1 ).stripWhiteSpace(); + } + // if comment is not empty, try to get keyword from it (separated by ':' symbol) + if ( !cmt.isEmpty() ) { + int index1 = cmt.find( ":" ); + if ( index1 >= 0 ) { + QString tmpstr = cmt.left( index1 ).stripWhiteSpace(); + if ( tmpstr == QString( "TITLE" ) || + tmpstr == QString( "COLUMN_TITLES" ) || + tmpstr == QString( "COLUMN_UNITS" ) || + tmpstr == QString( "COMMENT" ) ) { + keyword = tmpstr; + cmt = cmt.mid( index1+1 ).stripWhiteSpace(); + } + } + } + // if data is empty, process only comment + if ( data.isEmpty() ) { + // if keyword is found, try to process it + // elsewise it is a simple comment, just ignore it + if ( !keyword.isEmpty() ) { + if ( keyword == QString( "TITLE" ) ) { + QString title = cmt; + if ( aTable2D.myTitle != "" ) + title = QString( aTable2D.myTitle.c_str() ) + QString( " " ) + title; + if(MYDEBUG) std::cout << "...Table TITLE is: " << title.latin1() << std::endl; + aTable2D.myTitle = title.latin1(); + } + else if ( keyword == QString( "COLUMN_TITLES" ) ) { + // comment may contain column headers + QStringList aStrList = QStringList::split( "|", cmt ); + if(MYDEBUG) std::cout << "...Column TITLES are: "; + for ( int i = 0; i < aStrList.count(); i++ ) { + QString tmpstr = aStrList[ i ].stripWhiteSpace(); + if(MYDEBUG) std::cout << tmpstr.latin1() << " "; + aTable2D.myColumnTitles.push_back( tmpstr.latin1() ); + } + if(MYDEBUG) std::cout << std::endl; + } + else if ( keyword == QString( "COLUMN_UNITS" ) ) { + // comment may contain column units + QStringList aStrList = QStringList::split( " ", cmt ); + if(MYDEBUG) std::cout << "...Column UNITS are: "; + for ( int i = 0; i < aStrList.count(); i++ ) { + QString tmpstr = aStrList[ i ].stripWhiteSpace(); + if(MYDEBUG) std::cout << tmpstr.latin1() << " "; + aTable2D.myColumnUnits.push_back( tmpstr.latin1() ); + } + if(MYDEBUG) std::cout << std::endl; + } + else if ( keyword == QString( "COMMENT" ) ) { + // keyword 'COMMENT' processing can be here + // currently it is ignored + if(MYDEBUG) std::cout << "...COMMENT: " << cmt.latin1() << std::endl; + } + } + else { + if(MYDEBUG) std::cout << "...comment: " << cmt.latin1() << std::endl; + // simple comment processing can be here + // currently it is ignored + } + } + // if data is not empty, try to process it + else { + TTable2D::TRow aRow; + if(MYDEBUG) std::cout << "...New row is found: " << std::endl; + if ( !cmt.isEmpty() ) { + aRow.myTitle = cmt.latin1(); + if(MYDEBUG) std::cout << "......ROW TITLE is: " << cmt.latin1() << std::endl; + } + QString datar1 = data.replace(QRegExp("\t"), " "); + QStringList aValList = QStringList::split( " ", datar1 ); + for ( int i = 0; i < aValList.count(); i++ ) { + if ( aValList[i].stripWhiteSpace() != "" ) { + TTable2D::TValue aVal = aValList[i].stripWhiteSpace().latin1(); + aRow.myValues.push_back( aVal ); + } + } + if( aRow.myValues.size() > 0 ) + aTable2D.myRows.push_back( aRow ); + // ************** OLD CODE ****************** + /* + TValue aVal; + istrstream aStream( data ); + aStream.precision( STRPRECISION ); + while( aStream >> aVal ) { + aRow.myValues.push_back( aVal ); + } + if( aRow.myValues.size() > 0 ) + aTable2D.myRows.push_back( aRow ); + */ + // ************** OLD CODE ****************** + } + ::getLine( aStmIn, aTmp ); + } + if( aTable2D.Check() ) { + if(MYDEBUG) std::cout << "aTable2D is checked OK " << aTable2D.myTitle << std::endl; + theContainer.push_back( aTableIDMapper ); + } + } while ( !aStmIn.eof() ); + aStmIn.close(); + + if(MYDEBUG) std::cout << "After close" << std::endl; +} + + +//--------------------------------------------------------------- +VISU::TTableIDMapper +::TTableIDMapper(): + myOutput( vtkPolyData::New() ), + myXAxisPosition( -1 ) +{} + +VISU::TTableIDMapper +::~TTableIDMapper() +{ + myOutput->Delete(); +} + +vtkPolyData* +VISU::TTableIDMapper +::GetPolyDataOutput() +{ + if ( myXAxisPosition == -1 ) + SetXAxisPosition( 0 ); + + return myOutput; +} + +long unsigned int +VISU::TTableIDMapper +::GetMemorySize() +{ + return myOutput->GetActualMemorySize() * 1024; +} + +void +VISU::TTableIDMapper +::SetXAxisPosition( vtkIdType theAxisPosition ) +{ + if ( myXAxisPosition == theAxisPosition || !Check() ) + return; + + myOutput->Initialize(); + + if ( !Check() ) + return; + + TTable2D aTable2D; + getColumns( aTable2D ); + + vtkIdType aXSize = aTable2D.myRows[0].myValues.size(); + + // It is necessary to decrease the size at 1 take intoa account X axis + vtkIdType anYSize = aTable2D.myRows.size() - 1; + + vtkIdType aNbPoints = aXSize * anYSize; + + std::vector anXAxis(aXSize); + const TTable2D::TValues& aValues = aTable2D.myRows[theAxisPosition].myValues; + for ( vtkIdType aX = 0; aX < aXSize; aX++ ) + anXAxis[aX] = atof( aValues[aX].c_str() ); + + double aXRange = anXAxis[aXSize - 1] - anXAxis[0]; + double anYDelta = aXRange / anYSize; + std::vector anYAxis(anYSize); + for ( vtkIdType anY = 0; anY < anYSize; anY++ ) + anYAxis[anY] = anY * anYDelta; + + vtkPoints* aPoints = vtkPoints::New(); + aPoints->SetNumberOfPoints( aNbPoints ); + + vtkIntArray *aPointsIDMapper = vtkIntArray::New(); + aPointsIDMapper->SetName("VISU_POINTS_MAPPER"); + aPointsIDMapper->SetNumberOfComponents(2); + aPointsIDMapper->SetNumberOfTuples(aNbPoints); + int *aPointsIDMapperPtr = aPointsIDMapper->GetPointer(0); + + //vtkIntArray *aCellIDMapper = vtkIntArray::New(); + //aCellIDMapper->SetName("VISU_POINTS_MAPPER"); + //aCellIDMapper->SetNumberOfComponents(2); + //aCellIDMapper->SetNumberOfTuples(aNbPoints); + //int *aCellIDMapperPtr = aCellIDMapper->GetPointer(0); + + for ( vtkIdType aY = 0, aPntId = 0; aY < anYSize; aY++ ) { + for ( vtkIdType aX = 0; aX < aXSize; aX++, aPntId++ ) { + aPoints->SetPoint( aPntId, anXAxis[aX], anYAxis[aY], 0.0 ); + + *aPointsIDMapperPtr++ = aPntId; + *aPointsIDMapperPtr++ = 0; + + //*aCellIDMapperPtr++ = aPntId; + //*aCellIDMapperPtr++ = 0; + } + } + + std::vector anYData; + for ( vtkIdType anY = 0; anY < anYSize + 1; anY++ ) { + if ( anY == theAxisPosition ) + continue; + anYData.push_back( aTable2D.myRows[anY].myValues ); + } + + vtkDoubleArray* aScalars = vtkDoubleArray::New(); + aScalars->SetNumberOfComponents( 1 ); + aScalars->SetNumberOfTuples( aNbPoints ); + double *aScalarsPtr = aScalars->GetPointer(0); + for ( vtkIdType anY = 0; anY < anYSize; anY++ ) { + const TTable2D::TValues& aValues = anYData[anY]; + for ( vtkIdType aX = 0; aX < aXSize; aX++ ) { + double aValue = atof( aValues[aX].c_str() ); + *aScalarsPtr++ = aValue; + } + } + + vtkStructuredGrid* aStructuredGrid = vtkStructuredGrid::New(); + aStructuredGrid->SetPoints( aPoints ); + aPoints->Delete(); + + aStructuredGrid->SetDimensions( aXSize, anYSize, 1 ); + + aStructuredGrid->GetPointData()->AddArray( aPointsIDMapper ); + aPointsIDMapper->Delete(); + + //aStructuredGrid->GetCellData()->AddArray( aCellIDMapper ); + //aCellIDMapper->Delete(); + + aStructuredGrid->GetPointData()->SetScalars( aScalars ); + aScalars->Delete(); + + vtkStructuredGridGeometryFilter* aFilter = vtkStructuredGridGeometryFilter::New(); + aFilter->SetInput( aStructuredGrid ); + aFilter->Update(); + myOutput->ShallowCopy( aFilter->GetOutput() ); + aFilter->Delete(); +} diff --git a/src/CONVERTOR/VISU_TableReader.hxx b/src/CONVERTOR/VISU_TableReader.hxx new file mode 100644 index 00000000..1b724c34 --- /dev/null +++ b/src/CONVERTOR/VISU_TableReader.hxx @@ -0,0 +1,110 @@ +// VISU CONVERTOR : +// +// 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_TableReader.hxx +// Author : Alexey PETROV +// Module : VISU + +#ifndef VISU_TableReader_HeaderFile +#define VISU_TableReader_HeaderFile + +/*! + \file VISU_TableReader.hxx + \brief The file contains definition of the Table reading functionlity +*/ + +#include "VISUConvertor.hxx" + +#include "VISU_IDMapper.hxx" + +#include +#include + +namespace VISU +{ + //--------------------------------------------------------------- + struct VISU_CONVERTOR_EXPORT TTable2D + { + typedef std::string TValue; + typedef std::vector TValues; + + struct TRow + { + std::string myTitle; + std::string myUnit; + TValues myValues; + }; + + std::string myTitle; + std::vector myColumnUnits; + std::vector myColumnTitles; + + typedef std::vector TRows; + TRows myRows; + + int + Check(); + + void + getColumns( TTable2D& theTable2D ) const; + }; + + + //--------------------------------------------------------------- + class VISU_CONVERTOR_EXPORT TTableIDMapper: + public virtual TPolyDataIDMapper, + public virtual TTable2D + { + public: + TTableIDMapper(); + ~TTableIDMapper(); + + virtual + vtkPolyData* + GetPolyDataOutput(); + + virtual + long unsigned int + GetMemorySize(); + + void + SetXAxisPosition( vtkIdType theAxisPosition ); + + vtkIdType + GetXAxisPosition(); + + protected: + vtkIdType myXAxisPosition; + vtkPolyData* myOutput; + }; + typedef MED::SharedPtr PTableIDMapper; + + + //--------------------------------------------------------------- + typedef std::vector TTableContainer; + void ImportTables( const char* theFileName, TTableContainer& theContainer ); + + + //--------------------------------------------------------------- +} + +#endif diff --git a/src/OBJECT/Makefile.am b/src/OBJECT/Makefile.am index 555d1cd7..11b9d542 100644 --- a/src/OBJECT/Makefile.am +++ b/src/OBJECT/Makefile.am @@ -39,7 +39,9 @@ salomeinclude_HEADERS = \ VISU_MeshAct.h \ VISU_ScalarMapAct.h \ VISU_GaussPtsAct.h \ - VISU_VectorsAct.h + VISU_VectorsAct.h \ + VISU_PointMap3dActor.h \ + VISU_ActorBase.h dist_libVisuObject_la_SOURCES = \ VISU_Actor.cxx \ @@ -49,7 +51,9 @@ dist_libVisuObject_la_SOURCES = \ VISU_GaussPtsDeviceActor.cxx \ VISU_GaussPtsSettings.cxx \ VISU_GaussPtsAct.cxx \ - VISU_VectorsAct.cxx + VISU_VectorsAct.cxx \ + VISU_PointMap3dActor.cxx \ + VISU_ActorBase.cxx libVisuObject_la_CPPFLAGS= \ $(QT_INCLUDES) \ diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index ae36c573..e7200e45 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -30,6 +30,7 @@ #include "VISU_PipeLine.hxx" #include "VTKViewer_ShrinkFilter.h" #include "VTKViewer_GeometryFilter.h" +#include "VISU_ActorFactory.h" #include #include @@ -83,7 +84,6 @@ VISU_Actor ::VISU_Actor(): myIsVTKMapping(false), myPrs3d(NULL), - myActorFactory(NULL), myIsShrunk(false), myIsShrinkable(false), myShrinkFilter(VTKViewer_ShrinkFilter::New()), @@ -167,14 +167,14 @@ VISU_Actor } //---------------------------------------------------------------------------- -VISU::TActorFactory* +/*VISU::TActorFactory* VISU_Actor ::GetFactory() { return myActorFactory; -} +}*/ -void +/*void VISU_Actor ::SetFactory(VISU::TActorFactory* theActorFactory) { @@ -189,10 +189,10 @@ VISU_Actor _1)); myActorFactory = theActorFactory; -} +}*/ //---------------------------------------------------------------------------- -void +/*void VISU_Actor ::UpdateFromFactory() { @@ -201,7 +201,7 @@ VISU_Actor myActorFactory->UpdateActor(this); Update(); } -} +}*/ void VISU_Actor diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 96289417..d1c36b8c 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -30,7 +30,7 @@ #define VISU_ACTOR_H #include "SALOME_Actor.h" -#include "VISU_ActorFactory.h" +#include "VISU_ActorBase.h" #include "VISU_BoostSignals.h" #include "SVTK_DeviceActor.h" @@ -66,12 +66,10 @@ namespace VISU } //---------------------------------------------------------------------------- -class VTKOCC_EXPORT VISU_Actor : - public SALOME_Actor, - public boost::signalslib::trackable +class VTKOCC_EXPORT VISU_Actor : public VISU_ActorBase { public: - vtkTypeMacro(VISU_Actor,SALOME_Actor); + vtkTypeMacro(VISU_Actor, VISU_ActorBase); //static //VISU_Actor* @@ -99,19 +97,6 @@ class VTKOCC_EXPORT VISU_Actor : void SetPrs3d(VISU::Prs3d_i* thePrs3d); - //---------------------------------------------------------------------------- - VISU::TActorFactory* - GetFactory(); - - virtual - void - SetFactory(VISU::TActorFactory* theActorFactory); - - //---------------------------------------------------------------------------- - virtual - void - UpdateFromFactory(); - virtual void RemoveFromRender(); @@ -254,10 +239,6 @@ class VTKOCC_EXPORT VISU_Actor : VISU::Prs3d_i* myPrs3d; vtkSmartPointer myPipeLine; - VISU::TActorFactory* myActorFactory; - vtkTimeStamp myUpdateFromFactoryTime; - boost::signal1 myDestroySignal; - vtkSmartPointer myShrinkFilter; bool myIsShrinkable; bool myIsShrunk; diff --git a/src/OBJECT/VISU_ActorBase.cxx b/src/OBJECT/VISU_ActorBase.cxx new file mode 100644 index 00000000..812f790d --- /dev/null +++ b/src/OBJECT/VISU_ActorBase.cxx @@ -0,0 +1,82 @@ +// 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 : +// Author : +// Module : VISU +// $Header$ + +#include "VISU_ActorBase.h" +#include "VISU_ActorFactory.h" + +#include +#include + +VISU_ActorBase +::VISU_ActorBase() +{ + +} + +VISU_ActorBase +::~VISU_ActorBase() +{ + +} + +//---------------------------------------------------------------------------- +VISU::TActorFactory* +VISU_ActorBase +::GetFactory() +{ + return myActorFactory; +} + +void +VISU_ActorBase +::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_ActorBase +::UpdateFromFactory() +{ + if(myUpdateFromFactoryTime.GetMTime() < myActorFactory->GetMTime()){ + myUpdateFromFactoryTime.Modified(); + myActorFactory->UpdateActor(this); + Update(); + } +} + diff --git a/src/OBJECT/VISU_ActorBase.h b/src/OBJECT/VISU_ActorBase.h new file mode 100644 index 00000000..84909cbe --- /dev/null +++ b/src/OBJECT/VISU_ActorBase.h @@ -0,0 +1,78 @@ +// 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 : +// Author : +// Module : VISU +// $Header$ + +#ifndef VISU_ACTOR_BASE_H +#define VISU_ACTOR_BASE_H + +#include "SALOME_Actor.h" +#include "VISU_BoostSignals.h" + +#ifdef _WIN32 +#define VTKOCC_EXPORT __declspec (dllexport) +#else +#define VTKOCC_EXPORT VTK_EXPORT +#endif + + +//---------------------------------------------------------------------------- +namespace VISU +{ + struct TActorFactory; +} + + +//! This class defines an abstaract interface to manage actors +class VTKOCC_EXPORT VISU_ActorBase: public SALOME_Actor, + public boost::signalslib::trackable +{ + public: + vtkTypeMacro(VISU_ActorBase, SALOME_Actor); + + //---------------------------------------------------------------------------- + VISU::TActorFactory* + GetFactory(); + + virtual + void + SetFactory(VISU::TActorFactory* theActorFactory); + + //---------------------------------------------------------------------------- + virtual + void + UpdateFromFactory(); + + protected: + VISU_ActorBase(); + virtual ~VISU_ActorBase(); + + VISU::TActorFactory* myActorFactory; + vtkTimeStamp myUpdateFromFactoryTime; + boost::signal1 myDestroySignal; +}; + +#endif //VISU_ACTOR_BASE_H diff --git a/src/OBJECT/VISU_ActorFactory.h b/src/OBJECT/VISU_ActorFactory.h index ec7af383..c61061d2 100644 --- a/src/OBJECT/VISU_ActorFactory.h +++ b/src/OBJECT/VISU_ActorFactory.h @@ -30,8 +30,9 @@ #define VISU_ACTOR_FACTORY_H #include "VISU_BoostSignals.h" +#include "VISU_ActorBase.h" -class VISU_Actor; +class VISU_ActorBase; //---------------------------------------------------------------------------- namespace VISU @@ -66,12 +67,12 @@ namespace VISU //! To update the actor virtual void - UpdateActor(VISU_Actor* theActor) = 0; + UpdateActor(VISU_ActorBase* theActor) = 0; //! To unregister the actor virtual void - RemoveActor(VISU_Actor* theActor) = 0; + RemoveActor(VISU_ActorBase* theActor) = 0; }; } diff --git a/src/OBJECT/VISU_PointMap3dActor.cxx b/src/OBJECT/VISU_PointMap3dActor.cxx new file mode 100644 index 00000000..5fc9a53b --- /dev/null +++ b/src/OBJECT/VISU_PointMap3dActor.cxx @@ -0,0 +1,139 @@ +// 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 : +// Author : +// Module : VISU +// $Header$ + +#include "VISU_PointMap3dActor.h" +#include "VISU_PipeLine.hxx" +#include "VISU_ScalarBarActor.hxx" +#include "VISU_DeformedGridPL.hxx" + +#include +#include + +//using namespace std; +vtkStandardNewMacro(VISU_PointMap3dActor); + +//================================================================== +// function: Constructor +// purpose : +//================================================================== + +VISU_PointMap3dActor +::VISU_PointMap3dActor() +{ + myScalarBar = VISU_ScalarBarActor::New(); +} + +//================================================================== +// function: Destructor +// purpose : +//================================================================== + +VISU_PointMap3dActor +::~VISU_PointMap3dActor() +{ + myScalarBar->Delete(); +} + +//================================================================== +// function: AddToRender +// purpose : +//================================================================== +void +VISU_PointMap3dActor +::AddToRender(vtkRenderer* theRenderer) +{ + Superclass::AddToRender(theRenderer); + theRenderer->AddActor2D(myScalarBar); +} + +void +VISU_PointMap3dActor +::RemoveFromRender(vtkRenderer* theRenderer) +{ + if(myScalarBar) + theRenderer->RemoveActor(myScalarBar); + + Superclass::RemoveFromRender(theRenderer); +} + +//================================================================== +// function: Set & Get PipeLine +// purpose : +//================================================================== +void +VISU_PointMap3dActor +::SetPipeLine(VISU_DeformedGridPL* thePipeLine) +{ + myPipeLine = thePipeLine; + SetMapper(thePipeLine->GetMapper()); + myScalarBar->SetLookupTable(thePipeLine->GetBarTable()); +} + +VISU_DeformedGridPL* +VISU_PointMap3dActor +::GetPipeLine() +{ + return myPipeLine.GetPointer(); +} + +//================================================================== +// function: Visibility +// purpose : +//================================================================== + +void +VISU_PointMap3dActor +::SetVisibility(int theMode) +{ + Superclass::SetVisibility( theMode ); + + // myPointsActor->SetVisibility( theMode ); + + if(myScalarBar) + myScalarBar->SetVisibility(theMode); +} + +VISU_ScalarBarActor* +VISU_PointMap3dActor +::GetScalarBar() +{ + return myScalarBar; +} + +//================================================================== +// function: SetIO +// purpose : +//================================================================== + +void +VISU_PointMap3dActor +::setIO(const Handle(SALOME_InteractiveObject)& theIO) +{ + Superclass::setIO(theIO); + myName = theIO->getName(); +} diff --git a/src/OBJECT/VISU_PointMap3dActor.h b/src/OBJECT/VISU_PointMap3dActor.h new file mode 100644 index 00000000..4b960fa7 --- /dev/null +++ b/src/OBJECT/VISU_PointMap3dActor.h @@ -0,0 +1,95 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VISU_PointMap3dActor.h +// Author : Dmitry MATVEICHEV with help of Alexey PETROV +// Module : VISU +// $Header$ + +#ifndef VISU_PointMap3dActor_HeaderFile +#define VISU_PointMap3dActor_HeaderFile + +#include "SALOME_Actor.h" +#include "VISU_DataSetActor.h" +#include "VISU_BoostSignals.h" + +class VISU_ScalarBarActor; + +#ifdef _WIN32 +#define VTKOCC_EXPORT __declspec (dllexport) +#else +#define VTKOCC_EXPORT VTK_EXPORT +#endif + +class VISU_DeformedGridPL; + +class VTKOCC_EXPORT VISU_PointMap3dActor : public VISU_ActorBase +{ + public: + vtkTypeMacro(VISU_PointMap3dActor,SALOME_Actor); + + static + VISU_PointMap3dActor* + New(); + + ~VISU_PointMap3dActor(); + +//---------------------------------------------------------------------------- + virtual + void + AddToRender( vtkRenderer* ); + + virtual + void + RemoveFromRender( vtkRenderer* ); + + virtual + void + SetVisibility(int theMode); + + virtual + VISU_ScalarBarActor* + GetScalarBar(); + +//---------------------------------------------------------------------------- + virtual + void + setIO(const Handle(SALOME_InteractiveObject)& theIO); + +//---------------------------------------------------------------------------- + virtual + VISU_DeformedGridPL* + GetPipeLine(); + + virtual + void + SetPipeLine(VISU_DeformedGridPL* thePipeLine); + + protected: + VISU_PointMap3dActor(); + vtkSmartPointer myPipeLine; + + VISU_ScalarBarActor* myScalarBar; +}; + +#endif diff --git a/src/PIPELINE/Makefile.am b/src/PIPELINE/Makefile.am index 51adaa9a..34ae81b0 100644 --- a/src/PIPELINE/Makefile.am +++ b/src/PIPELINE/Makefile.am @@ -36,6 +36,7 @@ salomeinclude_HEADERS= \ VISU_PipeLineUtils.hxx \ VISU_PipeLine.hxx \ VISU_ColoredPL.hxx \ + VISU_MergedPL.hxx \ VISU_UnstructuredGridPL.hxx \ VISU_MeshPL.hxx \ VISU_ScalarMapPL.hxx \ @@ -50,8 +51,10 @@ salomeinclude_HEADERS= \ VISU_Extractor.hxx \ VISU_FieldTransform.hxx \ VISU_MaskPointsFilter.hxx \ + VISU_PolyDataPL.hxx \ VISU_GaussPointsPL.hxx \ VISU_Plot3DPL.hxx \ + VISU_DeformedGridPL.hxx \ VISU_OpenGLPointSpriteMapper.hxx \ VISU_ImplicitFunctionWidget.hxx \ SALOME_ExtractGeometry.h \ @@ -71,6 +74,7 @@ dist_libVisuPipeLine_la_SOURCES= \ VISU_PipeLineUtils.cxx \ VISU_PipeLine.cxx \ VISU_ColoredPL.cxx \ + VISU_MergedPL.cxx \ VISU_UnstructuredGridPL.cxx \ VISU_MeshPL.cxx \ VISU_ScalarMapPL.cxx \ @@ -85,8 +89,10 @@ dist_libVisuPipeLine_la_SOURCES= \ VISU_Extractor.cxx \ VISU_FieldTransform.cxx \ VISU_MaskPointsFilter.cxx \ + VISU_PolyDataPL.cxx \ VISU_GaussPointsPL.cxx \ VISU_Plot3DPL.cxx \ + VISU_DeformedGridPL.cxx \ SALOME_ExtractGeometry.cxx \ SALOME_ExtractPolyDataGeometry.cxx \ VISU_OpenGLPointSpriteMapper.cxx \ @@ -99,6 +105,7 @@ dist_libVisuPipeLine_la_SOURCES= \ libVisuPipeLine_la_CPPFLAGS= \ $(VTK_INCLUDES) \ + $(QT_INCLUDES) \ $(KERNEL_CXXFLAGS) \ $(GUI_CXXFLAGS) \ $(MED_CXXFLAGS) \ @@ -108,6 +115,7 @@ libVisuPipeLine_la_CPPFLAGS= \ libVisuPipeLine_la_LDFLAGS= \ $(MED2_LIBS) \ $(VTK_LIBS) -lVTKViewer \ + $(QT_LIBS) \ $(KERNEL_LDFLAGS) -lSALOMELocalTrace \ $(GUI_LDFLAGS) \ $(MED_LDFLAGS) \ diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 2e9f12c0..307f99f9 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -37,14 +37,17 @@ #include "VISU_Plot3DPL.hxx" #include "VISU_ScalarBarActor.hxx" +#include "VISU_DeformedGridPL.hxx" + #include "VISU_OpenGLPointSpriteMapper.hxx" #include "VTKViewer_GeometryFilter.h" #include #include "VISU_Convertor.hxx" +#include "VISU_TableReader.hxx" #include "VISU_ConvertorUtils.hxx" -typedef VISU_GaussPointsPL TPresent; +typedef VISU_StreamLinesPL TPresent; #include #include @@ -60,7 +63,9 @@ typedef VISU_GaussPointsPL TPresent; #include -static int isOnlyMesh = false; +#include + +#include //#define _DEBUG_ID_MAPPING_ @@ -164,149 +169,218 @@ CreateColoredPL(VISU_Convertor* theConvertor, } +//---------------------------------------------------------------------------- +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; + } +}; + + +//---------------------------------------------------------------------------- +struct TColoredPrsBulder: TMEDSource +{ + 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(); + } + } + 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()); + + theRenderer->AddActor2D(aScalarBar); + aScalarBar->Delete(); + + 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){ - 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(argv[1]); - 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; - const std::string& aMeshName = aMeshMapIter->first; - const VISU::PMesh aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; - VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; - if(isOnlyMesh){ - const VISU::TEntity& anEntity = VISU::CELL_ENTITY; - aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity); - - VISU::PNamedIDMapper anIDMapper = - aConvertor->GetMeshOnEntity(aMeshName,anEntity); - - VISU_MeshPL* aPresent = VISU_MeshPL::New(); - aPresent->SetUnstructuredGridIDMapper(anIDMapper); - - vtkActor* aActor = vtkActor::New(); - aActor->SetMapper(aPresent->GetMapper()); - aActor->GetProperty()->SetRepresentation(VTK_WIREFRAME); - //aRenderer->ResetCameraClippingRange(); - - aRenderer->AddActor(aActor); - - aWindow->Render(); - anInteractor->Start(); - return 0; - } - //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_iterator aValFieldIter = aValField.begin(); - if(aValFieldIter == aValField.end()) return 0; - int aTimeStamp = aValFieldIter->first; - - vtkActor* anActor = vtkActor::New(); - VISU_ColoredPL* aPresent = NULL; - if(anEntity != VISU::NODE_ENTITY){ - aPresent = CreateColoredPL(aConvertor, - aMeshName, - anEntity, - aFieldName, - aTimeStamp); - - anActor->SetMapper(aPresent->GetMapper()); - }else{ - continue; - aPresent = CreateColoredPL(aConvertor, - aMeshName, - anEntity, - aFieldName, - aTimeStamp); - - VTKViewer_GeometryFilter* aGeometryFilter = VTKViewer_GeometryFilter::New(); - aGeometryFilter->SetInput(aPresent->GetOutput()); - aGeometryFilter->SetInside(true); - - vtkMaskPoints* aMaskPoints = vtkMaskPoints::New(); - aMaskPoints->SetInput(aGeometryFilter->GetOutput()); - aMaskPoints->SetGenerateVertices(true); - aMaskPoints->SetOnRatio(1); - - VISU_OpenGLPointSpriteMapper* aMapper = VISU_OpenGLPointSpriteMapper::New(); - aMapper->SetAverageCellSize( VISU_DeformedShapePL::GetScaleFactor( aPresent->GetOutput() ) ); - - char aMainTexture[80]; - strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) ); - strcat( aMainTexture, "/share/salome/resources/visu/sprite_texture.vti" ); - - char anAlphaTexture[80]; - strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) ); - strcat( anAlphaTexture, "/share/salome/resources/visu/sprite_alpha.vti" ); - - vtkSmartPointer aTextureValue = - VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture ); - aMapper->SetImageData( aTextureValue.GetPointer() ); - - //vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New(); - aMapper->SetLookupTable(aPresent->GetMapperTable()); - aMapper->SetUseLookupTableScalarRange(true); - aMapper->SetColorModeToMapScalars(); - aMapper->SetScalarVisibility(true); - - aMapper->SetInput(aMaskPoints->GetOutput()); - aGeometryFilter->Delete(); - - anActor->SetMapper(aMapper); - aMapper->Delete(); - } - - VISU_ScalarBarActor * aScalarBar = VISU_ScalarBarActor::New(); - aScalarBar->SetLookupTable(aPresent->GetBarTable()); - - aRenderer->AddActor(anActor); - aRenderer->AddActor2D(aScalarBar); - - aWindow->Render(); - aRenderer->ResetCamera(); - - anInteractor->Start(); - return 0; - } + if (argc > 1) { + QFileInfo aFileInfo( argv[1] ); + if ( aFileInfo.isFile() ) { + QString anExtension = aFileInfo.extension(); + if ( anExtension == "med" ) { + //TMeshBulder aBuilder( argv ); + TColoredPrsBulder aBuilder( argv ); + return RenderPresentation( aBuilder ); + } else if ( anExtension == "xls" || anExtension == "txt" ) + return RenderPresentation( TXLSSource( argv ) ); } } }catch(std::exception& exc){ MSG(true, "Follow exception was occured :\n"<GetNbColors()); SetScaling(aPipeLine->GetScaling()); SetMapScale(aPipeLine->GetMapScale()); - if(this != thePipeLine){ - if(aPipeLine->IsExternalGeometryUsed()){ - ClearGeometry(); - int aNbOfGeometry = aPipeLine->GetNumberOfGeometry(); - for(int aGeomNumber = 0; aGeomNumber < aNbOfGeometry; aGeomNumber++) - AddGeometry(aPipeLine->GetGeometry(aGeomNumber)); - }else - SetSourceGeometry(); - } } } diff --git a/src/PIPELINE/VISU_ColoredPL.hxx b/src/PIPELINE/VISU_ColoredPL.hxx index c22351b8..e507f140 100644 --- a/src/PIPELINE/VISU_ColoredPL.hxx +++ b/src/PIPELINE/VISU_ColoredPL.hxx @@ -119,36 +119,6 @@ public: void SetSourceRange(); -public: - - virtual - void - SetSourceGeometry()=0; - - virtual - int - AddGeometry(vtkDataSet* theGeometry)=0; - - virtual - vtkDataSet* - GetGeometry(int theGeomNumber)=0; - - virtual - int - GetNumberOfGeometry()=0; - - virtual - bool - IsExternalGeometryUsed()=0; - - virtual - void - ClearGeometry()=0; - - virtual - vtkPointSet* - GetMergedInput()=0; - protected: //---------------------------------------------------------------------------- VISU_ColoredPL(); diff --git a/src/PIPELINE/VISU_DeformedGridPL.cxx b/src/PIPELINE/VISU_DeformedGridPL.cxx new file mode 100644 index 00000000..e9068b9a --- /dev/null +++ b/src/PIPELINE/VISU_DeformedGridPL.cxx @@ -0,0 +1,235 @@ +// 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_DeformedGridPL.cxx +// Author: Alexey PETROV +// Module : VISU + + +#include "VISU_DeformedGridPL.hxx" +#include "VISU_FieldTransform.hxx" +#include "VISU_Plot3DPL.hxx" + +#include "VISU_PipeLineUtils.hxx" + +#include +#include +#include + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(VISU_DeformedGridPL); + + +//---------------------------------------------------------------------------- +VISU_DeformedGridPL +::VISU_DeformedGridPL(): + myContourFilter(vtkContourFilter::New()), + myWarpScalar(vtkWarpScalar::New()), + myIsContour(false), + myScaleFactor(1.0) +{ + SetIsShrinkable(false); + SetNumberOfContours(32); +} + + +//---------------------------------------------------------------------------- +VISU_DeformedGridPL +::~VISU_DeformedGridPL() +{} + + +//---------------------------------------------------------------------------- +unsigned long int +VISU_DeformedGridPL +::GetMTime() +{ + unsigned long int aTime = Superclass::GetMTime(); + + aTime = std::max(aTime, myContourFilter->GetMTime()); + aTime = std::max(aTime, myWarpScalar->GetMTime()); + + return aTime; +} + + +//---------------------------------------------------------------------------- +unsigned long int +VISU_DeformedGridPL +::GetMemorySize() +{ + unsigned long int aSize = Superclass::GetMemorySize(); + + if(vtkDataObject* aDataObject = myContourFilter->GetInput()) + aSize += aDataObject->GetActualMemorySize() * 1024; + + if(vtkDataObject* aDataObject = myWarpScalar->GetInput()) + aSize += aDataObject->GetActualMemorySize() * 1024; + + return aSize; +} + + +//---------------------------------------------------------------------------- +void +VISU_DeformedGridPL +::DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput) +{ + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); + + if(VISU_DeformedGridPL *aPipeLine = dynamic_cast(thePipeLine)){ + SetScaleFactor( aPipeLine->GetScaleFactor() ); + SetContourPrs( aPipeLine->GetIsContourPrs() ); + SetNumberOfContours( aPipeLine->GetNumberOfContours() ); + } +} + + +//---------------------------------------------------------------------------- +void +VISU_DeformedGridPL +::Init() +{ + Superclass::Init(); + + vtkPointSet* aPointSet = GetFieldTransformFilter()->GetPolyDataOutput(); + SetScaleFactor( VISU_Plot3DPL::GetScaleFactor( this, aPointSet ) ); +} + + +//---------------------------------------------------------------------------- +void +VISU_DeformedGridPL +::Build() +{ + Superclass::Build(); + + myWarpScalar->SetInput( GetFieldTransformFilter()->GetPolyDataOutput() ); + GetPolyDataMapper()->SetInput( myWarpScalar->GetPolyDataOutput() ); +} + + +//---------------------------------------------------------------------------- +void +VISU_DeformedGridPL +::Update() +{ + vtkPointSet* aPointSet = GetFieldTransformFilter()->GetPolyDataOutput(); + if ( !myIsContour ) // surface prs + { + myWarpScalar->SetInput( aPointSet ); + } + else // contour prs + { + myContourFilter->SetInput( aPointSet ); + + vtkFloatingPointType aScalarRange[2]; + GetSourceRange( aScalarRange ); + + myContourFilter->GenerateValues( GetNumberOfContours(), aScalarRange ); + myWarpScalar->SetInput( myContourFilter->GetOutput() ); + } + + Superclass::Update(); +} + + +//---------------------------------------------------------------------------- +void +VISU_DeformedGridPL +::SetNumberOfContours(int theNumber) +{ + myContourFilter->SetNumberOfContours(theNumber); +} + + +//---------------------------------------------------------------------------- +int +VISU_DeformedGridPL +::GetNumberOfContours() +{ + return myContourFilter->GetNumberOfContours(); +} + + +//---------------------------------------------------------------------------- +void +VISU_DeformedGridPL +::SetScaleFactor(vtkFloatingPointType theScaleFactor) +{ + if ( VISU::CheckIsSameValue( myWarpScalar->GetScaleFactor(), theScaleFactor ) ) + return; + myScaleFactor = theScaleFactor; + myWarpScalar->SetScaleFactor(theScaleFactor); +} + + +//---------------------------------------------------------------------------- +vtkFloatingPointType +VISU_DeformedGridPL +::GetScaleFactor() +{ + return myScaleFactor; +} + + +//---------------------------------------------------------------------------- +void +VISU_DeformedGridPL +::SetContourPrs(bool theIsContourPrs ) +{ + if(myIsContour == theIsContourPrs) + return; + + myIsContour = theIsContourPrs; + Modified(); +} + + +//---------------------------------------------------------------------------- +bool +VISU_DeformedGridPL +::GetIsContourPrs() +{ + return myIsContour; +} + + +//---------------------------------------------------------------------------- +void +VISU_DeformedGridPL +::SetMapScale(vtkFloatingPointType theMapScale) +{ + Superclass::SetMapScale(theMapScale); + + if ( myIsContour ) { + vtkFloatingPointType aSourceRange[2]; + GetSourceRange( aSourceRange ); + vtkFloatingPointType aDeltaRange = aSourceRange[1] - aSourceRange[0]; + vtkFloatingPointType aNewRange[2] = { aSourceRange[1] - theMapScale*aDeltaRange, aSourceRange[1] }; + myContourFilter->GenerateValues( GetNumberOfContours(), aNewRange ); + } + + myWarpScalar->SetScaleFactor( myScaleFactor * theMapScale ); +} diff --git a/src/PIPELINE/VISU_DeformedGridPL.hxx b/src/PIPELINE/VISU_DeformedGridPL.hxx new file mode 100644 index 00000000..840059a7 --- /dev/null +++ b/src/PIPELINE/VISU_DeformedGridPL.hxx @@ -0,0 +1,116 @@ +// 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_ScalarMapPL.hxx +// Author: Alexey PETROV +// Module : VISU + +#ifndef VISU_DeformedGridPL_HeaderFile +#define VISU_DeformedGridPL_HeaderFile + +#include "VISUPipeline.hxx" +#include "VISU_PolyDataPL.hxx" + +class vtkWarpScalar; +class vtkContourFilter; + + +//---------------------------------------------------------------------------- +class VISU_PIPELINE_EXPORT VISU_DeformedGridPL : public VISU_PolyDataPL +{ +public: + vtkTypeMacro(VISU_DeformedGridPL, VISU_PolyDataPL); + + static + VISU_DeformedGridPL* + New(); + + //---------------------------------------------------------------------------- + virtual + unsigned long int + GetMTime(); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + //---------------------------------------------------------------------------- + void + SetScaleFactor( vtkFloatingPointType theScaleFactor ); + + vtkFloatingPointType + GetScaleFactor(); + + void + SetContourPrs( bool theIsContourPrs ); + + bool + GetIsContourPrs(); + + void + SetNumberOfContours( int theNumber ); + + int + GetNumberOfContours(); + + virtual + void + SetMapScale(vtkFloatingPointType theMapScale = 1.0); + + //---------------------------------------------------------------------------- + virtual + void + Init(); + + virtual + void + Update(); + +protected: + //---------------------------------------------------------------------------- + VISU_DeformedGridPL(); + + virtual + ~VISU_DeformedGridPL(); + + virtual + void + Build(); + + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput); + +private: + VISU_DeformedGridPL(const VISU_DeformedGridPL&); // Not implemented. + void operator=(const VISU_DeformedGridPL&); // Not implemented. + + vtkFloatingPointType myScaleFactor; + vtkContourFilter* myContourFilter; + vtkWarpScalar *myWarpScalar; + bool myIsContour; +}; + +#endif diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index ea42aaca..c59d0d19 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -194,6 +194,7 @@ VISU_GaussPointsPL bool theIsCopyInput) { Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); + VISU_MergedPL::DoShallowCopy(thePipeLine, theIsCopyInput); if(VISU_GaussPointsPL *aPipeLine = dynamic_cast(thePipeLine)){ SetPrimitiveType(aPipeLine->GetPrimitiveType()); diff --git a/src/PIPELINE/VISU_GaussPointsPL.hxx b/src/PIPELINE/VISU_GaussPointsPL.hxx index 05136235..e5118a80 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.hxx +++ b/src/PIPELINE/VISU_GaussPointsPL.hxx @@ -29,6 +29,7 @@ #define VISU_GaussPointsPL_HeaderFile #include "VISUPipeline.hxx" +#include "VISU_MergedPL.hxx" #include "VISU_ColoredPL.hxx" #include @@ -57,7 +58,8 @@ class VISU_GaussMergeFilter; * This class uses the special mapper (VISU_OpenGLPointSpriteMapper) * for rendering the Gauss Points as Point Sprites. */ -class VISU_PIPELINE_EXPORT VISU_GaussPointsPL : public VISU_ColoredPL +class VISU_PIPELINE_EXPORT VISU_GaussPointsPL : public VISU_MergedPL, + public VISU_ColoredPL { public: //---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_MergedPL.cxx b/src/PIPELINE/VISU_MergedPL.cxx new file mode 100644 index 00000000..4aa24b88 --- /dev/null +++ b/src/PIPELINE/VISU_MergedPL.cxx @@ -0,0 +1,51 @@ +// 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_MergedPL.cxx +// Author: Alexey PETROV +// Module : VISU + + +#include "VISU_MergedPL.hxx" +#include "VISU_PipeLine.hxx" + + +//---------------------------------------------------------------------------- +void +VISU_MergedPL +::DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput) +{ + if(VISU_MergedPL *aPipeLine = dynamic_cast(thePipeLine)){ + if ( this == aPipeLine ) + return; + + if ( aPipeLine->IsExternalGeometryUsed() ) { + ClearGeometry(); + int aNbOfGeometry = aPipeLine->GetNumberOfGeometry(); + for ( int aGeomNumber = 0; aGeomNumber < aNbOfGeometry; aGeomNumber++ ) + AddGeometry( aPipeLine->GetGeometry( aGeomNumber ) ); + }else + SetSourceGeometry(); + } +} diff --git a/src/PIPELINE/VISU_MergedPL.hxx b/src/PIPELINE/VISU_MergedPL.hxx new file mode 100644 index 00000000..9c8e9b97 --- /dev/null +++ b/src/PIPELINE/VISU_MergedPL.hxx @@ -0,0 +1,75 @@ +// 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_MergedPL.hxx +// Author: Alexey PETROV +// Module : VISU + +#ifndef VISU_MergedPL_HeaderFile +#define VISU_MergedPL_HeaderFile + +#include "VISUPipeline.hxx" + +class vtkDataSet; +class vtkPointSet; +class VISU_PipeLine; + + +//---------------------------------------------------------------------------- +struct VISU_PIPELINE_EXPORT VISU_MergedPL +{ + virtual + void + SetSourceGeometry() = 0; + + virtual + int + AddGeometry( vtkDataSet* theGeometry ) = 0; + + virtual + vtkDataSet* + GetGeometry( int theGeomNumber ) = 0; + + virtual + int + GetNumberOfGeometry() = 0; + + virtual + bool + IsExternalGeometryUsed() = 0; + + virtual + void + ClearGeometry() = 0; + + virtual + vtkPointSet* + GetMergedInput() = 0; + + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput); +}; + +#endif diff --git a/src/PIPELINE/VISU_MeshPL.cxx b/src/PIPELINE/VISU_MeshPL.cxx index 66317af0..9e5dd5d7 100644 --- a/src/PIPELINE/VISU_MeshPL.cxx +++ b/src/PIPELINE/VISU_MeshPL.cxx @@ -61,7 +61,7 @@ void VISU_MeshPL ::Build() { - GetDataSetMapperHolder()->GetDataSetMapper()->SetInput(GetClippedInput()); + GetDataSetMapper()->SetInput(GetClippedInput()); } diff --git a/src/PIPELINE/VISU_Plot3DPL.cxx b/src/PIPELINE/VISU_Plot3DPL.cxx index 7696d62e..c53afe9d 100644 --- a/src/PIPELINE/VISU_Plot3DPL.cxx +++ b/src/PIPELINE/VISU_Plot3DPL.cxx @@ -151,13 +151,14 @@ VISU_Plot3DPL //---------------------------------------------------------------------------- vtkFloatingPointType VISU_Plot3DPL -::GetScaleFactor(vtkDataSet* theDataSet) +::GetScaleFactor( VISU_ColoredPL* theColoredPL, + vtkDataSet* theDataSet ) { theDataSet->Update(); vtkFloatingPointType aLength = theDataSet->GetLength(); // diagonal length vtkFloatingPointType aScalarRange[2]; - GetSourceRange(aScalarRange); + theColoredPL->GetSourceRange(aScalarRange); static vtkFloatingPointType EPS = 0.3; vtkFloatingPointType aRange = aScalarRange[1]; @@ -176,7 +177,7 @@ VISU_Plot3DPL Superclass::Init(); myOrientation = GetOrientation(GetMergedInput()); - SetScaleFactor(GetScaleFactor(GetMergedInput())); + SetScaleFactor( GetScaleFactor( this, GetMergedInput() ) ); } diff --git a/src/PIPELINE/VISU_Plot3DPL.hxx b/src/PIPELINE/VISU_Plot3DPL.hxx index 2cb63767..8585fb8b 100644 --- a/src/PIPELINE/VISU_Plot3DPL.hxx +++ b/src/PIPELINE/VISU_Plot3DPL.hxx @@ -121,13 +121,17 @@ public: VISU_CutPlanesPL::PlaneOrientation GetOrientation(vtkDataSet* theDataSet); + static vtkFloatingPointType - GetScaleFactor(vtkDataSet* theDataSet); + GetScaleFactor( VISU_ColoredPL* theColoredPL, + vtkDataSet* theDataSet ); - void SetMapScale(vtkFloatingPointType theMapScale); + void + SetMapScale(vtkFloatingPointType theMapScale); protected: VISU_Plot3DPL(); + virtual ~VISU_Plot3DPL(); diff --git a/src/PIPELINE/VISU_PolyDataPL.cxx b/src/PIPELINE/VISU_PolyDataPL.cxx index 76e4c05a..68739149 100644 --- a/src/PIPELINE/VISU_PolyDataPL.cxx +++ b/src/PIPELINE/VISU_PolyDataPL.cxx @@ -27,303 +27,60 @@ #include "VISU_PolyDataPL.hxx" -#include "SALOME_ExtractPolyDataGeometry.h" +#include "VISU_PolyDataMapperHolder.hxx" -#include "VISU_PipeLineUtils.hxx" - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#ifdef _DEBUG_ -static int MYDEBUG = 0; -#else -static int MYDEBUG = 0; -#endif //---------------------------------------------------------------------------- VISU_PolyDataPL -::VISU_PolyDataPL(): - myExtractPolyDataGeometry(SALOME_ExtractPolyDataGeometry::New()) -{ - if(MYDEBUG) MESSAGE("VISU_PolyDataPL::VISU_PolyDataPL - "<Delete(); - myExtractPolyDataGeometry->SetStoreMapping(true); - - vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New(); - myExtractPolyDataGeometry->SetImplicitFunction(anImplicitBoolean); - anImplicitBoolean->SetOperationTypeToIntersection(); - anImplicitBoolean->Delete(); -} +::VISU_PolyDataPL() +{} //---------------------------------------------------------------------------- VISU_PolyDataPL ::~VISU_PolyDataPL() -{ - if(MYDEBUG) - MESSAGE("VISU_PolyDataPL::~VISU_PolyDataPL - "<SetInput(theIDMapper->GetPolyDataOutput()); - myPolyDataIDMapper = theIDMapper; - SetIDMapper(theIDMapper); -} - - -//---------------------------------------------------------------------------- -const VISU::PPolyDataIDMapper& -VISU_PolyDataPL -::GetPolyDataIDMapper() const -{ - return myPolyDataIDMapper; -} - - -//---------------------------------------------------------------------------- -vtkPolyData* -VISU_PolyDataPL -::GetPolyDataInput() -{ - if(myPolyDataIDMapper) - return myPolyDataIDMapper->GetPolyDataOutput(); - - return NULL; -} - - -//---------------------------------------------------------------------------- -vtkPointSet* -VISU_PolyDataPL -::GetClippedInput() const -{ - vtkPolyData* aDataSet = myExtractPolyDataGeometry->GetOutput(); - aDataSet->Update(); - return aDataSet; -} - - -//---------------------------------------------------------------------------- -void -VISU_PolyDataPL -::OnCreateMapper() -{ - myPolyDataMapper = vtkPolyDataMapper::New(); - myPolyDataMapper->Delete(); - SetMapper(myPolyDataMapper.GetPointer()); -} - - -//---------------------------------------------------------------------------- -void -VISU_PolyDataPL -::SetPolyDataMapper(vtkPolyDataMapper* theMapper) -{ - myPolyDataMapper = theMapper; - SetMapper(theMapper); -} - - -//---------------------------------------------------------------------------- -vtkPolyDataMapper* -VISU_PolyDataPL -::GetPolyDataMapper() -{ - return myPolyDataMapper.GetPointer(); -} +{} //---------------------------------------------------------------------------- -void +void VISU_PolyDataPL -::DoCopyMapper(VISU_PipeLine *thePipeLine, - bool theIsCopyInput) +::OnCreateMapperHolder() { - if(VISU_PolyDataPL* aPipeLine = dynamic_cast(thePipeLine)){ - if(theIsCopyInput) - SetPolyDataIDMapper(aPipeLine->GetPolyDataIDMapper()); - Update(); - VISU::CopyPolyDataMapper(GetPolyDataMapper(), - aPipeLine->GetPolyDataMapper(), - theIsCopyInput); - } -} + myPolyDataMapperHolder = VISU_PolyDataMapperHolder::New(); + myPolyDataMapperHolder->Delete(); - -//---------------------------------------------------------------------------- -void -VISU_PolyDataPL -::SetLookupTable(VISU_LookupTable* theLookupTable) -{ - myPolyDataMapper->SetLookupTable(theLookupTable); + SetMapperHolder(myPolyDataMapperHolder.GetPointer()); } -//---------------------------------------------------------------------------- -unsigned long int -VISU_PolyDataPL -::GetMemorySize() -{ - unsigned long int aSize = 0; - if(myExtractPolyDataGeometry->GetInput()) - if(vtkDataSet* aDataSet = myExtractPolyDataGeometry->GetOutput()) - aSize = aDataSet->GetActualMemorySize() * 1024; - - aSize += Superclass::GetMemorySize(); - - return aSize; -} - - -//------------------------ Clipping planes ----------------------------------- -bool -VISU_PolyDataPL -::AddClippingPlane(vtkPlane* thePlane) -{ - if (thePlane) { - if (vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()) { - vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); - aFunction->AddItem(thePlane); - // Check, that at least one cell present after clipping. - // This check was introduced because of bug IPAL8849. - vtkDataSet* aClippedDataSet = GetClippedInput(); - if(aClippedDataSet->GetNumberOfCells() < 1) - return false; - } - } - return true; -} - -//---------------------------------------------------------------------------- -vtkPlane* -VISU_PolyDataPL -::GetClippingPlane(vtkIdType theID) const -{ - vtkPlane* aPlane = NULL; - if(theID >= 0 && theID < GetNumberOfClippingPlanes()){ - if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){ - vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); - vtkImplicitFunction* aFun = NULL; - aFunction->InitTraversal(); - for(vtkIdType anID = 0; anID <= theID; anID++) - aFun = aFunction->GetNextItem(); - aPlane = dynamic_cast(aFun); - } - } - return aPlane; -} - //---------------------------------------------------------------------------- void VISU_PolyDataPL -::RemoveAllClippingPlanes() -{ - if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){ - vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); - aFunction->RemoveAllItems(); - aBoolean->Modified(); // VTK bug - } -} - -//---------------------------------------------------------------------------- -vtkIdType -VISU_PolyDataPL -::GetNumberOfClippingPlanes() const -{ - if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){ - vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); - return aFunction->GetNumberOfItems(); - } - return 0; -} - -//---------------------------------------------------------------------------- -vtkIdType -VISU_PolyDataPL -::GetNodeObjID(vtkIdType theID) -{ - vtkIdType anID = myExtractPolyDataGeometry->GetNodeObjId(theID); - return Superclass::GetNodeObjID(anID); -} - -vtkIdType -VISU_PolyDataPL -::GetNodeVTKID(vtkIdType theID) -{ - vtkIdType anID = Superclass::GetNodeVTKID(theID); - return myExtractPolyDataGeometry->GetNodeVTKId(anID); -} - -vtkFloatingPointType* -VISU_PolyDataPL -::GetNodeCoord(int theObjID) +::SetPolyDataIDMapper(const VISU::PPolyDataIDMapper& theIDMapper) { - return Superclass::GetNodeCoord(theObjID); + GetPolyDataMapperHolder()->SetPolyDataIDMapper( theIDMapper ); } //---------------------------------------------------------------------------- -vtkIdType -VISU_PolyDataPL -::GetElemObjID(vtkIdType theID) -{ - vtkIdType anID = myExtractPolyDataGeometry->GetElemObjId(theID); - return Superclass::GetElemObjID(anID); -} - -vtkIdType +VISU_PolyDataMapperHolder* VISU_PolyDataPL -::GetElemVTKID(vtkIdType theID) +::GetPolyDataMapperHolder() { - vtkIdType anID = Superclass::GetElemVTKID(theID); - return myExtractPolyDataGeometry->GetElemVTKId(anID); -} + GetMapperHolder(); -vtkCell* -VISU_PolyDataPL -::GetElemCell(vtkIdType theObjID) -{ - return Superclass::GetElemCell(theObjID); + return myPolyDataMapperHolder.GetPointer(); } //---------------------------------------------------------------------------- -void +vtkPolyDataMapper* VISU_PolyDataPL -::SetImplicitFunction(vtkImplicitFunction *theFunction) -{ - myExtractPolyDataGeometry->SetImplicitFunction(theFunction); -} - -vtkImplicitFunction * -VISU_PolyDataPL -::GetImplicitFunction() +::GetPolyDataMapper() { - return myExtractPolyDataGeometry->GetImplicitFunction(); + return GetPolyDataMapperHolder()->GetPolyDataMapper(); } -SALOME_ExtractPolyDataGeometry* -VISU_PolyDataPL -::GetExtractPolyDataGeometryFilter() -{ - return myExtractPolyDataGeometry.GetPointer(); -} - //---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_PolyDataPL.hxx b/src/PIPELINE/VISU_PolyDataPL.hxx index 1b8fa325..81beaf12 100644 --- a/src/PIPELINE/VISU_PolyDataPL.hxx +++ b/src/PIPELINE/VISU_PolyDataPL.hxx @@ -27,95 +27,28 @@ #ifndef VISU_PolyDataPL_HeaderFile #define VISU_PolyDataPL_HeaderFile +#include "VISUPipeline.hxx" #include "VISU_ColoredPL.hxx" +class VISU_PolyDataMapperHolder; class vtkPolyDataMapper; -class vtkPolyData; -class SALOME_ExtractPolyDataGeometry; //---------------------------------------------------------------------------- -class VISU_PolyDataPL : public VISU_ColoredPL +class VISU_PIPELINE_EXPORT VISU_PolyDataPL : public VISU_ColoredPL { public: vtkTypeMacro(VISU_PolyDataPL, VISU_ColoredPL); - //---------------------------------------------------------------------------- - virtual - vtkPolyDataMapper* - GetPolyDataMapper(); - - virtual - vtkPolyData* - GetPolyDataInput(); - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - - //---------------------------------------------------------------------------- - virtual - void - SetImplicitFunction(vtkImplicitFunction *theFunction); - - virtual - vtkImplicitFunction* - GetImplicitFunction(); - - virtual - SALOME_ExtractPolyDataGeometry* - GetExtractPolyDataGeometryFilter(); - - //---------------------------------------------------------------------------- - // Clipping planes - virtual - void - RemoveAllClippingPlanes(); - - virtual - vtkIdType - GetNumberOfClippingPlanes() const; - - virtual - bool - AddClippingPlane(vtkPlane* thePlane); - - virtual - vtkPlane* - GetClippingPlane(vtkIdType theID) const; - - //---------------------------------------------------------------------------- - virtual - vtkIdType - GetNodeObjID(vtkIdType theID); - - virtual - vtkIdType - GetNodeVTKID(vtkIdType theID); - - virtual - vtkFloatingPointType* - GetNodeCoord(vtkIdType theObjID); - - virtual - vtkIdType - GetElemObjID(vtkIdType theID); - - virtual - vtkIdType - GetElemVTKID(vtkIdType theID); - - virtual - vtkCell* - GetElemCell(vtkIdType theObjID); - //---------------------------------------------------------------------------- void SetPolyDataIDMapper(const VISU::PPolyDataIDMapper& theIDMapper); - const VISU::PPolyDataIDMapper& - GetPolyDataIDMapper() const; + VISU_PolyDataMapperHolder* + GetPolyDataMapperHolder(); + + vtkPolyDataMapper* + GetPolyDataMapper(); protected: VISU_PolyDataPL(); @@ -126,28 +59,10 @@ protected: virtual void - DoCopyMapper(VISU_PipeLine *thePipeLine, - bool theIsCopyInput); - - virtual - void - OnCreateMapper(); - - void - SetPolyDataMapper(vtkPolyDataMapper* theMapper); - - virtual - void - SetLookupTable(VISU_LookupTable* theLookupTable); - - virtual - vtkPointSet* - GetClippedInput() const; + OnCreateMapperHolder(); private: - VISU::PPolyDataIDMapper myPolyDataIDMapper; - vtkSmartPointer myPolyDataMapper; - vtkSmartPointer myExtractPolyDataGeometry; //!< Clipping + vtkSmartPointer myPolyDataMapperHolder; }; #endif diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index a8784c81..d7149129 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -144,6 +144,7 @@ VISU_ScalarMapPL bool theIsCopyInput) { Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); + VISU_MergedPL::DoShallowCopy(thePipeLine, theIsCopyInput); } diff --git a/src/PIPELINE/VISU_ScalarMapPL.hxx b/src/PIPELINE/VISU_ScalarMapPL.hxx index c23e95a6..dff91d39 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.hxx +++ b/src/PIPELINE/VISU_ScalarMapPL.hxx @@ -29,6 +29,7 @@ #define VISU_ScalarMapPL_HeaderFile #include "VISUPipeline.hxx" +#include "VISU_MergedPL.hxx" #include "VISU_ColoredPL.hxx" #include "VISU_UnstructuredGridPL.hxx" @@ -38,7 +39,8 @@ class VISU_MergeFilter; //---------------------------------------------------------------------------- -class VISU_PIPELINE_EXPORT VISU_ScalarMapPL : public VISU_ColoredPL, +class VISU_PIPELINE_EXPORT VISU_ScalarMapPL : public VISU_MergedPL, + public VISU_ColoredPL, public VISU_UnstructuredGridPL { public: diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index f5ad51ad..f5a02856 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -66,6 +66,7 @@ dist_libVISU_la_SOURCES= \ VisuGUI_ScalarMapOnDeformedShapeDlg.cxx \ VisuGUI_SetupPlot2dDlg.cxx \ VisuGUI_BuildProgressDlg.cxx \ + VisuGUI_Table3dDlg.cxx \ VisuGUI_TransparencyDlg.cxx \ VisuGUI_Timer.cxx \ VisuGUI_Slider.cxx \ @@ -98,6 +99,7 @@ MOC_FILES= \ VisuGUI_ScalarMapOnDeformedShapeDlg_moc.cxx \ VisuGUI_SetupPlot2dDlg_moc.cxx \ VisuGUI_BuildProgressDlg_moc.cxx \ + VisuGUI_Table3dDlg_moc.cxx \ VisuGUI_TransparencyDlg_moc.cxx \ VisuGUI_Slider_moc.cxx \ VisuGUI_InputPane_moc.cxx \ diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 1b619f70..58d6ee9b 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -970,6 +970,97 @@ msgstr "The common (Title, Label, Bar) width or height should not be greater the msgid "VisuGUI_BarPrefDlg::AUTO" msgstr "auto" +#: VisuGUI_Table3dDlg.cxx + +msgid "VisuGUI_Table3DDlg::DLG_PREF_TITLE" +msgstr "Table 3D Bar Preferences" + +msgid "VisuGUI_Table3DDlg::DLG_PROP_TITLE" +msgstr "Scalar Bar Properties" + +msgid "VisuGUI_TableScalarBarPane::SCALAR_RANGE_GRP" +msgstr "Scalar range" + +msgid "VisuGUI_TableScalarBarPane::LOGARITHMIC_SCALING" +msgstr "Logarithmic scaling" + +msgid "VisuGUI_TableScalarBarPane::FIELD_RANGE_BTN" +msgstr "Use field range" + +msgid "VisuGUI_TableScalarBarPane::IMPOSED_RANGE_BTN" +msgstr "Use imposed range" + +msgid "VisuGUI_TableScalarBarPane::LBL_MIN" +msgstr "Min:" + +msgid "VisuGUI_TableScalarBarPane::LBL_MAX" +msgstr "Max:" + +msgid "VisuGUI_TableScalarBarPane::COLORS_LABELS_GRP" +msgstr "Colors and labels" + +msgid "VisuGUI_TableScalarBarPane::LBL_NB_COLORS" +msgstr "Nb. of colors:" + +msgid "VisuGUI_TableScalarBarPane::LBL_NB_LABELS" +msgstr "Nb. of labels:" + +msgid "VisuGUI_TableScalarBarPane::ORIENTATION_GRP" +msgstr "Orientation" + +msgid "VisuGUI_TableScalarBarPane::VERTICAL_BTN" +msgstr "Vertical" + +msgid "VisuGUI_TableScalarBarPane::HORIZONTAL_BTN" +msgstr "Horizontal" + +msgid "VisuGUI_TableScalarBarPane::ORIGIN_GRP" +msgstr "Origin" + +msgid "VisuGUI_TableScalarBarPane::LBL_X" +msgstr "X:" + +msgid "VisuGUI_TableScalarBarPane::LBL_Y" +msgstr "Y:" + +msgid "VisuGUI_TableScalarBarPane::LBL_SHOW_PREVIEW" +msgstr "Show preview" + +msgid "VisuGUI_TableScalarBarPane::DIMENSIONS_GRP" +msgstr "Dimensions" + +msgid "VisuGUI_TableScalarBarPane::LBL_WIDTH" +msgstr "Width:" + +msgid "VisuGUI_TableScalarBarPane::LBL_HEIGHT" +msgstr "Height:" + +msgid "VisuGUI_TableScalarBarPane::SAVE_DEFAULT_CHK" +msgstr "Save as default values" + +msgid "VisuGUI_TableScalarBarPane::MSG_MINMAX_VALUES" +msgstr "Min value can not be higher or equal to Max value" + +msgid "VisuGUI_TableScalarBarPane::WRN_LOGARITHMIC_RANGE" +msgstr "Logarithmic scaling: use imposed range values > 0" + +msgid "VisuGUI_TableScalarBarPane::WRN_LOGARITHMIC_FIELD_RANGE" +msgstr "Logarithmic scaling: field range contains negative values, use imposed range instead" + +msgid "VisuGUI_Table3DPane::SCALE" +msgstr "Scale Factor:" + +msgid "VisuGUI_Table3DPane::PRESENTATION_TYPE" +msgstr "Presentation type" + +msgid "VisuGUI_Table3DPane::SURFACE" +msgstr "Surface" + +msgid "VisuGUI_Table3DPane::CONTOUR" +msgstr "Contour" + +msgid "VisuGUI_Table3DPane::NUMBER_CONTOURS" +msgstr "Number of contours:" #: VisuGUI_StreamLinesDlg.cxx diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 6f057444..64bab830 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -83,6 +83,7 @@ #include "VISU_Gen_i.hh" #include "VISU_Mesh_i.hh" #include "VISU_Table_i.hh" +#include "VISU_PointMap3d_i.hh" #include "VISU_Result_i.hh" #include "VISU_View_i.hh" #include "VISU_ViewManager_i.hh" @@ -106,6 +107,7 @@ #include "VisuGUI_BuildProgressDlg.h" #include "VisuGUI_TransparencyDlg.h" #include "VisuGUI_CacheDlg.h" +#include "VisuGUI_Table3dDlg.h" #include "VISU_ScalarMap_i.hh" #include "VisuGUI_ScalarBarDlg.h" @@ -746,10 +748,18 @@ VisuGUI VISU::VISUType aType = aBase->GetType(); switch (aType) { case VISU::TCURVE: - case VISU::TCONTAINER: + case VISU::TCONTAINER: case VISU::TTABLE: displayer()->Display(anIO->getEntry()); break; + case VISU::TPOINTMAP3D: + if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(this)){ + displayer()->Display(anIO->getEntry()); + aViewWindow->highlight(anIO, 1); + aViewWindow->getRenderer()->ResetCameraClippingRange(); + aViewWindow->Repaint(); + } + break; default: { VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dFromBase(aBase); if(aPrs3d){ @@ -1196,6 +1206,30 @@ VisuGUI dlg->show(); } +//---------------------------------------------------------------------------- +void +VisuGUI +::OnShowTablePlot() +{ + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.empty()) + return; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO; + VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase; + _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject; + if(VISU::PointMap3d_i* aTable = dynamic_cast(aBase)) { + VisuGUI_Table3DDlg*aDlg = new VisuGUI_Table3DDlg( this ); + aDlg->initFromPrsObject( aTable ); + if ( runAndWait(aDlg, 0) > 0 ) { + aDlg->storeToPrsObject(aTable); + aTable->UpdateActors(); + } + delete aDlg; + } +} + //---------------------------------------------------------------------------- void VisuGUI @@ -1295,7 +1329,7 @@ VisuGUI VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){ - if(aBase->GetType() == VISU::TTABLE) { + if(aBase->GetType() == VISU::TTABLE || aBase->GetType() == VISU::TPOINTMAP3D) { if(VISU::Table_i* aTable = dynamic_cast(aBase)){ _PTR(Study) aStudy = GetCStudy(GetAppStudy(this)); _PTR(SObject) aSObject = aStudy->FindObjectID( aTable->GetObjectEntry() ); @@ -2099,6 +2133,10 @@ VisuGUI tr("MEN_SHOW_TABLE"), "", 0, aParent, false, this, SLOT(OnShowTable())); + createAction( VISU_SHOW_TABLE_PLOT, tr("MEN_EDIT_PRS"), QIconSet(), + tr("MEN_EDIT_PRS"), "", 0, aParent, false, + this, SLOT(OnShowTablePlot())); + createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(), tr("MEN_CREATE_CURVES"), "", 0, aParent, false, this, SLOT(OnPlotData())); @@ -2861,13 +2899,23 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q VISU::VISUType aType = VISU::Storable::RestoringMap2Type( aMap ); if (aType == VISU::TANIMATION) { action( VISU_SHOW_ANIMATION )->addTo(theMenu); - } else if (isOBClient) { if (IsSObjectTable(aSObject)) { + action( VISU_DELETE_OBJS )->removeFrom(theMenu); + if (aType == VISU::TPOINTMAP3D) { + action( VISU_SHOW_TABLE_PLOT )->addTo(theMenu); + theMenu->insertSeparator(); + action( VISU_ERASE )->addTo(theMenu); + action( myEraseAll )->addTo(theMenu); + action( VISU_DISPLAY )->addTo(theMenu); + action( VISU_DISPLAY_ONLY )->addTo(theMenu); + theMenu->insertSeparator(); + } action( VISU_SHOW_TABLE )->addTo(theMenu); action( VISU_CREATE_CURVES )->addTo(theMenu); action( VISU_EXPORT_TABLE )->addTo(theMenu); theMenu->insertSeparator(); + action( VISU_DELETE_OBJS )->addTo(theMenu); } else { if (!CORBA::is_nil(anObject)) { SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject); @@ -2889,6 +2937,17 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q } } } + } else { + if (aType == VISU::TPOINTMAP3D) { + action( myEraseAll )->removeFrom(theMenu); + action( VISU_SHOW_TABLE_PLOT )->addTo(theMenu); + theMenu->insertSeparator(); + action( VISU_ERASE )->addTo(theMenu); + action( myEraseAll )->addTo(theMenu); + action( VISU_DISPLAY )->addTo(theMenu); + action( VISU_DISPLAY_ONLY )->addTo(theMenu); + theMenu->insertSeparator(); + } } } @@ -3693,4 +3752,3 @@ void VisuGUI::OnMultiprChangeRes(VISU::Result::Resolution theResolution) QApplication::restoreOverrideCursor(); } - diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 8cc477c9..2d6370b6 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -137,6 +137,7 @@ protected slots: void OnChangeLines(); void OnShowTable(); + void OnShowTablePlot(); void OnCreateTable(); void OnDeleteObjects(); void OnPlotData(); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 40ef7783..d69d1c46 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -45,6 +45,7 @@ #define VISU_DELETE_OBJS 4022 #define VISU_SHOW_TABLE 4023 +#define VISU_SHOW_TABLE_PLOT 4029 #define VISU_CREATE_CURVES 4024 #define VISU_EXPORT_TABLE 4025 diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.cxx b/src/VISUGUI/VisuGUI_ClippingDlg.cxx index 4a7d8b95..d91ad46d 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.cxx +++ b/src/VISUGUI/VisuGUI_ClippingDlg.cxx @@ -811,28 +811,14 @@ void VisuGUI_ClippingDlg::Sinchronize() SpinBoxIJKIndex ->setEnabled(anIsControlsEnable); CheckBoxIJKPlaneReverse->setEnabled(anIsControlsEnable); //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - if(myPrs3d){ + if ( myPrs3d ) { VISU_PipeLine* aPipeLine = myPrs3d->GetPipeLine(); VISU::PIDMapper anIDMapper = aPipeLine->GetIDMapper(); - if(anIDMapper->IsStructured()){ - VISU::TIdTypeVector aVec = anIDMapper->GetStructure(); - switch(aVec.size()){ - case 1: - ButtonGroupIJKAxis->find(0)->setEnabled(true); - ButtonGroupIJKAxis->find(1)->setEnabled(false); - ButtonGroupIJKAxis->find(2)->setEnabled(false); - break; - case 2: - ButtonGroupIJKAxis->find(0)->setEnabled(true); - ButtonGroupIJKAxis->find(1)->setEnabled(true); - ButtonGroupIJKAxis->find(2)->setEnabled(false); - break; - case 3: - ButtonGroupIJKAxis->find(0)->setEnabled(true); - ButtonGroupIJKAxis->find(1)->setEnabled(true); - ButtonGroupIJKAxis->find(2)->setEnabled(true); - break; - } + if ( anIDMapper->IsStructured() ) { + VISU::TStructuredId aStructuredId = anIDMapper->GetStructure(); + ButtonGroupIJKAxis->find(0)->setEnabled( aStructuredId[0] >= 0 ); + ButtonGroupIJKAxis->find(1)->setEnabled( aStructuredId[1] >= 0 ); + ButtonGroupIJKAxis->find(2)->setEnabled( aStructuredId[2] >= 0 ); } } //ENK: 23.11.2006 @@ -1079,8 +1065,8 @@ void VisuGUI_ClippingDlg::setIJKByNonStructured() int aNbAxes = 3; VISU_PipeLine* aPipeLine = myPrs3d->GetPipeLine(); VISU::PIDMapper anIDMapper = aPipeLine->GetIDMapper(); - if(anIDMapper->IsStructured() && !anIDMapper->myType) - aNbAxes = (anIDMapper->GetStructure()).size(); + if ( anIDMapper->IsStructured() && !anIDMapper->myIsPolarType ) + aNbAxes = anIDMapper->GetStructureDim(); for (i = 0; i < aNbAxes; ++i) { VISU::Result_i::TAxis axis = (VISU::Result_i::TAxis) i; CORBA::String_var aMeshName = myPrs3d->GetMeshName(); diff --git a/src/VISUGUI/VisuGUI_Displayer.cxx b/src/VISUGUI/VisuGUI_Displayer.cxx index 2361b992..e60a7e94 100644 --- a/src/VISUGUI/VisuGUI_Displayer.cxx +++ b/src/VISUGUI/VisuGUI_Displayer.cxx @@ -90,7 +90,15 @@ SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& theEntry, SALOM VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(aBase); VISU::ColoredPrs3d_var aColoredPrs3d = aHolder->GetDevice(); aPrs3d = dynamic_cast(VISU::GetServant(aColoredPrs3d).in()); - }else + }else if (aType == VISU::TPOINTMAP3D) { + VISU::PointMap3d_i* aTable3d = dynamic_cast(aBaseServant); + VISU_PointMap3dActor* aPointMap3dActor = aTable3d->CreateActor(); + if (aPointMap3dActor) { + aViewWindow->AddActor(aPointMap3dActor); + aViewWindow->Repaint(); + } + } + else aPrs3d = dynamic_cast(aBaseServant); if(aPrs3d){ diff --git a/src/VISUGUI/VisuGUI_Displayer.h b/src/VISUGUI/VisuGUI_Displayer.h index fdb729b5..9d47113e 100644 --- a/src/VISUGUI/VisuGUI_Displayer.h +++ b/src/VISUGUI/VisuGUI_Displayer.h @@ -32,6 +32,7 @@ #include #include #include +#include class SalomeApp_Application; class SVTK_ViewWindow; diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index 5c8ca103..ff95629b 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -550,7 +550,7 @@ int VisuGUI_GaussScalarBarPane::storeToPrsObject(VISU::GaussPoints_i* thePrs) { thePrs->SetPosition(XSpin->value(), YSpin->value()); thePrs->SetSize(WidthSpin->value(), HeightSpin->value()); - thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3d::VERTICAL : VISU::ColoredPrs3d::HORIZONTAL); + thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL); thePrs->SetNbColors(ColorSpin->value()); thePrs->SetLabels(LabelSpin->value()); diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx index b5747995..38db647f 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx @@ -1234,7 +1234,7 @@ int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { myScalarMap->SetLabelsFormat(myBarDlg->getLabelsFormat()); myScalarMap->SetUnitsVisible(myBarDlg->isUnitsVisible()); - myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3d::VERTICAL : VISU::ColoredPrs3d::HORIZONTAL); + myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL); if(isLogarithmic()) myScalarMap->SetScaling(VISU::LOGARITHMIC); else diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 3dcac912..bb92fe97 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -89,6 +89,19 @@ using namespace std; + +inline +QString +GetNumber( const VISU::TStructuredId& theStructuredId, + size_t theId ) +{ + if ( theStructuredId[theId] < 0 ) + return "-"; + + return QString::number( theStructuredId[theId] ); +} + + VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (const SalomeApp_Module* theModule): QDialog(VISU::GetDesktop(theModule), 0, @@ -439,23 +452,12 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { myIDValLbl->setText( QString::number(anID) ); myScalarValLbl->setText(getValue(aPntData, aVTKID)); myVectorValLbl->setText(getVector(aPntData, aVTKID)); - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing + const VISU::PIDMapper& aMapper = aPrs3d->GetPipeLine()->GetIDMapper(); - VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(anID); - switch(aVec.size()){ - case 3: - myKValLbl->setText(QString::number(aVec[2])); - case 2: - myJValLbl->setText(QString::number(aVec[1])); - case 1: - myIValLbl->setText(QString::number(aVec[0])); - break; - default: - myIValLbl->setText("-"); - myJValLbl->setText("-"); - myKValLbl->setText("-"); - } - //ENK: 23.11.2006 + VISU::TStructuredId aStructuredId = aMapper->GetIndexesOfNode(anID); + myKValLbl->setText( GetNumber( aStructuredId, 2 ) ); + myJValLbl->setText( GetNumber( aStructuredId, 1 ) ); + myIValLbl->setText( GetNumber( aStructuredId, 0 ) ); } break; case 1: @@ -493,20 +495,10 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { myListPoints->verticalHeader()->setLabel(i, QString::number( i )); vtkIdType aNodeObjId = anIter->first; //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(aNodeObjId); - QString aI,aJ,aK; - aI = "-"; - aJ = "-"; - aK = "-"; - switch(aVec.size()){ - case 3: - aK = QString::number(aVec[2]); - case 2: - aJ = QString::number(aVec[1]); - case 1: - aI = QString::number(aVec[0]); - break; - } + VISU::TStructuredId aStructuredId = aMapper->GetIndexesOfNode(aNodeObjId); + QString aI = GetNumber(aStructuredId, 0); + QString aJ = GetNumber(aStructuredId, 1); + QString aK = GetNumber(aStructuredId, 2); //ENK: 23.11.2006 myListPoints->setText(i, 0, QString::number( aNodeObjId )); diff --git a/src/VISUGUI/VisuGUI_Table3dDlg.cxx b/src/VISUGUI/VisuGUI_Table3dDlg.cxx new file mode 100644 index 00000000..6814347a --- /dev/null +++ b/src/VISUGUI/VisuGUI_Table3dDlg.cxx @@ -0,0 +1,771 @@ +// 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_Plot3DDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU +// $Header$ + +#include "VisuGUI_Table3dDlg.h" + +#include "VisuGUI.h" +#include "VisuGUI_Tools.h" +#include "VisuGUI_ViewTools.h" +#include "VisuGUI_InputPane.h" + +#include "VISU_ColoredPrs3dFactory.hh" +#include "VISU_ViewManager_i.hh" + +#include "SVTK_ViewWindow.h" + +#include "SALOME_Actor.h" +#include "SUIT_Desktop.h" +#include "SUIT_Session.h" +#include "SUIT_MessageBox.h" +#include "SUIT_ResourceMgr.h" +#include "LightApp_Application.h" + +#include "SVTK_FontWidget.h" + +#include "QtxDblSpinBox.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +#define SURFACE_PRS_ID 0 +#define CONTOUR_PRS_ID 1 + +//======================================================================= +//function : VisuGUI_Table3DPane +//purpose : +//======================================================================= +VisuGUI_Table3DPane::VisuGUI_Table3DPane (QWidget* parent) + : QVBox(parent), myViewWindow(VISU::GetActiveViewWindow()), myPrs(NULL), + myInitFromPrs(false) +{ + layout()->setAlignment(Qt::AlignTop); + setSpacing(6); + + // Scale, Presentation type, Nb Contours, Preview + + QFrame* bottomFrame = new QFrame (this); + QGridLayout* bottomLayout = new QGridLayout (bottomFrame); + bottomLayout->setAlignment(Qt::AlignTop); + bottomLayout->setSpacing(6); + bottomLayout->setMargin(11); + // scale + QLabel* scaleLabel = new QLabel (tr("SCALE"), bottomFrame); + ScaleSpn = new QtxDblSpinBox (-1.e6, 1.e6, 0.1, bottomFrame); + // Presentation type + GBPrsType = new QHButtonGroup (tr("PRESENTATION_TYPE"), bottomFrame); + new QRadioButton (tr("SURFACE"), GBPrsType); + new QRadioButton (tr("CONTOUR"), GBPrsType); + // nb Contours + QLabel* nbContLabel = new QLabel (tr("NUMBER_CONTOURS"), bottomFrame); + NbContoursSpn = new QSpinBox (1, 999, 1, bottomFrame, "NbContoursSpn"); + + bottomLayout->addWidget(scaleLabel, 0, 0); + bottomLayout->addWidget(ScaleSpn, 0, 1); + bottomLayout->addMultiCellWidget(GBPrsType, 1, 1, 0, 1); + bottomLayout->addWidget(nbContLabel, 2, 0); + bottomLayout->addWidget(NbContoursSpn, 2, 1); + + // signals and slots connections + + connect(GBPrsType, SIGNAL(clicked(int)), this, SLOT(onPrsType(int))); +} + +//======================================================================= +//function : destructor +//purpose : +//======================================================================= +VisuGUI_Table3DPane::~VisuGUI_Table3DPane() +{} + +//======================================================================= +//function : onPrsType +//purpose : +//======================================================================= +void VisuGUI_Table3DPane::onPrsType(int id) +{ + NbContoursSpn->setEnabled(id == CONTOUR_PRS_ID); +} + +//======================================================================= +//function : storeToPrsObject +//purpose : +//======================================================================= +int VisuGUI_Table3DPane::storeToPrsObject(VISU::PointMap3d_i* thePrs) +{ + + // scale + thePrs->SetScaleFactor(ScaleSpn->value()); + + // prs type + int id = GBPrsType->id (GBPrsType->selected()); + thePrs->SetContourPrs(id == CONTOUR_PRS_ID); + + // nb contours + thePrs->SetNbOfContours(NbContoursSpn->value()); + + return 1; +} + +//======================================================================= +//function : initFromPrsObject +//purpose : +//======================================================================= +void VisuGUI_Table3DPane::initFromPrsObject(VISU::PointMap3d_i* thePrs) +{ + myInitFromPrs = true; + myPrs = thePrs; + + // scale + ScaleSpn->setValue(thePrs->GetScaleFactor()); + + // prs type + int id = thePrs->GetIsContourPrs() ? CONTOUR_PRS_ID : SURFACE_PRS_ID; + GBPrsType->setButton(id); + onPrsType(id); + + // nb contours + NbContoursSpn->setValue(thePrs->GetNbOfContours()); +} + +//======================================================================= +//function : Table Scalar Bar +//purpose : +//======================================================================= + +VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane (QWidget * parent): + QVBox(parent), myBarPrs(NULL) +{ + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + QString propertyName; + propertyName = QString("scalar_bar_vertical_"); + myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.); + myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.); + myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.); + myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.); + myVerTW = aResourceMgr->integerValue("VISU", propertyName + "title_width", 0); + myVerTH = aResourceMgr->integerValue("VISU", propertyName + "title_height",0); + myVerLW = aResourceMgr->integerValue("VISU", propertyName + "label_width", 0); + myVerLH = aResourceMgr->integerValue("VISU", propertyName + "label_height",0); + myVerBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0); + myVerBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0); + + propertyName = QString("scalar_bar_horizontal_"); + myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.); + myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.); + myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.); + myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.); + myHorTW = aResourceMgr->integerValue("VISU", propertyName + "title_width", 0); + myHorTH = aResourceMgr->integerValue("VISU", propertyName + "title_height",0); + myHorLW = aResourceMgr->integerValue("VISU", propertyName + "label_width", 0); + myHorLH = aResourceMgr->integerValue("VISU", propertyName + "label_height",0); + myHorBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0); + myHorBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0); + + setSpacing(6); + setMargin(11); + + // Range ============================================================ + RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup"); + RangeGroup->setColumnLayout(0, Qt::Vertical ); + RangeGroup->layout()->setSpacing( 0 ); + RangeGroup->layout()->setMargin( 0 ); + QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() ); + RangeGroupLayout->setAlignment( Qt::AlignTop ); + RangeGroupLayout->setSpacing( 6 ); + RangeGroupLayout->setMargin( 11 ); + + CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), RangeGroup); + CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFrange"); + RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBIrange"); + RBFrange->setChecked( true ); + + MinEdit = new QLineEdit( RangeGroup, "MinEdit" ); + MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MinEdit->setMinimumWidth( 70 ); + MinEdit->setValidator( new QDoubleValidator(this) ); + MinEdit->setText( "0.0" ); + QLabel* MinLabel = new QLabel (tr("LBL_MIN"), RangeGroup, "MinLabel"); + MinLabel->setBuddy(MinEdit); + + MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" ); + MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MaxEdit->setMinimumWidth( 70 ); + MaxEdit->setValidator( new QDoubleValidator(this) ); + MaxEdit->setText( "0.0" ); + QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), RangeGroup, "MaxLabel"); + MaxLabel->setBuddy(MaxEdit); + + RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3); + RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1); + RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3); + RangeGroupLayout->addWidget( MinLabel, 3, 0 ); + RangeGroupLayout->addWidget( MinEdit, 3, 1 ); + RangeGroupLayout->addWidget( MaxLabel, 3, 2 ); + RangeGroupLayout->addWidget( MaxEdit, 3, 3 ); + + //TopLayout->addWidget( RangeGroup ); + + // Colors and Labels ======================================================== + QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup"); + ColLabGroup->setColumnLayout(0, Qt::Vertical ); + ColLabGroup->layout()->setSpacing( 0 ); + ColLabGroup->layout()->setMargin( 0 ); + QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() ); + ColLabGroupLayout->setAlignment( Qt::AlignTop ); + ColLabGroupLayout->setSpacing( 6 ); + ColLabGroupLayout->setMargin( 11 ); + + QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel"); + ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup ); + ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + ColorSpin->setMinimumWidth( 70 ); + ColorSpin->setValue( 64 ); + + QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel"); + LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup ); + LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + LabelSpin->setMinimumWidth( 70 ); + LabelSpin->setValue( 5 ); + + ColLabGroupLayout->addWidget( ColorLabel, 0, 0); + ColLabGroupLayout->addWidget( ColorSpin, 0, 1); + ColLabGroupLayout->addWidget( LabelLabel, 0, 2); + ColLabGroupLayout->addWidget( LabelSpin, 0, 3); + + //TopLayout->addWidget( ColLabGroup ); + + // Orientation ========================================================== + QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup"); + OrientGroup->setColumnLayout(0, Qt::Vertical ); + OrientGroup->layout()->setSpacing( 0 ); + OrientGroup->layout()->setMargin( 0 ); + QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() ); + OrientGroupLayout->setAlignment( Qt::AlignTop ); + OrientGroupLayout->setSpacing( 6 ); + OrientGroupLayout->setMargin( 11 ); + + RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert"); + RBvert->setChecked( true ); + RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori"); + OrientGroupLayout->addWidget( RBvert, 0, 0 ); + OrientGroupLayout->addWidget( RBhori, 0, 1 ); + + // TopLayout->addWidget( OrientGroup ); + + // Origin =============================================================== + QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup"); + OriginGroup->setColumnLayout(0, Qt::Vertical ); + OriginGroup->layout()->setSpacing( 0 ); + OriginGroup->layout()->setMargin( 0 ); + QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() ); + OriginGroupLayout->setAlignment( Qt::AlignTop ); + OriginGroupLayout->setSpacing( 6 ); + OriginGroupLayout->setMargin( 11 ); + + QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel"); + XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup ); + XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + XSpin->setMinimumWidth( 70 ); + XSpin->setValue( 0.01 ); + + QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel"); + YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup ); + YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + YSpin->setMinimumWidth( 70 ); + YSpin->setValue( 0.01 ); + + OriginGroupLayout->addWidget( XLabel, 0, 0); + OriginGroupLayout->addWidget( XSpin, 0, 1); + OriginGroupLayout->addWidget( YLabel, 0, 2); + OriginGroupLayout->addWidget( YSpin, 0, 3); + + //TopLayout->addWidget( OriginGroup ); + + // Dimensions ========================================================= + QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup"); + DimGroup->setColumnLayout(0, Qt::Vertical ); + DimGroup->layout()->setSpacing( 0 ); + DimGroup->layout()->setMargin( 0 ); + QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() ); + DimGroupLayout->setAlignment( Qt::AlignTop ); + DimGroupLayout->setSpacing( 6 ); + DimGroupLayout->setMargin( 11 ); + + QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel"); + WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup ); + WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + WidthSpin->setMinimumWidth( 70 ); + WidthSpin->setValue( 0.1 ); + + QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup, "HeightLabel"); + HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup ); + HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + HeightSpin->setMinimumWidth( 70 ); + HeightSpin->setValue( 0.8 ); + + DimGroupLayout->addWidget( WidthLabel, 0, 0); + DimGroupLayout->addWidget( WidthSpin, 0, 1); + DimGroupLayout->addWidget( HeightLabel, 0, 2); + DimGroupLayout->addWidget( HeightSpin, 0, 3); + + //TopLayout->addWidget( DimGroup ); + + QHBox* aSaveBox = new QHBox(this); + + myTextBtn = new QPushButton("Text properties...", aSaveBox); + myBarBtn = new QPushButton("Bar properties...", aSaveBox); + myTextDlg = new VisuGUI_TextPrefDlg(this); + myTextDlg->setTitleVisible(true); + myBarDlg = new VisuGUI_BarPrefDlg(this); + + + if(RBvert->isChecked()) { + myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + } else { + myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + } + + myBarDlg->setLabelsFormat(aResourceMgr->stringValue("VISU", propertyName + "label_format", "%-#6.3g")); + myBarDlg->setUnitsVisible(aResourceMgr->booleanValue("VISU", propertyName + "display_units", true)); + + // signals and slots connections =========================================== + connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) ); + connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) ); + connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) ); + connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) ); + connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) ); + connect( myBarBtn, SIGNAL( clicked() ), this, SLOT( onBarPref() ) ); + changeDefaults( 0 ); + myIsStoreTextProp = true; + myBusy = false; +} + +//---------------------------------------------------------------------------- + +void VisuGUI_TableScalarBarPane::onBarPref() +{ + if(RBvert->isChecked()) + myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + else + myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + if(myBarDlg->exec()) { + if(RBvert->isChecked()) + myBarDlg->getRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + else + myBarDlg->getRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + } +} + +//---------------------------------------------------------------------------- +/** + * Initialise dialog box from presentation object + */ +void VisuGUI_TableScalarBarPane::initFromPrsObject(VISU::PointMap3d_i* thePrs) +{ + myBarPrs = dynamic_cast(thePrs); + + if( !myBarPrs ) + return; + + switch(myBarPrs->GetScaling()){ + case VISU::LOGARITHMIC : + CBLog->setChecked( true ); + break; + default: + CBLog->setChecked( false ); + } + + setRange( myBarPrs->GetMin(), myBarPrs->GetMax(), myBarPrs->IsRangeFixed() ); + + setScalarBarData( myBarPrs->GetNbColors(), myBarPrs->GetLabels() ); + + // "Title" + CORBA::String_var aTitle = myBarPrs->GetTitle(); + myTextDlg->setTitleText(aTitle.in()); + myTitle = aTitle.in(); + + vtkFloatingPointType R, G, B; + myBarPrs->GetTitleColor(&R, &G, &B); + + setPosAndSize( myBarPrs->GetPosX(), + myBarPrs->GetPosY(), + myBarPrs->GetWidth(), + myBarPrs->GetHeight(), + myBarPrs->GetBarOrientation()); + + myVerTW = myBarPrs->GetTitleWidth(); + myVerTH = myBarPrs->GetTitleHeight(); + myVerLW = myBarPrs->GetLabelWidth(); + myVerLH = myBarPrs->GetLabelHeight(); + myVerBW = myBarPrs->GetBarWidth(); + myVerBH = myBarPrs->GetBarHeight(); + myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + + myBarDlg->setLabelsFormat(myBarPrs->GetLabelsFormat()); + myBarDlg->setUnitsVisible(myBarPrs->IsUnitsVisible()); + + myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), + myBarPrs->GetTitFontType(), + myBarPrs->IsBoldTitle(), + myBarPrs->IsItalicTitle(), + myBarPrs->IsShadowTitle()); + + // "Labels" + myBarPrs->GetLabelColor(&R, &G, &B); + + myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), + myBarPrs->GetLblFontType(), + myBarPrs->IsBoldLabel(), + myBarPrs->IsItalicLabel(), + myBarPrs->IsShadowLabel()); +} + +//---------------------------------------------------------------------------- +/** + * Store values to presentation object + */ +int VisuGUI_TableScalarBarPane::storeToPrsObject(VISU::PointMap3d_i* thePrs) { + if( !myBarPrs ) + return 0; + + myBarPrs->SetPosition(XSpin->value(), YSpin->value()); + myBarPrs->SetSize(WidthSpin->value(), HeightSpin->value()); + + myBarPrs->SetRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + + myBarPrs->SetLabelsFormat(myBarDlg->getLabelsFormat()); + myBarPrs->SetUnitsVisible(myBarDlg->isUnitsVisible()); + + myBarPrs->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL); + if(CBLog->isChecked()) + myBarPrs->SetScaling(VISU::LOGARITHMIC); + else + myBarPrs->SetScaling(VISU::LINEAR); + + if (RBFrange->isChecked()) { + myBarPrs->SetSourceRange(); + } else { + myBarPrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble()); + } + myBarPrs->SetNbColors(ColorSpin->value()); + myBarPrs->SetLabels(LabelSpin->value()); + + if (myIsStoreTextProp) { + // "Title" + myBarPrs->SetTitle(myTextDlg->getTitleText().latin1()); + + QColor aTitColor (255, 255, 255); + int aTitleFontFamily = VTK_ARIAL; + bool isTitleBold = false; + bool isTitleItalic = false; + bool isTitleShadow = false; + + myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily, isTitleBold, isTitleItalic, isTitleShadow); + + myBarPrs->SetBoldTitle(isTitleBold); + myBarPrs->SetItalicTitle(isTitleItalic); + myBarPrs->SetShadowTitle(isTitleShadow); + myBarPrs->SetTitFontType(aTitleFontFamily); + myBarPrs->SetTitleColor(aTitColor.red()/255., + aTitColor.green()/255., + aTitColor.blue()/255.); + + // "Label" + QColor aLblColor (255, 255, 255); + int aLabelFontFamily = VTK_ARIAL; + bool isLabelBold = false; + bool isLabelItalic = false; + bool isLabelShadow = false; + + myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily, isLabelBold, isLabelItalic, isLabelShadow); + + myBarPrs->SetBoldLabel(isLabelBold); + myBarPrs->SetItalicLabel(isLabelItalic); + myBarPrs->SetShadowLabel(isLabelShadow); + myBarPrs->SetLblFontType(aLabelFontFamily); + myBarPrs->SetLabelColor(aLblColor.red()/255., + aLblColor.green()/255., + aLblColor.blue()/255.); + // myIsStoreTextProp = false; + } + return 1; +} + +//---------------------------------------------------------------------------- +/*! + Sets default values and range mode +*/ +void VisuGUI_TableScalarBarPane::setRange( double imin, double imax, bool sbRange ) +{ + MinEdit->setText( QString::number( imin ) ); + MaxEdit->setText( QString::number( imax ) ); + + if( sbRange ) + RBIrange->setChecked( true ); + else + RBFrange->setChecked( true ); + + changeRange( sbRange ); +} + +//---------------------------------------------------------------------------- +/*! + Called when Range mode is changed +*/ +void VisuGUI_TableScalarBarPane::changeRange( int ) +{ + if ( RBFrange->isChecked() ) { + myBarPrs->SetSourceRange(); + MinEdit->setEnabled( false ); + MaxEdit->setEnabled( false ); + } else { + myBarPrs->SetRange( myBarPrs->GetMin(), myBarPrs->GetMax() ); + myBarPrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble()); + MinEdit->setEnabled( true ); + MaxEdit->setEnabled( true ); + } + + MinEdit->setText( QString::number( myBarPrs->GetMin() ) ); + MaxEdit->setText( QString::number( myBarPrs->GetMax() ) ); +} + +//---------------------------------------------------------------------------- +/*! + Called when X,Y position is changed +*/ +void VisuGUI_TableScalarBarPane::XYChanged( double ) +{ + QtxDblSpinBox* snd = (QtxDblSpinBox*)sender(); + if ( snd == XSpin ) { + WidthSpin->setMaxValue( 1.0 - XSpin->value() ); + } + if ( snd == YSpin ) { + HeightSpin->setMaxValue( 1.0 - YSpin->value() ); + } +} + +//---------------------------------------------------------------------------- +/*! + Sets size and position +*/ +void VisuGUI_TableScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert ) +{ + if ( vert ) { + myVerX = x; + myVerY = y; + myVerW = w; + myVerH = h; + RBvert->setChecked( true ); + } + else { + myHorX = x; + myHorY = y; + myHorW = w; + myHorH = h; + RBhori->setChecked( true ); + } + changeDefaults( 0 ); +} + +//---------------------------------------------------------------------------- +/*! + Sets colors and labels number +*/ +void VisuGUI_TableScalarBarPane::setScalarBarData( int colors, int labels ) +{ + ColorSpin->setValue( colors ); + LabelSpin->setValue( labels ); +} + +//---------------------------------------------------------------------------- +void VisuGUI_TableScalarBarPane::onTextPref() +{ + myTextDlg->storeBeginValues(); + myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp; +} + +//---------------------------------------------------------------------------- +VisuGUI_TableScalarBarPane::~VisuGUI_TableScalarBarPane() +{ +} + +//---------------------------------------------------------------------------- +/*! + Called when orientation is changed +*/ +void VisuGUI_TableScalarBarPane::changeDefaults( int ) +{ + if ( RBvert->isChecked() ) { + XSpin->setValue( myVerX ); + YSpin->setValue( myVerY ); + WidthSpin->setValue( myVerW ); + HeightSpin->setValue( myVerH ); + } + else { + XSpin->setValue( myHorX ); + YSpin->setValue( myHorY ); + WidthSpin->setValue( myHorW ); + HeightSpin->setValue( myHorH ); + } +} + + +//======================================================================= +//function : Constructor +//purpose : +//======================================================================= +VisuGUI_Table3DDlg::VisuGUI_Table3DDlg ( SalomeApp_Module* theModule ) + : QDialog ( VISU::GetDesktop(theModule), 0, false ) +{ + setCaption(tr("TITLE")); + setSizeGripEnabled(TRUE); + + QVBoxLayout* TopLayout = new QVBoxLayout(this); + TopLayout->setSpacing(6); + TopLayout->setMargin(11); + + myTabBox = new QTabWidget (this); + myIsoPane = new VisuGUI_Table3DPane (this); + myScalarBarPane = new VisuGUI_TableScalarBarPane (this); + + myIsoPane->setMargin(11); + myScalarBarPane->setMargin(11); + myTabBox->addTab(myIsoPane, tr("DLG_PREF_TITLE")); + myTabBox->addTab(myScalarBarPane, tr("DLG_PROP_TITLE")); + + TopLayout->addWidget(myTabBox); + + QGroupBox* GroupButtons = new QGroupBox (this, "GroupButtons"); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + QGridLayout* GroupButtonsLayout = new QGridLayout (GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + + QPushButton* buttonOk = new QPushButton (tr("&OK"), GroupButtons, "buttonOk"); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + + QPushButton* buttonApply = new QPushButton (tr("&Apply"), GroupButtons, "buttonApply"); + buttonApply->setAutoDefault(TRUE); + buttonApply->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2); + QPushButton* buttonCancel = new QPushButton (tr("&Cancel") , GroupButtons, "buttonCancel"); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + QPushButton* buttonHelp = new QPushButton (tr("&Help") , GroupButtons, "buttonHelp"); + buttonHelp->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonHelp, 0, 4); + + 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(buttonApply, SIGNAL(clicked()), this, SLOT(onApply())); +} + +VisuGUI_Table3DDlg::~VisuGUI_Table3DDlg() +{} + +//======================================================================= +//function : accept +//purpose : +//======================================================================= +void VisuGUI_Table3DDlg::accept() +{ + QDialog::accept(); +} + +//======================================================================= +//function : reject +//purpose : +//======================================================================= +void VisuGUI_Table3DDlg::reject() +{ + QDialog::reject(); +} + +//======================================================================= +//function : onApply +//purpose : +//======================================================================= +void VisuGUI_Table3DDlg::onApply() +{ + storeToPrsObject( myPrsCopy ); + myPrsCopy->UpdateActors(); +} + +//======================================================================= +//function : onHelp +//purpose : +//======================================================================= +void VisuGUI_Table3DDlg::onHelp() +{ + // "table_3d_page.html"; +} + +//======================================================================= +//function : storeToPrsObject +//purpose : +//======================================================================= +int VisuGUI_Table3DDlg::storeToPrsObject (VISU::PointMap3d_i* thePrs) +{ + int anIsOk = myIsoPane->storeToPrsObject( thePrs ); + anIsOk &= myScalarBarPane->storeToPrsObject( thePrs ); + + return anIsOk; +} + +//======================================================================= +//function : initFromPrsObject +//purpose : +//======================================================================= +void VisuGUI_Table3DDlg::initFromPrsObject (VISU::PointMap3d_i* thePrs) +{ + myPrsCopy = thePrs; + myIsoPane->initFromPrsObject( thePrs ); + myScalarBarPane->initFromPrsObject( thePrs ); +} + diff --git a/src/VISUGUI/VisuGUI_Table3dDlg.h b/src/VISUGUI/VisuGUI_Table3dDlg.h new file mode 100644 index 00000000..cc10bb3e --- /dev/null +++ b/src/VISUGUI/VisuGUI_Table3dDlg.h @@ -0,0 +1,187 @@ +// 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_Plot3DDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU +// $Header$ + +#ifndef VISUGUI_TABLE3D_H +#define VISUGUI_TABLE3D_H + +#include "VisuGUI_Prs3dDlg.h" + +#include +#include +#include +#include + +class SalomeApp_Module; + +namespace VISU +{ + class PointMap3d_i; +}; + +class VISU_Plot3DPL; +class SVTK_ViewWindow; +class SALOME_Actor; +class QtxDblSpinBox; + +class VisuGUI_Table3DPane : public QVBox +{ + Q_OBJECT + + public: + VisuGUI_Table3DPane(QWidget* parent); + ~VisuGUI_Table3DPane(); + + void initFromPrsObject (VISU::PointMap3d_i* thePrs); + int storeToPrsObject (VISU::PointMap3d_i* thePrs); + + VISU::PointMap3d_i* GetPrs() { return myPrs; } + + private: + bool myInitFromPrs; + + SVTK_ViewWindow* myViewWindow; + VISU::PointMap3d_i* myPrs; + + QtxDblSpinBox * ScaleSpn; + QHButtonGroup * GBPrsType; + QSpinBox * NbContoursSpn; + + private slots: + + void onPrsType( int ); +}; + +class VisuGUI_TableScalarBarPane : public QVBox +{ + Q_OBJECT; + + public: + VisuGUI_TableScalarBarPane(QWidget* parent); + ~VisuGUI_TableScalarBarPane(); + + void setRange( double imin, double imax, bool sbRange ); + void setDefaultRange(double imin, double imax); + int getOrientation(); + void setPosAndSize( double x, double y, double w, double h, bool vert ); + void setScalarBarData( int colors, int labels ); + bool isIRange(); + double getMin(); + double getMax(); + double getX(); + double getY(); + double getWidth(); + double getHeight(); + int getNbColors(); + int getNbLabels(); + bool isLogarithmic(); + void setLogarithmic( bool on ); + // bool isToSave() {return CBSave ? CBSave->isChecked() : false;} + + void storeToResources(); + + void initFromPrsObject(VISU::PointMap3d_i* thePrs); + int storeToPrsObject(VISU::PointMap3d_i* thePrs); + + bool check(); + + protected: + QButtonGroup* RangeGroup; + QRadioButton* RBFrange; + QRadioButton* RBIrange; + QLineEdit* MinEdit; + QLineEdit* MaxEdit; + + QRadioButton* RBhori; + QRadioButton* RBvert; + + QtxDblSpinBox* XSpin; + QtxDblSpinBox* YSpin; + + QtxDblSpinBox* WidthSpin; + QtxDblSpinBox* HeightSpin; + + QSpinBox* ColorSpin; + QSpinBox* LabelSpin; + + QCheckBox* CBSave; + QCheckBox* CBLog; + QComboBox* myModeCombo; + QPushButton* myTextBtn; + QPushButton* myBarBtn; + VisuGUI_TextPrefDlg* myTextDlg; + VisuGUI_BarPrefDlg* myBarDlg; + + double myHorX, myHorY, myHorW, myHorH; + double myVerX, myVerY, myVerW, myVerH; + int myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH; + int myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH; + bool myIsStoreTextProp; + + private slots: + void changeDefaults( int ); + void changeRange( int ); + void XYChanged( double ); + void changeScalarMode( int ); + void onTextPref(); + void onBarPref(); + + private: + std::string myTitle; + VISU::PointMap3d_i* myBarPrs; + + bool myBusy; +}; + +/////////////////////////////////////////////////////// + +class VisuGUI_Table3DDlg : public QDialog +{ + Q_OBJECT + + public: + VisuGUI_Table3DDlg (SalomeApp_Module* theModule); + ~VisuGUI_Table3DDlg(); + + virtual void initFromPrsObject( VISU::PointMap3d_i* thePrs ); + virtual int storeToPrsObject(VISU::PointMap3d_i* thePrs); + + protected slots: + void accept(); + void reject(); + void onHelp(); + void onApply(); + + private: + QTabWidget* myTabBox; + VisuGUI_Table3DPane* myIsoPane; + VisuGUI_TableScalarBarPane* myScalarBarPane; + + SALOME::GenericObjPtr myPrsCopy; +}; + +#endif // VISUGUI_TABLE3D_H diff --git a/src/VISUGUI/VisuGUI_ViewTools.cxx b/src/VISUGUI/VisuGUI_ViewTools.cxx index 6062909c..5e5c8a74 100644 --- a/src/VISUGUI/VisuGUI_ViewTools.cxx +++ b/src/VISUGUI/VisuGUI_ViewTools.cxx @@ -161,6 +161,18 @@ namespace VISU PlotTable(theModule, aTable, VISU::eErase ); break; } + case VISU::TPOINTMAP3D: { + if (VISU::PointMap3d_i* aTable3d = dynamic_cast(theBase)) { + if (SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(theModule)) { + if(VISU_ActorBase* anActor = FindActorBase(aViewWindow, aTable3d)){ + anActor->VisibilityOff(); + if(theDoRepaint) + aViewWindow->Repaint(); + } + } + } + break; + } default: { if(VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dFromBase(theBase)){ if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(theModule)){ diff --git a/src/VISUGUI/VisuGUI_ViewTools.h b/src/VISUGUI/VisuGUI_ViewTools.h index 521bafa6..80c03719 100644 --- a/src/VISUGUI/VisuGUI_ViewTools.h +++ b/src/VISUGUI/VisuGUI_ViewTools.h @@ -34,6 +34,7 @@ #include "VISU_Prs3d_i.hh" #include "VISU_Table_i.hh" +#include "VISU_PointMap3d_i.hh" #include "VISU_ViewManager_i.hh" #include "VISU_Actor.h" diff --git a/src/VISU_I/Makefile.am b/src/VISU_I/Makefile.am index b08daa88..9b17d534 100644 --- a/src/VISU_I/Makefile.am +++ b/src/VISU_I/Makefile.am @@ -34,6 +34,7 @@ salomeinclude_HEADERS = \ VISU_MultiResult_i.hh \ VISU_PrsObject_i.hh \ VISU_Table_i.hh \ + VISU_PointMap3d_i.hh \ VISU_Prs3d_i.hh \ VISU_Mesh_i.hh \ VISU_ColoredPrs3d_i.hh \ @@ -82,6 +83,7 @@ libVISUEngineImpl_la_SOURCES = \ VISU_TimeAnimation.cxx \ VISU_View_i.cc \ VISU_Table_i.cc \ + VISU_PointMap3d_i.cc \ VISU_DumpPython.cc \ SALOME_GenericObjPointer.cc diff --git a/src/VISU_I/VISUConfig.cc b/src/VISU_I/VISUConfig.cc index 31d8a6af..f42b1ff9 100644 --- a/src/VISU_I/VISUConfig.cc +++ b/src/VISU_I/VISUConfig.cc @@ -200,6 +200,8 @@ namespace VISU return VISU::TCURVE; if ( theComment == "TABLE" ) return VISU::TTABLE; + if ( theComment == "POINTMAP3D" ) + return VISU::TPOINTMAP3D; if ( theComment == "CONTAINER" ) return VISU::TCONTAINER; if ( theComment == "MESH" ) diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 4eb39df8..10e26802 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -929,7 +929,7 @@ VISU::ColoredPrs3d_i //---------------------------------------------------------------------------- void VISU::ColoredPrs3d_i -::SetBarOrientation(VISU::ColoredPrs3d::Orientation theOrientation) +::SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theOrientation) { if(myOrientation == theOrientation) return; @@ -941,7 +941,7 @@ VISU::ColoredPrs3d_i } //---------------------------------------------------------------------------- -VISU::ColoredPrs3d::Orientation +VISU::ColoredPrs3dBase::Orientation VISU::ColoredPrs3d_i ::GetBarOrientation() { @@ -1519,26 +1519,26 @@ VISU::ColoredPrs3d_i // Orientation int anOrientation = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0); if(anOrientation == 1) - SetBarOrientation(VISU::ColoredPrs3d::HORIZONTAL); + SetBarOrientation(VISU::ColoredPrs3dBase::HORIZONTAL); else - SetBarOrientation(VISU::ColoredPrs3d::VERTICAL); + SetBarOrientation(VISU::ColoredPrs3dBase::VERTICAL); // Scalar Bar origin QString propertyName = QString( "scalar_bar_%1_" ).arg( anOrientation == 0 ? "vertical" : "horizontal" ); - vtkFloatingPointType aXorigin = (myOrientation == VISU::ColoredPrs3d::VERTICAL) ? 0.01 : 0.2; + vtkFloatingPointType aXorigin = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.01 : 0.2; aXorigin = aResourceMgr->doubleValue("VISU", propertyName + "x", aXorigin); myPosition[0] = aXorigin; - vtkFloatingPointType aYorigin = (myOrientation == VISU::ColoredPrs3d::VERTICAL) ? 0.1 : 0.012; + vtkFloatingPointType aYorigin = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.1 : 0.012; aYorigin = aResourceMgr->doubleValue("VISU", propertyName + "y", aYorigin); myPosition[1] = aYorigin; // Scalar Bar size - myWidth = (myOrientation == VISU::ColoredPrs3d::VERTICAL)? 0.1 : 0.6; + myWidth = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.1 : 0.6; myWidth = aResourceMgr->doubleValue("VISU", propertyName + "width", myWidth); - myHeight = (myOrientation == VISU::ColoredPrs3d::VERTICAL)? 0.8:0.12; + myHeight = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.8:0.12; myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight); myTitleWidth = 0; @@ -1565,7 +1565,7 @@ VISU::ColoredPrs3d_i if (anIsArrangeBar){ aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0); } - if(myOrientation == VISU::ColoredPrs3d::HORIZONTAL){ + if(myOrientation == VISU::ColoredPrs3dBase::HORIZONTAL){ myPosition[1] += myHeight*(aPlace-1); } else { myPosition[0] += myWidth*(aPlace-1); @@ -1676,7 +1676,7 @@ VISU::ColoredPrs3d_i SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt()); SetUnitsVisible(VISU::Storable::FindValue(theMap,"myUnitsVisible", "1").toInt()); SetLabelsFormat(VISU::Storable::FindValue(theMap,"myLabelsFormat", "%-#6.3g")); - SetBarOrientation((VISU::ColoredPrs3d::Orientation)VISU::Storable::FindValue(theMap,"myOrientation").toInt()); + SetBarOrientation((VISU::ColoredPrs3dBase::Orientation)VISU::Storable::FindValue(theMap,"myOrientation").toInt()); SetTitle(VISU::Storable::FindValue(theMap,"myTitle").latin1()); myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt(); diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index cb22f72d..50177693 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -260,10 +260,10 @@ namespace VISU virtual void - SetBarOrientation(VISU::ColoredPrs3d::Orientation theOrientation); + SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theOrientation); virtual - VISU::ColoredPrs3d::Orientation + VISU::ColoredPrs3dBase::Orientation GetBarOrientation(); virtual @@ -650,7 +650,7 @@ namespace VISU int myNumberOfLabels; std::string myLabelsFormat; - VISU::ColoredPrs3d::Orientation myOrientation; + VISU::ColoredPrs3dBase::Orientation myOrientation; vtkFloatingPointType myPosition[2], myWidth, myHeight, myTitleWidth, myTitleHeight, diff --git a/src/VISU_I/VISU_CutLines_i.hh b/src/VISU_I/VISU_CutLines_i.hh index 742c1072..41027ff3 100644 --- a/src/VISU_I/VISU_CutLines_i.hh +++ b/src/VISU_I/VISU_CutLines_i.hh @@ -36,7 +36,7 @@ namespace VISU { //---------------------------------------------------------------------------- class VISU_I_EXPORT CutLines_i : public virtual POA_VISU::CutLines, - public virtual ScalarMap_i + public virtual ScalarMap_i { static int myNbPresent; CutLines_i(const CutLines_i&); diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index aea67bc0..5a3eb8a2 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -289,10 +289,10 @@ namespace VISU std::string aParam; switch(theServant->GetBarOrientation()){ - case ColoredPrs3d::HORIZONTAL: + case ColoredPrs3dBase::HORIZONTAL: aParam = "VISU.ColoredPrs3d.HORIZONTAL"; break; - case ColoredPrs3d::VERTICAL: + case ColoredPrs3dBase::VERTICAL: aParam = "VISU.ColoredPrs3d.VERTICAL"; break; } diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index befdcf63..72064cb4 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -916,7 +916,7 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::UpdateActor(VISU_Actor* theActor) +::UpdateActor(VISU_ActorBase* theActor) { if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)){ VISU_ScalarBarCtrl *aScalarBarCtrl = anActor->GetScalarBarCtrl(); diff --git a/src/VISU_I/VISU_GaussPoints_i.hh b/src/VISU_I/VISU_GaussPoints_i.hh index 117ab8ab..884d1b36 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -385,7 +385,7 @@ namespace VISU virtual void - UpdateActor(VISU_Actor* theActor); + UpdateActor(VISU_ActorBase* theActor); virtual void diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index 60b544ab..c9b85b1b 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -32,6 +32,7 @@ #include "VISU_Prs3d_i.hh" #include "VISU_Mesh_i.hh" #include "VISU_Table_i.hh" +#include "VISU_PointMap3d_i.hh" #include "VISU_TimeAnimation.h" #include "VISU_ColoredPrs3dFactory.hh" @@ -591,7 +592,16 @@ namespace VISU { if(myStudyDocument->GetProperties()->IsLocked()) return SALOMEDS::SObject::_nil(); + SALOMEDS::SObject_var aRes = VISU::ImportTables(theFileName,myStudyDocument); + + SALOMEDS::Study_var aStudy = aRes->GetStudy(); + SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(aRes); + for (; anIter->More(); anIter->Next()) { + SALOMEDS::SObject_var SO = anIter->Value(); + CreateTable( SO->GetID() ); + } + return aRes._retn(); } @@ -1074,7 +1084,6 @@ namespace VISU theIteration)._retn(); } - //--------------------------------------------------------------- struct CreateTableEvent: public SALOME_Event { @@ -1083,7 +1092,7 @@ namespace VISU typedef Table_ptr TResult; TResult myResult; - CreateTableEvent(const SALOMEDS::Study_var& theStudy, const char* theTableEntry) + CreateTableEvent(SALOMEDS::Study_var theStudy, const char* theTableEntry) { myStudyDocument = theStudy; myTableEntry = theTableEntry; @@ -1094,16 +1103,46 @@ namespace VISU void Execute() { + SALOMEDS::SObject_var SO = myStudyDocument->FindObjectID(myTableEntry); + SALOMEDS::GenericAttribute_var anAttr; + if ( SO->FindAttribute(anAttr, "AttributeTableOfReal") ) { + SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr); + if ( isSparseMatrix( aTableOfReal ) ) { + PointMap3d_i* pPresent = new PointMap3d_i(myStudyDocument,myTableEntry); + if(pPresent->Create() != NULL) + myResult = pPresent->_this(); + else { + pPresent->_remove_ref(); + myResult = VISU::Table::_nil(); + } + return; + } + } Table_i* pPresent = new Table_i(myStudyDocument,myTableEntry); if(pPresent->Create() != NULL) myResult = pPresent->_this(); - else{ + else { pPresent->_remove_ref(); myResult = VISU::Table::_nil(); } } - }; + virtual + bool + isSparseMatrix(SALOMEDS::AttributeTableOfReal_var theTableOfReal) + { + int aCols = theTableOfReal->GetNbColumns(); + int aRows = theTableOfReal->GetNbRows(); + + for (int i=1; i<=aCols; i++) { + for (int j=1; j<=aRows; j++) { + if ( !(theTableOfReal->HasValue(j, i)) ) + return false; + } + } + return true; + } + }; //--------------------------------------------------------------- Table_ptr @@ -1112,11 +1151,10 @@ namespace VISU { if(myStudyDocument->GetProperties()->IsLocked()) return Table::_nil(); - Mutex mt(myMutex); + return ProcessEvent(new CreateTableEvent(myStudyDocument, theTableEntry)); } - //--------------------------------------------------------------- Curve_ptr VISU_Gen_i diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index 6b9f8660..2672a90e 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -522,7 +522,7 @@ VISU::Mesh_i //---------------------------------------------------------------------------- void VISU::Mesh_i -::UpdateActor(VISU_Actor* theActor) +::UpdateActor(VISU_ActorBase* theActor) { if(VISU_MeshAct* anActor = dynamic_cast(theActor)){ if(MYDEBUG) MESSAGE("Mesh_i::UpdateActor"); diff --git a/src/VISU_I/VISU_Mesh_i.hh b/src/VISU_I/VISU_Mesh_i.hh index 6576b7be..b0395f14 100644 --- a/src/VISU_I/VISU_Mesh_i.hh +++ b/src/VISU_I/VISU_Mesh_i.hh @@ -178,7 +178,7 @@ namespace VISU virtual void - UpdateActor(VISU_Actor* theActor); + UpdateActor(VISU_ActorBase* theActor); }; } diff --git a/src/VISU_I/VISU_PointMap3d_i.cc b/src/VISU_I/VISU_PointMap3d_i.cc new file mode 100644 index 00000000..a6cf7b63 --- /dev/null +++ b/src/VISU_I/VISU_PointMap3d_i.cc @@ -0,0 +1,1166 @@ +// 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_PointMap3d_i.cc +// Author : Vadim SANDLER +// Module : VISU + +#include "VISU_PointMap3d_i.hh" + +#include "VISU_CutLines_i.hh" +#include "VISU_Result_i.hh" +#include "VISU_ViewManager_i.hh" +#include "VISU_ScalarBarActor.hxx" +#include "SUIT_ResourceMgr.h" + +#include "SALOME_Event.hxx" +#include "VISU_Prs3dUtils.hh" +#include "SPlot2d_Curve.h" +#include "VISU_PipeLineUtils.hxx" + +#include "VISU_TableReader.hxx" +#include "VISU_ConvertorUtils.hxx" +#include "VISU_DeformedGridPL.hxx" + +#include "SALOME_InteractiveObject.hxx" +#include "VISU_Gen_i.hh" + +#include +#include + +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +//---------------------------------------------------------------- +// PointMap3d Object +//---------------------------------------------------------------- +int VISU::PointMap3d_i::myNbPresent = 0; +const string VISU::PointMap3d_i::myComment = "POINTMAP3D"; +/*! + Generate unique name +*/ +QString VISU::PointMap3d_i::GenerateName() +{ + return VISU::GenerateName( "Table3D - ", ++myNbPresent ); +} +/*! + Gets comment string +*/ +const char* VISU::PointMap3d_i::GetComment() const +{ + return myComment.c_str(); +} +/*! + Constructor +*/ +VISU::PointMap3d_i::PointMap3d_i( SALOMEDS::Study_ptr theStudy, const char* theObjectEntry ) + : Table_i(theStudy, theObjectEntry), + myActorCollection(vtkActorCollection::New()), + myIsActiveState(true) +{ + MESSAGE("PointMap3d_i::PointMap3d_i - "<FindObjectID(theObjectEntry); + myOffset[0] = myOffset[1] = myOffset[2] = 0; + myActorCollection->Delete(); +} +/*! + Destructor +*/ +VISU::PointMap3d_i::~PointMap3d_i() +{ + MESSAGE("PointMap3d_i::~PointMap3d_i - "< TSignal; + const TSignal& mySignal; + + TInvokeSignalEvent(const TSignal& theSignal): + mySignal(theSignal) + {} + + virtual + void + Execute() + { + mySignal(); + } + }; +} + +//---------------------------------------------------------------------------- +void +VISU::PointMap3d_i +::SetTitle( const char* theTitle ) +{ + SetName( theTitle, true ); +} + +//---------------------------------------------------------------------------- +char* +VISU::PointMap3d_i +::GetTitle() +{ + return CORBA::string_dup( GetName().c_str() ); +} + +//---------------------------------------------------------------------------- +SALOMEDS::SObject_var +VISU::PointMap3d_i +::GetSObject() const +{ + return mySObj; +} + +//---------------------------------------------------------------------------- +std::string +VISU::PointMap3d_i +::GetObjectEntry() +{ + CORBA::String_var anEntry = mySObj->GetID(); + return anEntry.in(); +} + +//---------------------------------------------------------------------------- +/*! + Creates table3d object +*/ +VISU::Storable* VISU::PointMap3d_i::Create() +{ + // generate name ... + SetName(GetTableTitle().latin1(), false); + + if ( GetName() == "" ) { + if ( !mySObj->_is_nil() ) { + CutLines_i* pCutLines = NULL; + CORBA::Object_var anObj = SObjectToObject(mySObj); + if(!CORBA::is_nil(anObj)){ + VISU::CutLines_var aCutLines = VISU::CutLines::_narrow(anObj); + if(!aCutLines->_is_nil()) + pCutLines = dynamic_cast(GetServant(aCutLines).in()); + } + if (!pCutLines) + if (mySObj->GetName()) SetName(mySObj->GetName(), false); + } + } + + if ( GetName() == "" ) + SetName(GenerateName().latin1(), false); + + // Create Pipeline + myTablePL = VISU_DeformedGridPL::New(); + myTablePL->SetPolyDataIDMapper(GetTableIDMapper()); + myTablePL->Update(); + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + + bool isUnits = aResourceMgr->booleanValue( "VISU", "scalar_bar_display_units", true ); + SetUnitsVisible(isUnits); + + QString aLabelsFormat = aResourceMgr->stringValue( "VISU", "scalar_bar_label_format", "%-#6.3g" ); + const char *lf=aLabelsFormat.latin1(); + SetLabelsFormat(lf); + + // Orientation + int anOrientation = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0); + if(anOrientation == 1) + SetBarOrientation(VISU::ColoredPrs3dBase::HORIZONTAL); + else + SetBarOrientation(VISU::ColoredPrs3dBase::VERTICAL); + + // Scalar Bar origin + QString propertyName = QString( "scalar_bar_%1_" ).arg( anOrientation == 0 ? "vertical" : "horizontal" ); + + vtkFloatingPointType aXorigin = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.01 : 0.2; + aXorigin = aResourceMgr->doubleValue("VISU", propertyName + "x", aXorigin); + myPosition[0] = aXorigin; + + vtkFloatingPointType aYorigin = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.1 : 0.012; + aYorigin = aResourceMgr->doubleValue("VISU", propertyName + "y", aYorigin); + myPosition[1] = aYorigin; + + // Scalar Bar size + myWidth = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.1 : 0.6; + myWidth = aResourceMgr->doubleValue("VISU", propertyName + "width", myWidth); + + myHeight = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.8:0.12; + myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight); + + myTitleWidth = aResourceMgr->doubleValue("VISU", propertyName + "title_width", 0); + myTitleHeight = aResourceMgr->doubleValue("VISU", propertyName + "title_height", 0); + myLabelWidth = aResourceMgr->doubleValue("VISU", propertyName + "label_width", 0); + myLabelHeight = aResourceMgr->doubleValue("VISU", propertyName + "label_height", 0); + myBarWidth = aResourceMgr->doubleValue("VISU", propertyName + "bar_width", 0); + myBarHeight = aResourceMgr->doubleValue("VISU", propertyName + "bar_height", 0); + + // Nb of Labels + myNumberOfLabels = aResourceMgr->integerValue( "VISU", "scalar_bar_num_labels", 5 ); + + // Fonts properties definition + myIsBoldTitle = myIsItalicTitle = myIsShadowTitle = true; + myTitFontType = VTK_ARIAL; + + if(aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" )){ + QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" ); + if ( f.family() == "Arial" ) + myTitFontType = VTK_ARIAL; + else if ( f.family() == "Courier" ) + myTitFontType = VTK_COURIER; + else if ( f.family() == "Times" ) + myTitFontType = VTK_TIMES; + + myIsBoldTitle = f.bold(); + myIsItalicTitle = f.italic(); + myIsShadowTitle = f.underline(); + } + + 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; + + myIsBoldLabel = myIsItalicLabel = myIsShadowLabel = true; + myLblFontType = VTK_ARIAL; + + if( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" )){ + QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" ); + if ( f.family() == "Arial" ) + myLblFontType = VTK_ARIAL; + else if ( f.family() == "Courier" ) + myLblFontType = VTK_COURIER; + else if ( f.family() == "Times" ) + myLblFontType = VTK_TIMES; + + myIsBoldLabel = f.bold(); + myIsItalicLabel = f.italic(); + myIsShadowLabel = f.underline(); + } + + 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; + + // scalar bar default position + bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0); + int aPlace = 1; + if (anIsArrangeBar){ + aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0); + } + if(myBarOrientation == VISU::ColoredPrs3dBase::HORIZONTAL){ + myPosition[1] += myHeight*(aPlace-1); + } else { + myPosition[0] += myWidth*(aPlace-1); + } + + return Build( false ); +} + +/* + GetIDMapper +*/ + +VISU::PTableIDMapper +VISU::PointMap3d_i +::GetTableIDMapper() +{ + //Initialisate table mapper + SALOMEDS::GenericAttribute_var anAttr; + mySObj->FindAttribute(anAttr, "AttributeTableOfReal"); + SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr); + + PTableIDMapper aTableIDMapper( new TTableIDMapper() ); + TTable2D& aTable2D = *aTableIDMapper; + + aTable2D.myTitle = aTableOfReal->GetTitle(); + + SALOMEDS::StringSeq_var aColStrList = aTableOfReal->GetColumnTitles(); + SALOMEDS::StringSeq_var aRowStrList = aTableOfReal->GetRowTitles(); + + for ( int i = 0; i < aRowStrList->length(); i++ ) { + aTable2D.myColumnTitles.push_back( aRowStrList[ i ].in() ); + } + + int aCols = aTableOfReal->GetNbColumns(); + int aRows = aTableOfReal->GetNbRows(); + + for (int i=1; i<=aCols; i++) { + TTable2D::TRow aRow; + aRow.myTitle = aColStrList[ i-1 ].in(); + for (int j=1; j<=aRows; j++) { + double aVal = aTableOfReal->GetValue(j, i); + QString aValStr = QString::number(aVal); + aRow.myValues.push_back( aValStr ); + } + if( aRow.myValues.size() > 0 ) + aTable2D.myRows.push_back( aRow ); + } + + return aTableIDMapper; +} + +/* + Create Actor +*/ +VISU_PointMap3dActor* VISU::PointMap3d_i::CreateActor() +{ + VISU_PointMap3dActor* anActor = VISU_PointMap3dActor::New(); + anActor->SetPipeLine(myTablePL); + anActor->SetFactory(this); + + Handle (SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(GetEntry().c_str(), "VISU", GetName().c_str()); + anActor->setIO(anIO); + + myUpdateActorsSignal.connect(boost::bind(&VISU_Actor::UpdateFromFactory,anActor)); + // myRemoveActorsFromRendererSignal.connect(boost::bind(&VISU_Actor::RemoveFromRender,anActor)); + + myActorCollection->AddItem(anActor); + + UpdateActor( anActor ); + + return anActor; +} + +/* + Update Actor +*/ +void VISU::PointMap3d_i::UpdateActor(VISU_ActorBase* theActor) +{ + if(VISU_PointMap3dActor* anActor = dynamic_cast(theActor)){ + VISU_ScalarBarActor *aScalarBar = anActor->GetScalarBar(); + aScalarBar->SetLookupTable(GetSpecificPL()->GetBarTable()); + aScalarBar->SetTitle(GetTitle()); + aScalarBar->SetOrientation(GetBarOrientation()); + aScalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); + aScalarBar->GetPositionCoordinate()->SetValue(GetPosX(),GetPosY()); + aScalarBar->SetWidth(GetWidth()); + aScalarBar->SetHeight(GetHeight()); + aScalarBar->SetNumberOfLabels(GetLabels()); + aScalarBar->SetRatios(myTitleWidth, myTitleHeight, + myLabelWidth, myLabelHeight, + myBarWidth, myBarHeight); + aScalarBar->SetNumberOfLabels(GetLabels()); + aScalarBar->SetLabelFormat(GetLabelsFormat()); + + vtkFloatingPointType anRGB[3]; + + vtkTextProperty* aTitleProp = aScalarBar->GetTitleTextProperty(); + aTitleProp->SetFontFamily(GetTitFontType()); + + GetTitleColor(&anRGB[0],&anRGB[1],&anRGB[2]); + aTitleProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + + IsBoldTitle()? aTitleProp->BoldOn() : aTitleProp->BoldOff(); + IsItalicTitle()? aTitleProp->ItalicOn() : aTitleProp->ItalicOff(); + IsShadowTitle()? aTitleProp->ShadowOn() : aTitleProp->ShadowOff(); + + vtkTextProperty* aLabelProp = aScalarBar->GetLabelTextProperty(); + aLabelProp->SetFontFamily(GetLblFontType()); + + GetLabelColor(&anRGB[0],&anRGB[1],&anRGB[2]); + aLabelProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + + IsBoldLabel()? aLabelProp->BoldOn() : aLabelProp->BoldOff(); + IsItalicLabel()? aLabelProp->ItalicOn() : aLabelProp->ItalicOff(); + IsShadowLabel()? aLabelProp->ShadowOn() : aLabelProp->ShadowOff(); + + aScalarBar->Modified(); + } + theActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]); +} + +void +VISU::PointMap3d_i +::UpdateActors() +{ + if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActors - this = "< + (GetSpecificPL(), &VISU_PipeLine::Update)); + + ProcessVoidEvent(new VISU::TInvokeSignalEvent(myUpdateActorsSignal)); +} + +/*! + Builds presentation of table +*/ +VISU::Storable* VISU::PointMap3d_i::Build( int theRestoring ) +{ + + // look for reference SObject with table attribute + SALOMEDS::SObject_var SO = mySObj; + + if ( !SO->_is_nil() ) { + CutLines_i* pCutLines = NULL; + CORBA::Object_var anObj = SObjectToObject(SO); + if(!CORBA::is_nil(anObj)){ + VISU::CutLines_var aCutLines = VISU::CutLines::_narrow(anObj); + if(!aCutLines->_is_nil()) + pCutLines = dynamic_cast(GetServant(aCutLines).in()); + } + SALOMEDS::Study_var aStudy = GetStudyDocument(); + SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + // look for component + if ( !theRestoring ) { + SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() ); + // create SObject and set attributes + QString aComment; + if(pCutLines) + aComment.sprintf("myComment=%s;mySourceId=CutLines",GetComment()); + else{ + aComment.sprintf("myComment=%s;mySourceId=TableAttr",GetComment()); + SALOMEDS::SObject_var aFatherSObject = SO->GetFather(); + if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){ + SALOMEDS::AttributeString_var aCommentAttr = + SALOMEDS::AttributeString::_narrow(anAttr); + CORBA::String_var aValue = aCommentAttr->Value(); + Storable::TRestoringMap aMap; + Storable::StringToMap(aValue.in(),aMap); + bool anIsExist; + QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist); + if(anIsExist){ + if(strcmp(aMethodName.latin1(),"ImportTables") == 0){ + aComment.sprintf("myComment=%s;mySourceId=TableFile",GetComment()); + } + } + } + } + + string anEntry = CreateAttributes( GetStudyDocument(), + SO->GetID(),//SComponent->GetID(), + "ICON_TREE_TABLE", + GetID(), + GetName(), + "", + aComment.latin1(), + pCutLines ); + // create SObject referenced to real table object + mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID( anEntry.c_str() )); + if(pCutLines) { + pCutLines->BuildTableOfReal(mySObj); + } + // mpv (PAL5357): reference attributes are unnecessary now + //SALOMEDS::SObject_var refSO = Builder->NewObject( mySObj ); + //Builder->Addreference( refSO, SO ); + } + + return this; + } + return NULL; +} +/*! + Restores table object from stream +*/ +VISU::Storable* VISU::PointMap3d_i::Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO) +{ + if(MYDEBUG) MESSAGE(GetComment()); + SetName(VISU::Storable::FindValue(theMap,"myName").latin1(), false); + myTitle = VISU::Storable::FindValue(theMap,"myTitle").latin1(); + myOrientation = ( VISU::Table::Orientation )( VISU::Storable::FindValue(theMap,"myOrientation").toInt() ); + mySObj = SALOMEDS::SObject::_duplicate(SO); + + //Create PipeLine + myTablePL = VISU_DeformedGridPL::New(); + myTablePL->SetPolyDataIDMapper(GetTableIDMapper()); + myTablePL->Update(); + + //Restore Other Values + + float aMin = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble(); + float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble(); + SetRange(aMin, aMax); + + UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange", "0").toInt()); + + SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt()); + SetUnitsVisible(VISU::Storable::FindValue(theMap,"myUnitsVisible", "1").toInt()); + SetLabelsFormat(VISU::Storable::FindValue(theMap,"myLabelsFormat", "%-#6.3g")); + SetBarOrientation((VISU::ColoredPrs3dBase::Orientation)VISU::Storable::FindValue(theMap,"myBarOrientation").toInt()); + + SetTitle(VISU::Storable::FindValue(theMap,"myTitle").latin1()); + myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt(); + myPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble(); + myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble(); + myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble(); + myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble(); + myTitleWidth = VISU::Storable::FindValue(theMap,"myTitleWidth").toInt(); + myTitleHeight = VISU::Storable::FindValue(theMap,"myTitleHeight").toInt(); + myLabelWidth = VISU::Storable::FindValue(theMap,"myLabelWidth").toInt(); + myLabelHeight = VISU::Storable::FindValue(theMap,"myLabelHeight").toInt(); + myBarWidth = VISU::Storable::FindValue(theMap,"myBarWidth").toInt(); + myBarHeight = VISU::Storable::FindValue(theMap,"myBarHeight").toInt(); + + myTitFontType = VISU::Storable::FindValue(theMap,"myTitFontType").toInt(); + myIsBoldTitle = VISU::Storable::FindValue(theMap,"myIsBoldTitle").toInt(); + myIsItalicTitle = VISU::Storable::FindValue(theMap,"myIsItalicTitle").toInt(); + myIsShadowTitle = VISU::Storable::FindValue(theMap,"myIsShadowTitle").toInt(); + myTitleColor[0] = VISU::Storable::FindValue(theMap,"myTitleColor[0]").toFloat(); + myTitleColor[1] = VISU::Storable::FindValue(theMap,"myTitleColor[1]").toFloat(); + myTitleColor[2] = VISU::Storable::FindValue(theMap,"myTitleColor[2]").toFloat(); + + myLblFontType = VISU::Storable::FindValue(theMap,"myLblFontType").toInt(); + myIsBoldLabel = VISU::Storable::FindValue(theMap,"myIsBoldLabel").toInt(); + myIsItalicLabel = VISU::Storable::FindValue(theMap,"myIsItalicLabel").toInt(); + myIsShadowLabel = VISU::Storable::FindValue(theMap,"myIsShadowLabel").toInt(); + myLabelColor[0] = VISU::Storable::FindValue(theMap,"myLabelColor[0]").toFloat(); + myLabelColor[1] = VISU::Storable::FindValue(theMap,"myLabelColor[1]").toFloat(); + myLabelColor[2] = VISU::Storable::FindValue(theMap,"myLabelColor[2]").toFloat(); + + myParamsTime.Modified(); + return Build( true ); +} +/*! + Flushes table data into stream +*/ +void VISU::PointMap3d_i::ToStream( std::ostringstream& theStr ) +{ + Storable::DataToStream( theStr, "myName", GetName().c_str() ); + Storable::DataToStream( theStr, "myTitle", myTitle.c_str() ); + Storable::DataToStream( theStr, "myOrientation", myOrientation ); + + Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() ); + Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() ); + Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() ); + + Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) ); + Storable::DataToStream( theStr, "myBarOrientation", myBarOrientation ); + + Storable::DataToStream( theStr, "myTitle", myTitle.c_str() ); + Storable::DataToStream( theStr, "myUnitsVisible", myIsUnits ); + Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels ); + Storable::DataToStream( theStr, "myLabelsFormat", myLabelsFormat.c_str() ); + Storable::DataToStream( theStr, "myPosition[0]", myPosition[0] ); + Storable::DataToStream( theStr, "myPosition[1]", myPosition[1] ); + Storable::DataToStream( theStr, "myWidth", myWidth ); + Storable::DataToStream( theStr, "myHeight", myHeight ); + Storable::DataToStream( theStr, "myTitleWidth", myTitleWidth ); + Storable::DataToStream( theStr, "myTitleHeight", myTitleHeight ); + Storable::DataToStream( theStr, "myLabelWidth", myLabelWidth ); + Storable::DataToStream( theStr, "myLabelHeight", myLabelHeight ); + Storable::DataToStream( theStr, "myBarWidth", myBarWidth ); + Storable::DataToStream( theStr, "myBarHeight", myBarHeight ); + + Storable::DataToStream( theStr, "myTitFontType", myTitFontType ); + Storable::DataToStream( theStr, "myIsBoldTitle", myIsBoldTitle ); + Storable::DataToStream( theStr, "myIsItalicTitle", myIsItalicTitle ); + Storable::DataToStream( theStr, "myIsShadowTitle", myIsShadowTitle ); + Storable::DataToStream( theStr, "myTitleColor[0]", myTitleColor[0] ); + Storable::DataToStream( theStr, "myTitleColor[1]", myTitleColor[1] ); + Storable::DataToStream( theStr, "myTitleColor[2]", myTitleColor[2] ); + + Storable::DataToStream( theStr, "myLblFontType", myLblFontType ); + Storable::DataToStream( theStr, "myIsBoldLabel", myIsBoldLabel ); + Storable::DataToStream( theStr, "myIsItalicLabel", myIsItalicLabel ); + Storable::DataToStream( theStr, "myIsShadowLabel", myIsShadowLabel ); + Storable::DataToStream( theStr, "myLabelColor[0]", myLabelColor[0] ); + Storable::DataToStream( theStr, "myLabelColor[1]", myLabelColor[1] ); + Storable::DataToStream( theStr, "myLabelColor[2]", myLabelColor[2] ); +} +/*! + Called from engine to restore table from the file +*/ +VISU::Storable* VISU::PointMap3d_i::StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile) +{ + SALOMEDS::Study_var aStudy = theSObject->GetStudy(); + VISU::PointMap3d_i* pResent = new VISU::PointMap3d_i( aStudy, "" ); + return pResent->Restore( theMap, theSObject); +} +/*! + Gets title for the original table object +*/ +QString VISU::PointMap3d_i::GetTableTitle() +{ + SALOMEDS::SObject_var SO = mySObj; + SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeTableOfInteger_var anInt; + SALOMEDS::AttributeTableOfReal_var aReal; + if ( !SO->_is_nil() ) { + if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) { + anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); + CORBA::String_var aString = anInt->GetTitle(); + return aString.in(); + } + else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) { + aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); + CORBA::String_var aString = aReal->GetTitle(); + return aString.in(); + } + } + return ""; +} + +//--------------------------------------------------------------- +void VISU::PointMap3d_i::RemoveFromStudy() +{ + struct TRemoveFromStudy: public SALOME_Event + { + VISU::PointMap3d_i* myRemovable; + TRemoveFromStudy(VISU::PointMap3d_i* theRemovable): + myRemovable(theRemovable) + {} + + virtual + void + Execute() + { + VISU::RemoveFromStudy(myRemovable->GetSObject(),false); + } + }; + + // Remove the table with all curves + ProcessVoidEvent(new TRemoveFromStudy(this)); +} + +//---------------------------------------------------------------- +void VISU::PointMap3d_i::SetOffset(CORBA::Float theDx, CORBA::Float theDy, CORBA::Float theDz) +{ + myOffset[0] = theDx; + myOffset[1] = theDy; + myOffset[2] = theDz; + myParamsTime.Modified(); +} + +void VISU::PointMap3d_i::GetOffset(CORBA::Float& theDx, CORBA::Float& theDy, CORBA::Float& theDz) +{ + theDx = myOffset[0]; + theDy = myOffset[1]; + theDz = myOffset[2]; +} + +CORBA::Float VISU::PointMap3d_i::GetMemorySize() +{ + CORBA::Float aSize = GetSpecificPL()->GetMemorySize(); + + int anEnd = myActorCollection->GetNumberOfItems(); + for(int anId = 0; anId < anEnd; anId++) + if(vtkObject* anObject = myActorCollection->GetItemAsObject(anId)) + if(VISU_Actor* anActor = dynamic_cast(anObject)){ + aSize += anActor->GetMemorySize(); + //cout<<"Prs3d_i::GetMemorySize - "< +#include + +#include + +namespace VISU +{ + + struct TActorFactory; + + //============================================================================== + class VISU_I_EXPORT PointMap3d_i : public virtual POA_VISU::PointMap3d, + public virtual SALOME::GenericObj_i, + public virtual TActorFactory, + public virtual Table_i + { + static int myNbPresent; + PointMap3d_i( const PointMap3d_i& ); + public: + PointMap3d_i( SALOMEDS::Study_ptr theStudy, const char* theObjectEntry); + + virtual ~PointMap3d_i(); + virtual VISU::VISUType GetType() { return VISU::TPOINTMAP3D;}; + + virtual void SetTitle( const char* theTitle ); + virtual char* GetTitle(); + + virtual void RemoveFromStudy(); + virtual void UpdateActor(VISU_ActorBase* thePointMap3dActor); + virtual void UpdateActors(); + + //----------- override Prs3d methods ----------------------------- + + //! Move the 3D presentation according to the given offset parameters + virtual void SetOffset(CORBA::Float theDx, CORBA::Float theDy, CORBA::Float theDz); + + //! Gets offset parameters for the 3D presentation + virtual void GetOffset(CORBA::Float& theDx, CORBA::Float& theDy, CORBA::Float& theDz); + + //! Gets memory size actually used by the presentation (Mb). + virtual CORBA::Float GetMemorySize(); + + //----------- override ColoredPrs3dBase methods ------------------ + + virtual CORBA::Double GetMin(); + virtual CORBA::Double GetMax(); + virtual void SetRange(CORBA::Double theMin, CORBA::Double theMax); + + virtual CORBA::Double GetSourceMin(); + virtual CORBA::Double GetSourceMax(); + virtual void SetSourceRange(); + + virtual CORBA::Boolean IsRangeFixed(); + + virtual void SetPosition(CORBA::Double X, CORBA::Double Y); + virtual CORBA::Double GetPosX(); + virtual CORBA::Double GetPosY(); + + virtual void SetSize(CORBA::Double theWidth, CORBA::Double theHeight); + + virtual void SetRatios(CORBA::Long theTitleWidth, CORBA::Long theTitleHeight, + CORBA::Long theLabelWidth, CORBA::Long theLabelHeight, + CORBA::Long theBarWidth, CORBA::Long theBarHeight); + + virtual CORBA::Double GetWidth(); + virtual CORBA::Double GetHeight(); + + virtual void SetNbColors(CORBA::Long theNbColors); + virtual CORBA::Long GetNbColors(); + + virtual void SetLabels(CORBA::Long theNbLabels); + virtual CORBA::Long GetLabels(); + + virtual void SetLabelsFormat(const char* theFormat); + virtual char* GetLabelsFormat(); + + virtual void SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theOrientation); + virtual VISU::ColoredPrs3dBase::Orientation GetBarOrientation(); + + void UseFixedRange(bool theUseFixedRange); + + // ScaledMap Methods + + virtual VISU::Scaling GetScaling(); + virtual void SetScaling(VISU::Scaling theScaling); + + // Plot3dBase methods + + void SetScaleFactor (CORBA::Double theScaleFactor); + double GetScaleFactor(); + + void SetContourPrs (CORBA::Boolean theIsContourPrs ); + bool GetIsContourPrs(); + + void SetNbOfContours (CORBA::Long); + long GetNbOfContours(); + + VISU_DeformedGridPL* GetSpecificPL() const { return myTablePL; } + + // TActorFactory Methods + + //! Gets know whether the factory instance can be used for actor management or not + virtual bool GetActiveState(); + + virtual void SetActiveState(bool theState); + + //! Return modified time of the factory + virtual unsigned long int GetMTime(); + + //! To unregister the actor + virtual void RemoveActor(VISU_ActorBase* theActor); + virtual void RemoveActors(); + + //------ Text Properties & Label Properties ------------------------ + + virtual bool IsBoldTitle(); + virtual void SetBoldTitle(bool isBold); + virtual bool IsItalicTitle(); + virtual void SetItalicTitle(bool isItalic); + virtual bool IsShadowTitle(); + virtual void SetShadowTitle(bool isShadow); + virtual int GetTitFontType(); + virtual void SetTitFontType(int theType); + virtual void GetTitleColor(vtkFloatingPointType* theR, + vtkFloatingPointType* theG, + vtkFloatingPointType* theB); + virtual void SetTitleColor(vtkFloatingPointType theR, + vtkFloatingPointType theG, + vtkFloatingPointType theB); + + virtual bool IsBoldLabel(); + virtual void SetBoldLabel(bool isBold); + virtual bool IsItalicLabel(); + virtual void SetItalicLabel(bool isItalic); + virtual bool IsShadowLabel(); + virtual void SetShadowLabel(bool isShadow); + virtual int GetLblFontType(); + virtual void SetLblFontType(int theType); + virtual void GetLabelColor(vtkFloatingPointType* theR, + vtkFloatingPointType* theG, + vtkFloatingPointType* theB); + virtual void SetLabelColor(vtkFloatingPointType theR, + vtkFloatingPointType theG, + vtkFloatingPointType theB); + + //------------------------------------------------------------------- + virtual CORBA::Long GetTitleWidth(); + virtual CORBA::Long GetTitleHeight(); + virtual CORBA::Long GetLabelWidth(); + virtual CORBA::Long GetLabelHeight(); + virtual CORBA::Long GetBarWidth(); + virtual CORBA::Long GetBarHeight(); + + virtual void SetUnitsVisible(CORBA::Boolean isVisible); + virtual CORBA::Boolean IsUnitsVisible(); + + //------------------------------------------------------------------- + + protected: + Storable* Build(int theRestoring); + + VISU::Table::Orientation myOrientation; + VISU::ColoredPrs3dBase::Orientation myBarOrientation; + std::string myTitle; + std::string myScalarBarTitle; + bool myIsUnits; + SALOMEDS::SObject_var mySObj; + int myNumberOfLabels; + std::string myLabelsFormat; + vtkFloatingPointType myPosition[2], + myWidth, myHeight, + myTitleWidth, myTitleHeight, + myLabelWidth, myLabelHeight, + myBarWidth, myBarHeight; + bool myIsFixedRange; + CORBA::Float myOffset[3]; + bool myIsActiveState; + vtkTimeStamp myParamsTime; + + + //Font management + bool myIsBoldTitle; + bool myIsItalicTitle; + bool myIsShadowTitle; + int myTitFontType; + vtkFloatingPointType myTitleColor[3]; + + bool myIsBoldLabel; + bool myIsItalicLabel; + bool myIsShadowLabel; + int myLblFontType; + vtkFloatingPointType myLabelColor[3]; + + boost::signal0 myUpdateActorsSignal; + boost::signal0 myRemoveActorsFromRendererSignal; + vtkSmartPointer myActorCollection; + + public: + // virtual Storable* Create( const VISU::PTableIDMapper& theTableIDMapper ); + virtual Storable* Create(); + VISU_PointMap3dActor* CreateActor(); + VISU::PTableIDMapper GetTableIDMapper(); + + SALOMEDS::SObject_var GetSObject() const; + VISU_DeformedGridPL* myTablePL; + + virtual Storable* Restore( const Storable::TRestoringMap& theMap, + SALOMEDS::SObject_ptr SO); + + static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile); + + virtual void ToStream( std::ostringstream& theStr ); + static const std::string myComment; + virtual const char* GetComment() const; + virtual QString GenerateName(); + virtual QString GetTableTitle(); + + virtual std::string GetObjectEntry(); + }; +} + +#endif diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 466e104e..521cd57a 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -515,7 +515,7 @@ VISU::Prs3d_i //---------------------------------------------------------------------------- void VISU::Prs3d_i -::RemoveActor(VISU_Actor* theActor) +::RemoveActor(VISU_ActorBase* theActor) { if(MYDEBUG) MESSAGE("Prs3d_i::RemoveActor - this = "<GetReferenceCount()); myActorCollection->RemoveItem(theActor); @@ -534,11 +534,13 @@ VISU::Prs3d_i //---------------------------------------------------------------------------- void VISU::Prs3d_i -::UpdateActor(VISU_Actor* theActor) +::UpdateActor(VISU_ActorBase* theActor) { - if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor - this = "< -#include -#include - -#include -#include -#include -#include - -using namespace std; +#include "VISU_TableReader.hxx" +#include "VISU_ConvertorUtils.hxx" #ifdef _DEBUG_ static int MYDEBUG = 0; @@ -1178,207 +1170,14 @@ SALOMEDS::SObject_var VISU::Container_i::GetSObject() return mySObj; } -//------------------------------------------------------------- -// Implementation of reading from file -//------------------------------------------------------------- -typedef string TValue; -typedef vector TValues; - -struct TRow{ - string myTitle; - string myUnit; - TValues myValues; -}; - -typedef vector TRows; - -struct TTable2D { - string myTitle; - vector myColumnUnits; - vector myColumnTitles; - TRows myRows; - int Check(){ - if(myRows.empty()) return 0; - int iEnd = myRows[0].myValues.size(); - if(iEnd == 0) return 0; - if(myColumnTitles.size() != iEnd) myColumnTitles.resize(iEnd); - if(myColumnUnits.size() != iEnd) myColumnUnits.resize(iEnd); - int jEnd = myRows.size(); - for(int j = 0; j < jEnd; j++) - if(myRows[j].myValues.size() != iEnd) - return 0; - return 1; - } - void getColumns(TTable2D& theTable2D) const { - TRows& aRows = theTable2D.myRows; - aRows.clear(); - if(myRows.empty()) return; - int jEnd = myRows.size(); - //Define Titles & Units - theTable2D.myColumnTitles.resize(jEnd); - theTable2D.myColumnUnits.resize(jEnd); - for(int j = 0; j < jEnd; j++){ - theTable2D.myColumnTitles[j] = myRows[j].myTitle; - theTable2D.myColumnUnits[j] = myRows[j].myUnit; - } - //Define Rows - int iEnd = myRows[0].myValues.size(); - for(int i = 0; i < iEnd; i++){ - TRow aNewRow; - aNewRow.myTitle = myColumnTitles[i]; - aNewRow.myUnit = myColumnUnits[i]; - aNewRow.myValues.resize(jEnd); - for(int j = 0; j < jEnd; j++){ - aNewRow.myValues[j] = myRows[j].myValues[i]; - } - aRows.push_back(aNewRow); - } - } -}; - -typedef vector TTableCont; - -int getLine(ifstream& theStmIn, QString& theString){ - char tmp; - ostrstream aStrOut; - while(theStmIn.get(tmp)){ - aStrOut<= 0 ) { - data = aTmp.left( index ).stripWhiteSpace(); - cmt = aTmp.mid( index+1 ).stripWhiteSpace(); - } - // if comment is not empty, try to get keyword from it (separated by ':' symbol) - if ( !cmt.isEmpty() ) { - int index1 = cmt.find( ":" ); - if ( index1 >= 0 ) { - QString tmpstr = cmt.left( index1 ).stripWhiteSpace(); - if ( tmpstr == QString( "TITLE" ) || - tmpstr == QString( "COLUMN_TITLES" ) || - tmpstr == QString( "COLUMN_UNITS" ) || - tmpstr == QString( "COMMENT" ) ) { - keyword = tmpstr; - cmt = cmt.mid( index1+1 ).stripWhiteSpace(); - } - } - } - // if data is empty, process only comment - if ( data.isEmpty() ) { - // if keyword is found, try to process it - // elsewise it is a simple comment, just ignore it - if ( !keyword.isEmpty() ) { - if ( keyword == QString( "TITLE" ) ) { - QString title = cmt; - if ( aTable2D.myTitle != "" ) - title = QString( aTable2D.myTitle.c_str() ) + QString( " " ) + title; - if(MYDEBUG) cout << "...Table TITLE is: " << title.latin1() << endl; - aTable2D.myTitle = title.latin1(); - } - else if ( keyword == QString( "COLUMN_TITLES" ) ) { - // comment may contain column headers - QStringList aStrList = QStringList::split( "|", cmt ); - if(MYDEBUG) cout << "...Column TITLES are: "; - for ( int i = 0; i < aStrList.count(); i++ ) { - QString tmpstr = aStrList[ i ].stripWhiteSpace(); - if(MYDEBUG) cout << tmpstr.latin1() << " "; - aTable2D.myColumnTitles.push_back( tmpstr.latin1() ); - } - if(MYDEBUG) cout << endl; - } - else if ( keyword == QString( "COLUMN_UNITS" ) ) { - // comment may contain column units - QStringList aStrList = QStringList::split( " ", cmt ); - if(MYDEBUG) cout << "...Column UNITS are: "; - for ( int i = 0; i < aStrList.count(); i++ ) { - QString tmpstr = aStrList[ i ].stripWhiteSpace(); - if(MYDEBUG) cout << tmpstr.latin1() << " "; - aTable2D.myColumnUnits.push_back( tmpstr.latin1() ); - } - if(MYDEBUG) cout << endl; - } - else if ( keyword == QString( "COMMENT" ) ) { - // keyword 'COMMENT' processing can be here - // currently it is ignored - if(MYDEBUG) cout << "...COMMENT: " << cmt.latin1() << endl; - } - } - else { - if(MYDEBUG) cout << "...comment: " << cmt.latin1() << endl; - // simple comment processing can be here - // currently it is ignored - } - } - // if data is not empty, try to process it - else { - TRow aRow; - if(MYDEBUG) cout << "...New row is found: " << endl; - if ( !cmt.isEmpty() ) { - aRow.myTitle = cmt.latin1(); - if(MYDEBUG) cout << "......ROW TITLE is: " << cmt.latin1() << endl; - } - QString datar1 = data.replace(QRegExp("\t"), " "); - QStringList aValList = QStringList::split( " ", datar1 ); - for ( int i = 0; i < aValList.count(); i++ ) { - if ( aValList[i].stripWhiteSpace() != "" ) { - TValue aVal = aValList[i].stripWhiteSpace().latin1(); - aRow.myValues.push_back( aVal ); - } - } - if( aRow.myValues.size() > 0 ) - aTable2D.myRows.push_back( aRow ); - // ************** OLD CODE ****************** - /* - TValue aVal; - istrstream aStream( data ); - aStream.precision( STRPRECISION ); - while( aStream >> aVal ) { - aRow.myValues.push_back( aVal ); - } - if( aRow.myValues.size() > 0 ) - aTable2D.myRows.push_back( aRow ); - */ - // ************** OLD CODE ****************** - } - getLine( aStmIn, aTmp ); - } - if( aTable2D.Check() ) { - if(MYDEBUG) cout << "aTable2D is checked OK " << aTable2D.myTitle << endl; - theTableCont.push_back( aTable2D ); - } - } - while( !aStmIn.eof() ); - aStmIn.close(); - if(MYDEBUG) cout << "After close" << endl; -} +SALOMEDS::SObject_var +VISU::ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy) +{ + TTableContainer aContainer; + ImportTables( theFileName, aContainer ); + if ( aContainer.empty() ) + return SALOMEDS::SObject::_nil(); -SALOMEDS::SObject_var VISU::ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy){ - TTableCont aTableCont; - ImportTables(theFileName,aTableCont); - if(aTableCont.empty()) return SALOMEDS::SObject::_nil(); SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); SALOMEDS::SComponent_var theSComponent = VISU::FindOrCreateVisuComponent(theStudy); SALOMEDS::SObject_var aFileObject = aStudyBuilder->NewObject(theSComponent); @@ -1393,19 +1192,21 @@ SALOMEDS::SObject_var VISU::ImportTables(const char* theFileName, SALOMEDS::Stud aString.sprintf("myComment=ImportTables;myFileName=%s", aFileInfo.absFilePath().latin1()); aComment->SetValue(aString.latin1()); - for(int i = 0, iEnd = aTableCont.size(); i < iEnd; i++){ - const TTable2D& aTable2D = aTableCont[i]; + for(int i = 0, iEnd = aContainer.size(); i < iEnd; i++){ + PTableIDMapper aTableIDMapper = aContainer[i]; + const TTable2D& aTable2D = *aTableIDMapper; SALOMEDS::SObject_var aRealObject = aStudyBuilder->NewObject(aFileObject); anAttr = aStudyBuilder->FindOrCreateAttribute(aRealObject, "AttributeName"); aName = SALOMEDS::AttributeName::_narrow(anAttr); if(MYDEBUG) cout<<"aTable2D.myTitle = "<SetValue(aTable2D.myTitle.c_str()); - else{ + } else { QString aNewName; aNewName.sprintf("Table:%d",i); aName->SetValue(aNewName.latin1()); } + anAttr = aStudyBuilder->FindOrCreateAttribute(aRealObject, "AttributeTableOfReal"); SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr); aTableOfReal->SetTitle(aTable2D.myTitle.c_str()); diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index 439bb3a4..873d1ed1 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -47,6 +47,8 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include "VISU_ActorFactory.h" + #include "SALOME_Event.hxx" #include "SALOME_ListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx" @@ -480,6 +482,35 @@ namespace VISU { } + //---------------------------------------------------------------------------- + struct TIsSameActor + { + VISU::TActorFactory* myActor; + + TIsSameActor(VISU::TActorFactory* theActor): + myActor(theActor) + {} + + bool + operator()(VISU_ActorBase* theActor) + { + return theActor->GetFactory() == myActor; + } + }; + + //---------------------------------------------------------------------------- + VISU_ActorBase* + FindActorBase(SVTK_ViewWindow* theViewWindow, VISU::TActorFactory* theActor) + { + if(!theActor) + return NULL; + + vtkRenderer* aRenderer = theViewWindow->getRenderer(); + vtkActorCollection* anActors = aRenderer->GetActors(); + return SVTK::Find(anActors, VISU::TIsSameActor(theActor)); + } + + //---------------------------------------------------------------------------- struct TDeleteActorsEvent: public SALOME_Event { diff --git a/src/VISU_I/VISU_ViewManager_i.hh b/src/VISU_I/VISU_ViewManager_i.hh index 607e750e..b612b8a8 100644 --- a/src/VISU_I/VISU_ViewManager_i.hh +++ b/src/VISU_I/VISU_ViewManager_i.hh @@ -32,6 +32,7 @@ class SalomeApp_Application; class VISU_Actor; +class VISU_ActorBase; class SUIT_ViewWindow; @@ -45,6 +46,7 @@ class vtkCamera; namespace VISU { class Prs3d_i; class Curve_i; + class TActorFactory; class VISU_I_EXPORT ViewManager_i : public virtual POA_VISU::ViewManager, public virtual Base_i @@ -74,6 +76,7 @@ namespace VISU { void UpdatePlot2d (Plot2d_ViewFrame *theView, int theDisplaying, Curve_i* theCurve); VISU_I_EXPORT VISU_Actor* FindActor(SVTK_ViewWindow* theViewWindow, VISU::Prs3d_i* thePrs3d); + VISU_I_EXPORT VISU_ActorBase* FindActorBase(SVTK_ViewWindow* theViewWindow, VISU::TActorFactory* theActor); void DeleteActors (VISU::Prs3d_i* thePrs); void DeleteActors (VISU::Curve_i* thePrs); diff --git a/src/VISU_I/VISU_View_i.cc b/src/VISU_I/VISU_View_i.cc index c25f276c..065953e8 100644 --- a/src/VISU_I/VISU_View_i.cc +++ b/src/VISU_I/VISU_View_i.cc @@ -29,6 +29,7 @@ #include "VISU_Gen_i.hh" #include "VISU_Prs3d_i.hh" #include "VISU_Table_i.hh" +#include "VISU_PointMap3d_i.hh" #include "VISU_ScalarMap_i.hh" #include "VISU_ViewManager_i.hh" @@ -36,6 +37,8 @@ #include "VISU_Actor.h" #include "VISU_ScalarMapAct.h" +#include "VISU_PointMap3dActor.h" +#include "VISU_DeformedGridPL.hxx" #include "SALOME_Event.hxx" @@ -62,6 +65,7 @@ #include #include +#include using namespace std; @@ -1625,7 +1629,7 @@ namespace VISU { vtkActorCollection* anActors = aRenderer->GetActors(); anActors->InitTraversal(); while (vtkActor *anAct = anActors->GetNextActor()) { - if (VISU_Actor* anActor = dynamic_cast(anAct)) { + if (VISU_ActorBase* anActor = dynamic_cast(anAct)) { if (anActor->GetVisibility()) anActor->UpdateFromFactory(); } @@ -1926,6 +1930,27 @@ namespace VISU { } }; + class TDisplayTableEvent: public SALOME_Event + { + SUIT_ViewWindow* myVW; + PointMap3d_i* myTable; + int myDisplaying; + public: + TDisplayTableEvent( SUIT_ViewWindow* theView, + PointMap3d_i* theTable, + int theDisplaying ) : + myVW (theView), + myTable (theTable), + myDisplaying (theDisplaying) + {} + virtual void Execute() { + SVTK_ViewWindow* aViewWindow = dynamic_cast(myVW); + VISU_PointMap3dActor* anActor = myTable->CreateActor(); + myTable->UpdateActor( anActor ); + aViewWindow->AddActor( anActor ); + } + }; + void View3D_i::EraseAll() { if(MYDEBUG) MESSAGE("View3D_i::EraseAll"); @@ -1957,9 +1982,14 @@ namespace VISU { if(MYDEBUG) MESSAGE("View3D_i::Display"); SUIT_ViewWindow* aVW = GetViewWindow(); CORBA::Object_ptr anObj = thePrsObj; - Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in()); + Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in()); if (aVW && aPrs) ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplay)); + else if (aVW && !aPrs) { + PointMap3d_i* aTable = dynamic_cast(VISU::GetServant(anObj).in()); + if (aTable) + ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplay)); + } } void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj) @@ -1970,6 +2000,11 @@ namespace VISU { Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in()); if (aVW && aPrs) ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplayOnly)); + else if (aVW && !aPrs) { + PointMap3d_i* aTable = dynamic_cast(VISU::GetServant(anObj).in()); + if (aTable) + ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplayOnly)); + } } void View3D_i::FitAll() diff --git a/src/VVTK/VVTK_ViewModel.cxx b/src/VVTK/VVTK_ViewModel.cxx index b1b3ec4e..7faa3743 100644 --- a/src/VVTK/VVTK_ViewModel.cxx +++ b/src/VVTK/VVTK_ViewModel.cxx @@ -18,12 +18,12 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "VVTK_ViewModel.h" - +#include "VISU_ActorFactory.h" #include "VVTK_ViewWindow.h" #include "VTKViewer_Algorithm.h" #include "SVTK_Functor.h" -#include "VISU_Actor.h" +#include "VISU_ActorBase.h" #include "SVTK_View.h" #include "SVTK_Prs.h" @@ -67,7 +67,7 @@ VVTK_Viewer return; if(vtkActorCollection* aCollection = aPrs->GetObjects()){ aCollection->InitTraversal(); - while(VISU_Actor* anActor = dynamic_cast(aCollection->GetNextActor())){ + while(VISU_ActorBase* anActor = dynamic_cast(aCollection->GetNextActor())){ if(!anActor->GetFactory()->GetActiveState()) continue; QPtrVector aViews = myViewManager->getViews(); -- 2.39.2