From 7f210aeaaca5668fad485887e09acf20f523596e Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 24 Jul 2008 11:09:41 +0000 Subject: [PATCH] Merge from BR_Dev_For_4_0 branch (from tag mergeto_BR_QT4_Dev_07Jul08) --- idl/VISU_Gen.idl | 213 +++-- src/CONVERTOR/Makefile.am | 7 +- src/CONVERTOR/VISUConvertor.cxx | 45 +- src/CONVERTOR/VISU_Convertor_impl.cxx | 58 +- src/CONVERTOR/VISU_IDMapper.cxx | 82 +- src/CONVERTOR/VISU_IDMapper.hxx | 50 +- src/CONVERTOR/VISU_MedConvertor.cxx | 126 +-- src/CONVERTOR/VISU_Structures_impl.cxx | 44 +- src/CONVERTOR/VISU_Structures_impl.hxx | 20 + src/CONVERTOR/VISU_TableReader.cxx | 401 ++++++++ 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 | 141 +++ src/OBJECT/VISU_PointMap3dActor.h | 95 ++ src/PIPELINE/Makefile.am | 11 +- 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 | 8 +- src/VISUGUI/VISU_msg_en.ts | 152 ++++ src/VISUGUI/VisuGUI.cxx | 87 +- src/VISUGUI/VisuGUI.h | 3 + src/VISUGUI/VisuGUI_ActionsDef.h | 3 + src/VISUGUI/VisuGUI_ClippingDlg.cxx | 30 +- src/VISUGUI/VisuGUI_Displayer.cxx | 10 +- src/VISUGUI/VisuGUI_Displayer.h | 1 + src/VISUGUI/VisuGUI_FileInfoDlg.cxx | 78 ++ src/VISUGUI/VisuGUI_FileInfoDlg.h | 41 + src/VISUGUI/VisuGUI_GaussPointsDlg.cxx | 2 +- src/VISUGUI/VisuGUI_Prs3dDlg.cxx | 2 +- src/VISUGUI/VisuGUI_Selection.cxx | 51 +- src/VISUGUI/VisuGUI_Table3dDlg.cxx | 748 +++++++++++++++ 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_CorbaMedConvertor.cxx | 25 +- 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 | 1165 ++++++++++++++++++++++++ src/VISU_I/VISU_PointMap3d_i.hh | 261 ++++++ src/VISU_I/VISU_Prs3d_i.cc | 12 +- src/VISU_I/VISU_Prs3d_i.hh | 5 +- src/VISU_I/VISU_Result_i.cc | 81 +- src/VISU_I/VISU_Result_i.hh | 4 + src/VISU_I/VISU_ScalarMap_i.cc | 2 +- src/VISU_I/VISU_ScalarMap_i.hh | 2 +- src/VISU_I/VISU_Table_i.cc | 228 +---- src/VISU_I/VISU_ViewManager_i.cc | 30 + src/VISU_I/VISU_ViewManager_i.hh | 3 + src/VISU_I/VISU_View_i.cc | 39 +- src/VVTK/VVTK_ViewModel.cxx | 6 +- 78 files changed, 5072 insertions(+), 1189 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_FileInfoDlg.cxx create mode 100644 src/VISUGUI/VisuGUI_FileInfoDlg.h 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 d3fb0c9e..d1b5c73e 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 { }; //------------------------------------------------------- @@ -1811,6 +1831,9 @@ module VISU { /*! Gets current resolution of multi resolution structure for the given mesh and part names */ void SetResolution(in EntityName theMeshName, in EntityName thePartName, in Resolution theResolution); + + /*! Gets information about imported MED file */ + SALOME_MED::MedFileInfo GetMEDFileInfo(); }; //------------------------------------------------------- diff --git a/src/CONVERTOR/Makefile.am b/src/CONVERTOR/Makefile.am index 411873b0..1f377fb6 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 \ @@ -84,6 +86,7 @@ libVisuConvertor_la_CPPFLAGS= \ libVisuConvertor_la_LDFLAGS= \ + $(MED2_LIBS) \ $(QT_LIBS) \ $(CAS_KERNEL) \ $(CAS_MATH) \ diff --git a/src/CONVERTOR/VISUConvertor.cxx b/src/CONVERTOR/VISUConvertor.cxx index 63a5f481..db268df7 100644 --- a/src/CONVERTOR/VISUConvertor.cxx +++ b/src/CONVERTOR/VISUConvertor.cxx @@ -27,12 +27,14 @@ #include "VISU_Convertor.hxx" #include "VISU_ConvertorUtils.hxx" +#include "VISU_Convertor_impl.hxx" +#include "VISU_TableReader.hxx" + #include #include -#include #include -#include "VISU_Convertor_impl.hxx" +#include #include #include @@ -53,7 +55,7 @@ static int MYDEBUG = 0; typedef vtkUnstructuredGrid TOutput; -void parseFile(const char* theFileName) +void ParseMEDFile(const char* theFileName) { #ifndef _DEXCEPT_ try{ @@ -180,20 +182,33 @@ 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.absoluteFilePath()); - QStringList aStringList = aDir.entryList(QStringList("*.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.absoluteFilePath() ); + QStringList wildcards; wildcards << "*.med"; + QStringList aStringList = aDir.entryList( wildcards, QDir::Files ); int jEnd = aStringList.count(); - for(int j = 0; j < jEnd; j++){ - parseFile((const char*)aDir.filePath(aStringList[j]).toLatin1()); + for ( int j = 0; j < jEnd; j++ ) { + ParseMEDFile( aDir.filePath( aStringList[j] ).toLatin1().data() ); } - }else{ - parseFile(argv[1]); + } else { + QString anExtension = aFileInfo.suffix(); + if ( anExtension == "med" ) + ParseMEDFile( argv[1] ); + else if ( anExtension == "xls" || anExtension == "txt" ) + ParseXLSFile( argv[1] ); } } } diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 024ccf7c..0e8a49a1 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -663,17 +663,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()); @@ -685,14 +679,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; @@ -744,23 +732,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){ @@ -837,13 +818,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){ @@ -991,12 +968,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 eaedc649..df36b0c9 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -24,7 +24,6 @@ // Author : Alexey PETROV // Module : VISU - #include "VISU_MedConvertor.hxx" #include "VISU_ConvertorUtils.hxx" @@ -403,7 +402,9 @@ namespace aGauss->myGaussInfo = aGaussInfo; aGauss->myName = aGaussInfo->GetName(); aGauss->myNbPoints = aGaussInfo->GetNbGauss(); - } + } else if ( aTimeStampInfo.GetNbGauss(aMGeom) > 1 ) + EXCEPTION( std::runtime_error, "aGaussIter == aGeom2Gauss.end()" + " && aTimeStampInfo.GetNbGauss(aMGeom) > 1 !!!" ); aGaussSubMesh->myNbCells = aNbCells*aGauss->myNbPoints; aGaussSubMesh->myCellsSize = aGaussSubMesh->myNbCells*2; @@ -478,36 +479,6 @@ namespace } } - - //--------------------------------------------------------------- - void - InitGaussProfile(const MED::PWrapper& theMEDWrapper, - const MED::PMeshInfo& theMeshInfo, - MED::PTimeStampValueBase& theTimeStampValue, - VISU::TMEDMeshOnEntity& theMeshOnEntity, - MED::EEntiteMaillage theMEntity, - const MED::TGeom2Size& theGeom2Size, - VISU::TMEDValForTime& theValForTime) - { - VISU::TTimerLog aTimerLog(MYDEBUG,"InitGaussProfile"); - INITMSG(MYDEBUG,"InitGaussProfile"<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; @@ -1465,10 +1430,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 @@ -2876,13 +2840,13 @@ LoadValForTime(const MED::PWrapper& theMed, aMKey2Profile, aKey2Gauss); - InitGaussProfile(theMed, - aMeshInfo, - aTimeStampValue, - theMeshOnEntity, - aMEntity, - aGeom2Size, - theValForTime); + InitProfile(theMed, + aMeshInfo, + aTimeStampValue, + theMeshOnEntity, + aMEntity, + aGeom2Size, + theValForTime); LoadProfile(theMed, theMesh, @@ -2890,12 +2854,18 @@ LoadValForTime(const MED::PWrapper& theMed, theValForTime, theMeshOnEntity); - if(theIsGauss) + if(theIsGauss) { + InitGaussMesh(aTimeStampValue, + theMeshOnEntity, + aGeom2Size, + theValForTime); + LoadGaussMesh(theMed, theMesh, aTimeStampValue, theValForTime, theMeshOnEntity); + } VISU::PMEDProfile aProfile = theValForTime->myProfile; VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; 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 fe6a7cc5..fbcabfef 100644 --- a/src/CONVERTOR/VISU_Structures_impl.hxx +++ b/src/CONVERTOR/VISU_Structures_impl.hxx @@ -614,6 +614,11 @@ namespace VISU { TSubMeshImpl(); + //! Reimplements the TStructured::CopyStructure + virtual + void + CopyStructure( PStructured theStructured ); + //! To implement the TIDMapper::GetElemObjID virtual vtkIdType @@ -645,6 +650,11 @@ namespace VISU { TMeshOnEntityImpl(); + //! Reimplements the TStructured::CopyStructure + virtual + void + CopyStructure( PStructured theStructured ); + //! Reimplement the TIDMapper::GetNodeVTKID virtual vtkIdType @@ -700,6 +710,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 ; @@ -745,6 +760,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..33676e26 --- /dev/null +++ b/src/CONVERTOR/VISU_TableReader.cxx @@ -0,0 +1,401 @@ +// 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 +#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 ).trimmed(); + cmt = aTmp.mid( index+1 ).trimmed(); + } + // if comment is not empty, try to get keyword from it (separated by ':' symbol) + if ( !cmt.isEmpty() ) { + int index1 = cmt.indexOf( ":" ); + if ( index1 >= 0 ) { + QString tmpstr = cmt.left( index1 ).trimmed(); + if ( tmpstr == QString( "TITLE" ) || + tmpstr == QString( "COLUMN_TITLES" ) || + tmpstr == QString( "COLUMN_UNITS" ) || + tmpstr == QString( "COMMENT" ) ) { + keyword = tmpstr; + cmt = cmt.mid( index1+1 ).trimmed(); + } + } + } + // 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.toLatin1().constData() << std::endl; + aTable2D.myTitle = title.toLatin1().constData(); + } + else if ( keyword == QString( "COLUMN_TITLES" ) ) { + // comment may contain column headers + QStringList aStrList = cmt.split( "|", QString::SkipEmptyParts ); + if(MYDEBUG) std::cout << "...Column TITLES are: "; + for ( int i = 0; i < aStrList.count(); i++ ) { + QString tmpstr = aStrList[ i ].trimmed(); + if(MYDEBUG) std::cout << tmpstr.toLatin1().constData() << " "; + aTable2D.myColumnTitles.push_back( tmpstr.toLatin1().constData() ); + } + if(MYDEBUG) std::cout << std::endl; + } + else if ( keyword == QString( "COLUMN_UNITS" ) ) { + // comment may contain column units + QStringList aStrList = cmt.split( " ", QString::SkipEmptyParts ); + if(MYDEBUG) std::cout << "...Column UNITS are: "; + for ( int i = 0; i < aStrList.count(); i++ ) { + QString tmpstr = aStrList[ i ].trimmed(); + if(MYDEBUG) std::cout << tmpstr.toLatin1().constData() << " "; + aTable2D.myColumnUnits.push_back( tmpstr.toLatin1().constData() ); + } + 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.toLatin1().constData() << std::endl; + } + } + else { + if(MYDEBUG) std::cout << "...comment: " << cmt.toLatin1().constData() << 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.toLatin1().constData(); + if(MYDEBUG) std::cout << "......ROW TITLE is: " << cmt.toLatin1().constData() << std::endl; + } + QString datar1 = data.replace(QRegExp("\t"), " "); + QStringList aValList = datar1.split( " ", QString::SkipEmptyParts ); + for ( int i = 0; i < aValList.count(); i++ ) { + if ( aValList[i].trimmed() != "" ) { + TTable2D::TValue aVal = aValList[i].trimmed().toLatin1().constData(); + 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 3dcac5f0..0f022b75 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 8d448e7f..43b6c761 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 "SALOME_InteractiveObject.hxx" #include @@ -84,7 +85,6 @@ VISU_Actor ::VISU_Actor(): myIsVTKMapping(false), myPrs3d(NULL), - myActorFactory(NULL), myIsShrunk(false), myIsShrinkable(false), myShrinkFilter(VTKViewer_ShrinkFilter::New()), @@ -168,14 +168,14 @@ VISU_Actor } //---------------------------------------------------------------------------- -VISU::TActorFactory* +/*VISU::TActorFactory* VISU_Actor ::GetFactory() { return myActorFactory; -} +}*/ -void +/*void VISU_Actor ::SetFactory(VISU::TActorFactory* theActorFactory) { @@ -190,10 +190,10 @@ VISU_Actor _1)); myActorFactory = theActorFactory; -} +}*/ //---------------------------------------------------------------------------- -void +/*void VISU_Actor ::UpdateFromFactory() { @@ -202,7 +202,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..99e31230 --- /dev/null +++ b/src/OBJECT/VISU_PointMap3dActor.cxx @@ -0,0 +1,141 @@ +// 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 +#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 44925dee..adb0d87b 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) \ @@ -110,7 +117,9 @@ libVisuPipeLine_la_LDFLAGS= \ $(GUI_LDFLAGS) \ $(MED_LDFLAGS) \ ../CONVERTOR/libVisuConvertor.la \ - $(VTK_LIBS) -lVTKViewer + $(VTK_LIBS) -lVTKViewer \ + $(MED2_LIBS) \ + $(QT_LIBS) # Executables targets diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 2e9f12c0..4b658ba1 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.suffix(); + 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..1f20a5b4 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -66,12 +66,14 @@ 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 \ VisuGUI_InputPane.cxx \ VisuGUI_CacheDlg.cxx \ - VisuGUI_FieldFilter.cxx + VisuGUI_FieldFilter.cxx \ + VisuGUI_FileInfoDlg.cxx MOC_FILES= \ VisuGUI_moc.cxx \ @@ -98,10 +100,12 @@ 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 \ - VisuGUI_CacheDlg_moc.cxx + VisuGUI_CacheDlg_moc.cxx \ + VisuGUI_FileInfoDlg_moc.cxx nodist_libVISU_la_SOURCES=$(MOC_FILES) diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 9218e1f6..2125dcc0 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -1204,6 +1204,10 @@ Please, refer to the documentation. SHOW_LEVEL_LABELS Show level labels + + MEN_FILE_INFO + MED File information + VisuGUI_AxisWg @@ -3212,4 +3216,152 @@ Please, refer to the documentation. auto + + VisuGUI_Table3DDlg + + DLG_PREF_TITLE + Table 3D Bar Preferences + + + DLG_PROP_TITLE + Scalar Bar Properties + + + + VisuGUI_TableScalarBarPane + + SCALAR_RANGE_GRP + Scalar range + + + LOGARITHMIC_SCALING + Logarithmic scaling + + + FIELD_RANGE_BTN + Use field range + + + IMPOSED_RANGE_BTN + Use imposed range + + + LBL_MIN + Min: + + + LBL_MAX + Max: + + + COLORS_LABELS_GRP + Colors and labels + + + LBL_NB_COLORS + Nb. of colors: + + + LBL_NB_LABELS + Nb. of labels: + + + ORIENTATION_GRP + Orientation + + + VERTICAL_BTN + Vertical + + + HORIZONTAL_BTN + Horizontal + + + ORIGIN_GRP + Origin + + + LBL_X + X: + + + LBL_Y + Y: + + + LBL_SHOW_PREVIEW + Show preview + + + DIMENSIONS_GRP + Dimensions + + + LBL_WIDTH + Width: + + + LBL_HEIGHT + Height: + + + SAVE_DEFAULT_CHK + Save as default values + + + MSG_MINMAX_VALUES + Min value can not be higher or equal to Max value + + + WRN_LOGARITHMIC_RANGE + Logarithmic scaling: use imposed range values > 0 + + + WRN_LOGARITHMIC_FIELD_RANGE + Logarithmic scaling: field range contains negative values, use imposed range instead + + + + VisuGUI_Table3DPane + + SCALE + Scale Factor: + + + PRESENTATION_TYPE + Presentation type + + + SURFACE + Surface + + + CONTOUR + Contour + + + NUMBER_CONTOURS + Number of contours: + + + + VisuGUI_FileInfoDlg + + CAPTION + File information + + + FILE_NAME + File name + + + FILE_SIZE + File size (bytes) + + + MED_VERSION + MED version + + diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index d7784739..810aeb27 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -81,6 +81,7 @@ #include "LightApp_SelectionMgr.h" #include "LightApp_Selection.h" #include "LightApp_Preferences.h" +#include "LightApp_DataOwner.h" #include "QtxAction.h" #include "QtxFontEdit.h" @@ -89,6 +90,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" @@ -112,6 +114,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" @@ -138,6 +141,7 @@ #include "VisuGUI_VectorsDlg.h" #include "VisuGUI_TableDlg.h" +#include "VisuGUI_FileInfoDlg.h" #include "SALOMEconfig.h" #include CORBA_SERVER_HEADER(MED_Gen) @@ -755,6 +759,14 @@ VisuGUI 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){ @@ -1201,6 +1213,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 @@ -1300,7 +1336,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() ); @@ -2104,6 +2140,10 @@ VisuGUI tr("MEN_SHOW_TABLE"), "", 0, aParent, false, this, SLOT(OnShowTable())); + createAction( VISU_SHOW_TABLE_PLOT, tr("MEN_EDIT_PRS"), QIcon(), + tr("MEN_EDIT_PRS"), "", 0, aParent, false, + this, SLOT(OnShowTablePlot())); + createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIcon(), tr("MEN_CREATE_CURVES"), "", 0, aParent, false, this, SLOT(OnPlotData())); @@ -2370,6 +2410,10 @@ VisuGUI createAction( VISU_MULTIPR_HIDE, tr("MEN_MULTIPR_VIEW_HIDE"), QIcon(aPixmap), tr("MEN_MULTIPR_VIEW_HIDE"), "", 0, aParent, false, this, SLOT(OnMultiprViewHide())); + + createAction( VISU_FILE_INFO, tr("MEN_FILE_INFO"), QIcon(), + tr("MEN_FILE_INFO"), "", 0, aParent, false, + this, SLOT(OnFileInfo())); } void @@ -2552,6 +2596,8 @@ VisuGUI mgr->insert( action( VISU_MULTIPR_LOW_RES ), -1, -1, -1 ); mgr->insert( action( VISU_MULTIPR_HIDE ), -1, -1, -1 ); + mgr->insert( action( VISU_FILE_INFO ), -1, -1, -1 ); + // Rules QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " @@ -2743,6 +2789,8 @@ VisuGUI QString aCustomRule = aRule + "resolutionState!='H'"; mgr->setRule( action( VISU_MULTIPR_HIDE), aCustomRule ); } + + mgr->setRule( action( VISU_FILE_INFO ), "selcount=1 and type in {'VISU::TRESULT'}" ); } //*************************************************************************** @@ -2866,13 +2914,23 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QMenu* theMenu, QStrin VISU::VISUType aType = VISU::Storable::RestoringMap2Type( aMap ); if (aType == VISU::TANIMATION) { theMenu->addAction( action( VISU_SHOW_ANIMATION ) ); - } else if (isOBClient) { if (IsSObjectTable(aSObject)) { + theMenu->removeAction( action( VISU_DELETE_OBJS ) ); + if (aType == VISU::TPOINTMAP3D) { + theMenu->addAction( action( VISU_SHOW_TABLE_PLOT ) ); + theMenu->addSeparator(); + theMenu->addAction( action( VISU_ERASE ) ); + theMenu->addAction( action( myEraseAll ) ); + theMenu->addAction( action( VISU_DISPLAY ) ); + theMenu->addAction( action( VISU_DISPLAY_ONLY ) ); + theMenu->addSeparator(); + } theMenu->addAction( action( VISU_SHOW_TABLE ) ); theMenu->addAction( action( VISU_CREATE_CURVES ) ); theMenu->addAction( action( VISU_EXPORT_TABLE ) ); theMenu->addSeparator(); + theMenu->addAction( action( VISU_DELETE_OBJS ) ); } else { if (!CORBA::is_nil(anObject)) { SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject); @@ -2894,6 +2952,17 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QMenu* theMenu, QStrin } } } + } else { + if (aType == VISU::TPOINTMAP3D) { + theMenu->removeAction( action( myEraseAll ) ); + theMenu->addAction( action( VISU_SHOW_TABLE_PLOT ) ); + theMenu->addSeparator(); + theMenu->addAction( action( VISU_ERASE ) ); + theMenu->addAction( action( myEraseAll ) ); + theMenu->addAction( action( VISU_DISPLAY ) ); + theMenu->addAction( action( VISU_DISPLAY_ONLY ) ); + theMenu->addSeparator(); + } } } @@ -3725,3 +3794,17 @@ void VisuGUI::OnMultiprChangeRes(VISU::Result::Resolution theResolution) QApplication::restoreOverrideCursor(); } +//--------------------------------------------------------------- +void VisuGUI::OnFileInfo() +{ + SalomeApp_Study* aStudy = dynamic_cast( getApp()->activeStudy() ); + SUIT_DataOwnerPtrList lst; + getApp()->selectionMgr()->selected( lst ); + LightApp_DataOwner* owner = dynamic_cast( lst.first().get() ); + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry( aStudy, owner->entry().toLatin1().constData() ); + VISU::Result_i* aCResult = dynamic_cast( anObjectInfo.myBase ); + if(!aCResult) + return; + VisuGUI_FileInfoDlg dlg( getApp()->desktop(), aCResult->GetMEDFileInfo() ); + dlg.exec(); +} diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 536a45a3..a4f00aac 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -139,6 +139,7 @@ protected slots: void OnChangeLines(); void OnShowTable(); + void OnShowTablePlot(); void OnCreateTable(); void OnDeleteObjects(); void OnPlotData(); @@ -176,6 +177,8 @@ protected slots: void OnMultiprViewHide(); void OnMultiprChangeRes(VISU::Result::Resolution theResolution); + void OnFileInfo(); + protected: virtual LightApp_Selection* createSelection() const; diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 40ef7783..aab3df54 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 @@ -124,4 +125,6 @@ #define VISU_MULTIPR_LOW_RES 4097 #define VISU_MULTIPR_HIDE 4098 +#define VISU_FILE_INFO 4100 + #endif diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.cxx b/src/VISUGUI/VisuGUI_ClippingDlg.cxx index a5aca09a..7dc9d39b 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.cxx +++ b/src/VISUGUI/VisuGUI_ClippingDlg.cxx @@ -817,28 +817,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->button(0)->setEnabled(true); - ButtonGroupIJKAxis->button(1)->setEnabled(false); - ButtonGroupIJKAxis->button(2)->setEnabled(false); - break; - case 2: - ButtonGroupIJKAxis->button(0)->setEnabled(true); - ButtonGroupIJKAxis->button(1)->setEnabled(true); - ButtonGroupIJKAxis->button(2)->setEnabled(false); - break; - case 3: - ButtonGroupIJKAxis->button(0)->setEnabled(true); - ButtonGroupIJKAxis->button(1)->setEnabled(true); - ButtonGroupIJKAxis->button(2)->setEnabled(true); - break; - } + if ( anIDMapper->IsStructured() ) { + VISU::TStructuredId aStructuredId = anIDMapper->GetStructure(); + ButtonGroupIJKAxis->button(0)->setEnabled( aStructuredId[0] >= 0 ); + ButtonGroupIJKAxis->button(1)->setEnabled( aStructuredId[1] >= 0 ); + ButtonGroupIJKAxis->button(2)->setEnabled( aStructuredId[2] >= 0 ); } } //ENK: 23.11.2006 @@ -1085,8 +1071,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 18c57ce8..7b8daf94 100644 --- a/src/VISUGUI/VisuGUI_Displayer.cxx +++ b/src/VISUGUI/VisuGUI_Displayer.cxx @@ -92,7 +92,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_FileInfoDlg.cxx b/src/VISUGUI/VisuGUI_FileInfoDlg.cxx new file mode 100644 index 00000000..78d8c090 --- /dev/null +++ b/src/VISUGUI/VisuGUI_FileInfoDlg.cxx @@ -0,0 +1,78 @@ +// 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_FileInfoDlg.cxx +// Author : Alexandre SOLOVYOV, Open CASCADE S.A.S. ( alexander.solovyov@opencascade.com) +// Module : VISU +// + +#include + +#include + +#include +#include +#include + +VisuGUI_FileInfoDlg::VisuGUI_FileInfoDlg( QWidget* parent, SALOME_MED::MedFileInfo* inf ) + : QtxDialog( parent, true, true, QtxDialog::OK ) +{ + setWindowTitle( tr( "CAPTION" ) ); + setSizeGripEnabled( true ); + + QLineEdit* fname = new QLineEdit( mainFrame() ); + fname->setReadOnly( true ); + QLineEdit* fsize = new QLineEdit( mainFrame() ); + fsize->setReadOnly( true ); + QLineEdit* medversion = new QLineEdit( mainFrame() ); + medversion->setReadOnly( true ); + fname->setMinimumWidth( 300 ); + + QGridLayout* lay = new QGridLayout( mainFrame() ); + lay->setMargin( 5 ); lay->setSpacing( 5 ); + lay->addWidget( new QLabel( tr( "FILE_NAME" ), mainFrame() ), 0, 0 ); + lay->addWidget( fname, 0, 1 ); + lay->addWidget( new QLabel( tr( "FILE_SIZE" ), mainFrame() ), 1, 0 ); + lay->addWidget( fsize, 1, 1 ); + lay->addWidget( new QLabel( tr( "MED_VERSION" ), mainFrame() ), 2, 0 ); + lay->addWidget( medversion, 2, 1 ); + + fname->setText( (char*)inf->fileName ); + fname->home( false ); + fsize->setText( QString::number( inf->fileSize ) ); + + QString version; + if( inf->major>=0 ) + { + version = QString::number( inf->major ); + if( inf->minor>=0 ) + { + version += "." + QString::number( inf->minor ); + if( inf->release>=0 ) + version += "." + QString::number( inf->release ); + } + } + medversion->setText( version ); +} + +VisuGUI_FileInfoDlg::~VisuGUI_FileInfoDlg() +{ +} diff --git a/src/VISUGUI/VisuGUI_FileInfoDlg.h b/src/VISUGUI/VisuGUI_FileInfoDlg.h new file mode 100644 index 00000000..c755474b --- /dev/null +++ b/src/VISUGUI/VisuGUI_FileInfoDlg.h @@ -0,0 +1,41 @@ +// 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_FileInfoDlg.h +// Author : Alexandre SOLOVYOV, Open CASCADE S.A.S. ( alexander.solovyov@opencascade.com) +// + +#ifndef VISUGUI_FILEINFODLG_H +#define VISUGUI_FILEINFODLG_H + +#include +#include + +class VisuGUI_FileInfoDlg : public QtxDialog +{ + Q_OBJECT + +public: + VisuGUI_FileInfoDlg( QWidget*, SALOME_MED::MedFileInfo* ); + virtual ~VisuGUI_FileInfoDlg(); +}; + +#endif // VISUGUI_FILEINFODLG_H diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index e6c531db..c8fa4f7e 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -591,7 +591,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 681cc9e5..3dcc4386 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx @@ -1290,7 +1290,7 @@ int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { myScalarMap->SetLabelsFormat(myBarDlg->getLabelsFormat().toLatin1().data()); 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 20462021..5d9bd5b4 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -92,6 +92,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), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),//WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), @@ -493,23 +506,11 @@ 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; @@ -548,20 +549,10 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { myListPoints->model()->setHeaderData( i, Qt::Vertical, QVariant(QString::number( i )), Qt::DisplayRole ); 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 QAbstractItemModel* aModel = myListPoints->model(); diff --git a/src/VISUGUI/VisuGUI_Table3dDlg.cxx b/src/VISUGUI/VisuGUI_Table3dDlg.cxx new file mode 100644 index 00000000..d76db59b --- /dev/null +++ b/src/VISUGUI/VisuGUI_Table3dDlg.cxx @@ -0,0 +1,748 @@ +// 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_Table3dDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// + +#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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SURFACE_PRS_ID 0 +#define CONTOUR_PRS_ID 1 + +//======================================================================= +//function : VisuGUI_Table3DPane +//purpose : +//======================================================================= +VisuGUI_Table3DPane::VisuGUI_Table3DPane( QWidget* parent ) + : QWidget( parent ), + myViewWindow( VISU::GetActiveViewWindow() ), + myPrs( 0 ), + myInitFromPrs( false ) +{ + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setMargin( 11 ); + topLayout->setSpacing( 6 ); + + // scale + QLabel* scaleLabel = new QLabel( tr( "SCALE" ), this ); + ScaleSpn = new QtxDoubleSpinBox( -1.e6, 1.e6, 0.1, this ); + // Presentation type + GBPrsTypeBox = new QGroupBox( tr( "PRESENTATION_TYPE" ), this ); + GBPrsType = new QButtonGroup( GBPrsTypeBox ); + QRadioButton* rb1 = new QRadioButton( tr( "SURFACE" ), GBPrsTypeBox ); + QRadioButton* rb2 = new QRadioButton( tr( "CONTOUR" ), GBPrsTypeBox ); + GBPrsType->addButton( rb1, SURFACE_PRS_ID ); + GBPrsType->addButton( rb2, CONTOUR_PRS_ID ); + QHBoxLayout* GBPrsTypeBoxLayout = new QHBoxLayout( GBPrsTypeBox ); + GBPrsTypeBoxLayout->setMargin( 11 ); + GBPrsTypeBoxLayout->setSpacing( 6 ); + GBPrsTypeBoxLayout->addWidget( rb1 ); + GBPrsTypeBoxLayout->addWidget( rb2 ); + + // nb Contours + QLabel* nbContLabel = new QLabel( tr( "NUMBER_CONTOURS" ), this ); + NbContoursSpn = new QSpinBox( this ); + NbContoursSpn->setMinimum( 1 ); + NbContoursSpn->setMaximum( 999 ); + NbContoursSpn->setSingleStep( 1 ); + + topLayout->addWidget( scaleLabel, 0, 0 ); + topLayout->addWidget( ScaleSpn, 0, 1 ); + topLayout->addWidget( GBPrsTypeBox, 1, 0, 1, 2 ); + topLayout->addWidget( nbContLabel, 2, 0 ); + topLayout->addWidget( NbContoursSpn, 2, 1 ); + topLayout->setRowStretch( 3, 5 ); + + // signals and slots connections + + connect( GBPrsType, SIGNAL( buttonClicked( 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 + thePrs->SetContourPrs( GBPrsType->checkedId() == CONTOUR_PRS_ID ); + + // nb contours + thePrs->SetNbOfContours( NbContoursSpn->value() ); + + return 1; +} + +//======================================================================= +//function : GetPrs +//purpose : +//======================================================================= +VISU::PointMap3d_i* VisuGUI_Table3DPane::GetPrs() +{ + return myPrs; +} + +//======================================================================= +//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->button( id )->setChecked( true ); + onPrsType( id ); + + // nb contours + NbContoursSpn->setValue( thePrs->GetNbOfContours() ); +} + +//======================================================================= +//function : Table Scalar Bar +//purpose : +//======================================================================= + +VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane( QWidget* parent ) + : QWidget( parent ), + myBarPrs( 0 ) +{ + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setSpacing( 6 ); + topLayout->setMargin( 11 ); + + 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 ); + + // Range ============================================================ + RangeGroup = new QGroupBox( tr( "SCALAR_RANGE_GRP" ), this ); + QButtonGroup* RangeRB = new QButtonGroup( RangeGroup ); + QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup ); + RangeGroupLayout->setSpacing( 6 ); + RangeGroupLayout->setMargin( 11 ); + + CBLog = new QCheckBox( tr( "LOGARITHMIC_SCALING" ), RangeGroup ); + + RBFrange = new QRadioButton( tr( "FIELD_RANGE_BTN" ), RangeGroup ); + RBIrange = new QRadioButton( tr( "IMPOSED_RANGE_BTN" ), RangeGroup ); + RangeRB->addButton( RBFrange, 0 ); + RangeRB->addButton( RBIrange, 1 ); + RBFrange->setChecked( true ); + + MinEdit = new QLineEdit( RangeGroup ); + MinEdit->setMinimumWidth( 70 ); + MinEdit->setValidator( new QDoubleValidator( this ) ); + MinEdit->setText( "0.0" ); + QLabel* MinLabel = new QLabel( tr( "LBL_MIN" ), RangeGroup ); + MinLabel->setBuddy( MinEdit ); + + MaxEdit = new QLineEdit( RangeGroup ); + MaxEdit->setMinimumWidth( 70 ); + MaxEdit->setValidator( new QDoubleValidator( this ) ); + MaxEdit->setText( "0.0" ); + QLabel* MaxLabel = new QLabel( tr( "LBL_MAX" ), RangeGroup ); + MaxLabel->setBuddy( MaxEdit ); + + RangeGroupLayout->addWidget( CBLog, 1, 0, 1, 4 ); + RangeGroupLayout->addWidget( RBFrange, 2, 0, 1, 2 ); + RangeGroupLayout->addWidget( RBIrange, 2, 2, 1, 2 ); + RangeGroupLayout->addWidget( MinLabel, 3, 0 ); + RangeGroupLayout->addWidget( MinEdit, 3, 1 ); + RangeGroupLayout->addWidget( MaxLabel, 3, 2 ); + RangeGroupLayout->addWidget( MaxEdit, 3, 3 ); + + // Colors and Labels ======================================================== + QGroupBox* ColLabGroup = new QGroupBox( tr( "COLORS_LABELS_GRP" ), this ); + QHBoxLayout* ColLabGroupLayout = new QHBoxLayout( ColLabGroup ); + ColLabGroupLayout->setSpacing( 6 ); + ColLabGroupLayout->setMargin( 11 ); + + QLabel* ColorLabel = new QLabel( tr( "LBL_NB_COLORS" ), ColLabGroup ); + ColorSpin = new QSpinBox( ColLabGroup ); + ColorSpin->setMinimum( 2 ); + ColorSpin->setMaximum( 256 ); + ColorSpin->setSingleStep( 1 ); + ColorSpin->setMinimumWidth( 70 ); + ColorSpin->setValue( 64 ); + + QLabel* LabelLabel = new QLabel( tr( "LBL_NB_LABELS" ), ColLabGroup ); + LabelSpin = new QSpinBox( ColLabGroup ); + LabelSpin->setMinimum( 2 ); + LabelSpin->setMaximum( 65 ); + LabelSpin->setSingleStep( 1 ); + LabelSpin->setMinimumWidth( 70 ); + LabelSpin->setValue( 5 ); + + ColLabGroupLayout->addWidget( ColorLabel ); + ColLabGroupLayout->addWidget( ColorSpin ); + ColLabGroupLayout->addWidget( LabelLabel ); + ColLabGroupLayout->addWidget( LabelSpin ); + + // Orientation ========================================================== + QGroupBox* OrientGroup = new QGroupBox( tr( "ORIENTATION_GRP" ), this ); + QButtonGroup* OrientRB = new QButtonGroup( OrientGroup ); + QHBoxLayout* OrientGroupLayout = new QHBoxLayout( OrientGroup ); + OrientGroupLayout->setSpacing( 6 ); + OrientGroupLayout->setMargin( 11 ); + + RBvert = new QRadioButton( tr( "VERTICAL_BTN" ), OrientGroup ); + RBhori = new QRadioButton( tr( "HORIZONTAL_BTN" ), OrientGroup ); + OrientRB->addButton( RBvert, 0 ); + OrientRB->addButton( RBhori, 1 ); + RBvert->setChecked( true ); + OrientGroupLayout->addWidget( RBvert ); + OrientGroupLayout->addWidget( RBhori ); + + // Origin =============================================================== + QGroupBox* OriginGroup = new QGroupBox( tr( "ORIGIN_GRP" ), this ); + QHBoxLayout* OriginGroupLayout = new QHBoxLayout( OriginGroup ); + OriginGroupLayout->setSpacing( 6 ); + OriginGroupLayout->setMargin( 11 ); + + QLabel* XLabel = new QLabel( tr( "LBL_X" ), OriginGroup ); + XSpin = new QtxDoubleSpinBox( 0.0, 1.0, 0.1, OriginGroup ); + XSpin->setMinimumWidth( 70 ); + XSpin->setValue( 0.01 ); + + QLabel* YLabel = new QLabel( tr( "LBL_Y" ), OriginGroup ); + YSpin = new QtxDoubleSpinBox( 0.0, 1.0, 0.1, OriginGroup ); + YSpin->setMinimumWidth( 70 ); + YSpin->setValue( 0.01 ); + + OriginGroupLayout->addWidget( XLabel ); + OriginGroupLayout->addWidget( XSpin ); + OriginGroupLayout->addWidget( YLabel ); + OriginGroupLayout->addWidget( YSpin ); + + // Dimensions ========================================================= + QGroupBox* DimGroup = new QGroupBox( tr( "DIMENSIONS_GRP" ), this ); + QHBoxLayout* DimGroupLayout = new QHBoxLayout( DimGroup ); + DimGroupLayout->setSpacing( 6 ); + DimGroupLayout->setMargin( 11 ); + + QLabel* WidthLabel = new QLabel( tr( "LBL_WIDTH" ), DimGroup ); + WidthSpin = new QtxDoubleSpinBox( 0.0, 1.0, 0.1, DimGroup ); + WidthSpin->setMinimumWidth( 70 ); + WidthSpin->setValue( 0.1 ); + + QLabel* HeightLabel = new QLabel( tr( "LBL_HEIGHT" ), DimGroup ); + HeightSpin = new QtxDoubleSpinBox( 0.0, 1.0, 0.1, DimGroup ); + HeightSpin->setMinimumWidth( 70 ); + HeightSpin->setValue( 0.8 ); + + DimGroupLayout->addWidget( WidthLabel ); + DimGroupLayout->addWidget( WidthSpin ); + DimGroupLayout->addWidget( HeightLabel ); + DimGroupLayout->addWidget( HeightSpin ); + + myTextBtn = new QPushButton( tr( "Text properties..." ), this ); + myBarBtn = new QPushButton( tr( "Bar properties..." ), this ); + + // main layout ========================================================= + + topLayout->addWidget( RangeGroup, 0, 0, 1, 2 ); + topLayout->addWidget( ColLabGroup, 1, 0, 1, 2 ); + topLayout->addWidget( OrientGroup, 2, 0, 1, 2 ); + topLayout->addWidget( OriginGroup, 3, 0, 1, 2 ); + topLayout->addWidget( DimGroup, 4, 0, 1, 2 ); + topLayout->addWidget( myTextBtn, 5, 0 ); + topLayout->addWidget( myBarBtn, 5, 1 ); + + // init ================================================================ + + 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( RangeRB, SIGNAL( buttonClicked( int ) ), this, SLOT( changeRange( int ) ) ); + connect( OrientRB, SIGNAL( buttonClicked( 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().toLatin1().constData() ); + 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().toLatin1().constData() ); + + 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 ) +{ + QtxDoubleSpinBox* snd = (QtxDoubleSpinBox*)sender(); + if ( snd == XSpin ) { + WidthSpin->setMaximum( 1.0 - XSpin->value() ); + } + if ( snd == YSpin ) { + HeightSpin->setMaximum( 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 ) ) +{ + setModal( false ); + setWindowTitle( 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 ); + + myTabBox->addTab( myIsoPane, tr( "DLG_PREF_TITLE" ) ); + myTabBox->addTab( myScalarBarPane, tr( "DLG_PROP_TITLE" ) ); + + QGroupBox* GroupButtons = new QGroupBox( this ); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons ); + buttonOk->setAutoDefault( true ); + buttonOk->setDefault( true ); + QPushButton* buttonApply = new QPushButton( tr( "&Apply" ), GroupButtons ); + buttonApply->setAutoDefault( true ); + QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ), GroupButtons ); + buttonCancel->setAutoDefault( true ); + QPushButton* buttonHelp = new QPushButton( tr( "&Help" ), GroupButtons ); + buttonHelp->setAutoDefault( true ); + + GroupButtonsLayout->addWidget( buttonOk ); + GroupButtonsLayout->addWidget( buttonApply ); + GroupButtonsLayout->addSpacing( 10 ); + GroupButtonsLayout->addStretch(); + GroupButtonsLayout->addWidget( buttonCancel ); + GroupButtonsLayout->addWidget( buttonHelp ); + + TopLayout->addWidget( myTabBox ); + TopLayout->addWidget( GroupButtons ); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onApply() ) ); +} + +//======================================================================= +//function : Destructor +//purpose : +//======================================================================= +VisuGUI_Table3DDlg::~VisuGUI_Table3DDlg() +{ +} + +//======================================================================= +//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..3945fb33 --- /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_Table3dDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// + +#ifndef VISUGUI_TABLE3D_H +#define VISUGUI_TABLE3D_H + +#include "VisuGUI_Prs3dDlg.h" + +#include +#include + +class QTabWidget; +class QButtonGroup; +class QGroupBox; +class QComboBox; +class QCheckBox; +class QLineEdit; +class QRadioButton; +class QPushButton; +class QSpinBox; +class QtxDoubleSpinBox; +class VisuGUI_TextPrefDlg; +class VisuGUI_BarPrefDlg; +class SVTK_ViewWindow; +class SalomeApp_Module; + +namespace VISU +{ + class PointMap3d_i; +}; + +class VisuGUI_Table3DPane : public QWidget +{ + Q_OBJECT + +public: + VisuGUI_Table3DPane( QWidget* ); + ~VisuGUI_Table3DPane(); + + void initFromPrsObject( VISU::PointMap3d_i* ); + int storeToPrsObject( VISU::PointMap3d_i* ); + + VISU::PointMap3d_i* GetPrs(); + +private slots: + void onPrsType( int ); + +private: + bool myInitFromPrs; + + SVTK_ViewWindow* myViewWindow; + VISU::PointMap3d_i* myPrs; + + QtxDoubleSpinBox* ScaleSpn; + QGroupBox* GBPrsTypeBox; + QButtonGroup* GBPrsType; + QSpinBox* NbContoursSpn; +}; + +class VisuGUI_TableScalarBarPane : public QWidget +{ + Q_OBJECT + +public: + VisuGUI_TableScalarBarPane( QWidget* ); + ~VisuGUI_TableScalarBarPane(); + + void setRange( double, double, bool ); + void setDefaultRange( double, double ); + int getOrientation(); + void setPosAndSize( double, double, double, double, bool ); + void setScalarBarData( int, int ); + 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* ); + int storeToPrsObject( VISU::PointMap3d_i* ); + + bool check(); + +private slots: + void changeDefaults( int ); + void changeRange( int ); + void XYChanged( double ); + void changeScalarMode( int ); + void onTextPref(); + void onBarPref(); + +private: + QGroupBox* RangeGroup; + QRadioButton* RBFrange; + QRadioButton* RBIrange; + QLineEdit* MinEdit; + QLineEdit* MaxEdit; + + QRadioButton* RBhori; + QRadioButton* RBvert; + + QtxDoubleSpinBox* XSpin; + QtxDoubleSpinBox* YSpin; + + QtxDoubleSpinBox* WidthSpin; + QtxDoubleSpinBox* 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; + + std::string myTitle; + VISU::PointMap3d_i* myBarPrs; + + bool myBusy; +}; + +/////////////////////////////////////////////////////// + +class VisuGUI_Table3DDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_Table3DDlg( SalomeApp_Module* ); + ~VisuGUI_Table3DDlg(); + + virtual void initFromPrsObject( VISU::PointMap3d_i* ); + virtual int storeToPrsObject( VISU::PointMap3d_i* ); + +protected slots: + 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 bff866e9..165bfffe 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 014ae5a5..d61e29bb 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 3cc68f91..a4ff436a 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 5fe77d32..2ff2fd7f 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 045c26ad..2bdb127f 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() { @@ -1518,26 +1518,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; @@ -1564,7 +1564,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); @@ -1675,7 +1675,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").toLatin1().data()); - 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").toLatin1().data()); 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_CorbaMedConvertor.cxx b/src/VISU_I/VISU_CorbaMedConvertor.cxx index 02d6c664..385ca3f2 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -673,8 +673,16 @@ VISU_MEDFieldConvertor vtkIdType aDataType = VTK_DOUBLE; SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(myField); - if(aFieldDouble->_is_nil()) - aDataType = VTK_LONG; + if(aFieldDouble->_is_nil()) { + // PAL18313: Mandriva 64 porting: CRASH at creating presentation on "Import Structure". + if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h) + aDataType = VTK_LONG; + else if (sizeof(int) == 4) + aDataType = VTK_INT; + else { + throw std::runtime_error("Can't map CORBA::Long to a VTK type"); + } + } aField->Init(myField->getNumberOfComponents(), aDataType); if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<Init(aMEDField->getNumberOfComponents(), aDataType); if(MYDEBUG) 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 6b07b81b..8c4f613f 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 42e007a0..d8f465ce 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 99a7a9ac..88e772ea 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -387,7 +387,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 242001aa..f4ccad96 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" @@ -592,7 +593,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(); } @@ -1075,7 +1085,6 @@ namespace VISU theIteration)._retn(); } - //--------------------------------------------------------------- struct CreateTableEvent: public SALOME_Event { @@ -1084,7 +1093,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; @@ -1095,16 +1104,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 @@ -1113,11 +1152,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 70707f2f..3886da2a 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..ed2c2c01 --- /dev/null +++ b/src/VISU_I/VISU_PointMap3d_i.cc @@ -0,0 +1,1165 @@ +// 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.h" +#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().toLatin1().constData(), 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().toLatin1().constData(), 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" ); + SetLabelsFormat(aLabelsFormat.toLatin1().constData()); + + // 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.toLatin1().constData() ); + } + 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(aMethodName == "ImportTables"){ + aComment.sprintf("myComment=%s;mySourceId=TableFile",GetComment()); + } + } + } + } + + string anEntry = CreateAttributes( GetStudyDocument(), + SO->GetID(),//SComponent->GetID(), + "ICON_TREE_TABLE", + GetID(), + GetName(), + "", + aComment.toLatin1().constData(), + 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").toLatin1().constData(), false); + myTitle = VISU::Storable::FindValue(theMap,"myTitle").toLatin1().constData(); + 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").toLatin1().constData()); + SetBarOrientation((VISU::ColoredPrs3dBase::Orientation)VISU::Storable::FindValue(theMap,"myBarOrientation").toInt()); + + SetTitle(VISU::Storable::FindValue(theMap,"myTitle").toLatin1().constData()); + 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 + +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 baabd4a1..9951cbbe 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 - -using namespace std; +#include "VISU_TableReader.hxx" +#include "VISU_ConvertorUtils.hxx" #ifdef _DEBUG_ static int MYDEBUG = 0; @@ -1177,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 ).trimmed(); - cmt = aTmp.mid( index+1 ).trimmed(); - } - // if comment is not empty, try to get keyword from it (separated by ':' symbol) - if ( !cmt.isEmpty() ) { - int index1 = cmt.indexOf( ":" ); - if ( index1 >= 0 ) { - QString tmpstr = cmt.left( index1 ).trimmed(); - if ( tmpstr == QString( "TITLE" ) || - tmpstr == QString( "COLUMN_TITLES" ) || - tmpstr == QString( "COLUMN_UNITS" ) || - tmpstr == QString( "COMMENT" ) ) { - keyword = tmpstr; - cmt = cmt.mid( index1+1 ).trimmed(); - } - } - } - // 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.toLatin1().data() << endl; - aTable2D.myTitle = title.toLatin1().data(); - } - else if ( keyword == QString( "COLUMN_TITLES" ) ) { - // comment may contain column headers - QStringList aStrList = cmt.split( "|", QString::SkipEmptyParts ); - if(MYDEBUG) cout << "...Column TITLES are: "; - for ( int i = 0; i < aStrList.count(); i++ ) { - QString tmpstr = aStrList[ i ].trimmed(); - if(MYDEBUG) cout << tmpstr.toLatin1().data() << " "; - aTable2D.myColumnTitles.push_back( tmpstr.toLatin1().data() ); - } - if(MYDEBUG) cout << endl; - } - else if ( keyword == QString( "COLUMN_UNITS" ) ) { - // comment may contain column units - QStringList aStrList = cmt.split( " ", QString::SkipEmptyParts ); - if(MYDEBUG) cout << "...Column UNITS are: "; - for ( int i = 0; i < aStrList.count(); i++ ) { - QString tmpstr = aStrList[ i ].trimmed(); - if(MYDEBUG) cout << tmpstr.toLatin1().data() << " "; - aTable2D.myColumnUnits.push_back( tmpstr.toLatin1().data() ); - } - if(MYDEBUG) cout << endl; - } - else if ( keyword == QString( "COMMENT" ) ) { - // keyword 'COMMENT' processing can be here - // currently it is ignored - if(MYDEBUG) cout << "...COMMENT: " << cmt.toLatin1().data() << endl; - } - } - else { - if(MYDEBUG) cout << "...comment: " << cmt.toLatin1().data() << 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.toLatin1().data(); - if(MYDEBUG) cout << "......ROW TITLE is: " << cmt.toLatin1().data() << endl; - } - QString datar1 = data.replace(QRegExp("\t"), " "); - QStringList aValList = datar1.split( " ", QString::SkipEmptyParts ); - for ( int i = 0; i < aValList.count(); i++ ) { - if ( aValList[i].trimmed() != "" ) { - TValue aVal = aValList[i].trimmed().toLatin1().data(); - 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); @@ -1392,19 +1192,21 @@ SALOMEDS::SObject_var VISU::ImportTables(const char* theFileName, SALOMEDS::Stud aString.sprintf("myComment=ImportTables;myFileName=%s", aFileInfo.absoluteFilePath().toLatin1().data()); aComment->SetValue(aString.toLatin1().data()); - 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.toLatin1().data()); } + 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 f8e58417..24eba803 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -30,6 +30,7 @@ #include "VISU_Table_i.hh" #include "VISU_Actor.h" +#include "VISU_ActorFactory.h" #include "SUIT_Tools.h" #include "SUIT_Session.h" @@ -481,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 8ecf13a4..22f813cd 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.h" @@ -63,6 +66,7 @@ #include #include +#include using namespace std; @@ -1629,7 +1633,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(); } @@ -1930,6 +1934,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"); @@ -1961,9 +1986,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) @@ -1974,6 +2004,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 df70b083..977d3848 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" @@ -69,7 +69,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; QVector aViews = myViewManager->getViews(); -- 2.39.2