From 3d952f63e0ce875d00749559438676053ca1fa31 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 29 Nov 2005 09:04:54 +0000 Subject: [PATCH] Merge with maintanace of the Base version of the D5-38-2003 --- doc/salome/VISU_index.html | 19 +- doc/salome/gui/Makefile.in | 4 + idl/VISU_Gen.idl | 32 +- resources/Vertex_Program_ARB.txt | 19 +- src/CONVERTOR/VISUConvertor.cxx | 6 +- src/CONVERTOR/VISU_Convertor.cxx | 1 - src/CONVERTOR/VISU_Convertor.hxx | 137 +- src/CONVERTOR/VISU_ConvertorDef.hxx | 5 + src/CONVERTOR/VISU_ConvertorUtils.cxx | 39 +- src/CONVERTOR/VISU_ConvertorUtils.hxx | 19 + src/CONVERTOR/VISU_Convertor_impl.cxx | 46 +- src/CONVERTOR/VISU_Convertor_impl.hxx | 291 +++- src/CONVERTOR/VISU_IDMapper.hxx | 32 +- src/CONVERTOR/VISU_MedConvertor.cxx | 674 +++++---- src/CONVERTOR/VISU_MedConvertor.hxx | 22 +- src/ENGINE/VISU_Engine_i.cc | 5 + src/ENGINE/VISU_Engine_i.hh | 1 + src/OBJECT/VISU_Actor.cxx | 4 +- src/OBJECT/VISU_Actor.h | 2 +- src/OBJECT/VISU_ActorFactory.h | 13 + src/OBJECT/VISU_Event.h | 3 + src/OBJECT/VISU_GaussPtsAct.cxx | 223 ++- src/OBJECT/VISU_GaussPtsAct.h | 54 +- src/OBJECT/VISU_GaussPtsActorFactory.h | 3 + src/OBJECT/VISU_GaussPtsDeviceActor.cxx | 43 + src/OBJECT/VISU_GaussPtsDeviceActor.h | 4 + src/OBJECT/VISU_GaussPtsSettings.cxx | 4 + src/OBJECT/VISU_GaussPtsSettings.h | 23 +- src/PIPELINE/Makefile.in | 1 + src/PIPELINE/VISU_Extractor.cxx | 3 +- src/PIPELINE/VISU_GaussPointsPL.hxx | 50 +- src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx | 133 +- src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx | 204 +-- src/PIPELINE/VISU_PipeLine.cxx | 6 +- src/PIPELINE/VISU_PipeLine.hxx | 4 +- src/VISUGUI/Makefile.in | 4 +- src/VISUGUI/VISUM_msg_en.po | 77 +- src/VISUGUI/VisuGUI.cxx | 101 +- src/VISUGUI/VisuGUI_GaussPointsDlg.cxx | 9 +- src/VISUGUI/VisuGUI_GaussPointsDlg.h | 13 +- src/VISUGUI/VisuGUI_Module.cxx | 73 +- src/VISUGUI/VisuGUI_Module.h | 19 +- src/VISUGUI/VisuGUI_OffsetDlg.cxx | 2 +- src/VISUGUI/VisuGUI_Prs3dTools.h | 9 +- src/VISUGUI/VisuGUI_Selection.cxx | 58 +- src/VISUGUI/VisuGUI_Selection.h | 4 +- src/VISUGUI/VisuGUI_Timer.cxx | 5 +- src/VISUGUI/VisuGUI_Tools.cxx | 37 +- src/VISUGUI/VisuGUI_ViewTools.cxx | 9 +- src/VISU_I/Makefile.in | 2 +- src/VISU_I/VISU_GaussPoints_i.cc | 10 +- src/VISU_I/VISU_GaussPoints_i.hh | 38 +- src/VISU_I/VISU_Gen_i.cc | 17 + src/VISU_I/VISU_Gen_i.hh | 1 + src/VISU_I/VISU_Prs3d_i.cc | 27 +- src/VISU_I/VISU_Prs3d_i.hh | 34 + src/VISU_I/VISU_Result_i.cc | 1219 +++++++++++++---- src/VISU_I/VISU_Result_i.hh | 37 +- src/VISU_I/VISU_TimeAnimation.cxx | 29 + src/VVTK/VVTK_InteractorStyle.cxx | 102 +- src/VVTK/VVTK_InteractorStyle.h | 83 +- src/VVTK/VVTK_MainWindow.cxx | 34 +- src/VVTK/VVTK_MainWindow.h | 50 +- src/VVTK/VVTK_PickingDlg.cxx | 64 +- src/VVTK/VVTK_PickingDlg.h | 13 + src/VVTK/VVTK_Renderer.cxx | 34 +- src/VVTK/VVTK_Renderer.h | 33 +- src/VVTK/VVTK_SegmentationCursorDlg.cxx | 11 +- src/VVTK/VVTK_SegmentationCursorDlg.h | 9 + src/VVTK/VVTK_ViewManager.h | 5 +- src/VVTK/VVTK_ViewModel.h | 21 +- src/VVTK/VVTK_ViewWindow.h | 29 +- 72 files changed, 3223 insertions(+), 1228 deletions(-) diff --git a/doc/salome/VISU_index.html b/doc/salome/VISU_index.html index 84118080..a69a8403 100644 --- a/doc/salome/VISU_index.html +++ b/doc/salome/VISU_index.html @@ -65,25 +65,16 @@
-
-
GUI Documentation
-
- -
+
+ +
Gauss Viewer User Guide
-

-
- -
+
TUI Documentation
- -
- -
- +


diff --git a/doc/salome/gui/Makefile.in b/doc/salome/gui/Makefile.in index e03160f1..805d892e 100644 --- a/doc/salome/gui/Makefile.in +++ b/doc/salome/gui/Makefile.in @@ -16,6 +16,7 @@ VPATH=.:@srcdir@ docs: cp -fr $(srcdir)/VISU ./ + cp -fr $(srcdir)/GAUSS ./ -find $(PWD) -name CVS -exec rm -rf {} \; clean: @@ -23,11 +24,14 @@ clean: distclean: clean rm -fr VISU + rm -fr GAUSS install: mkdir -p $(docdir)/gui cp -rf VISU $(docdir)/gui + cp -rf GAUSS $(docdir)/gui -find $(PWD) -name CVS -exec rm -rf {} \; uninstall: rm -rf $(docdir)/gui/VISU + rm -rf $(docdir)/gui/GAUSS diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 2b04645b..72b6829f 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -1250,10 +1250,33 @@ module VISU { * for further construction of graphical presentations. */ interface Result : RemovableObject, SALOME::GenericObj { - //interface Result : Base{ /*! Reads all data from the corresponding sources. By default the data is loaded on demand. */ boolean BuildAll(); + + /*! Start to parse the source MED file and publish all its entities into the study*/ + boolean Build(in boolean theIsBuildAll, in boolean theIsAtOnce); + + /*! Allow to check is all requested MED entites already loaded or not */ + boolean IsDone(); + + /*! Allow to check is corresponding MED entites already loaded or not */ + boolean IsEntitiesDone(); + + /*! Choose to parse MED fields and perform global min / max on the MED timestamps.*/ + void SetBuildFields(in boolean theIsBuildFields, in boolean theIsCalculateMinMax); + + /*! Allow to check is corresponding MED fields already loaded or not */ + boolean IsFieldsDone(); + + /*! Choose to parse MED groups.*/ + void SetBuildGroups(in boolean theIsBuildGroups); + + /*! Allow to check is corresponding MED groups and families already loaded or not */ + boolean IsGroupsDone(); + + /*! Allow to check is min / max calculation over field's components already perfrormed or not */ + boolean IsMinMaxDone(); }; //------------------------------------------------------- @@ -1298,6 +1321,13 @@ module VISU { */ Result ImportFile(in string theFileName); + /*! + * Create result and initialize its with the file. The access to this file will be conserved outside of the application. + * \param theFileName String parameter defining the name of the file + * from which the data will be imported. + */ + Result CreateResult(in string theFileName); + /*! * Imports data from a file. The access to this file will closed. * \param theFileName String parameter defining the name of the file diff --git a/resources/Vertex_Program_ARB.txt b/resources/Vertex_Program_ARB.txt index 965b523d..e13d0258 100755 --- a/resources/Vertex_Program_ARB.txt +++ b/resources/Vertex_Program_ARB.txt @@ -1,21 +1,12 @@ -attribute int mode; -attribute float clamp; -attribute float geomSize; -attribute float minSize; -attribute float maxSize; -attribute float magnification; +attribute float clamp_size; void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - gl_FrontColor = gl_Color; + gl_FrontColor.x = gl_Color.x; + gl_FrontColor.y = gl_Color.y; + gl_FrontColor.z = gl_Color.z; - float size; - if( mode == 0 ) - size = minSize + ( maxSize - minSize ) * ( 1 - gl_Color.w / 241.0f ); - else - size = geomSize; - - gl_PointSize = min( magnification * size * gl_ProjectionMatrix[0].x, clamp ); + gl_PointSize = min( gl_Color.w * gl_ProjectionMatrix[0].x, clamp_size ); } diff --git a/src/CONVERTOR/VISUConvertor.cxx b/src/CONVERTOR/VISUConvertor.cxx index f34d4935..273b62a8 100644 --- a/src/CONVERTOR/VISUConvertor.cxx +++ b/src/CONVERTOR/VISUConvertor.cxx @@ -59,7 +59,11 @@ void parseFile(const char* theFileName) auto_ptr aCon(CreateConvertor(theFileName)); //aCon->GetSize(); //return; + aCon->BuildEntities(); + aCon->BuildFields(); + aCon->BuildMinMax(); const VISU::TMeshMap& aMeshMap = aCon->GetMeshMap(); + //return; VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ //continue; @@ -108,7 +112,7 @@ void parseFile(const char* theFileName) } */ } - goto OK; + //goto OK; } } } diff --git a/src/CONVERTOR/VISU_Convertor.cxx b/src/CONVERTOR/VISU_Convertor.cxx index 0a599cd1..f417ad07 100644 --- a/src/CONVERTOR/VISU_Convertor.cxx +++ b/src/CONVERTOR/VISU_Convertor.cxx @@ -56,7 +56,6 @@ const VISU::TMeshMap& VISU_Convertor ::GetMeshMap() { - if(!myIsDone) { myIsDone = true; Build();} return myMeshMap; } diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index d9145a7c..ea3debee 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -27,6 +27,11 @@ #ifndef VISU_Convertor_HeaderFile #define VISU_Convertor_HeaderFile +/*! + \file VISU_Convertor.hxx + \brief The file contains definitions for basic classes of the VISU CONVERTER package +*/ + #include "VISU_IDMapper.hxx" #include "VISU_ConvertorDef.hxx" @@ -48,6 +53,7 @@ namespace VISU typedef TVector TNames; //--------------------------------------------------------------- + //! Define a basic class for all MED entites which can be identified by its number struct TIntId: virtual TBaseStructure { vtkIdType myId; @@ -61,12 +67,17 @@ namespace VISU typedef std::map TMeshOnEntityMap; typedef std::map TGroupMap; + //! Define a basic class which corresponds to MED MESH entity + /*! + This class in its turn contains map of TMeshOnEntity and TGroup substructures, + also it keeps name and dimention of corresponding MED MESH entity. + */ struct TMesh: virtual TBaseStructure { - TMeshOnEntityMap myMeshOnEntityMap; - TGroupMap myGroupMap; - TName myName; - int myDim; + TMeshOnEntityMap myMeshOnEntityMap; //!< Contains corresponding meshes for MED ENTITIES + TGroupMap myGroupMap; //!< Contains map of bounded MED GROUPS + TName myName; //! Name of the corresponding MED MESH + int myDim; //! Dimension of the corresponding MED MESH TMesh(): myDim(0) {} @@ -75,11 +86,13 @@ namespace VISU //--------------------------------------------------------------- + //! Define a basic class which corresponds to MED PROFILE entity struct TSubProfile: virtual TBaseStructure {}; //--------------------------------------------------------------- + //! Define a containerfor MED PROFILE entities which belongs to the same MED ENTITY struct TProfile: virtual TIDMapper {}; @@ -93,18 +106,21 @@ namespace VISU //--------------------------------------------------------------- + //! Define a basic class for MED GAUSS entity struct TGauss: virtual TBaseStructure {}; //--------------------------------------------------------------- + //! Define a container for mesh generated from MED GAUSS and corresponding MED PROFILE struct TGaussSubMesh: virtual TBaseStructure { - PSubProfile mySubProfile; + PSubProfile mySubProfile; //!< Keeps reference on what submesh the Gauss Points are located }; //--------------------------------------------------------------- + //! Define a container for all TGaussSubMesh that belongs to the same MED ENTITY struct TGaussMesh: virtual TGaussPtsIDMapper {}; @@ -122,31 +138,38 @@ namespace VISU typedef std::map TFamilyMap; typedef std::map TFieldMap; + //! Define a basic class which corresponds to MED ENTITY + /*! + This class in its turn contains map of TGaussMesh and TProfile substructures, + also it keeps corresponding map of MED FAMILIES and FIELDS. + */ struct TMeshOnEntity: virtual TNamedIDMapper { - TGaussMeshMap myGaussMeshMap; - TProfileMap myProfileMap; + TGaussMeshMap myGaussMeshMap; //!< Contains map of Gauss mesh which exist on it + TProfileMap myProfileMap; //!< Contains map of Profile mesh which exist on it - TFamilyMap myFamilyMap; - TFieldMap myFieldMap; + TFamilyMap myFamilyMap; //!< Contains map of MED FAMILIES which belongs to it + TFieldMap myFieldMap; //!< Contains map of MED FIELDS which belongs to it - TName myMeshName; - TEntity myEntity; + TName myMeshName; //!< Contains name of the MED MESH where the it belongs to. + TEntity myEntity; //!< Referes to MED ENTITY where the it belongs to. }; //--------------------------------------------------------------- + //! Define a basic class for MED FAMILY entity struct TFamily: virtual TIntId, virtual TIDMapper { - TEntity myEntity; - TName myName; + TEntity myEntity; //!< Referes to MED ENTITY where the TFamily belongs to. + TName myName; //!< Contains name of the corresponding MED FAMILY }; //--------------------------------------------------------------- typedef std::set TFamilySet; + //! Define a basic class for MED GROUP entity struct TGroup: virtual TIDMapper { TFamilySet myFamilySet; @@ -157,16 +180,22 @@ namespace VISU typedef std::map TValField; typedef std::pair TMinMax; + //! Define a basic class for MED FIELD entity struct TField: virtual TIntId { - TEntity myEntity; - TName myName; - TName myMeshName; - TValField myValField; - TNames myCompNames; - TNames myUnitNames; - vtkIdType myNbComp; - + TEntity myEntity; //!< Referes to MED ENTITY where it belongs to. + TName myName; //!< Contains name of the corresponding MED FIELD + TName myMeshName; //!< Contains name of the MED MESH where it belongs to. + TValField myValField; //!< Contains sequence of values for corresponding MED TIMESTAMPS + TNames myCompNames; //!< Contains names of components of the MED FIELD + TNames myUnitNames; //!< Contains names of units of the MED FIELD + vtkIdType myNbComp; //!< Keeps number of components for the MED FIELD + + //! Calculate min/max values for each of the MED FIELD components among all its timestamps + /*! + Numeration of the components starts from 1. + Zero component contains min/max value for modulus of corresponding vector + */ virtual TMinMax GetMinMax(vtkIdType theCompID) = 0; @@ -179,19 +208,21 @@ namespace VISU //--------------------------------------------------------------- typedef std::pair TTime; + //! Define a basic class for MED TIMESTAMP entity struct TValForTime: virtual TIntId { - TEntity myEntity; - TName myMeshName; - TName myFieldName; + TEntity myEntity; //!< Referes to MED ENTITY where it belongs to. + TName myMeshName; //!< Contains name of the MED MESH where it belongs to. + TName myFieldName; //!< Contains name of the MED FIELD where it belongs to. TTime myTime; - PProfile myProfile; + PProfile myProfile; //!< Contains corresponding MED PROFILE where the MED TIEMSTMAP attached to PGaussMesh myGaussMesh; }; //--------------------------------------------------------------- + //! The utility function allows to write vtkUnstructuredGrid to a file with defined name void WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName); @@ -199,6 +230,20 @@ namespace VISU //--------------------------------------------------------------- +//! This class defines interface to read VTK interpretation of MED entities +/*! + It is the main class of the VISU CONVERTER package. + Following MED entities can be retrived from any MED file: + - mesh from corresponding MED ENTITIES; + - MED TIMESTAMPS; + - MED FAMILIES; + - MED GROUPS. + The class produce its work in two main steps: + 1. Perfrom parsing of MED file to get known what MED entities are pressent in it + 2. Get VTK representation for any existing MED entity + Also, it can perform some additional work to calculate expected amount of memory to build defined VTK representation + +*/ class VISU_Convertor { protected: @@ -211,58 +256,93 @@ public: ~VISU_Convertor() {}; + //! Get brief name of the corresponding source MED file virtual const std::string& GetName(){ return myName;} + //! Let known whether the source MED file parsed or not virtual int IsDone() const { return myIsDone; } + //! Defines what subtype of vtkDataSet is used for MED to VTK mapping typedef VISU::TVTKOutput TOutput; + //! This method perform first parsing of MED file to get known what MED entities are pressent in it virtual VISU_Convertor* Build() = 0; + //! This method perform first parsing of MED file to get known what MED mesh entities are pressent in it + virtual + VISU_Convertor* + BuildEntities() = 0; + + //! This method perform first parsing of MED file to get known what MED fields are pressent in it + virtual + VISU_Convertor* + BuildFields() = 0; + + //! This min /max calculation over existing MED fields + virtual + VISU_Convertor* + BuildMinMax() = 0; + + //! This method perform first parsing of MED file to get known what MED groups are pressent in it + virtual + VISU_Convertor* + BuildGroups() = 0; + + //! This method allow to get known what MED entities are present is the MED file virtual const VISU::TMeshMap& GetMeshMap(); + //! Get amount of memory to build VTK representations for all existing MED entities virtual float GetSize() = 0; + //! Get mesh for corresponding MED ENTITY virtual VISU::PNamedIDMapper GetMeshOnEntity(const std::string& theMeshName, const VISU::TEntity& theEntity) = 0; + //! Get amount of memory to build mesh for corresponding MED ENTITY virtual float GetMeshOnEntitySize(const std::string& theMeshName, const VISU::TEntity& theEntity) = 0; + //! Get mesh for corresponding MED FAMILY virtual VISU::PIDMapper GetFamilyOnEntity(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFamilyName) = 0; + + //! Get amount of memory to build mesh for corresponding MED FAMILY virtual float GetFamilyOnEntitySize(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFamilyName) = 0; + + //! Get mesh for corresponding MED GROUP virtual VISU::PIDMapper GetMeshOnGroup(const std::string& theMeshName, const std::string& theGroupName) = 0; + //! Get amount of memory to build mesh for corresponding MED GROUP virtual float GetMeshOnGroupSize(const std::string& theMeshName, const std::string& theGroupName) = 0; + //! Get mesh with attached values for corresponding MED TIMESTAMP virtual VISU::PIDMapper GetTimeStampOnMesh(const std::string& theMeshName, @@ -270,6 +350,7 @@ public: const std::string& theFieldName, int theStampsNum) = 0; + //! Get Gauss Points mesh with attached values for corresponding MED TIMESTAMP virtual VISU::PGaussPtsIDMapper GetTimeStampOnGaussPts(const std::string& theMeshName, @@ -277,6 +358,7 @@ public: const std::string& theFieldName, int theStampsNum) = 0; + //! Get amount of memory to build mesh for corresponding MED TIMESTAMP virtual float GetTimeStampSize(const std::string& theMeshName, @@ -284,18 +366,21 @@ public: const std::string& theFieldName, int theStampsNum) = 0; + //! Get amount of memory to build all MED TIMESTAMPS for corresponding MED FIELD virtual float GetFieldOnMeshSize(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFieldName) = 0; + //! Find MED FIELD container virtual const VISU::PField GetField(const std::string& theMeshName, VISU::TEntity theEntity, const std::string& theFieldName) = 0; + //! Find MED TIMESTAMP container virtual const VISU::PValForTime GetTimeStamp(const std::string& theMeshName, @@ -303,6 +388,7 @@ public: const std::string& theFieldName, int theStampsNum) = 0; + //! Allow to generate pretty name for MED TIMESTAMP static std::string GenerateName(const VISU::TTime& aTime); @@ -314,6 +400,7 @@ public: extern "C" { + //! Instatiate proper VISU_Convertor subclass VISU_Convertor* CreateConvertor(const std::string& theFileName); }; diff --git a/src/CONVERTOR/VISU_ConvertorDef.hxx b/src/CONVERTOR/VISU_ConvertorDef.hxx index 4744e653..0fedadc5 100644 --- a/src/CONVERTOR/VISU_ConvertorDef.hxx +++ b/src/CONVERTOR/VISU_ConvertorDef.hxx @@ -27,6 +27,11 @@ #ifndef VISU_ConvertorDef_HeaderFile #define VISU_ConvertorDef_HeaderFile +/*! + \file VISU_ConvertorDef.hxx + \brief The file contains predeclarations for basic classes of the VISU CONVERTER package +*/ + #include "MED_SharedPtr.hxx" namespace VISU diff --git a/src/CONVERTOR/VISU_ConvertorUtils.cxx b/src/CONVERTOR/VISU_ConvertorUtils.cxx index fcfb6f95..a4d0f3bb 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.cxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.cxx @@ -25,9 +25,18 @@ // Module : VISU #include "VISU_ConvertorUtils.hxx" + #include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif -namespace VISU{ +namespace VISU +{ void WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName) @@ -40,4 +49,32 @@ namespace VISU{ aWriter->Delete(); } + + TTimerLog + ::TTimerLog(int theIsDebug, + const std::string& theName): + myIsDebug(MYDEBUG + theIsDebug), + myTimerLog(vtkTimerLog::New()), + myPrefixPrinter(myIsDebug == 1), + myName(theName) + { + myCPUTime = myTimerLog->GetCPUTime(); + BEGMSG(myIsDebug > 1,"{\n"); + } + + TTimerLog + ::~TTimerLog() + { + myCPUTime = myTimerLog->GetCPUTime() - myCPUTime; + + if(myIsDebug > 1){ + BEGMSG(myIsDebug,"} = "<Delete(); + myTimerLog = NULL; + } + } diff --git a/src/CONVERTOR/VISU_ConvertorUtils.hxx b/src/CONVERTOR/VISU_ConvertorUtils.hxx index 1ef42e36..154589fc 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.hxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.hxx @@ -34,11 +34,30 @@ #include "MED_Utilities.hxx" class vtkUnstructuredGrid; +class vtkTimerLog; + +namespace MED +{ + class PrefixPrinter; +} namespace VISU{ void WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName); + + class TTimerLog + { + int myIsDebug; + double myCPUTime; + std::string myName; + vtkTimerLog* myTimerLog; + MED::PrefixPrinter myPrefixPrinter; + public: + TTimerLog(int theIsDebug, + const std::string& theName); + ~TTimerLog(); + }; } diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index ad2a643c..fd4dbd11 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -59,7 +59,7 @@ static int MYVTKDEBUG = 0; #ifdef _DEBUG_ static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; -//#define _DEXCEPT_ +#define _DEXCEPT_ #else static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; @@ -1765,6 +1765,50 @@ VISU_Convertor_impl {} +//--------------------------------------------------------------- +VISU_Convertor* +VISU_Convertor_impl +::Build() +{ + if(!myIsDone){ + myIsDone = true; + BuildEntities(); + BuildFields(); + BuildMinMax(); + BuildGroups(); + } + return this; +} + +VISU_Convertor* +VISU_Convertor_impl +::BuildEntities() +{ + return this; +} + +VISU_Convertor* +VISU_Convertor_impl +::BuildFields() +{ + return this; +} + +VISU_Convertor* +VISU_Convertor_impl +::BuildMinMax() +{ + return this; +} + +VISU_Convertor* +VISU_Convertor_impl +::BuildGroups() +{ + return this; +} + + //--------------------------------------------------------------- VISU::PNamedIDMapper VISU_Convertor_impl diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index 08771a4c..5e910090 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -49,15 +49,18 @@ class VISU_MergeFilter; namespace VISU { + //! Defines VISU enumeration of geometrical types enum EGeometry {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203, eQUAD4=204, eTRIA6=206,eQUAD8=208, eTETRA4=304, ePYRA5=305, ePENTA6=306, eHEXA8=308, eTETRA10=310, ePYRA13=313, ePENTA15=315, eHEXA20=320, ePOLYGONE=400, ePOLYEDRE=500, eNONE=-1}; + //! Get number of nodes for defined geometrical type vtkIdType VISUGeom2NbNodes(EGeometry theGeom); + //! Maps VISU geometrical type to VTK one vtkIdType VISUGeom2VTK(EGeometry theGeom); @@ -76,24 +79,27 @@ namespace VISU typedef float TCoord; //--------------------------------------------------------------- + //! Define an utility base class which is repsonsible for preventing repetion struct TIsVTKDone: virtual TBaseStructure { TIsVTKDone(); - bool myIsDone; - bool myIsVTKDone; + bool myIsDone; //!< Say, is the corresponding MED entity already loaded into intermediate data structure + bool myIsVTKDone; //!< Say, is the corresponding intermediate data structure already mapped into VTK representation }; //--------------------------------------------------------------- + //! Define an utility base class which allow to keep calculated number of cells and their size struct TSizeCounter: virtual TIsVTKDone { TSizeCounter(); - vtkIdType myNbCells; - vtkIdType myCellsSize; + vtkIdType myNbCells; //!< Number of cells contained into corresponding sublclass + vtkIdType myCellsSize; //!< Size of cells contained into corresponding sublclass }; //--------------------------------------------------------------- + //! Define a container for VTK representation class TSource: public virtual TSizeCounter { protected: @@ -101,9 +107,11 @@ namespace VISU public: TSource(); + //! This method allow to create corresponding VTK data set by demand (not at once) const TVTKSource& GetSource() const; + //! Reimplement the TIDMapper::GetVTKOutput virtual TVTKOutput* GetVTKOutput(); @@ -111,6 +119,10 @@ namespace VISU //--------------------------------------------------------------- + //! Define a container for VTK representation + /*! + This container allow to combine other VTK representation into single one. + */ class TAppendFilter: public virtual TIsVTKDone, public virtual TIDMapper { @@ -119,9 +131,11 @@ namespace VISU public: TAppendFilter(); + //! This method allow to create corresponding VTK filter by demand (not at once) const TVTKAppendFilter& GetFilter() const; + //! Reimplement the TIDMapper::GetVTKOutput virtual TVTKOutput* GetVTKOutput(); @@ -129,6 +143,10 @@ namespace VISU //--------------------------------------------------------------- + //! Define a container for VTK representation + /*! + This container allow to assign data to mesh and represent them into single VTK representation + */ class TMergeFilter: public virtual TIsVTKDone, public virtual TIDMapper { @@ -137,9 +155,11 @@ namespace VISU public: TMergeFilter(); + //! This method allow to create corresponding VTK filter by demand (not at once) const TVTKMergeFilter& GetFilter() const; + //! Reimplement the TIDMapper::GetVTKOutput virtual TVTKOutput* GetVTKOutput(); @@ -151,25 +171,34 @@ namespace VISU typedef TSlice TCoordSlice; typedef TCSlice TCCoordSlice; + //! This class is responsible for representation of mesh nodes class TPointCoords: public virtual TBaseStructure { protected: - vtkIdType myDim; - vtkIdType myNbPoints; + vtkIdType myDim; //!< Dimension of the nodal coordinates + vtkIdType myNbPoints; //!< Number of nodes in corresponding mesh - TCoordArray myCoord; - TVTKPoints myPoints; + //! An container for coordinates of the nodes + /*! + Usage of slices allow to minimize amount of memory to store the nodal coordinates and + provide unifirm way of conversation with this coordinates (independant from mesh dimension) + */ + TCoordArray myCoord; + TVTKPoints myPoints; //!< VTK representation for the mesh nodes public: TPointCoords(); + //! To initilize the class void Init(vtkIdType theNbPoints, vtkIdType theDim); + //! Get slice of coordinates for defined node (const version) TCCoordSlice GetCoordSlice(vtkIdType theNodeId) const; + //! Get slice of coordinates for defined node TCoordSlice GetCoordSlice(vtkIdType theNodeId); @@ -192,35 +221,46 @@ namespace VISU typedef TVector TVectorID; typedef std::map TObj2VTKID; + //! This class is responsible for representation of mesh nodes + /*! + In additition to its base functionlity it support mapping of VTK to object numeration and + keeps names for each of nodes. + */ class TNamedPointCoords: public virtual TPointCoords { protected: typedef TVector TPointsDim; - TPointsDim myPointsDim; - TVectorID myVectorID; - TObj2VTKID myObj2VTKID; + TPointsDim myPointsDim; //!< Keeps name of each dimension + TVectorID myVectorID; //!< Keeps object¶ numeration + TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one public: + //! To initilize the class (numeration of the nodes can be missed) void Init(vtkIdType theNbPoints, vtkIdType theDim, const TVectorID& theVectorID = TVectorID()); + //! Get name for defined dimension std::string& GetName(vtkIdType theDim); + //! Get name for defined dimension (const version) const std::string& GetName(vtkIdType theDim) const; + //! Get object number for node by its VTK one virtual vtkIdType GetObjID(vtkIdType theID) const; + //! Get VTK number for node by its object one virtual vtkIdType GetVTKID(vtkIdType theID) const; + //! Get name of node by its object number virtual std::string GetNodeName(vtkIdType theObjID) const; @@ -229,13 +269,14 @@ namespace VISU //--------------------------------------------------------------- + //! Specialize TMesh to provide VTK mapping for nodes struct TMeshImpl: virtual TMesh, virtual TIsVTKDone { - PNamedPointCoords myNamedPointCoords; + PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes - TVTKPoints myPoints; - vtkIdType myNbPoints; + TVTKPoints myPoints; //!< Keeps VTK representation of the nodes + vtkIdType myNbPoints; //!< Keeps number of the nodes TMeshImpl(); }; @@ -246,20 +287,27 @@ namespace VISU typedef TVector TSubMeshID; typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus; + //! Specialize TSubProfile to provide VTK mapping struct TSubProfileImpl: virtual TSubProfile, virtual TSource { TSubProfileImpl(); - EGeometry myGeom; - std::string myName; + EGeometry myGeom; //!< Defines to what geometrical type the MED PROFILE belong to + std::string myName; //!< Keeps its name + //! Get object number of mesh cell by its VTK one virtual vtkIdType GetElemObjID(int theVtkI) const; - ESubMeshStatus myStatus; - TSubMeshID mySubMeshID; + //! Keeps status of the structure + /*! + In some cases MED file does not use MED PROFILES, but at VISU creates corresponding data strucutre + in order to construct mesh for MED TIEMSTAMPS in uniform way. + */ + ESubMeshStatus myStatus; + TSubMeshID mySubMeshID; //!< Keeps numbers of mesh cell which contain the MED PROFILE }; typedef SharedPtr PSubProfileImpl; @@ -271,81 +319,97 @@ namespace VISU typedef TVector TSubProfileArr; typedef std::map TGeom2SubProfile; + //! Specialize TProfile to provide VTK mapping for MED TIMESTAMP mesh struct TProfileImpl: virtual TProfile, virtual TAppendFilter { TProfileImpl(); - bool myIsAll; + bool myIsAll; //!< Say, whether the MED TIMESTAMP defined on all MED ENTITY or not + //! Reimplement the TIDMapper::GetNodeObjID virtual vtkIdType GetNodeObjID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetNodeVTKID virtual vtkIdType GetNodeVTKID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetNodeCoord virtual float* GetNodeCoord(vtkIdType theObjID); + //! Reimplement the TIDMapper::GetElemObjID virtual vtkIdType GetElemObjID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetElemVTKID virtual vtkIdType GetElemVTKID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetElemCell virtual vtkCell* GetElemCell(vtkIdType theObjID); + //! Reimplement the TIDMapper::GetVTKOutput virtual TVTKOutput* GetVTKOutput(); - TID2ID myElemObj2VTKID; - TSubProfileArr mySubProfileArr; - PNamedPointCoords myNamedPointCoords; - TMeshOnEntityImpl* myMeshOnEntity; + TID2ID myElemObj2VTKID; //!< Keeps object to VTK numeration mapping + TSubProfileArr mySubProfileArr; //!< Keeps sequence of TSubProfiles as they were added into TAppendFilter + PNamedPointCoords myNamedPointCoords; //!< Keeps reference on the same TNamedPointCoords as TMesh + TMeshOnEntityImpl* myMeshOnEntity; // PProfileImpl; //--------------------------------------------------------------- + //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh struct TIDMapperFilter: virtual TMergeFilter { - TAppendFilter myIDMapper; - TSource mySource; + TAppendFilter myIDMapper; //!< Responsible for numbering + TSource mySource; //!< Keeps assigned data + //! Reimplement the TIDMapper::GetNodeObjID virtual vtkIdType GetNodeObjID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetNodeVTKID virtual vtkIdType GetNodeVTKID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetNodeCoord virtual float* GetNodeCoord(vtkIdType theObjID); + //! Reimplement the TIDMapper::GetElemObjID virtual vtkIdType GetElemObjID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetElemVTKID virtual vtkIdType GetElemVTKID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetElemCell virtual vtkCell* GetElemCell(vtkIdType theObjID); + //! Reimplement the TIDMapper::GetVTKOutput virtual TVTKOutput* GetVTKOutput(); @@ -354,28 +418,38 @@ namespace VISU //--------------------------------------------------------------- + //! Specialize TGauss to provide more detail information of the MED GAUSS entity for VTK mapping struct TGaussImpl: virtual TGauss { - EGeometry myGeom; - std::string myName; - vtkIdType myNbPoints; + EGeometry myGeom; //!< Define, to which geometrical type the MED GAUSS entity belongs + std::string myName; //!< Keeps name of the MED GAUSS entity + vtkIdType myNbPoints; // PGaussImpl; //--------------------------------------------------------------- + //! Specialize TGaussSubMesh to provide VTK mapping for the entity struct TGaussSubMeshImpl: virtual TGaussSubMesh, virtual TSource { TGaussSubMeshImpl(); + //! To implement the TGaussPtsIDMapper::GetObjID virtual TGaussPointID GetObjID(vtkIdType theID) const; - PGaussImpl myGauss; + PGaussImpl myGauss; // PGaussSubMeshImpl; @@ -384,40 +458,48 @@ namespace VISU typedef TVector TGaussSubMeshArr; typedef std::map TGeom2GaussSubMesh; + //! Specialize TGaussMesh to provide VTK mapping for the entity struct TGaussMeshImpl: virtual TGaussMesh, virtual TAppendFilter { TGaussMeshImpl(); + //! Reimplement the TGaussPtsIDMapper::GetObjID virtual TGaussPointID GetObjID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetVTKOutput virtual TVTKOutput* GetVTKOutput(); + //! Reimplement the TGaussPtsIDMapper::GetParent virtual TNamedIDMapper* GetParent(); - TSource mySource; - TNamedIDMapper* myParent; - TGaussSubMeshArr myGaussSubMeshArr; - TGeom2GaussSubMesh myGeom2GaussSubMesh; + TSource mySource; //!< Keeps VTK representation of the Gauss Points + TNamedIDMapper* myParent; //!< Refer to parent mesh + TGaussSubMeshArr myGaussSubMeshArr; //!< Keeps sequence of TGaussSubMesh as they were added into TAppendFilter + TGeom2GaussSubMesh myGeom2GaussSubMesh; //!< Keeps TGaussSubMesh according to their geometrical type }; typedef SharedPtr PGaussMeshImpl; + //--------------------------------------------------------------- + //! Specialize TGaussPtsIDMapper to provide VTK mapping for MED TIMESTAMP mesh struct TGaussPtsIDFilter: virtual TIDMapperFilter, virtual TGaussPtsIDMapper { PGaussPtsIDMapper myGaussPtsIDMapper; + //! Reimplement the TGaussPtsIDMapper::GetObjID virtual TGaussPointID GetObjID(vtkIdType theID) const; + //! Reimplement the TGaussPtsIDMapper::GetParent virtual TNamedIDMapper* GetParent(); @@ -429,18 +511,22 @@ namespace VISU typedef TVector TConnect; typedef TVector TCell2Connect; + //! The class is responsible for mapping of cells of defined geometrical type struct TSubMeshImpl: virtual TSource { + + //! To implement the TIDMapper::GetElemObjID virtual vtkIdType GetElemObjID(vtkIdType theID) const; + //! To implement the TNamedIDMapper::GetElemName virtual std::string GetElemName(vtkIdType theObjID) const; vtkIdType myStartID; - TCell2Connect myCell2Connect; + TCell2Connect myCell2Connect; //!< Contains connectivity for the cells }; typedef SharedPtr PSubMeshImpl; @@ -449,39 +535,46 @@ namespace VISU typedef std::map TGeom2SubMesh; typedef TVector TSubMeshArr; + //! Specialize TMeshOnEntity to provide VTK mapping for the entity struct TMeshOnEntityImpl: virtual TMeshOnEntity, virtual TAppendFilter, virtual TSizeCounter { + //! Reimplement the TIDMapper::GetNodeVTKID virtual vtkIdType GetNodeVTKID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetNodeObjID virtual vtkIdType GetNodeObjID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetElemVTKID virtual vtkIdType GetElemVTKID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetElemObjID virtual vtkIdType GetElemObjID(vtkIdType theID) const; + //! Reimplement the TNamedIDMapper::GetNodeName virtual std::string GetNodeName(vtkIdType theObjID) const; + //! Reimplement the TNamedIDMapper::GetElemName virtual std::string GetElemName(vtkIdType theObjID) const; - TID2ID myElemObj2VTKID; - TSubMeshArr mySubMeshArr; - PNamedPointCoords myNamedPointCoords; + TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping + TSubMeshArr mySubMeshArr; //!< Keeps sequence of TSubMeshImpl as they were added into TAppendFilter + PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping - TGeom2SubMesh myGeom2SubMesh; + TGeom2SubMesh myGeom2SubMesh; //!< Keeps TSubMeshImpl according to their geometrical type }; typedef SharedPtr PMeshOnEntityImpl; @@ -489,33 +582,39 @@ namespace VISU //--------------------------------------------------------------- typedef std::map TGeom2SubMeshID; + //! Specialize TFamily to provide VTK mapping for the entity struct TFamilyImpl: virtual TFamily, virtual TSource { + //! Reimplement the TIDMapper::GetNodeObjID vtkIdType GetNodeObjID(vtkIdType theID) const ; + //! Reimplement the TIDMapper::GetNodeVTKID virtual vtkIdType GetNodeVTKID(vtkIdType theID) const ; + //! Reimplement the TIDMapper::GetElemVTKID virtual vtkIdType GetElemVTKID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetElemObjID virtual vtkIdType GetElemObjID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetVTKOutput virtual TVTKOutput* GetVTKOutput(); - PNamedPointCoords myNamedPointCoords; - TID2ID myElemObj2VTKID; - TSubMeshID myMeshID; + PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping + TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping + TSubMeshID myMeshID; //!< Keeps numbers of mesh elements that belongs to the MED FAMILY - TGeom2SubMeshID myGeom2SubMeshID; + TGeom2SubMeshID myGeom2SubMeshID; //!< Keeps TSubMeshID according to their geometrical type }; typedef SharedPtr PFamilyImpl; @@ -524,31 +623,37 @@ namespace VISU typedef std::pair TNbASizeCells; typedef TVector TFamilyArr; + //! Specialize TGroup to provide VTK mapping for the entity struct TGroupImpl: virtual TGroup, virtual TAppendFilter { + //! Calculate pair of values - number of cells and its size TNbASizeCells GetNbASizeCells() const; + //! Reimplement the TIDMapper::GetElemVTKID virtual vtkIdType GetElemVTKID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetElemObjID virtual vtkIdType GetElemObjID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetNodeObjID virtual vtkIdType GetNodeObjID(vtkIdType theID) const; + //! Reimplement the TIDMapper::GetNodeVTKID virtual vtkIdType GetNodeVTKID(vtkIdType theID) const; - TID2ID myElemObj2VTKID; - TFamilyArr myFamilyArr; - PNamedPointCoords myNamedPointCoords; + TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping + TFamilyArr myFamilyArr; //!< Keeps sequence of TFamily as they were added into TAppendFilter + PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping }; typedef SharedPtr PGroupImpl; @@ -556,16 +661,19 @@ namespace VISU //--------------------------------------------------------------- typedef TVector TMinMaxArr; + //! Specialize TField to provide VTK mapping for the entity struct TFieldImpl: virtual TField { - vtkIdType myDataSize; + vtkIdType myDataSize; //!< Keeps size of the assigned data - TMinMaxArr myMinMaxArr; + TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD + //! Implement the TField::GetMinMax virtual TMinMax GetMinMax(vtkIdType theCompID); + //! To initialize the data structure void InitArrays(vtkIdType theNbComp); @@ -582,29 +690,35 @@ namespace VISU typedef TVector TCValueSliceArr; typedef TVector TValueSliceArr; + //! Define a container to get access to data assigned to mesh struct TMeshValue { - TValue myValue; + TValue myValue; //!< Keeps all values as one dimensional sequence - vtkIdType myNbElem; - vtkIdType myNbComp; - vtkIdType myNbGauss; - vtkIdType myStep; + vtkIdType myNbElem; //!< Defines number of mesh elements where the data assigned to + vtkIdType myNbComp; //!< Keeps number of components of corresponding MED FIELD + vtkIdType myNbGauss; //!< Defines number of Gauss Points + vtkIdType myStep; //! Internal variable + //! To intitilize the data strucutre void Init(vtkIdType theNbElem, vtkIdType theNbGauss, vtkIdType theNbComp); + //! To get assigned values first by Gauss Points and then by components (constant version) TCValueSliceArr GetGaussValueSliceArr(vtkIdType theElemId) const; + //! To get assigned values first by Gauss Points and then by components TValueSliceArr GetGaussValueSliceArr(vtkIdType theElemId); + //! To get assigned values first by components and then by Gauss Points (constant version) TCValueSliceArr GetCompValueSliceArr(vtkIdType theElemId) const; + //! To get assigned values first by components and then by Gauss Points TValueSliceArr GetCompValueSliceArr(vtkIdType theElemId); }; @@ -613,21 +727,25 @@ namespace VISU //--------------------------------------------------------------- typedef std::map TGeom2Value; + //! Specialize TValForTime to provide VTK mapping for the entity struct TValForTimeImpl: virtual TValForTime { - PGaussPtsIDFilter myGaussPtsIDFilter; - PIDMapperFilter myIDMapperFilter; - TGeom2Value myGeom2Value; - vtkIdType myNbGauss; + PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points + PIDMapperFilter myIDMapperFilter; //!< Keep VTK representation for ordinary mesh and data + TGeom2Value myGeom2Value; //!< Keep value that is assigned to the mesh + vtkIdType myNbGauss; //!< Keep number of Gauss Points TValForTimeImpl(); + //! Get mesh data for defined geometrical type (constant version) const TMeshValue& GetMeshValue(EGeometry theGeom) const; + //! Get mesh data for defined geometrical type TMeshValue& GetMeshValue(EGeometry theGeom); + //! Get number of Gauss Points for defined geometrical type virtual int GetNbGauss(EGeometry theGeom) const; @@ -636,6 +754,11 @@ namespace VISU } +//! This class perfroms mapping of intermediate data strucutres into corresponding VTK representation +/*! + It implements VISU_Convertor public interface and declare new pure virtual functions + to fill its intermediate data structure from a MED source +*/ class VISU_Convertor_impl: public VISU_Convertor { public: @@ -644,49 +767,75 @@ public: virtual ~VISU_Convertor_impl(); + //! Just to define default behaviour virtual VISU_Convertor* - Build() - { - return this; - } + Build(); + + //! Just to define default behaviour + virtual + VISU_Convertor* + BuildEntities(); + + //! Just to define default behaviour + virtual + VISU_Convertor* + BuildFields(); + + //! Just to define default behaviour + virtual + VISU_Convertor* + BuildMinMax(); + + //! Just to define default behaviour + virtual + VISU_Convertor* + BuildGroups(); + //! Implemention of the VISU_Convertor::GetSize virtual float GetSize(); + //! Implemention of the VISU_Convertor::GetMeshOnEntity virtual VISU::PNamedIDMapper GetMeshOnEntity(const std::string& theMeshName, const VISU::TEntity& theEntity); + //! Implemention of the VISU_Convertor::GetMeshOnEntitySize virtual float GetMeshOnEntitySize(const std::string& theMeshName, const VISU::TEntity& theEntity); + //! Implemention of the VISU_Convertor::GetFamilyOnEntity virtual VISU::PIDMapper GetFamilyOnEntity(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFamilyName); + //! Implemention of the VISU_Convertor::GetFamilyOnEntitySize virtual float GetFamilyOnEntitySize(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFamilyName); + //! Implemention of the VISU_Convertor::GetMeshOnGroup virtual VISU::PIDMapper GetMeshOnGroup(const std::string& theMeshName, const std::string& theGroupName); + //! Implemention of the VISU_Convertor::GetMeshOnGroupSize virtual float GetMeshOnGroupSize(const std::string& theMeshName, const std::string& theGroupName); + //! Implemention of the VISU_Convertor::GetTimeStampOnMesh virtual VISU::PIDMapper GetTimeStampOnMesh(const std::string& theMeshName, @@ -694,6 +843,7 @@ public: const std::string& theFieldName, int theStampsNum); + //! Implemention of the VISU_Convertor::GetTimeStampSize virtual float GetTimeStampSize(const std::string& theMeshName, @@ -701,6 +851,7 @@ public: const std::string& theFieldName, int theStampsNum); + //! Implemention of the VISU_Convertor::GetTimeStampOnGaussPts virtual VISU::PGaussPtsIDMapper GetTimeStampOnGaussPts(const std::string& theMeshName, @@ -708,18 +859,21 @@ public: const std::string& theFieldName, int theStampsNum); + //! Implemention of the VISU_Convertor::GetFieldOnMeshSize virtual float GetFieldOnMeshSize(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFieldName); + //! Implemention of the VISU_Convertor::GetField virtual const VISU::PField GetField(const std::string& theMeshName, VISU::TEntity theEntity, const std::string& theFieldName); + //! Implemention of the VISU_Convertor::GetTimeStamp virtual const VISU::PValForTime GetTimeStamp(const std::string& theMeshName, @@ -728,25 +882,30 @@ public: int theStampsNum); protected: + //! An utility method to find TMesh by its name VISU::PMeshImpl FindMesh(const std::string& theMeshName); + //! An utility method to find TMeshOnEntity by name of its parent mesh and entity typedef boost::tuple TFindMeshOnEntity; TFindMeshOnEntity FindMeshOnEntity(const std::string& theMeshName, const VISU::TEntity& theEntity); + //! An utility method to find TFamily by name of its parent mesh, corresponding entity and its name typedef boost::tuple TFindFamilyOnEntity; TFindFamilyOnEntity FindFamilyOnEntity(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFamilyName); + //! An utility method to find Group by name of its parent mesh and its name typedef boost::tuple TFindMeshOnGroup; TFindMeshOnGroup FindMeshOnGroup(const std::string& theMeshName, const std::string& theGroupName); + //! An utility method to find TField by name of its parent mesh, corresponding entity and its name typedef boost::tuple @@ -40,42 +45,58 @@ namespace VISU using MED::SharedPtr; //--------------------------------------------------------------- + //! Defines a basic class for intemediate data structures struct TBaseStructure { + //! Just to provide possibility of dynamic navigation through the class hierarchy virtual ~TBaseStructure() {} + + std::string myEntry; //!< To simplify publication of the object tree }; typedef SharedPtr PBaseStructure; //--------------------------------------------------------------- typedef vtkUnstructuredGrid TVTKOutput; + //! Defines a basic abstract interface for VTK to object ID's and backward mapping + /*! + Where object ID means ID which attached to corresponding MED entity. + For example, each MED node can have its own ID as well as any other mesh cell + */ struct TIDMapper: virtual TBaseStructure { + //! Get node object ID for corresponding VTK ID virtual vtkIdType GetNodeObjID(vtkIdType theID) const; + //! Get node VTK ID for corresponding object ID virtual vtkIdType GetNodeVTKID(vtkIdType theID) const; + //! Get coordinates of node for corresponding object ID virtual float* GetNodeCoord(vtkIdType theObjID); + //! Get cell object ID for corresponding VTK ID virtual vtkIdType GetElemObjID(vtkIdType theID) const; + //! Get cell VTK ID for corresponding object ID virtual vtkIdType GetElemVTKID(vtkIdType theID) const; + //! Get VTK representation of mesh cell for corresponding object ID virtual vtkCell* GetElemCell(vtkIdType theObjID); + //! Get VTK representation of mesh for corresponding MED entity virtual TVTKOutput* GetVTKOutput() = 0; @@ -84,12 +105,18 @@ namespace VISU //--------------------------------------------------------------- + //! Defines an abstract interface for VTK to object ID's and backward mapping + /*! + This class defines some additional methods that allow get names for corresponding mesh elements + */ struct TNamedIDMapper: virtual TIDMapper { + //! Get name of mesh node for corresponding object ID virtual std::string GetNodeName(vtkIdType theObjID) const = 0; + //! Get name of mesh cell for corresponding object ID virtual std::string GetElemName(vtkIdType theObjID) const = 0; @@ -98,16 +125,19 @@ namespace VISU //--------------------------------------------------------------- - typedef vtkIdType TCellID; + typedef vtkIdType TCellID; typedef vtkIdType TLocalPntID; + //! Defines a type that represent complex ID for defined Gauss Point typedef std::pair TGaussPointID; struct TGaussPtsIDMapper: virtual TIDMapper { + //! Gets complex Gauss Point ID by its VTK ID virtual TGaussPointID GetObjID(vtkIdType theID) const = 0; + //! Gets parent TNamedIDMapper, which contains reference mesh cells virtual TNamedIDMapper* GetParent() = 0; diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 4ab71595..5616c086 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -49,16 +49,12 @@ using MED::EBooleen; #ifdef _DEBUG_ static int MYDEBUG = 0; static int MYVALUEDEBUG = 0; -static int MYMEMORYDEBUG = 0; -static int MYTHREADDEBUG = 0; static int MY_FAMILY_DEBUG = 0; static int MY_GROUP_DEBUG = 0; -//#define _DEXCEPT_ +#define _DEXCEPT_ #else static int MYDEBUG = 0; static int MYVALUEDEBUG = 0; -static int MYMEMORYDEBUG = 0; -static int MYTHREADDEBUG = 0; static int MY_FAMILY_DEBUG = 0; static int MY_GROUP_DEBUG = 0; #endif @@ -312,6 +308,7 @@ namespace const MED::TGeom2Size& theGeom2Size, VISU::TMEDValForTime& theValForTime) { + TTimerLog aTimerLog(MYDEBUG,"InitProfile"); INITMSG(MYDEBUG,"InitProfile"<myGeom2SubProfile; - const MED::TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile(); const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo(); const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss(); @@ -429,6 +426,7 @@ namespace const MED::TGeom2Size& theGeom2Size, VISU::TMEDValForTime& theValForTime) { + TTimerLog aTimerLog(MYDEBUG,"InitGaussMesh"); INITMSG(MYDEBUG,"InitGaussMesh"< TFamilyCounterMap; - void BuildMeshOnEntityMap(PMEDMesh theMesh, - TFamilyCounterMap& theFamilyID2CellsSize, const MED::TEntityInfo& theEntityInfo, const MED::PNodeInfo& theNodeInfo, const MED::PWrapper& theMEDWrapper) { + TTimerLog aTimerLog(MYDEBUG,"BuildMeshOnEntityMap"); INITMSG(MYDEBUG,"BuildMeshOnEntityMap"<myMeshInfo; const std::string& aMeshName = theMesh->myName; TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; @@ -524,7 +522,8 @@ namespace aMeshOnEntity->myEntity = aVEntity; aMeshOnEntity->myMeshName = aMeshName; aMeshOnEntity->myGeom2Size = aGeom2Size; - + TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize; + INITMSG(MYDEBUG, "- aMEntity = "< PFieldMinMax; - - - //--------------------------------------------------------------- - void - GetFieldMinMax(PFieldMinMax theFieldMinMax) - { - theFieldMinMax->Calculate(); - } - - - //--------------------------------------------------------------- - struct TCalculateMinMax - { - VISU::PMEDMesh myMesh; - MED::TEntityInfo myEntityInfo; - MED::TMKey2Profile myMKey2Profile; - MED::TKey2Gauss myKey2Gauss; - MED::PWrapper myMEDWrapper; - - TCalculateMinMax(const VISU::PMEDMesh& theMesh, - const MED::TEntityInfo& theEntityInfo, - const MED::TMKey2Profile& theMKey2Profile, - const MED::TKey2Gauss& theKey2Gauss, - const MED::PWrapper& theMEDWrapper): - myMesh(theMesh), - myEntityInfo(theEntityInfo), - myMKey2Profile(theMKey2Profile), - myKey2Gauss(theKey2Gauss), - myMEDWrapper(theMEDWrapper) - { - INITMSG(MYMEMORYDEBUG,"TCalculateMinMax() - "<GetNbFields(); - MED::PMeshInfo aMeshInfo = myMesh->myMeshInfo; - const std::string& aMeshName = myMesh->myName; - INITMSG(MYDEBUG,"MinMaxCalculation: aNbFields = "<GetPFieldInfo(aMeshInfo,iField); - TInt aNbComp = aFieldInfo->GetNbComp(); - std::string aFieldName = aFieldInfo->GetName(); - - MED::TGeom2Size aGeom2Size; - MED::EEntiteMaillage aMEntity; - TInt aNbTimeStamps = myMEDWrapper->GetNbTimeStamps(aFieldInfo, - myEntityInfo, - aMEntity, - aGeom2Size); - if(aNbTimeStamps < 1) - continue; - - TEntity aVEntity = MEDEntityToVTK(aMEntity); - PMEDMeshOnEntity aMeshOnEntity = myMesh->myMeshOnEntityMap[aVEntity]; - TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; - PMEDField aField = aFieldMap[aFieldName]; - - PFieldMinMax aFieldMinMax(new TFieldMinMax(aField, - aFieldInfo, - aNbTimeStamps, - aMEntity, - aGeom2Size, - myMKey2Profile, - myKey2Gauss, - myMEDWrapper)); - - boost::thread aThread(boost::bind(&GetFieldMinMax,aFieldMinMax)); - } - } - }; - typedef SharedPtr PCalculateMinMax; - - - //--------------------------------------------------------------- - void - CalculateMinMax(PCalculateMinMax theCalculateMinMax) - { - theCalculateMinMax->Calculate(); - } - - //--------------------------------------------------------------- void BuildFieldMap(PMEDMesh theMesh, const MED::TEntityInfo& theEntityInfo, - const MED::TMKey2Profile& theMKey2Profile, - const MED::TKey2Gauss& theKey2Gauss, MED::PWrapper theMEDWrapper) { + TTimerLog aTimerLog(MYDEBUG,"BuildFieldMap"); TInt aNbFields = theMEDWrapper->GetNbFields(); MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo; const std::string& aMeshName = theMesh->myName; INITMSG(MYDEBUG,"BuildFieldMap: aNbFields = "<GetPFieldInfo(aMeshInfo,iField); TInt aNbComp = aFieldInfo->GetNbComp(); std::string aFieldName = aFieldInfo->GetName(); @@ -895,15 +673,14 @@ namespace } for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){ + TTimerLog aTimerLog(MYDEBUG,"GetPTimeStampInfo"); MED::PTimeStampInfo aTimeStampInfo = theMEDWrapper->GetPTimeStampInfo(aFieldInfo, aMEntity, aGeom2Size, iTimeStamp); TFloat aDt = aTimeStampInfo->GetDt(); std::string anUnitDt = aTimeStampInfo->GetUnitDt(); - MED::PTimeStampVal aTimeStampVal = theMEDWrapper->GetPTimeStampVal(aTimeStampInfo, - theMKey2Profile, - theKey2Gauss); + TValField& aValField = aField->myValField; PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime()); aValForTime->myId = iTimeStamp; @@ -913,14 +690,6 @@ namespace aValForTime->myNbGauss = aTimeStampInfo->GetNbGauss(); aValForTime->myTime = VISU::TTime(aDt,anUnitDt); INITMSG(MYDEBUG,"aDt = '"<myMeshInfo; MED::TEntity2FamilySet aEntity2FamilySet = MED::GetEntity2FamilySet(theMEDWrapper,theEntity2TGeom2ElemInfo,theFamilyInfoSet); MED::TEntity2FamilySet::const_iterator aEntity2FamilySetIter = aEntity2FamilySet.begin(); @@ -945,6 +715,7 @@ namespace TEntity aVEntity = MEDEntityToVTK(aMEntity); PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity]; + const TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize; TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; if(aFamilyTSizeSet.empty()) @@ -973,8 +744,8 @@ namespace aFamily->myNbCells = aSize; aFamily->myCellsSize = 0; - TFamilyCounterMap::const_iterator anIter = theFamilyID2CellsSize.find(anId); - if(anIter != theFamilyID2CellsSize.end()) + TFamilyID2CellsSize::const_iterator anIter = aFamilyID2CellsSize.find(anId); + if(anIter != aFamilyID2CellsSize.end()) aFamily->myCellsSize = anIter->second; INITMSG(MY_FAMILY_DEBUG, @@ -1004,7 +775,9 @@ namespace BuildGroupMap(PMEDMesh theMesh, const MED::TFamilyInfoSet& theFamilyInfoSet) { - INITMSG(MYDEBUG,"BuildGroupMap:\n"); + TTimerLog aTimerLog(MYDEBUG,"BuildGroupMap"); + INITMSG(MYDEBUG,"BuildGroupMap\n"); + TGroupMap& aGroupMap = theMesh->myGroupMap; MED::TGroupInfo aGroupInfo = MED::GetGroupInfo(theFamilyInfoSet); MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin(); @@ -1137,6 +910,20 @@ namespace return myElemInfo->GetElemName(theObjID); return TSubMeshImpl::GetElemName(theObjID); } + + struct TSetIsDone + { + bool& myIsDone; + TSetIsDone(bool& theIsDone): + myIsDone(theIsDone) + {} + + ~TSetIsDone() + { + myIsDone = true; + } + + }; } @@ -1149,7 +936,11 @@ CreateConvertor(const string& theFileName) } VISU_MedConvertor -::VISU_MedConvertor(const string& theFileName) +::VISU_MedConvertor(const string& theFileName): + myIsEntitiesDone(false), + myIsFieldsDone(false), + myIsGroupsDone(false), + myIsMinMaxDone(false) { myFileInfo.setFile(QString(theFileName.c_str())); myName = myFileInfo.baseName().latin1(); @@ -1159,42 +950,41 @@ VISU_MedConvertor //--------------------------------------------------------------- VISU_Convertor* VISU_MedConvertor -::Build() +::BuildEntities() { - MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); + if(myIsEntitiesDone) + return this; - MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(aMed); - MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(aMed); + TSetIsDone aSetIsDone(myIsEntitiesDone); + TTimerLog aTimerLog(MYDEBUG,"BuildEntities"); + MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); TInt aNbMeshes = aMed->GetNbMeshes(); TMeshMap& aMeshMap = myMeshMap; - MSG(MYDEBUG,"VISU_MedConvertor::Build()"); - INITMSG(MYDEBUG,"GetNbMeshes() = "<GetPMeshInfo(iMesh); + std::string aMeshName = aMeshInfo->GetName(); + TInt aDim = aMeshInfo->GetDim(); MED::PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo); - MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo); - - MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo = - MED::GetEntity2TGeom2ElemInfo(aMed,aMeshInfo,aEntityInfo); - - // creating TMesh structure and TMeshOnEntityMap - TInt aDim = aMeshInfo->GetDim(); - std::string aMeshName = aMeshInfo->GetName(); + MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo); + // creating TMesh structure and TMeshOnEntityMap PMEDMesh aMesh = aMeshMap[aMeshName](new TMEDMesh()); aMesh->myDim = aDim; aMesh->myName = aMeshName; aMesh->myNbPoints = aNodeInfo->GetNbElem(); aMesh->myMeshInfo = aMeshInfo; - aMesh->myEntityInfo = aEntityInfo; + aMesh->myEntityInfo = anEntityInfo; aMesh->myNamedPointCoords(new TMEDNamedPointCoords()); INITMSG(MYDEBUG,"aMeshName = '"<GetNbMeshes(); + TMeshMap& aMeshMap = myMeshMap; + + INITMSG(MYDEBUG,"BuildFields - aNbMeshes = "<GetPMeshInfo(iMesh); + std::string aMeshName = aMeshInfo->GetName(); + + TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName); + if(anIter == aMeshMap.end()) + continue; + PMEDMesh aMesh = anIter->second; + + INITMSG(MYDEBUG,"aMeshName = '"<GetEntityInfo(aMeshInfo); + BuildFieldMap(aMesh, - aEntityInfo, - aMKey2Profile, - aKey2Gauss, + anEntityInfo, aMed); +#ifndef _DEXCEPT_ + }catch(std::exception& exc){ + MSG(MYDEBUG,"Follow exception was occured in:\n"<GetNbMeshes(); + TMeshMap& aMeshMap = myMeshMap; + + INITMSG(MYDEBUG,"BuildMinMax - aNbMeshes = "<GetPMeshInfo(iMesh); + std::string aMeshName = aMeshInfo->GetName(); + + TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName); + if(anIter == aMeshMap.end()) + continue; + PMEDMesh aMesh = anIter->second; + +#ifndef _DEXCEPT_ + try{ +#endif + TInt aNbFields = aMed->GetNbFields(); + + INITMSG(MYDEBUG, + "- aMeshName = '"<GetEntityInfo(aMeshInfo); + + for(TInt iField = 1; iField <= aNbFields; iField++){ + TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPFieldInfo()"); + MED::PFieldInfo aFieldInfo = aMed->GetPFieldInfo(aMeshInfo,iField); + std::string aFieldName = aFieldInfo->GetName(); + INITMSG(MYDEBUG,"- aFieldName = '"<GetNbTimeStamps(aFieldInfo, + anEntityInfo, + aMEntity, + aGeom2Size); + if(aNbTimeStamps < 1) + continue; + + TEntity aVEntity = MEDEntityToVTK(aMEntity); + PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity]; + TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + PMEDField aField = aFieldMap[aFieldName]; + + TInt aNbComp = aField->myNbComp; + int aNbComp2 = aNbComp; + if(aNbComp == 2 || aNbComp == 4) + aNbComp2 = 2; + else if(aNbComp > 4) + aNbComp2 = 3; + + TMinMaxArr& aMinMaxArr = aField->myMinMaxArr; + for(TInt iTimeStamp = aNbTimeStamps; iTimeStamp >= 1; iTimeStamp--){ + TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPTimeStampInfo()"); + INITMSG(MYDEBUG,"- iTimeStamp = "<GetPTimeStampInfo(aFieldInfo, + aMEntity, + aGeom2Size, + iTimeStamp); + + MED::PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStampInfo, + aMKey2Profile, + aKey2Gauss); + + const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss(); -#ifdef _LOAD_FAMILIES_ + const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal; + + const MED::TGeom2Value& aGeom2Value = aTimeStampValRef.myGeom2Value; + MED::TGeom2Value::const_iterator anIter = aGeom2Value.begin(); + for(; anIter != aGeom2Value.end(); anIter++){ + const MED::TMeshValue& aMMeshValue = anIter->second; + MED::EGeometrieElement aMGeom = anIter->first; + + TInt aNbElem = aMMeshValue.myNbElem; + TInt aNbGauss = aMMeshValue.myNbGauss; + + MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom); + if(aGaussIter == aGeom2Gauss.end()) + aNbGauss = 1; + + INITMSG(MYDEBUG, + "- aMGeom = "<GetNbMeshes(); + TMeshMap& aMeshMap = myMeshMap; + + INITMSG(MYDEBUG,"BuildGroups - aNbMeshes = "<GetPMeshInfo(iMesh); + std::string aMeshName = aMeshInfo->GetName(); + + TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName); + if(anIter == aMeshMap.end()) + continue; + PMEDMesh aMesh = anIter->second; + + INITMSG(MYDEBUG,"aMeshName = '"<GetEntityInfo(aMeshInfo); + + MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo = + MED::GetEntity2TGeom2ElemInfo(aMed,aMeshInfo,anEntityInfo); + +#ifndef _DEXCEPT_ + try{ +#endif MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(aMed,aMeshInfo); BuildFamilyMap(aMesh, - aFamilyID2CellsSize, - aEntityInfo, + anEntityInfo, anEntity2TGeom2ElemInfo, aFamilyInfoSet, aMed); BuildGroupMap(aMesh, aFamilyInfoSet); -#endif - - PCalculateMinMax aCalculateMinMax(new TCalculateMinMax(aMesh, - aEntityInfo, - aMKey2Profile, - aKey2Gauss, - aMed)); - - boost::thread aThread(boost::bind(&CalculateMinMax,aCalculateMinMax)); #ifndef _DEXCEPT_ }catch(std::exception& exc){ MSG(MYDEBUG,"Follow exception was occured in:\n"<myEntity; @@ -1289,6 +1357,9 @@ VISU_MedConvertor VISU::PMeshOnEntityImpl theMeshOnEntity, VISU::PFamilyImpl theFamily) { + TTimerLog aTimerLog(MYDEBUG,"LoadFamilyOnEntity"); + INITMSG(MYDEBUG,"LoadFamilyOnEntity"<myEntity; @@ -1310,6 +1381,9 @@ VISU_MedConvertor ::LoadMeshOnGroup(VISU::PMeshImpl theMesh, const VISU::TFamilySet& theFamilySet) { + TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnGroup"); + INITMSG(MYDEBUG,"LoadMeshOnGroup"<myEntity; @@ -1358,6 +1435,9 @@ VISU_MedConvertor VISU::PFieldImpl theField, VISU::PValForTimeImpl theValForTime) { + TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts"); + INITMSG(MYDEBUG,"LoadValForTimeOnGaussPts"<myEntity; @@ -1376,6 +1456,7 @@ VISU_MedConvertor ::LoadPoints(const MED::PWrapper& theMed, VISU::PMEDMesh theMesh) { + TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts"); try{ //Check on existing family PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY]; @@ -1440,6 +1521,7 @@ VISU_MedConvertor const VISU::PMEDMesh theMesh, const VISU::PMEDFamily theFamily) { + TTimerLog aTimerLog(MYDEBUG,"LoadPointsOnFamily"); try{ if(theFamily->myIsDone) return 0; @@ -1477,6 +1559,7 @@ VISU_MedConvertor const VISU::PMEDMesh theMesh, const VISU::PMEDMeshOnEntity theMeshOnEntity) { + TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnEntity"); #ifndef _DEXCEPT_ try{ #endif @@ -1703,6 +1786,7 @@ VISU_MedConvertor const VISU::PMEDMeshOnEntity theMeshOnEntity, const VISU::PMEDFamily theFamily) { + TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnFamily"); #ifndef _DEXCEPT_ try{ #endif @@ -1776,6 +1860,7 @@ LoadProfile(const MED::PWrapper& theMed, VISU::TMEDValForTime& theValForTime, VISU::TMEDMeshOnEntity& theMeshOnEntity) { + TTimerLog aTimerLog(MYDEBUG,"LoadProfile"); INITMSG(MYDEBUG,"LoadProfile"< #include +#include + #include +#include #include #include @@ -304,6 +309,9 @@ VISU_GaussPtsAct theWidgetCtrl->AddObserver(vtkCommand::DisableEvent, myEventCallbackCommand.GetPointer(), myPriority); + theWidgetCtrl->AddObserver(vtkCommand::StartInteractionEvent, + myEventCallbackCommand.GetPointer(), + myPriority); theWidgetCtrl->AddObserver(vtkCommand::EndInteractionEvent, myEventCallbackCommand.GetPointer(), myPriority); @@ -497,37 +505,37 @@ bool VISU_GaussPtsAct::PreHighlight(vtkInteractorStyle* theInteractorStyle, return false; } - if(theSelectionEvent->mySelectionMode == ActorSelection || !theIsHighlight) - return Superclass::PreHighlight(theInteractorStyle, - theSelectionEvent, - theIsHighlight); - + if(!theIsHighlight) + myLastObjPointID = -1; - bool anIsSelectionModeChanged = (theSelectionEvent->mySelectionMode != mySelectionMode); - if(!anIsSelectionModeChanged && mySelectionMode == ActorSelection) - return false; + Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode; - mySelectionMode = theSelectionEvent->mySelectionMode; - - bool anIsChanged = false; - if(theIsHighlight){ - switch(mySelectionMode){ - case NodeSelection: - case CellSelection: - { - myPointPicker->Pick(theSelectionEvent->myX, - theSelectionEvent->myY, - 0.0, - theInteractorStyle->GetCurrentRenderer()); - - if(myPointPicker->GetActor() != this) - return false; - - vtkIdType aVtkId = myPointPicker->GetPointId(); - - if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){ - vtkIdType anObjId = GetNodeObjId( aVtkId ); - if(myLastObjPointID != anObjId){ + if(aSelectionMode == ActorSelection || !theIsHighlight) + return Superclass::PreHighlight(theInteractorStyle, + theSelectionEvent, + theIsHighlight); + + bool anIsChanged = (mySelectionMode != aSelectionMode); + bool anIsPreselected = myIsPreselected; + myIsPreselected = false; + + if(aSelectionMode == GaussPointSelection && theIsHighlight){ + myPointPicker->Pick(theSelectionEvent->myX, + theSelectionEvent->myY, + 0.0, + theInteractorStyle->GetCurrentRenderer()); + + if(myPointPicker->GetActor() != this) + return (anIsPreselected != myIsPreselected); + + vtkIdType aVtkId = myPointPicker->GetPointId(); + + if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){ + vtkIdType anObjId = GetNodeObjId( aVtkId ); + myIsPreselected = (anObjId >= 0); + if(myIsPreselected){ + anIsChanged = (myLastObjPointID != anObjId); + if(anIsChanged){ float* aNodeCoord = GetNodeCoord(anObjId); vtkDataSet* aDataSet = GetInput(); vtkCellData* aCellData = aDataSet->GetCellData(); @@ -535,44 +543,89 @@ bool VISU_GaussPtsAct::PreHighlight(vtkInteractorStyle* theInteractorStyle, float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray); float aPyramidHeight = myPickingSettings->GetPyramidHeight(); aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize(); + //float aColor[3] = myPreHighlightActor->GetProperty()->GetColor(); + float aColor[3]; + theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor ); + aColor[0] = 1. - aColor[0]; + aColor[1] = 1. - aColor[1]; + aColor[2] = 1. - aColor[2]; myCursorPyramid->Init(aPyramidHeight, aRadius, aNodeCoord, - myPreHighlightActor->GetProperty()->GetColor()); + aColor); } myLastObjPointID = anObjId; } myCursorPyramid->SetVisibility(true); - myIsPreselected = theIsHighlight; - anIsChanged = true; } } - break; - } } + + mySelectionMode = aSelectionMode; + anIsChanged |= (anIsPreselected != myIsPreselected); return anIsChanged; } //---------------------------------------------------------------------------- +inline +void +ChangeZoom(VISU_PickingSettings *thePickingSettings, + vtkInteractorStyle* theInteractorStyle, + int theInitialHasIndex, + SVTK_Selector* theSelector, + const Handle(SALOME_InteractiveObject)& theIO) +{ + int aCurrentHasIndex = theSelector->HasIndex(theIO); + + if(theInitialHasIndex + aCurrentHasIndex == 1){ + vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer(); + vtkCamera *aCamera = aRenderer->GetActiveCamera(); + float aZoomFactor = thePickingSettings->GetZoomFactor(); + double aScale = aCamera->GetParallelScale(); + if (!theInitialHasIndex && aCurrentHasIndex) { + aCamera->SetParallelScale(aScale/aZoomFactor); + } + else { + aCamera->SetParallelScale(aScale*aZoomFactor); + } + } + +} + bool VISU_GaussPtsAct::Highlight(vtkInteractorStyle* theInteractorStyle, SVTK_SelectionEvent* theSelectionEvent, bool theIsHighlight) { + Handle(SALOME_InteractiveObject) anIO = getIO(); + int anInitialHasIndex = mySelector->HasIndex(anIO); + + Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode; + // + if(!theIsHighlight && aSelectionMode == GaussPointSelection){ + mySelector->RemoveIObject(anIO); + + ChangeZoom(myPickingSettings, + theInteractorStyle, + anInitialHasIndex, + mySelector.GetPointer(), + anIO); + + return true; + } + if (!myBarVisibility) { return false; } // - Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode; - // if(aSelectionMode == ActorSelection){ return Superclass::Highlight(theInteractorStyle, theSelectionEvent, theIsHighlight); } // - if(!theSelectionEvent->myIsRectangle){ + if(aSelectionMode == GaussPointSelection && !theSelectionEvent->myIsRectangle){ vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer(); myPointPicker->Pick(theSelectionEvent->myX, @@ -582,6 +635,13 @@ bool VISU_GaussPtsAct::Highlight(vtkInteractorStyle* theInteractorStyle, if(myPointPicker->GetActor() != this) { mySelector->ClearIObjects(); + + ChangeZoom(myPickingSettings, + theInteractorStyle, + anInitialHasIndex, + mySelector.GetPointer(), + anIO); + return true; } @@ -616,11 +676,23 @@ bool VISU_GaussPtsAct::Highlight(vtkInteractorStyle* theInteractorStyle, mySelectionMode = aSelectionMode; + ChangeZoom(myPickingSettings, + theInteractorStyle, + anInitialHasIndex, + mySelector.GetPointer(), + anIO); + return true; // }// if( anObjId >= 0 ) { }//if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) && hasIO()) }//if(!theSelectionEvent->myIsRectangle){ + + ChangeZoom(myPickingSettings, + theInteractorStyle, + anInitialHasIndex, + mySelector.GetPointer(), + anIO); return false; } @@ -643,8 +715,12 @@ VISU_GaussPtsAct bool anIsVisible = GetVisibility(); - if(mySelector->SelectionMode() == ActorSelection) + Selection_Mode aSelectionMode = mySelector->SelectionMode(); + + if(aSelectionMode == ActorSelection) Superclass::highlight(theIsHighlight); + else if(aSelectionMode != GaussPointSelection) + return; TColStd_IndexedMapOfInteger aMapIndex; mySelector->GetIndex( getIO(), aMapIndex ); @@ -664,12 +740,9 @@ VISU_GaussPtsAct float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.}; // vtkDataSet* aDataSet = GetInput(); - vtkCellData* aCellData = aDataSet->GetCellData(); + vtkCellData* aDataSetAttributes = aDataSet->GetCellData(); // - vtkDataArray* aScalarArray = aCellData->GetScalars(); - vtkDataArray *aVectorArray = aCellData->GetVectors(); - // - if(aScalarArray){ + if(vtkDataArray* aScalarArray = aDataSetAttributes->GetScalars()){ aVal = aScalarArray->GetTuple1(aVtkId); aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray); // @@ -678,7 +751,7 @@ VISU_GaussPtsAct GetScalarBarCtrl()->Update(); // float aPyramidHeight = myPickingSettings->GetPyramidHeight(); - aPyramidHeight=aPyramidHeight*myGaussPointsPL->GetMaxPointSize(); + aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize(); myCursorPyramidSelected->Init(aPyramidHeight, aRadius, aNodeCoord, @@ -700,9 +773,20 @@ VISU_GaussPtsAct aStr<<"\nLocalPntID: "<GetTuple3(aVtkId); - aStr<<"\nVector: {"<GetArray("VISU_FIELD")){ + if(vtkFloatArray *aFloatArray = dynamic_cast(aFieldArray)){ + int aNbComp = aFloatArray->GetNumberOfComponents(); + aStr<<"\nData: {"; + int anId = 0; + while(anId < aNbComp){ + float aComp = aFloatArray->GetComponent(aVtkId,anId++); + aStr<AddObserver(VISU::UpdatePickingSettingsEvent, myEventCallbackCommand.GetPointer(), myPriority); + this->UpdatePickingSettings(); + } } void VISU_GaussPtsAct ::UpdatePickingSettings() { - // Update picking parameters using myPickingSettings object myTextActor->SetModePosition(myPickingSettings->GetInfoWindowPosition()); myTextActor->SetTransparency(myPickingSettings->GetInfoWindowTransparency()); - float aHeight= - myGaussPointsPL->GetMaxPointSize()*myPickingSettings->GetPyramidHeight(); + + float aHeight = myGaussPointsPL->GetMaxPointSize()*myPickingSettings->GetPyramidHeight(); myCursorPyramid->SetHeight(aHeight); myCursorPyramidSelected->SetHeight(aHeight); - // + + myHighlightActor->GetProperty()->SetColor( myPickingSettings->GetColor() ); + myPointPicker->SetTolerance( myPickingSettings->GetPointTolerance() ); + Highlight(isHighlighted()); Update(); @@ -921,8 +1010,6 @@ VISU_GaussPtsAct1 myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL); myOutsideDeviceActor->SetVisibility(false); - - myCurrentPL = myDeviceActor->GetPipeLine(); } if(theWidgetCtrl){ @@ -954,14 +1041,16 @@ VISU_GaussPtsAct1 if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){ myInsideDeviceActor->SetPipeLine(aPipeLine); + aPipeLine->Delete(); } if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){ myOutsideDeviceActor->SetPipeLine(aPipeLine); + aPipeLine->Delete(); - myOutsideDeviceActor->GetMapper()->ScalarVisibilityOff(); - - myOutsideDeviceActor->GetPipeLine()->SetExtractInside(true); + SALOME_ExtractGeometry* anExtractGeometry = aPipeLine->GetExtractGeometryFilter(); + anExtractGeometry->SetExtractBoundaryCells(true); + anExtractGeometry->SetExtractInside(true); } } @@ -1012,9 +1101,12 @@ VISU_GaussPtsAct1 myOutsideCursorSettings = theOutsideCursorSettings; if(theOutsideCursorSettings) + { theOutsideCursorSettings->AddObserver(VISU::UpdateOutsideSettingsEvent, myEventCallbackCommand.GetPointer(), myPriority); + this->UpdateOutsideCursorSettings(); + } } void @@ -1066,8 +1158,14 @@ VISU_GaussPtsAct1 ::OnInteractorEvent(unsigned long theEvent) { switch(theEvent){ + case vtkCommand::StartInteractionEvent: + myDeviceActor->SetVisibility(GetVisibility()); + myInsideDeviceActor->SetVisibility(false); + myOutsideDeviceActor->SetVisibility(false); + break; case vtkCommand::EnableEvent: case vtkCommand::DisableEvent: + case vtkCommand::EndInteractionEvent: myDeviceActor->SetVisibility(GetVisibility() && !myWidgetCtrl->GetEnabled()); myInsideDeviceActor->SetVisibility(GetVisibility() && myWidgetCtrl->GetEnabled()); myOutsideDeviceActor->SetVisibility(GetVisibility() && myWidgetCtrl->GetEnabled()); @@ -1075,18 +1173,6 @@ VISU_GaussPtsAct1 default: break; } - - - switch(theEvent){ - case vtkCommand::EnableEvent: - myCurrentPL = myInsideDeviceActor->GetPipeLine(); - break; - case vtkCommand::DisableEvent: - myCurrentPL = myDeviceActor->GetPipeLine(); - break; - default: - break; - } Superclass::OnInteractorEvent(theEvent); } @@ -1139,6 +1225,7 @@ VISU_GaussPtsAct2 if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){ myDeviceActor->SetPipeLine(aPipeLine); myCurrentPL = aPipeLine; + aPipeLine->Delete(); } } diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index e69f2356..13eec03f 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -65,6 +65,16 @@ class VISU_OutsideCursorSettings; //============================================================================ +//! Base class for Gauss Points Actors. +/*! + The actor is responsible for representation of Gauss Points. + It render corresponding presentation by usage of corresponding VISU_GaussPtsDeviceActor. + Usage of such technic of rendering gives addititional flexibility to change its behaviour in run-time. + Also, the base class implements the following functionality: + - implements a highlight and prehighlight functionality; + - defining a way to handle VISU_ImplicitFunctionWidget; + - global / local scalar bar mamangement. +*/ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor { public: @@ -88,14 +98,17 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor ShallowCopyPL(VISU_PipeLine* thePipeLine); //---------------------------------------------------------------------------- + //! Redefined method of getting a native mapper of the actor. virtual vtkMapper* GetMapper(); + //! Redefined method of getting an actor bounds. virtual float* GetBounds(); + //! Redefined method of getting an actor input. virtual vtkDataSet* GetInput(); @@ -109,59 +122,75 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor GetGaussPtsFactory(); //---------------------------------------------------------------------------- + //! Add actor to the renderer. virtual void AddToRender(vtkRenderer* theRenderer); + //! Remove actor from the renderer. virtual void RemoveFromRender(vtkRenderer* theRenderer); + //! Set the Render Window Interactor to the actor. virtual void SetInteractor(vtkRenderWindowInteractor* theInteractor); + //! Apply the transform on the actor. virtual void SetTransform(VTKViewer_Transform* theTransform); + //! Redefined method of rendering the Opaque Geometry. virtual int RenderOpaqueGeometry(vtkViewport *viewport); + //! Redefined method of rendering the Translucent Geometry. virtual int RenderTranslucentGeometry(vtkViewport *viewport); //---------------------------------------------------------------------------- + //! Set actor visibility. virtual void SetVisibility(int theMode); + //! Set Scalar Bar Control to the actor. VISU_ScalarBarCtrl* GetScalarBarCtrl(); + //! Set the Scalar Bar Control visibility. void SetBarVisibility(bool theMode); + //! Get the Scalar Bar Control visibility. bool GetBarVisibility(); virtual void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl); + //! Return the information about pipeline magnification changing. + /*! True indicates that magnification is increased, false - decreased. */ bool ChangeMagnification(); //---------------------------------------------------------------------------- + //! Internal highlight. virtual void Highlight(bool theIsHighlight); + //! Redefined method of the actor's prehighlighting virtual bool PreHighlight(vtkInteractorStyle* theInteractorStyle, SVTK_SelectionEvent* theSelectionEvent, bool theIsHighlight); + + //! Redefined method of the actor's highlighting virtual bool Highlight(vtkInteractorStyle* theInteractorStyle, @@ -169,6 +198,7 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor bool theIsHighlight); //---------------------------------------------------------------------------- + //! Set the picking settings to the actor. void SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings); @@ -182,6 +212,7 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor void SetPickingSettings(VISU_PickingSettings* thePickingSettings); + //! Apply the picking settings on the actor. void UpdatePickingSettings(); @@ -196,6 +227,7 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor virtual ~VISU_GaussPtsAct(); + // Redefined method of setting mapper input. virtual void SetMapperInput(vtkDataSet* theDataSet); @@ -207,13 +239,15 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor //---------------------------------------------------------------------------- vtkSmartPointer myEventCallbackCommand; - // Main process VTK event method + //! Main process VTK event method static void ProcessEvents(vtkObject* theObject, unsigned long theEvent, void* theClientData, void* theCallData); + + // To process VTK event method virtual void OnInteractorEvent(unsigned long theEvent); @@ -252,6 +286,12 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor //============================================================================ class VISU_GaussPtsAct2; +//! Gauss Points Actor, displayed in the Base View. +/*! + * Contains device actor (VISU_GaussPtsDeviceActor), + * which has two representation modes - outside and + * inside segmentation cursor. + */ class VTKOCC_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct { public: @@ -266,6 +306,7 @@ class VTKOCC_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct ShallowCopyPL(VISU_PipeLine* thePipeLine); //---------------------------------------------------------------------------- + //! Set actor visibility. virtual void SetVisibility(int theMode); @@ -279,21 +320,26 @@ class VTKOCC_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct UpdateInsideCursorSettings(); //---------------------------------------------------------------------------- + //! Set the Outside Cursor Gauss Points settings to the actor. void SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings); + //! Apply the Outside Cursor Gauss Points settings on the actor. void UpdateOutsideCursorSettings(); //---------------------------------------------------------------------------- + //! Add actor to the renderer. virtual void AddToRender(vtkRenderer* theRenderer); + //! Remove actor from the renderer. virtual void RemoveFromRender(vtkRenderer* theRenderer); + //! Apply the transform on the actor. virtual void SetTransform(VTKViewer_Transform* theTransform); @@ -307,6 +353,7 @@ class VTKOCC_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct virtual ~VISU_GaussPtsAct1(); + // Redefined method of setting mapper input. virtual void SetMapperInput(vtkDataSet* theDataSet); @@ -334,7 +381,7 @@ class VTKOCC_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct }; -//============================================================================ +//! Gauss Points Actor, displayed in the Segmented View. class VTKOCC_EXPORT VISU_GaussPtsAct2 : public VISU_GaussPtsAct { public: @@ -344,6 +391,7 @@ class VTKOCC_EXPORT VISU_GaussPtsAct2 : public VISU_GaussPtsAct VISU_GaussPtsAct2* New(); + // Redefined method of setting mapper input. virtual void SetMapperInput(vtkDataSet* theDataSet); @@ -353,10 +401,12 @@ class VTKOCC_EXPORT VISU_GaussPtsAct2 : public VISU_GaussPtsAct ShallowCopyPL(VISU_PipeLine* thePipeLine); //---------------------------------------------------------------------------- + //! Set actor visibility. virtual void SetVisibility(int theMode); + //! Get actor visibility. virtual int GetVisibility(); diff --git a/src/OBJECT/VISU_GaussPtsActorFactory.h b/src/OBJECT/VISU_GaussPtsActorFactory.h index 9557c60a..ba785efc 100644 --- a/src/OBJECT/VISU_GaussPtsActorFactory.h +++ b/src/OBJECT/VISU_GaussPtsActorFactory.h @@ -38,12 +38,15 @@ class VISU_GaussPtsAct2; //---------------------------------------------------------------------------- namespace VISU { + //! Extend an abstaract interface to manage Gauss points actors struct TGaussPtsActorFactory: virtual TActorFactory { + //! To create VISU_GaussPtsAct2 actor (segemented representation) from VISU_GaussPtsAct1 (basic representation) virtual VISU_GaussPtsAct2* CloneActor(VISU_GaussPtsAct1* theActor) = 0; + //! The VISU_GaussPtsAct can update its presentation virtual void UpdateFromActor(VISU_GaussPtsAct* theActor) = 0; diff --git a/src/OBJECT/VISU_GaussPtsDeviceActor.cxx b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx index 86eb25d2..519a74da 100644 --- a/src/OBJECT/VISU_GaussPtsDeviceActor.cxx +++ b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx @@ -40,6 +40,9 @@ #include #include #include +#include +#include + #include "utilities.h" #ifdef _DEBUG_ @@ -80,6 +83,46 @@ VISU_GaussPtsDeviceActor } +//---------------------------------------------------------------- +void +VISU_GaussPtsDeviceActor +::Render(vtkRenderer *ren, vtkMapper *vtkNotUsed(m)) +{ + if (this->Mapper == NULL) + { + vtkErrorMacro("No mapper for actor."); + return; + } + + // render the property + if (!this->Property) + { + // force creation of a property + this->GetProperty(); + } + this->Property->Render(this, ren); + if (this->BackfaceProperty) + { + this->BackfaceProperty->BackfaceRender(this, ren); + this->Device->SetBackfaceProperty(this->BackfaceProperty); + } + this->Device->SetProperty(this->Property); + + // render the texture + if (this->Texture) + { + this->Texture->Render(ren); + } + + // make sure the device has the same matrix + vtkMatrix4x4 *matrix = this->Device->GetUserMatrix(); + this->GetMatrix(matrix); + + this->Device->Render(ren,Mapper); + this->EstimatedRenderTime = Mapper->GetTimeToDraw(); +} + + //---------------------------------------------------------------- void VISU_GaussPtsDeviceActor diff --git a/src/OBJECT/VISU_GaussPtsDeviceActor.h b/src/OBJECT/VISU_GaussPtsDeviceActor.h index 4f4d5e3e..41f4ebd3 100644 --- a/src/OBJECT/VISU_GaussPtsDeviceActor.h +++ b/src/OBJECT/VISU_GaussPtsDeviceActor.h @@ -52,6 +52,10 @@ class VISU_GaussPtsDeviceActor: public vtkLODActor VISU_GaussPtsDeviceActor* New(); + virtual + void + Render(vtkRenderer *, vtkMapper *); + //---------------------------------------------------------------------------- void AddToRender(vtkRenderer* theRenderer); diff --git a/src/OBJECT/VISU_GaussPtsSettings.cxx b/src/OBJECT/VISU_GaussPtsSettings.cxx index b0b36ab6..d7e5d1ea 100644 --- a/src/OBJECT/VISU_GaussPtsSettings.cxx +++ b/src/OBJECT/VISU_GaussPtsSettings.cxx @@ -83,6 +83,10 @@ VISU_PickingSettings::VISU_PickingSettings() this->Initial = true; this->PyramidHeight = -1; + this->PointTolerance = -1; + this->Color[0] = -1; + this->Color[1] = -1; + this->Color[1] = -1; this->InfoWindowTransparency = -1; this->InfoWindowPosition = -1; this->ZoomFactor = -1; diff --git a/src/OBJECT/VISU_GaussPtsSettings.h b/src/OBJECT/VISU_GaussPtsSettings.h index 12f241f9..8f53ecae 100644 --- a/src/OBJECT/VISU_GaussPtsSettings.h +++ b/src/OBJECT/VISU_GaussPtsSettings.h @@ -100,6 +100,12 @@ private: //============================================================================ +//! Class of Outside Cursor Gauss Points settings. +/*! + * Contains information about the point sprite parameters: + * Clamp, Texture, Alpha threshold, Const size and Color. + * Used by Gauss Points Actor. + */ class VISU_OutsideCursorSettings : public vtkObject { public: @@ -149,7 +155,14 @@ private: }; -//============================================================================ +//! Class of Picking settings. +/*! + * Contains information about the following parameters: + * Cursor Pyramid height, Info Window transparency, + * Info Window position, Zoom factor on first selected point, + * Camera movement steps number and Display parent mesh. + * Used by Gauss Points Actor. + */ class VISU_PickingSettings : public vtkObject { public: @@ -171,6 +184,12 @@ class VISU_PickingSettings : public vtkObject vtkSetMacro( PyramidHeight, float ); vtkGetMacro( PyramidHeight, float ); + vtkSetVector3Macro( Color, float ); + vtkGetVector3Macro( Color, float ); + + vtkSetMacro( PointTolerance, float ); + vtkGetMacro( PointTolerance, float ); + vtkSetMacro( InfoWindowTransparency, float ); vtkGetMacro( InfoWindowTransparency, float ); @@ -190,6 +209,8 @@ private: bool Initial; float PyramidHeight; + float PointTolerance; + float Color[3]; float InfoWindowTransparency; int InfoWindowPosition; float ZoomFactor; diff --git a/src/PIPELINE/Makefile.in b/src/PIPELINE/Makefile.in index a2f495ec..cc97361b 100644 --- a/src/PIPELINE/Makefile.in +++ b/src/PIPELINE/Makefile.in @@ -52,6 +52,7 @@ EXPORT_HEADERS = \ VISU_Plot3DPL.hxx \ VISU_OpenGLPointSpriteMapper.hxx \ VISU_ImplicitFunctionWidget.hxx \ + SALOME_ExtractGeometry.h \ VISU_ScalarBarCtrl.hxx \ VISU_PlanesWidget.hxx \ VISU_SphereWidget.hxx \ diff --git a/src/PIPELINE/VISU_Extractor.cxx b/src/PIPELINE/VISU_Extractor.cxx index 6b182da2..63e26e03 100644 --- a/src/PIPELINE/VISU_Extractor.cxx +++ b/src/PIPELINE/VISU_Extractor.cxx @@ -62,7 +62,6 @@ execute(int theNbElems, { if(theNbElems < 1 ) return; - vtkDataArray* aVectors = theInputData->GetVectors(); vtkDataArray* aFieldArray = theInputData->GetArray("VISU_FIELD"); if(vtkFloatArray *aFloatArray = dynamic_cast(aFieldArray)){ int aNbComp = aFloatArray->GetNumberOfComponents(); @@ -104,6 +103,7 @@ void VISU_Extractor::Execute(){ else output->GetPointData()->CopyScalarsOn(); outData->PassData(inData); + outData->AddArray(inData->GetArray("VISU_FIELD")); }else{ output->GetCellData()->CopyVectorsOn(); int aNbElems = input->GetNumberOfCells(); @@ -113,5 +113,6 @@ void VISU_Extractor::Execute(){ else output->GetCellData()->CopyScalarsOn(); outData->PassData(inData); + outData->AddArray(inData->GetArray("VISU_FIELD")); } } diff --git a/src/PIPELINE/VISU_GaussPointsPL.hxx b/src/PIPELINE/VISU_GaussPointsPL.hxx index 8ecdeabb..7e24000c 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.hxx +++ b/src/PIPELINE/VISU_GaussPointsPL.hxx @@ -46,6 +46,11 @@ class vtkCellDataToPointData; class vtkWarpVector; class SALOME_Transform; +//! Pipeline for the Gauss Points presentation. +/*! + * This class uses the special mapper (VISU_OpenGLPointSpriteMapper) + * for rendering the Gauss Points as Point Sprites. + */ class VISU_GaussPointsPL : public VISU_ScalarMapPL { protected: @@ -64,17 +69,21 @@ public: void ShallowCopy(VISU_PipeLine *thePipeLine); + //! Get the native mapper. virtual TMapper* GetMapper(); + //! Get the internal #VISU_OpenGLPointSpriteMapper. VISU_OpenGLPointSpriteMapper* GetPSMapper(); + //! Redefined method for building the pipeline. virtual void Build(); + //! Redefined method for updating the pipeline. virtual void Update(); @@ -89,13 +98,27 @@ public: const VISU::PGaussPtsIDMapper& GetGaussPtsIDMapper() const; + //! Set the Bicolor mode. + /*! + * When the Bicolor parameter is set to true, scalar bars are + * drawing with two colors : red color correspoonds to positive + * scalar values, blue color - to negative values. + */ void SetBicolor(bool theBicolor); + //! Get the Bicolor mode. bool GetBicolor(); - void SetIsColored(bool theIsColored); + //! Set the Multicolored mode. + /*! + * This parameter is using to switch between Results and Geometry + * modes. Multiple colors are using when the presentation is + * drawing in the Results mode, one color - in the Geometry mode. + */ + void + SetIsColored(bool theIsColored); void SetPrimitiveType(int thePrimitiveType); @@ -103,66 +126,91 @@ public: int GetPrimitiveType() { return myPrimitiveType; } + //! Get the maximum Point Sprite size, which is supported by hardware. float GetMaximumSupportedSize(); + //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteClamp. void SetClamp(float theClamp); + //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteClamp, float). float GetClamp() { return myClamp; } + //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteSize. void SetSize(float theSize); + //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteSize, float). float GetSize() { return mySize; } + //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteMinSize. void SetMinSize(float theMinSize); + //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteMinSize, float). float GetMinSize() { return myMinSize; } + //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteMinSize. void SetMaxSize(float theMaxSize); + //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteMaxSize, float). float GetMaxSize() { return myMaxSize; } + //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteMagnification. void SetMagnification(float theMagnification); + //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteMagnification, float). float GetMagnification() { return myMagnification; } + //! Set the increment of changing Magnification parameter. void SetMagnificationIncrement(float theIncrement); + //! Get the increment of changing Magnification parameter. float GetMagnificationIncrement() { return myMagnificationIncrement; } + //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteAlphaThreshold. void SetAlphaThreshold(float theAlphaThreshold); + //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteAlphaThreshold, float). float GetAlphaThreshold() { return myAlphaThreshold; } + //! Method for changing the Magnification parameter. void ChangeMagnification( bool up ); + //! Get the maximum size of Point Sprites in the presentation. float GetMaxPointSize(); + //! Get point size by element's Id. float GetPointSize(vtkIdType theID); + //! Get point size by element's Id using the specified scalar array. float GetPointSize(vtkIdType theID, vtkDataArray* theScalarArray); + //! Set image data for the Point Sprite texture. void SetImageData(vtkImageData* theImageData); + //! Make the image data for Point Sprite texture. + /*! + * First parameter - texture for shape. + * Second parameter - texture for alpha mask. + */ static vtkImageData* MakeTexture( const char* theMainTexture, diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx index f56b98c9..0240d986 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx @@ -52,7 +52,6 @@ #include #include #include -#include #ifndef VTK_IMPLEMENT_MESA_CXX vtkCxxRevisionMacro(VISU_OpenGLPointSpriteMapper, "Revision$"); @@ -67,7 +66,6 @@ vtkStandardNewMacro(VISU_OpenGLPointSpriteMapper); #define VTK_PDPSM_NORMAL_TYPE_FLOAT 0x0010 #define VTK_PDPSM_NORMAL_TYPE_DOUBLE 0x0020 #define VTK_PDPSM_OPAQUE_COLORS 0x0040 -#define VTK_PDPSM_ALPHA_ARRAY 0x0080 #ifndef APIENTRY #define APIENTRY @@ -166,18 +164,12 @@ static int IsARBInitialized = InitializeARB(); // Construct empty object. VISU_OpenGLPointSpriteMapper::VISU_OpenGLPointSpriteMapper() { + this->RenderMode = VISU_OpenGLPointSpriteMapper::Occlude; + this->ListId = 0; this->TotalCells = 0; this->ExtensionsInitialized = 0; - this->ExtensionsOK = 0; - this->AlphaChannelArray = NULL; - this->SizeChannelArray = NULL; - this->DefaultPointSize = 10.0; - this->QuadraticPointDistanceAttenuation[0] = 1.0; - this->QuadraticPointDistanceAttenuation[1] = 0.0; - this->QuadraticPointDistanceAttenuation[2] = 0.0; - - this->RenderMode = VISU_OpenGLPointSpriteMapper::Occlude; + this->DefaultPointSize = 20.0; this->UsePointSprites = true; this->UseTextures = true; @@ -188,7 +180,7 @@ VISU_OpenGLPointSpriteMapper::VISU_OpenGLPointSpriteMapper() this->PointSpritePrimitiveType = 0; this->PointSpriteClamp = 100.0; - this->PointSpriteSize = 0.0; + this->PointSpriteSize = 30.0; this->PointSpriteMinSize = 15.0; this->PointSpriteMaxSize = 50.0; this->PointSpriteMagnification = 1.0; @@ -207,16 +199,6 @@ VISU_OpenGLPointSpriteMapper::~VISU_OpenGLPointSpriteMapper() { this->ReleaseGraphicsResources(this->LastWindow); } - if (this->AlphaChannelArray) - { - delete [] this->AlphaChannelArray; - this->AlphaChannelArray = NULL; - } - if (this->SizeChannelArray) - { - delete [] this->SizeChannelArray; - this->SizeChannelArray = NULL; - } } //----------------------------------------------------------------------------- void VISU_OpenGLPointSpriteMapper::ShallowCopy( vtkAbstractMapper* mapper ) @@ -296,10 +278,10 @@ void VISU_OpenGLPointSpriteMapper::InitShader() vglCompileShaderARB( VertexShader ); //this->PrintInfoLog( VertexShader ); - myVertexProgram = vglCreateProgramObjectARB(); - vglAttachObjectARB( myVertexProgram, VertexShader ); + this->VertexProgram = vglCreateProgramObjectARB(); + vglAttachObjectARB( this->VertexProgram, VertexShader ); - vglLinkProgramARB( myVertexProgram ); + vglLinkProgramARB( this->VertexProgram ); //this->PrintInfoLog( VertexProgram ); /* cout << "Shader from " << fileName << endl; @@ -313,21 +295,15 @@ void VISU_OpenGLPointSpriteMapper::InitShader() cout << "Loading vertex program... failed" << endl << endl; */ free( shader ); - - glMatrixMode( GL_MODELVIEW ); - glLoadIdentity(); - glTranslatef( 0.0f, 0.0f, -4.0f ); - glRotatef( 0.0f, 1.0f, 0.0f, 0.0f ); - glRotatef( 0.0f, 0.0f, 1.0f, 0.0f ); } //----------------------------------------------------------------------------- void VISU_OpenGLPointSpriteMapper::SetShaderVariable( const char* variable, float value ) { - //cout << myVertexProgram << " "; - //cout << vglGetAttribLocationARB( myVertexProgram, variable ) << " "; + //cout << this->VertexProgram << " "; + //cout << vglGetAttribLocationARB( this->VertexProgram, variable ) << " "; //cout << variable << " " << value << endl; - vglVertexAttrib1fARB( vglGetAttribLocationARB( myVertexProgram, variable ), value ); + vglVertexAttrib1fARB( vglGetAttribLocationARB( this->VertexProgram, variable ), value ); } //----------------------------------------------------------------------------- void VISU_OpenGLPointSpriteMapper::SetPointSpriteMode( int theMode ) @@ -400,7 +376,6 @@ void VISU_OpenGLPointSpriteMapper::InitExtensions() if( this->UseShader ) this->InitShader(); - this->ExtensionsOK = 1; this->ExtensionsInitialized = 1; } //----------------------------------------------------------------------------- @@ -457,12 +432,6 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act) // make sure our window is current ren->GetRenderWindow()->MakeCurrent(); - // For vertex coloring, this sets this->Colors as side effect. - // Color arrays are cached. If nothing has changed, - // then the scalars do not have to be regenerted. - this->ActorOpacity = act->GetProperty()->GetOpacity(); - this->MapScalars(this->ActorOpacity); - // Initializing the texture for Point Sprites if( this->UseTextures && this->PointSpritePrimitiveType == 0 ) this->InitTextures(); @@ -477,6 +446,9 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act) act->GetProperty()->GetMTime() > this->BuildTime || ren->GetRenderWindow() != this->LastWindow) { + // sets this->Colors as side effect + this->MapScalars( act->GetProperty()->GetOpacity() ); + if (!this->ImmediateModeRendering && !this->GetGlobalImmediateModeRendering()) { @@ -521,6 +493,9 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act) if (this->ImmediateModeRendering || this->GetGlobalImmediateModeRendering()) { + // sets this->Colors as side effect + this->MapScalars( act->GetProperty()->GetOpacity() ); + // Time the actual drawing this->Timer->StartTimer(); this->Draw(ren,act); @@ -537,7 +512,7 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act) //----------------------------------------------------------------------------- float VISU_OpenGLPointSpriteMapper::GetMaximumSupportedSize() { - float maximumSupportedSize = 300.0; + float maximumSupportedSize = 512.0; //glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maximumSupportedSize ); return maximumSupportedSize; @@ -588,7 +563,7 @@ void VISU_OpenGLPointSpriteMapper::InitPointSprites() //----------------------------------------------------------------------------- void VISU_OpenGLPointSpriteMapper::CleanupPointSprites() { - // Set GL params back to normal to stop other vtkMappers diusplaying wrongly + // Set GL params back to normal to stop other vtkMappers displaying wrongly glDisable( GL_ALPHA_TEST ); glEnable( GL_BLEND ); @@ -695,8 +670,7 @@ struct TVertex }; //----------------------------------------------------------------------------- -void VISU_OpenGLPointSpriteMapper::DrawPoints(int idx, - vtkPoints *p, +void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *p, vtkUnsignedCharArray *colors, vtkFloatArray *alpha, vtkIdType &cellNum, @@ -710,14 +684,9 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(int idx, glPointSize( this->DefaultPointSize ); - vglUseProgramObjectARB( myVertexProgram ); + vglUseProgramObjectARB( this->VertexProgram ); - this->SetShaderVariable( "mode", this->PointSpriteMode ); - this->SetShaderVariable( "clamp", this->PointSpriteClamp ); - this->SetShaderVariable( "geomSize", this->PointSpriteSize ); - this->SetShaderVariable( "minSize", this->PointSpriteMinSize ); - this->SetShaderVariable( "maxSize", this->PointSpriteMaxSize ); - this->SetShaderVariable( "magnification", this->PointSpriteMagnification ); + this->SetShaderVariable( "clamp_size", this->PointSpriteClamp ); TVertex* aVertex = new TVertex[ this->TotalCells ]; @@ -754,7 +723,16 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(int idx, aVertex[i].g = green; aVertex[i].b = blue; - aVertex[i].hue = ComputeHue( ( int )( red * 255 ), ( int )( green * 255 ), ( int )( blue * 255 ) ); + float size = 0.0; + if( this->PointSpriteMode == 0 ) + { + float h = ComputeHue( ( int )( red * 255 ), ( int )( green * 255 ), ( int )( blue * 255 ) ); + size = this->PointSpriteMinSize + ( PointSpriteMaxSize - PointSpriteMinSize ) * ( 1 - h / 241.0f ); + } + else + size = this->PointSpriteSize; + + aVertex[i].hue = this->PointSpriteMagnification * size; } GLuint aBufferObjectID = 0; @@ -772,13 +750,13 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(int idx, glColorPointer( 4, GL_FLOAT, sizeof(TVertex), (void*)0 ); glVertexPointer( 3, GL_FLOAT, sizeof(TVertex), (void*)(4*sizeof(GLfloat)) ); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState( GL_VERTEX_ARRAY ); + glEnableClientState( GL_COLOR_ARRAY ); - glDrawArrays(GL_POINTS,0,this->TotalCells); + glDrawArrays( GL_POINTS, 0, this->TotalCells ); - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState( GL_COLOR_ARRAY ); + glDisableClientState( GL_VERTEX_ARRAY ); vglDeleteBuffersARB( 1, &aBufferObjectID ); @@ -831,42 +809,10 @@ int VISU_OpenGLPointSpriteMapper::Draw(vtkRenderer *aren, vtkActor *act) } } - unsigned long idx = 0; - if (colors) - { - idx |= VTK_PDPSM_COLORS; - if (colors->GetName()) - { - // In the future, I will look at the number of components. - // All paths will have to handle 3 component colors. - idx |= VTK_PDPSM_OPAQUE_COLORS; - } - } - if (cellScalars) - { - idx |= VTK_PDPSM_CELL_COLORS; - } - - // store the types in the index - if (points->GetDataType() == VTK_FLOAT) - { - idx |= VTK_PDPSM_POINT_TYPE_FLOAT; - } - else if (points->GetDataType() == VTK_DOUBLE) - { - idx |= VTK_PDPSM_POINT_TYPE_DOUBLE; - } - - if (this->AlphaChannelArray && (alpha = vtkFloatArray::SafeDownCast(input->GetPointData()->GetArray(this->AlphaChannelArray))) - ) - { - idx |= VTK_PDPSM_ALPHA_ARRAY; - } - // we need to know the total number of cells so that we can report progress this->TotalCells = input->GetVerts()->GetNumberOfCells(); - this->DrawPoints(idx, points, colors, alpha, cellNum, noAbort, input->GetVerts(), ren, act); + this->DrawPoints(points, colors, alpha, cellNum, noAbort, input->GetVerts(), ren, act); this->UpdateProgress(1.0); return noAbort; @@ -887,8 +833,3 @@ void VISU_OpenGLPointSpriteMapper::ReleaseGraphicsResources(vtkWindow *win) this->LastWindow = NULL; } //----------------------------------------------------------------------------- -void VISU_OpenGLPointSpriteMapper::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); -} -//----------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx index 82df736a..87fe2d72 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx @@ -60,99 +60,92 @@ class vtkXMLImageDataReader; typedef GLuint GLhandleARB; #endif +//---------------------------------------------------------------------------- +//! OpenGL Point Sprites PolyData Mapper. +/*! + * VISU_OpenGLPointSpriteMapper is a class that maps polygonal data + * (i.e., vtkPolyData) to graphics primitives. It is performing the mapping + * to the rendering/graphics hardware/software. It is now possible to set a + * memory limit for the pipeline in the mapper. If the total estimated memory + * usage of the pipeline is larger than this limit, the mapper will divide + * the data into pieces and render each in a for loop. + */ class VISU_OpenGLPointSpriteMapper : public MAPPER_SUPERCLASS { public: -//BTX - enum RenderModes { - Accumulate=0, - Occlude - }; -//ETX + //! The Point Sprites rendering mode. + /*! + * Accumulate : Uses glBlendFunc(GL_SRC_ALPHA, GL_ONE), and no depth testing + * so that points are accumulated. Suitable for Galaxy plots. + * Occlude : No blending. Particles are solid spheres and depth testing is + * used as usual. Suitable for most particle simulations without the need + * for opacity. + */ + enum RenderModes { Accumulate = 0, Occlude }; + static VISU_OpenGLPointSpriteMapper *New(); vtkTypeRevisionMacro(VISU_OpenGLPointSpriteMapper,MAPPER_SUPERCLASS); - virtual void PrintSelf(ostream& os, vtkIndent indent); void ShallowCopy(vtkAbstractMapper*); - // Description: - // Specify the name of a scalar array which will be used to control - // the alpha value of each point. The values should be between 0,1 - vtkSetStringMacro(AlphaChannelArray); - vtkGetStringMacro(AlphaChannelArray); - - // Description: - // Specify the name of a scalar array which will be used to control - // the size of each point. - // NOT YET IMPLEMENTED - vtkSetStringMacro(SizeChannelArray); - vtkGetStringMacro(SizeChannelArray); - - // Description: - // Set the initial point size to be used. This value forms the - // base upon which the distance attenuation acts. - // Usually the pointsize is set to the maximum supported by the graphics - // card for sprite display, then the quadratic factors are adjusted to - // bring the size down. - // Set the default size to -1 if you wish the value returned by - // glGetFloatv( GL_POINT_SIZE_MAX_ARB, &MaximimSupportedSize ); - // to be used as the initial default point size. + //! Set the initial point size to be used. + /*! + * This value forms the base upon which the distance attenuation acts. + * Usually the pointsize is set to the maximum supported by the graphics + * card for sprite display, then the quadratic factors are adjusted to + * bring the size down. + */ vtkSetMacro(DefaultPointSize, float); - vtkGetMacro(DefaultPointSize, float); - // Description: - // Set the 3 values (a,b,c) of the parametric function which controls the - // reduction in point size with increasing distance (d). - // e.g. (1,0,0) will give all points the same size regardless of distance. - // @verbatim - // point fading = _____1_______ - // (a + bd + cd^2) - // @endverbatim - vtkSetVector3Macro(QuadraticPointDistanceAttenuation, float); - vtkGetVector3Macro(QuadraticPointDistanceAttenuation, float); + //! Get the initial point size to be used. + vtkGetMacro(DefaultPointSize, float); - // Description: - // Set/Get the RenderMode for this mapper. Currently 2 modes are supported - // Accumulate : Uses glBlendFunc(GL_SRC_ALPHA, GL_ONE), and no depth testing - // so that points are accumulated. Suitable for Galaxy plots. - // Occlude : No blending. Particles are solid spheres and depth testing is - // used as usual. Suitable for most particle simulations without the need - // for opacity. + //! Set the Render Mode for the mapper. vtkSetMacro(RenderMode, int); + + //! Get the Render Mode for the mapper. vtkGetMacro(RenderMode, int); - void SetRenderModeToAccumulate() { this->SetRenderMode(Accumulate); } - void SetRenderModeToOcclude() { this->SetRenderMode(Occlude); } - // Description: - // Implement superclass render method. + //! Implement superclass render method. virtual void RenderPiece(vtkRenderer *ren, vtkActor *a); - // Description: - // Release any graphics resources that are being consumed by this mapper. - // The parameter window could be used to determine which graphic - // resources to release. + //! Release any graphics resources that are being consumed by this mapper. void ReleaseGraphicsResources(vtkWindow *); - // Description: - // Draw method for OpenGL. + //! Draw method for OpenGL. virtual int Draw(vtkRenderer *ren, vtkActor *a); - // Description: - // Return the maximum point size supported by the graphics hardware. - float GetMaximumSupportedSize(); + //! Return the maximum point size supported by the graphics hardware. + static float GetMaximumSupportedSize(); + + //! Set usage of #vtkOpenGLPolyDataMapper. + /*! + * This flags prevents using of the VISU_OpenGLPointSpriteMapper + * (#vtkOpenGLPolyDataMapper is using instead). + */ + vtkSetMacro(UseOpenGLMapper, bool); - // Set/Get usage of Point Sprites + //! Get usage of #vtkOpenGLPolyDataMapper. + vtkGetMacro(UseOpenGLMapper, bool); + + //! Set usage of Point Sprites. vtkSetMacro(UsePointSprites, bool); + + //! Get usage of Point Sprites. vtkGetMacro(UsePointSprites, bool); - // Set/Get usage of textures for Point Sprites - // (only if usage of Point Sprites is turned on) + //! Set usage of textures for Point Sprites. + /*! Works only if usage of Point Sprites is turned on. */ vtkSetMacro(UseTextures, bool); + + //! Get usage of textures for Point Sprites. vtkGetMacro(UseTextures, bool); - // Set/Get usage of vertex shader - // (only if usage of Point Sprites is turned on) + //! Set usage of vertex shader. + /*! Works only if usage of Point Sprites is turned on. */ vtkSetMacro(UseShader, bool); + + //! Get usage of vertex shader. vtkGetMacro(UseShader, bool); // Description: @@ -168,32 +161,54 @@ public: vtkGetMacro(PointSpritePrimitiveType, int); void SetPointSpritePrimitiveType( int ); - // Description: - // Point Sprite size parameters + //! Set Point Sprite Clamp. + void SetPointSpriteClamp( float ); + + //! Get Point Sprite Clamp. vtkGetMacro(PointSpriteClamp, float); - vtkGetMacro(PointSpriteSize, float); - vtkGetMacro(PointSpriteMinSize, float); - vtkGetMacro(PointSpriteMaxSize, float); - vtkGetMacro(PointSpriteMagnification, float); - void SetPointSpriteClamp( float ); + //! Set Point Sprite Const Size. void SetPointSpriteSize( float ); + + //! Get Point Sprite Const Size. + vtkGetMacro(PointSpriteSize, float); + + //! Set Point Sprite Minimum Size. void SetPointSpriteMinSize( float ); + + //! Get Point Sprite Minimum Size. + vtkGetMacro(PointSpriteMinSize, float); + + //! Set Point Sprite Maximum Size. void SetPointSpriteMaxSize( float ); + + //! Get Point Sprite Maximum Size. + vtkGetMacro(PointSpriteMaxSize, float); + + //! Set Point Sprite Magnification. void SetPointSpriteMagnification( float ); - vtkGetMacro(PointSpriteAlphaThreshold, float); + //! Get Point Sprite Magnification. + vtkGetMacro(PointSpriteMagnification, float); + + //! Set Point Sprite AlphaThreshold. void SetPointSpriteAlphaThreshold( float ); + //! Get Point Sprite AlphaThreshold. + vtkGetMacro(PointSpriteAlphaThreshold, float); + + //! Set ImageData for Point Sprite Texture. void SetImageData(vtkImageData* theImageData); + + //! Get ImageData for Point Sprite Texture. vtkImageData* GetImageData(); protected: VISU_OpenGLPointSpriteMapper(); ~VISU_OpenGLPointSpriteMapper(); - void DrawPoints(int idx, - vtkPoints *p, + //! Internal method of the Point Sprites drawing. + void DrawPoints(vtkPoints *p, vtkUnsignedCharArray *c, vtkFloatArray *alpha, vtkIdType &cellNum, @@ -202,38 +217,41 @@ protected: vtkRenderer *ren, vtkActor *act); - // Initializing OpenGL extensions + //! Initializing OpenGL extensions. void InitExtensions(); - // Activate/deactivate Point Sprites + //! Activate Point Sprites. void InitPointSprites(); + + //! Deactivate Point Sprites. void CleanupPointSprites(); - // Initializing textures for Point Sprites + //! Initializing textures for Point Sprites. void InitTextures(); + //! Initializing of the Vertex Shader. + void InitShader(); + + //! Set Vertex Shader variable. + void SetShaderVariable( const char* variable, float value ); + + //! Getting information about Vertex Shader compiling and linking. + void PrintInfoLog( GLhandleARB ); + +private: + bool UseOpenGLMapper; + bool UsePointSprites; bool UseTextures; bool UseShader; - - vtkIdType TotalCells; - + int RenderMode; int ListId; + vtkIdType TotalCells; int ExtensionsInitialized; - int ExtensionsOK; - char *AlphaChannelArray; - double ActorOpacity; - char *SizeChannelArray; float DefaultPointSize; - float QuadraticPointDistanceAttenuation[3]; - int RenderMode; - - void InitShader(); - void PrintInfoLog( GLhandleARB ); - void SetShaderVariable( const char* variable, float value ); - GLhandleARB myVertexProgram; + GLhandleARB VertexProgram; int PointSpriteMode; @@ -248,8 +266,6 @@ protected: float PointSpriteAlphaThreshold; vtkSmartPointer ImageData; - - bool UseOpenGLMapper; }; #endif diff --git a/src/PIPELINE/VISU_PipeLine.cxx b/src/PIPELINE/VISU_PipeLine.cxx index fa92ebda..e6d40ae3 100644 --- a/src/PIPELINE/VISU_PipeLine.cxx +++ b/src/PIPELINE/VISU_PipeLine.cxx @@ -470,9 +470,9 @@ VISU_PipeLine return myExtractGeometry->GetImplicitFunction(); } -void +SALOME_ExtractGeometry* VISU_PipeLine -::SetExtractInside(int theFlag) +::GetExtractGeometryFilter() { - myExtractGeometry->SetExtractInside(theFlag); + return myExtractGeometry.GetPointer(); } diff --git a/src/PIPELINE/VISU_PipeLine.hxx b/src/PIPELINE/VISU_PipeLine.hxx index 09945f79..6109c2a9 100644 --- a/src/PIPELINE/VISU_PipeLine.hxx +++ b/src/PIPELINE/VISU_PipeLine.hxx @@ -199,8 +199,8 @@ public: vtkImplicitFunction* GetImplicitFunction(); - void - SetExtractInside(int); + SALOME_ExtractGeometry* + GetExtractGeometryFilter(); protected: VISU_PipeLine(); diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index 84579bf2..f787a02d 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -70,6 +70,7 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_CutPlanesDlg.cxx \ VisuGUI_StreamLinesDlg.cxx \ VisuGUI_VectorsDlg.cxx \ + VisuGUI_BuildProgressDlg.cxx \ VisuGUI_Timer.cxx LIB_MOC = VisuGUI.h \ @@ -91,7 +92,8 @@ LIB_MOC = VisuGUI.h \ VisuGUI_CutLinesDlg.h \ VisuGUI_CutPlanesDlg.h \ VisuGUI_StreamLinesDlg.h \ - VisuGUI_VectorsDlg.h + VisuGUI_VectorsDlg.h \ + VisuGUI_BuildProgressDlg.h LIB_CLIENT_IDL = SALOME_Exception.idl \ VISU_Gen.idl \ diff --git a/src/VISUGUI/VISUM_msg_en.po b/src/VISUGUI/VISUM_msg_en.po index 88a91075..9cad7e96 100644 --- a/src/VISUGUI/VISUM_msg_en.po +++ b/src/VISUGUI/VISUM_msg_en.po @@ -6,6 +6,12 @@ msgstr "" "Last-Translator: FULLNAME \n" "Content-Type: text/plain; charset=iso-8859-1\n" +msgid "INF_VISU" +msgstr "Post-Pro Info" + +msgid "IMPORT_DONE" +msgstr "Importing is done" + msgid "VisuGUI_Module::MEN_VISUALISATION" msgstr "Visualization" @@ -130,6 +136,15 @@ msgstr "Cursor" msgid "VisuGUI_Module::VISU_PICKING_PREF_PYRAMID_HEIGHT" msgstr "Height of the pyramids" +msgid "VisuGUI_Module::VISU_PICKING_PREF_SELECTION_COLOR" +msgstr "Selection cursor color" + +msgid "VisuGUI_Module::VISU_PICKING_PREF_TOLERANCE_GROUP_TTL" +msgstr "Tolerance" + +msgid "VisuGUI_Module::VISU_PICKING_PREF_POINT_SELECTION_TOLERANCE" +msgstr "Point selection tolerance" + msgid "VisuGUI_Module::VISU_PICKING_PREF_INFO_WINDOW_GROUP_TTL" msgstr "Information window" @@ -161,7 +176,7 @@ msgid "VisuGUI_Module::VISU_PICKING_PREF_DISPLAY_PARENT_MESH" msgstr "Display parent mesh element" msgid "VisuGUI_Module::VISU_MOUSE_PREF_TAB_TLT" -msgstr "Spacemouse" +msgstr "Navigation" msgid "VisuGUI_Module::VISU_MOUSE_PREF_GROUP_TLT" msgstr "Mouse" @@ -247,6 +262,57 @@ msgstr "Gauss Points Preferences" msgid "VisuGUI_GaussPointsDlg::DLG_PROP_TITLE" msgstr "Gauss Points Properties" +msgid "VisuGUI_BuildProgressDlg::DLG_BUILD_PROGRESS_TITLE" +msgstr "Build progress" + +msgid "VisuGUI_BuildProgressDlg::IMPORT_SETTINGS" +msgstr "Settings" + +msgid "VisuGUI_BuildProgressDlg::FILE_NAME" +msgstr "Import file : " + +msgid "VisuGUI_BuildProgressDlg::BUILD_AT_ONCE" +msgstr "Build at once" + +msgid "VisuGUI_BuildProgressDlg::BUILD_ALL" +msgstr "Build all" + +msgid "VisuGUI_BuildProgressDlg::IMPORT_PROGRESS" +msgstr "Import progress" + +msgid "VisuGUI_BuildProgressDlg::BUILD_ENTITIES" +msgstr "Build entities" + +msgid "VisuGUI_BuildProgressDlg::BUILD_FIELDS" +msgstr "Build fields" + +msgid "VisuGUI_BuildProgressDlg::BUILD_GROUPS" +msgstr "Build groups" + +msgid "VisuGUI_BuildProgressDlg::BUILD_MINMAX" +msgstr "Build min/max" + +msgid "VisuGUI_BuildProgressDlg::IMPORT_TIME" +msgstr "Time" + +msgid "VisuGUI_BuildProgressDlg::TIME" +msgstr "Elapsed time : " + +msgid "VisuGUI_BuildProgressDlg::IMPORT_FROM_FILE" +msgstr "Import from File" + +msgid "VisuGUI_BuildProgressDlg::FLT_ALL_FILES" +msgstr "All Files (*.*)" + +msgid "VisuGUI_BuildProgressDlg::FLT_MED_FILES" +msgstr "MED Files (*.med)" + +msgid "VisuGUI_BuildProgressDlg::START" +msgstr "Start" + +msgid "VisuGUI_BuildProgressDlg::CLOSE" +msgstr "Close" + msgid "VVTK_ViewManager::VTK_VIEW_TITLE" msgstr "VISU scene:%1 - viewer:%2" @@ -529,6 +595,15 @@ msgstr "Cursor" msgid "VVTK_PickingDlg::PYRAMID_HEIGHT" msgstr "Height of the pyramids :" +msgid "VVTK_PickingDlg::SELECTION_COLOR" +msgstr "Selection cursor color :" + +msgid "VVTK_PickingDlg::TOLERANCE_TITLE" +msgstr "Tolerance" + +msgid "VVTK_PickingDlg::POINT_TOLERANCE" +msgstr "Point tolerance :" + msgid "VVTK_PickingDlg::INFO_WINDOW_TITLE" msgstr "Information window" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 99b80b0e..16b33f07 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -37,11 +37,13 @@ #include #include #include +#include // VTK Includes #include #include #include +#include // SALOME Includes #include "SALOME_LifeCycleCORBA.hxx" @@ -102,6 +104,7 @@ #include "VisuGUI_Plot3DDlg.h" #include "VisuGUI_OffsetDlg.h" #include "VisuGUI_Displayer.h" +#include "VisuGUI_BuildProgressDlg.h" #include "VISU_ScalarMap_i.hh" #include "VisuGUI_ScalarBarDlg.h" @@ -158,63 +161,16 @@ VisuGUI::~VisuGUI() { } - void VisuGUI:: OnImportFromFile() { - VisuGUI_Timer aTimer; - aTimer.Start(); - if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()"); - if ( CheckLock(GetCStudy(GetAppStudy(this))) ) - return; - SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - - QStringList aFilter; - aFilter.append( tr("FLT_MED_FILES") ); - aFilter.append( tr("FLT_ALL_FILES") ); - - QFileInfo aFileInfo = - SUIT_FileDlg::getFileName(GetDesktop(this), - "", - aFilter, - tr("MEN_IMPORT_FROM_FILE"), - true); - if(aFileInfo.exists()) { - application()->putInfo( "Importing From File " + aFileInfo.filePath() + "...", -1 ); - - VISU::Result_var aResult; - bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false); - if (VisuGUI_FileDlg::IsBuild) { - aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath()); - if (!CORBA::is_nil(aResult.in())) - if (Result_i* aRes = dynamic_cast(GetServant(aResult).in())) { - if (!aRes->IsPossible()) - SUIT_MessageBox::warn1(GetDesktop(this), - tr("WRN_VISU"), - tr("ERR_CANT_BUILD_PRESENTATION"), - tr("BUT_OK")); - else - aRes->BuildAll(); - } - } else { - aResourceMgr->setValue("VISU", "full_med_loading", false); - aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath()); - aResourceMgr->setValue("VISU", "full_med_loading", anIsBuild); - } + CheckLock(GetCStudy(GetAppStudy(this))); - if (CORBA::is_nil(aResult.in())) { - SUIT_MessageBox::warn1(GetDesktop(this), - tr("WRN_VISU"), - tr("ERR_ERROR_IN_THE_FILE"), - tr("BUT_OK")); - }else{ - UpdateObjBrowser(this); - application()->putInfo(aFileInfo.filePath() + tr("INF_DONE") + - " in " + aTimer.GetTime() + " seconds", -1 ); - } - } + VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) ); + aBuildProgressDlg->setGenerator( GetVisuGen(this) ); + aBuildProgressDlg->show(); } @@ -714,7 +670,7 @@ OnEditScalarMap() Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ aViewWindow->highlight(anIO, 1); } } @@ -728,7 +684,7 @@ OnEditDeformedShape() Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ aViewWindow->highlight(anIO, 1); } } @@ -742,7 +698,7 @@ OnEditCutPlanes() Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ aViewWindow->highlight(anIO, 1); } } @@ -756,7 +712,7 @@ OnEditCutLines() Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ aViewWindow->highlight(anIO, 1); } } @@ -770,7 +726,7 @@ OnEditIsoSurfaces() Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ aViewWindow->highlight(anIO, 1); } } @@ -784,7 +740,7 @@ OnEditVectors() Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ aViewWindow->highlight(anIO, 1); } } @@ -798,7 +754,7 @@ OnEditStreamLines() Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ aViewWindow->highlight(anIO, 1); } } @@ -812,7 +768,7 @@ OnEditPlot3D() Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ aViewWindow->highlight(anIO, 1); } } @@ -824,7 +780,7 @@ VisuGUI:: OnEraseAll() { startOperation( myEraseAll ); - if (SVTK_ViewWindow* vw = GetViewWindow()) { + if (SVTK_ViewWindow* vw = GetViewWindow(this)) { vw->unHighlightAll(); if (vtkRenderer *aRen = vw->getRenderer()) { vtkActor *anActor; @@ -911,7 +867,7 @@ OnChangeColor() VISU::Prs3d_i* aPrs3d = dynamic_cast(aServant.in()); if (!aPrs3d) return; - SVTK_ViewWindow* vw = GetViewWindow(); + SVTK_ViewWindow* vw = GetViewWindow(this); if (!vw) return; VISU_Actor* anActor = GetActor(aPrs3d, vw); @@ -983,7 +939,7 @@ OnChangeWireframeColor() VISU::Prs3d_i* aPrs3d = dynamic_cast(aServant.in()); if (!aPrs3d) return; - SVTK_ViewWindow* vw = GetViewWindow(); + SVTK_ViewWindow* vw = GetViewWindow(this); if (!vw) return; VISU_Actor* anActor = GetActor(aPrs3d, vw); @@ -1018,7 +974,7 @@ OnChangeOpacity() VISU::Prs3d_i* aPrsObject = dynamic_cast(aServant.in()); if (!aPrsObject) return; - SVTK_ViewWindow* vw = GetViewWindow(); + SVTK_ViewWindow* vw = GetViewWindow(this); if (!vw) return; VISU_Actor* anActor = GetActor(aPrsObject, vw); @@ -1058,7 +1014,7 @@ OnChangeLines() VISU::Prs3d_i* aPrsObject = dynamic_cast(aServant.in()); if (!aPrsObject) return; - SVTK_ViewWindow* vw = GetViewWindow(); + SVTK_ViewWindow* vw = GetViewWindow(this); if (!vw) return; VISU_Actor* anActor = GetActor(aPrsObject, vw); @@ -1584,7 +1540,7 @@ OnSweep() VISU::ScalarMap_i* aPrsObject = dynamic_cast(aServant.in()); if (!aPrsObject) return; - SVTK_ViewWindow* vw = GetViewWindow(); + SVTK_ViewWindow* vw = GetViewWindow(this); if (!vw) return; VISU_Actor* aActor = GetActor(aPrsObject, vw); @@ -1627,9 +1583,11 @@ void VisuGUI:: OnTimeAnimation() { + if(!VISU::GetViewWindow()) + return; + _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); VisuGUI_TimeAnimationDlg* aAnimationDlg = -// new VisuGUI_TimeAnimationDlg(GetDesktop(this), aCStudy); new VisuGUI_TimeAnimationDlg (this, aCStudy); LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); @@ -1664,6 +1622,9 @@ void VisuGUI:: OnShowAnimation() { + if(!VISU::GetViewWindow()) + return; + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); @@ -1794,8 +1755,8 @@ void VisuGUI:: OnSelectionInfo() { - if (GetViewWindow()) - (new VisuGUI_SelectionDlg(GetDesktop(this)))->show(); + if (GetViewWindow(this)) + (new VisuGUI_SelectionDlg(this))->show(); else SUIT_MessageBox::warn1(GetDesktop(this), tr("WRN_VISU"), @@ -1944,7 +1905,7 @@ void VisuGUI:: OnArrangeActors() { - SVTK_ViewWindow* vw = GetViewWindow(); + SVTK_ViewWindow* vw = GetViewWindow(this); if (vw) { ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw); aDlg->exec(); @@ -2579,7 +2540,7 @@ createPopupMenus() aRule = "client='VTKViewer' and selcount=1" + aInsideType; mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true ); - aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1"; + aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1 and activeView='VTKViewer'"; mgr->setRule( action( VISU_ANIMATION ), aRule, true ); aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}"; diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index 3b8e345c..098f8bff 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -33,6 +33,7 @@ #include "VISU_GaussPoints_i.hh" #include "VISU_GaussPointsPL.hxx" +#include "VISU_OpenGLPointSpriteMapper.hxx" #include "VISU_Convertor.hxx" #include "VVTK_PrimitiveBox.h" @@ -246,7 +247,7 @@ VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent, bool S // signals and slots connections =========================================== connect( myRBLocal, SIGNAL( toggled( bool ) ), myCBDisplayed, SLOT( setEnabled( bool ) ) ); - connect( myRBGlobal, SIGNAL( toggled( bool ) ), myCBDisplayed, SLOT( setChecked( bool ) ) ); + connect( myRBGlobal, SIGNAL( clicked() ), this, SLOT( onSetDisplayGlobal() ) ); connect( RainbowButton, SIGNAL( toggled( bool ) ), ColorLabel, SLOT( setEnabled( bool ) ) ); connect( RainbowButton, SIGNAL( toggled( bool ) ), ColorSpin, SLOT( setEnabled( bool ) ) ); connect( RainbowButton, SIGNAL( toggled( bool ) ), LabelLabel, SLOT( setEnabled( bool ) ) ); @@ -260,6 +261,12 @@ VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent, bool S myIsStoreTextProp = false; } +void VisuGUI_GaussScalarBarPane::onSetDisplayGlobal() +{ + myCBDisplayed->setChecked( true ); +} + + /** * Initialise dialog box from presentation object */ diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.h b/src/VISUGUI/VisuGUI_GaussPointsDlg.h index 6ffd3bd4..27b46071 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.h +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.h @@ -53,6 +53,8 @@ namespace VISU class GaussPoints_i; } +//! Specific Scalar Bar tab. +/*! Uses for set up Gauss Points Scalar Bars preferenses. */ class VisuGUI_GaussScalarBarPane : public QVBox { Q_OBJECT @@ -115,17 +117,26 @@ class VisuGUI_GaussScalarBarPane : public QVBox void changeRange( int ); void XYChanged( double ); void onTextPref(); + void onSetDisplayGlobal(); }; - +//! Create Gauss Points Presentation Dialog. +/*! + * Uses for set up initial parameters of the Gauss Points + * presentation and edit them interactively. + */ class VisuGUI_GaussPointsDlg : public QDialog { Q_OBJECT + public: VisuGUI_GaussPointsDlg (SalomeApp_Module* theModule, bool SetPref = FALSE); ~VisuGUI_GaussPointsDlg() {} + //! Initializing dialog from the Gauss Points presentation. void initFromPrsObject(VISU::GaussPoints_i* thePrs); + + //! Update Gauss Points presentation using parameters from the dialog. int storeToPrsObject(VISU::GaussPoints_i* thePrs); protected slots: diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 510f6f9d..4c5f00e2 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -73,8 +73,11 @@ #include "VVTK_MainWindow.h" #include "VISU_View_i.hh" +#include + #include #include +#include #include @@ -86,7 +89,9 @@ static int MYDEBUG = 0; #define GAUSS_NEW_VIEWER 5100 #define GAUSS_CREATE_PRS 5200 +#define GAUSS_RENAME 5210 #define GAUSS_EDIT_PRS 5300 +#define GAUSS_COPY_PRS 5310 #define GAUSS_ERASE_PRS 5400 #define GAUSS_DISPLAY_PRS 5500 #define GAUSS_DISPLAY_ONLY_PRS 5600 @@ -238,6 +243,14 @@ VisuGUI_Module createMenu( action( GAUSS_CREATE_PRS ), createMenu( tr( "MEN_VISUALISATION" ), -1 ), -1 ); createTool( GAUSS_CREATE_PRS, createTool( tr( "TOOL_VISUALISATION" ) ), -1 ); + createAction( GAUSS_RENAME, VisuGUI::tr("MEN_RENAME"), QIconSet(), + VisuGUI::tr("MEN_RENAME"), "", 0, this, false, + this, SLOT(OnRename())); + mgr->insert( action( GAUSS_RENAME ), -1, 0, -1 ); + mgr->setRule( action( GAUSS_RENAME ), + "selcount=1 and type='VISU::TGAUSSPOINTS'", + true ); + createAction( GAUSS_EDIT_PRS, VisuGUI::tr("MEN_EDIT_PRS"), QIconSet(), VisuGUI::tr("MEN_EDIT_PRS"), "", 0, this, false, this, SLOT(OnEditGaussPoints())); @@ -246,6 +259,15 @@ VisuGUI_Module "selcount=1 and type='VISU::TGAUSSPOINTS'", true ); + createAction( GAUSS_COPY_PRS, VisuGUI::tr("MEN_COPY_PRS"), QIconSet(), + VisuGUI::tr("MEN_COPY_PRS"), "", 0, this, false, + this, SLOT(OnCopyPresentation())); + mgr->insert( action( GAUSS_COPY_PRS ), -1, 0, -1 ); + mgr->setRule( action( GAUSS_COPY_PRS ), + "selcount=1 and type='VISU::TGAUSSPOINTS'", + true ); + action( GAUSS_COPY_PRS )->setEnabled(false); + aRule = "(selcount>0 and type='VISU::TGAUSSPOINTS')"; createAction( GAUSS_ERASE_PRS, VisuGUI::tr("MEN_ERASE"), QIconSet(), @@ -580,12 +602,28 @@ VisuGUI_Module { int pickingTab = addPreference( tr( "VISU_PICKING_PREF_TAB_TTL" ) ); + // Cursor int cursorGr = addPreference( tr( "VISU_PICKING_PREF_CURSOR_GROUP_TTL" ), pickingTab ); + setPreferenceProperty( cursorGr, "columns", 1 ); + int pyramidHeightPref = addPreference( tr( "VISU_PICKING_PREF_PYRAMID_HEIGHT" ), cursorGr, LightApp_Preferences::DblSpin, "VISU", "picking_pyramid_height" ); setPreferenceProperty( pyramidHeightPref, "min", 1 ); setPreferenceProperty( pyramidHeightPref, "max", 100 ); + int selectionColorPref = addPreference( tr( "VISU_PICKING_PREF_SELECTION_COLOR" ), cursorGr, + LightApp_Preferences::Color, "VISU", "picking_selection_color" ); + + // Tolerance + int toleranceGr = addPreference( tr( "VISU_PICKING_PREF_TOLERANCE_GROUP_TTL" ), pickingTab ); + + int pointTolerancePref = addPreference( tr( "VISU_PICKING_PREF_POINT_SELECTION_TOLERANCE" ), toleranceGr, + LightApp_Preferences::DblSpin, "VISU", "picking_point_tolerance" ); + setPreferenceProperty( pointTolerancePref, "min", 0.001 ); + setPreferenceProperty( pointTolerancePref, "max", 10 ); + setPreferenceProperty( pointTolerancePref, "step", 0.01 ); + + // Info window int infoWindowGr = addPreference( tr( "VISU_PICKING_PREF_INFO_WINDOW_GROUP_TTL" ), pickingTab ); setPreferenceProperty( infoWindowGr, "columns", 1 ); @@ -606,6 +644,7 @@ VisuGUI_Module setPreferenceProperty( positionPref, "strings", values ); setPreferenceProperty( positionPref, "indexes", indices ); + // Camera int cameraGr = addPreference( tr( "VISU_PICKING_PREF_CAMERA_GROUP_TTL" ), pickingTab ); setPreferenceProperty( cameraGr, "columns", 1 ); @@ -620,6 +659,7 @@ VisuGUI_Module setPreferenceProperty( stepNumberPref, "min", 1 ); setPreferenceProperty( stepNumberPref, "max", 100 ); + // Display parent mesh int parentMeshGr = addPreference( tr( "VISU_PICKING_PREF_PARENT_MESH_TTL" ), pickingTab ); setPreferenceProperty( parentMeshGr, "columns", 1 ); @@ -703,7 +743,10 @@ void VisuGUI_Module ::OnCreateGaussPoints() { + double initialTime = vtkTimerLog::GetCPUTime(); CreatePrs3d(this,true); + INFOS( "VisuGUI_Module::OnCreateGaussPoints() : Gauss Points created in " << + vtkTimerLog::GetCPUTime() - initialTime << " seconds" ); } void @@ -844,10 +887,15 @@ VisuGUI_Module if(!CORBA::is_nil(anObject)){ if(VISU::Prs3d_i* aPrs3d = dynamic_cast(VISU::GetServant(anObject).in())){ if(MYDEBUG) MESSAGE("VisuGUI_Module::OnDisplayPrs : Prs3d object"); - if(aPrs3d->GetType() != VISU::TGAUSSPOINTS) - VISU::UpdateViewer(this,aPrs3d,false,true,true); - else + if(aPrs3d->GetType() == VISU::TGAUSSPOINTS) VISU::UpdateViewer(this,aPrs3d,false,true,true); + else if(SUIT_ViewManager* aViewManager = getApp()->activeViewManager()){ + QString aType = aViewManager->getType(); + if(aType == SVTK_Viewer::Type()) + VISU::UpdateViewer(this,aPrs3d,false,true,true); + else if(aType == VVTK_Viewer::Type()) + VISU::UpdateViewer(this,aPrs3d,false,true,true); + } continue; } } @@ -901,24 +949,7 @@ void VisuGUI_Module ::OnDisplayOnlyPrs() { - if(LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this)){ - SALOME_ListIO aList; - aSelectionMgr->selectedObjects(aList); - for(SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next()){ - Handle(SALOME_InteractiveObject) anIO = it.Value(); - CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() ); - - if(!CORBA::is_nil(anObject)){ - if(VISU::Prs3d_i* aPrs3d = dynamic_cast(VISU::GetServant(anObject).in())){ - if(aPrs3d->GetType() != VISU::TGAUSSPOINTS) - VISU::OnEraseAll(this); - else - VISU::OnEraseAll(this); - break; - } - } - } - } + OnEraseAll(); OnDisplayPrs(); } diff --git a/src/VISUGUI/VisuGUI_Module.h b/src/VISUGUI/VisuGUI_Module.h index 1081b16f..58644baa 100644 --- a/src/VISUGUI/VisuGUI_Module.h +++ b/src/VISUGUI/VisuGUI_Module.h @@ -46,7 +46,8 @@ namespace VISU typedef std::map TViewerMap; } - +//! This class inherits base VisuGUI. +/*! Used to display, erase end edit presentations in the VVTK viewer. */ class VisuGUI_Module: public VisuGUI { Q_OBJECT; @@ -59,10 +60,12 @@ public: virtual ~VisuGUI_Module(); + //! Redifined method of the module initializing. virtual void initialize( CAM_Application* ); + //! Redefined method of creating prefernces. virtual void createPreferences(); @@ -77,23 +80,28 @@ public: const bool theIsCreate); public slots: + //! Reimplemented method of the module deactivation. virtual bool deactivateModule( SUIT_Study* ); + //! Reimplemented method of the module activation. virtual bool activateModule( SUIT_Study* ); protected: + //! Create preferences for Gauss Points presentation. virtual void createGaussPointsPreferences(); + //! Create preferences for Gauss Points Scalar Bars. virtual void createScalarBarPreferences(); + //! Create preferences for Outside Cursor Gauss Points presentations. virtual void createInsideCursorPreferences(); @@ -102,10 +110,12 @@ protected: void createOutsideCursorPreferences(); + //! Create preferences for Picking. virtual void createPickingPreferences(); + //! Create preferences for Space Mouse. virtual void createSpaceMousePreferences(); @@ -126,30 +136,37 @@ protected slots: void OnViewManagerAdded(SUIT_ViewManager*); + //! Reimplemented method of the Gauss Points edition. virtual void OnEditGaussPoints(); + //! Reimplemented method of the Gauss Points displaying. virtual void OnDisplayPrs(); + //! Reimplemented method of the Gauss Points displaying only. virtual void OnDisplayOnlyPrs(); + //! Reimplemented method of the Gauss Points full erasing. virtual void OnEraseAll(); + //! Reimplemented method of the Gauss Points erasing. virtual void OnErasePrs(); + //! Reimplemented method of saving view parameters. virtual void OnSaveViewParams(); + //! Reimplemented method of restoring view parameters. virtual void OnRestoreViewParams(); diff --git a/src/VISUGUI/VisuGUI_OffsetDlg.cxx b/src/VISUGUI/VisuGUI_OffsetDlg.cxx index bb078813..7465cee5 100644 --- a/src/VISUGUI/VisuGUI_OffsetDlg.cxx +++ b/src/VISUGUI/VisuGUI_OffsetDlg.cxx @@ -156,7 +156,7 @@ void VisuGUI_OffsetDlg::updateOffset (VISU::Prs3d_i* thePrs, float* theOffset) ViewManagerList aViewManagerList; SalomeApp_Application* anApp = myModule->getApp(); - anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList); + anApp->viewManagers(aViewManagerList); QPtrListIterator anVMIter (aViewManagerList); for (; anVMIter.current(); ++anVMIter) { SUIT_ViewManager* aViewManager = anVMIter.current(); diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index 4287a9ab..d9a4b448 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -213,8 +213,15 @@ namespace VISU CreatePrs3d(VisuGUI* theModule, const bool theIsCreateView = true) { - CreatePrs3d(theModule,theIsCreateView); + if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){ + QString aType = aViewManager->getType(); + if(aType == SVTK_Viewer::Type()) + CreatePrs3d(theModule,theIsCreateView); + else if(aType == VVTK_Viewer::Type()) + CreatePrs3d(theModule,theIsCreateView); + } } + } #endif diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 4ffcf68d..d5043f9c 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -89,10 +89,13 @@ using namespace std; static VisuGUI_SelectionDlg* mySelectionDlg = NULL; -VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (QWidget* parent) - : QDialog(parent, 0, false, WStyle_Customize | WStyle_NormalBorder | - WStyle_Title | WStyle_SysMenu | WDestructiveClose), - mySelectionMgr(NULL) +VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (const SalomeApp_Module* theModule): + QDialog(VISU::GetDesktop(theModule), + 0, + false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), + mySelectionMgr(NULL), + myModule(theModule) { if (mySelectionDlg) mySelectionDlg->close(true); @@ -259,10 +262,9 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (QWidget* parent) myFl = false; // Activate Points pane - SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow(); myWidgetStack->raiseWidget(myPointsPane); - if (aSVTKVW) - aSVTKVW->SetSelectionMode(NodeSelection); + if(SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule)) + aViewWindow->SetSelectionMode(NodeSelection); onSelectionEvent(); mySelectionDlg = this; @@ -274,23 +276,23 @@ VisuGUI_SelectionDlg::~VisuGUI_SelectionDlg() void VisuGUI_SelectionDlg::onSelectionChange (int theId) { - SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow(); - if (!aSVTKVW) return; + SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule); + if (!aViewWindow) return; switch (theId) { case 0: // Points myWidgetStack->raiseWidget(myPointsPane); - aSVTKVW->SetSelectionMode(NodeSelection); + aViewWindow->SetSelectionMode(NodeSelection); onPointIdEdit(myIDValLbl->text()); break; case 1: // Cells myWidgetStack->raiseWidget(myCellsPane); - aSVTKVW->SetSelectionMode(CellSelection); + aViewWindow->SetSelectionMode(CellSelection); onCellIdEdit(myCellIDValLbl->text()); break; case 2: // Actor myWidgetStack->raiseWidget(myActorsPane); - aSVTKVW->SetSelectionMode(ActorSelection); + aViewWindow->SetSelectionMode(ActorSelection); onSelectionEvent(); } } @@ -298,11 +300,9 @@ void VisuGUI_SelectionDlg::onSelectionChange (int theId) void VisuGUI_SelectionDlg::closeEvent (QCloseEvent* theEvent) { - SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow(); - mySelectionDlg = NULL; - if (aSVTKVW) - aSVTKVW->SetSelectionMode(ActorSelection); + if(SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule)) + aViewWindow->SetSelectionMode(ActorSelection); disconnect(mySelectionMgr,0,0,0); QDialog::closeEvent(theEvent); } @@ -328,8 +328,8 @@ template QString getVector(TData* theData, int theId){ #define ABS(a) (a>=0)?a:-a void VisuGUI_SelectionDlg::onSelectionEvent() { - SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow(); - if (!aSVTKVW) return; + SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule); + if (!aViewWindow) return; if (myFl) return; myFl = true; @@ -339,14 +339,14 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { SalomeApp_Application* anApp = dynamic_cast (SUIT_Session::session()->activeApplication()); - SVTK_Selector* aSelector = aSVTKVW->GetSelector(); + SVTK_Selector* aSelector = aViewWindow->GetSelector(); VISU::Prs3d_i* aPrs3d = NULL; _PTR(SObject) aSObject; Handle(SALOME_InteractiveObject) anIO; SALOME_ListIO aListIO; - mySelectionMgr->selectedObjects(aListIO, SVTK_Viewer::Type()); + mySelectionMgr->selectedObjects(aListIO); if (aListIO.Extent() == 1) { anIO = aListIO.First(); @@ -392,7 +392,7 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { myFieldName->setText((aFieldName == "NULL") ? QString("No name") : aFieldName); VISU_Actor* anVISUActor = - VISU::FindActor(aSVTKVW, aSObject->GetID().c_str()); + VISU::FindActor(aViewWindow, aSObject->GetID().c_str()); if (anVISUActor) { float aCoord[6]; anVISUActor->GetBounds(aCoord); @@ -512,16 +512,16 @@ typedef vtkIdType (vtkDataSet::* TDataSetMethod)(); bool onIdEdit (const QString& theText, TDataSetMethod theMethod, bool theIsCell, + const SalomeApp_Module* theModule, LightApp_SelectionMgr* theSelectionMgr, QLabel* theMeshName, QString theValue, QLabel* theFieldName) { - SalomeApp_Application* anApp = dynamic_cast - (SUIT_Session::session()->activeApplication()); - SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow(); - if (!aSVTKVW) return false; - SVTK_Selector* aSelector = aSVTKVW->GetSelector(); + SalomeApp_Application* anApp = theModule->getApp(); + SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(theModule); + if (!aViewWindow) return false; + SVTK_Selector* aSelector = aViewWindow->GetSelector(); VISU::Prs3d_i* aPrs3d = NULL; Handle(SALOME_InteractiveObject) anIO; @@ -561,7 +561,7 @@ bool onIdEdit (const QString& theText, TColStd_MapOfInteger newIndices; newIndices.Add(anId); aSelector->AddOrRemoveIndex(anIO, newIndices, false); - aSVTKVW->highlight(anIO, true, true); + aViewWindow->highlight(anIO, true, true); return true; @@ -576,7 +576,7 @@ void VisuGUI_SelectionDlg::onPointIdEdit (const QString& theText) { if (myFl) return; TDataSetMethod aMethod = &vtkDataSet::GetNumberOfPoints; - bool anIsSelected = onIdEdit(theText,aMethod,false,mySelectionMgr, + bool anIsSelected = onIdEdit(theText,aMethod,false,myModule,mySelectionMgr, myMeshName,tr("WRN_NO_AVAILABLE_DATA"), myFieldName); if (anIsSelected) @@ -590,7 +590,7 @@ void VisuGUI_SelectionDlg::onCellIdEdit (const QString& theText) { if (myFl) return; TDataSetMethod aMethod = &vtkDataSet::GetNumberOfCells; - bool anIsSelected = onIdEdit(theText,aMethod,true,mySelectionMgr, + bool anIsSelected = onIdEdit(theText,aMethod,true,myModule,mySelectionMgr, myMeshName,tr("WRN_NO_AVAILABLE_DATA"), myFieldName); if (anIsSelected) diff --git a/src/VISUGUI/VisuGUI_Selection.h b/src/VISUGUI/VisuGUI_Selection.h index 4fc4f265..467e9c18 100644 --- a/src/VISUGUI/VisuGUI_Selection.h +++ b/src/VISUGUI/VisuGUI_Selection.h @@ -38,12 +38,13 @@ class QLineEdit; class QTable; class LightApp_SelectionMgr; class SalomeApp_Application; +class SalomeApp_Module; class VisuGUI_SelectionDlg: public QDialog { Q_OBJECT public: - VisuGUI_SelectionDlg (QWidget*); + VisuGUI_SelectionDlg (const SalomeApp_Module* theModule); virtual ~VisuGUI_SelectionDlg (); protected: @@ -85,6 +86,7 @@ private slots: QLabel* myDYLbl; QLabel* myDZLbl; + const SalomeApp_Module* myModule; LightApp_SelectionMgr* mySelectionMgr; bool myFl; }; diff --git a/src/VISUGUI/VisuGUI_Timer.cxx b/src/VISUGUI/VisuGUI_Timer.cxx index ce88bbfc..ca1eea96 100644 --- a/src/VISUGUI/VisuGUI_Timer.cxx +++ b/src/VISUGUI/VisuGUI_Timer.cxx @@ -74,8 +74,9 @@ void VisuGUI_Timer::Stop() int diffr_sys = RefToCurrentTMS->tms_stime - RefToInitialTMS->tms_stime; gettimeofday(RefToCurrentTimeB,tz); - Cumul_user += (double) diffr_user / CLK_TCK ; - Cumul_sys += (double) diffr_sys / CLK_TCK ; + static long aCLK_TCK=sysconf(_SC_CLK_TCK); + Cumul_user += (double) diffr_user / aCLK_TCK ; + Cumul_sys += (double) diffr_sys / aCLK_TCK ; #else SYSTEMTIME st; GetSystemTime(&st); diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 5484e621..1fc889d1 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -462,9 +462,7 @@ namespace VISU ChangeRepresentation (const SalomeApp_Module* theModule, VISU::PresentationType theType) { - SUIT_ViewWindow* aView = GetActiveView(theModule, SVTK_Viewer::Type()); - if (!aView) return; - SVTK_ViewWindow* vw = dynamic_cast( aView ); + SVTK_ViewWindow* vw = GetViewWindow( theModule, false ); if( !vw ) return; @@ -653,11 +651,15 @@ namespace VISU /*SVTK_ViewWindow* GetViewWindow(const SalomeApp_Module* theModule, const bool theCreate ) { - if(SalomeApp_Application* anApp = theModule->getApp()){ - if(SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), theCreate )){ - if(SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()){ - return dynamic_cast(aViewWindow); - } + if (SalomeApp_Application* anApp = theModule->getApp()) + { + SVTK_ViewWindow* wnd = dynamic_cast(anApp->desktop()->activeWindow()); + if( wnd ) + return wnd; + else + { + if(SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), theCreate )) + return dynamic_cast( aViewManager->getActiveView() ); } } return NULL; @@ -816,15 +818,7 @@ namespace VISU try { thePrs->Update(); - - TViewWindows aViewWindows = GetViews(theModule); - for (int i = 0, iEnd = aViewWindows.size(); i < iEnd; i++) { - SVTK_ViewWindow* aView = aViewWindows[i]; - if (VISU_Actor* anActor = FindActor(aView, anEntry.in())) { - isPublished = true; - thePrs->UpdateActor(anActor); - } - } + thePrs->UpdateActors(); } catch (std::runtime_error& ex) { INFOS(ex.what()); QApplication::restoreOverrideCursor(); @@ -832,14 +826,7 @@ namespace VISU QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(ex.what()), QObject::tr("BUT_OK")); - TViewWindows aViewWindows = GetViews(theModule); - for (int i = 0, iEnd = aViewWindows.size(); i < iEnd; i++) { - SVTK_ViewWindow* aView = aViewWindows[i]; - if (VISU_Actor* anActor = FindActor(aView, anEntry.in())) { - aView->RemoveActor(anActor); - anActor->Delete(); - } - } + thePrs->RemoveActors(); return; } QApplication::restoreOverrideCursor(); diff --git a/src/VISUGUI/VisuGUI_ViewTools.cxx b/src/VISUGUI/VisuGUI_ViewTools.cxx index bc2650dc..868ab606 100644 --- a/src/VISUGUI/VisuGUI_ViewTools.cxx +++ b/src/VISUGUI/VisuGUI_ViewTools.cxx @@ -61,8 +61,13 @@ namespace VISU if(VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(theBase).in())){ if(aType == VISU::TGAUSSPOINTS) ErasePrs3d(theModule,aPrsObject,thIsUpdate); - else - ErasePrs3d(theModule,aPrsObject,thIsUpdate); + else if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){ + QString aType = aViewManager->getType(); + if(aType == SVTK_Viewer::Type()) + ErasePrs3d(theModule,aPrsObject,thIsUpdate); + else if(aType == VVTK_Viewer::Type()) + ErasePrs3d(theModule,aPrsObject,thIsUpdate); + } } }} // switch (aType) } diff --git a/src/VISU_I/Makefile.in b/src/VISU_I/Makefile.in index 107f3e24..dedfe061 100644 --- a/src/VISU_I/Makefile.in +++ b/src/VISU_I/Makefile.in @@ -19,6 +19,7 @@ VPATH=.:@srcdir@:@top_srcdir@/idl LIB = libVISUEngineImpl.la LIB_SRC = \ + VISU_Result_i.cc \ VISUConfig.cc \ VISU_PrsObject_i.cc \ VISU_Prs3d_i.cc \ @@ -35,7 +36,6 @@ LIB_SRC = \ VISU_Mesh_i.cc \ VISU_Table_i.cc \ VISU_Gen_i.cc \ - VISU_Result_i.cc \ VISU_ViewManager_i.cc \ VISU_View_i.cc \ VISU_TimeAnimation.cxx \ diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index 6c0d4a64..f255cd5d 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -606,7 +606,6 @@ VISU::GaussPoints_i vtkIdType aScalarMode = GetScalarMode(); TMinMax aTMinMax = myField->GetMinMax(aScalarMode); aScalarBarCtrl->SetRangeGlobal(aTMinMax.first, aTMinMax.second); - aScalarBarCtrl->SetOrientation(myOrientation); int aScalarBarMode; @@ -620,6 +619,15 @@ VISU::GaussPoints_i } } + if (aScalarBarMode==1){ + float aRangeGlobal[2]; + // + aRangeGlobal[0]=aTMinMax.first; + aRangeGlobal[1]=aTMinMax.second; + + GetGaussPointsPL()->GetMapper()->SetScalarRange(aRangeGlobal); + } + aScalarBarCtrl->SetMode(aScalarBarMode); // Position diff --git a/src/VISU_I/VISU_GaussPoints_i.hh b/src/VISU_I/VISU_GaussPoints_i.hh index 3ae3acd0..c6fe0cd9 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -34,6 +34,7 @@ class VISU_GaussPointsPL; namespace VISU { + //! Class of the Gauss Points presentation. class GaussPoints_i : public virtual POA_VISU::GaussPoints, public virtual VISU::TGaussPtsActorFactory, public virtual ColoredPrs3d_i @@ -65,6 +66,7 @@ namespace VISU typedef VISU::GaussPoints TInterface; + //! Get the Gauss Points Pipeline. VISU_GaussPointsPL* GetGaussPointsPL(); @@ -80,37 +82,49 @@ namespace VISU void SetScaleFactor( float theScaleFactor ); + //! Get color for Geometry mode of the presentation. QColor GetColor() { return myColor; } + //! Set color for Geometry mode of the presentation. void SetColor( const QColor& theColor ) { myColor = theColor; } + //! Get flag indicating which mode of the presentation is active. + /*! When Results mode is active, returns true. Geometry - false. */ bool GetIsColored() { return myIsColored; } + //! Get flag indicating which mode of the presentation is active. void SetIsColored( bool theIsColored ); + //! Set path to the image using for Main Point Sprite texture. bool SetMainTexture( const QString& theMainTexture ); + //! Get path to the image using for Main Point Sprite texture. const QString& GetMainTexture(); + //! Set path to the image using for Alpha Point Sprite texture. bool SetAlphaTexture( const QString& theAlphaTexture ); + //! Get path to the image using for Alpha Point Sprite texture. const QString& GetAlphaTexture(); + //! Convert Main and AlphaMask images to VTI format and set them to pipeline. void SetTextures( const QString& theMainTexture, const QString& theAlphaTexture ); + //! Redirect the request to VISU_GaussPointsPL::SetAlphaThreshold. void SetAlphaThreshold(float theAlphaThreshold); + //! Redirect the request to VISU_GaussPointsPL::GetAlphaThreshold. float GetAlphaThreshold(); @@ -120,69 +134,87 @@ namespace VISU int GetPrimitiveType(); + //! Redirect the request to VISU_GaussPointsPL::GetMaximumSupportedSize. float GetMaximumSupportedSize(); + //! Redirect the request to VISU_GaussPointsPL::SetClamp. void SetClamp(float theClamp); + //! Redirect the request to VISU_GaussPointsPL::GetClamp. float GetClamp(); + //! Redirect the request to VISU_GaussPointsPL::SetSize. void SetGeomSize(float theGeomSize); + //! Redirect the request to VISU_GaussPointsPL::GetSize. float GetGeomSize(); + //! Redirect the request to VISU_GaussPointsPL::SetMinSize. void SetMinSize(float theMinSize); + //! Redirect the request to VISU_GaussPointsPL::GetMinSize. float GetMinSize(); + //! Redirect the request to VISU_GaussPointsPL::SetMaxSize. void SetMaxSize(float theMaxSize); + //! Redirect the request to VISU_GaussPointsPL::GetMaxSize. float GetMaxSize(); - float - GetMaxPointSize(); - + //! Redirect the request to VISU_GaussPointsPL::SetMagnification. void SetMagnification(float theMagnification); + //! Redirect the request to VISU_GaussPointsPL::GetMagnification. float GetMagnification(); + //! Redirect the request to VISU_GaussPointsPL::SetMagnificationIncrement. void SetMagnificationIncrement(float theIncrement); + //! Redirect the request to VISU_GaussPointsPL::GetMagnificationIncrement. float GetMagnificationIncrement(); + //! Set flag indicating which scalar bar is active. void SetIsActiveLocalScalarBar(const bool theFlag); + //! Get flag indicating which scalar bar is active. bool GetIsActiveLocalScalarBar() const; + //! Set flag indicating visibility of global scalar bar. void SetIsDispGlobalScalarBar(const bool theFlag); + //! Get flag indicating visibility of global scalar bar. bool GetIsDispGlobalScalarBar() const; + //! Redirect the request to VISU_GaussPointsPL::SetBicolor. void SetBiColor(bool theIsBiColor); + //! Redirect the request to VISU_GaussPointsPL::GetBicolor. bool GetBiColor(); + //! Set value of the distance between global and local scalar bars. void SetSpacing(const float theSpacing); + //! Get value of the distance between global and local scalar bars. float GetSpacing() const; diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index cda09ad0..41911815 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -499,6 +499,23 @@ namespace VISU{ } } + Result_ptr VISU_Gen_i::CreateResult(const char* theFileName){ + if(myStudyDocument->GetProperties()->IsLocked()) + return Result::_nil(); + Mutex mt(myMutex); + aFileInfo.setFile(theFileName); + Result_i* pResult = new Result_i(myStudyDocument, + Result_i::eFile, + Result_i::eImportFile, + false); + if(pResult->Create(theFileName) != NULL) + return pResult->_this(); + else{ + pResult->_remove_ref(); + return VISU::Result::_nil(); + } + } + Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){ if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index a387b2e5..4ad14670 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -44,6 +44,7 @@ namespace VISU{ //Create Result virtual Result_ptr ImportFile(const char* theFileName); + virtual Result_ptr CreateResult(const char* theFileName); virtual Result_ptr CopyAndImportFile(const char* theFileName); virtual Result_ptr ImportMed(SALOMEDS::SObject_ptr theMedSObject); virtual Result_ptr ImportMedField(SALOME_MED::FIELD_ptr theField); diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 2cd19583..17c7d61a 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -212,7 +212,7 @@ VISU::Prs3d_i theActor->SetPipeLine(GetPipeLine()); theActor->SetFactory(this); - myUpdateActorsSignal.connect(boost::bind(&VISU_Actor::Update,theActor)); + myUpdateActorsSignal.connect(boost::bind(&VISU_Actor::UpdateFromFactory,theActor)); myRemoveActorsFromRendererSignal.connect(boost::bind(&VISU_Actor::RemoveFromRender,theActor)); myActorCollection->AddItem(theActor); @@ -230,20 +230,29 @@ VISU::Prs3d_i void VISU::Prs3d_i -::UpdateActor(VISU_Actor* theActor) +::RemoveActor(VISU_Actor* theActor) { - if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor - this = "< +#include + +#include +#include + // QT Includes #include #include +#include +#include // VTK Includes #include @@ -51,92 +65,718 @@ using namespace std; #ifdef _DEBUG_ static int MYDEBUG = 0; +static int MYTIMEDEBUG = 0; #else static int MYDEBUG = 0; +static int MYTIMEDEBUG = 0; #endif -VISU::Result_var VISU::FindResult (SALOMEDS::SObject_ptr theSObject) + +namespace VISU { - SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent(); - SALOMEDS::SObject_var aFather = theSObject->GetFather(); - CORBA::String_var aComponentID (aSComponent->GetID()); - CORBA::String_var aFatherID (aFather->GetID()); - VISU::Result_var aResult; - while (strcmp(aComponentID, aFatherID) != 0) { - CORBA::Object_var anObject = VISU::SObjectToObject(aFather); - if (!CORBA::is_nil(anObject)) { - aResult = VISU::Result::_narrow(anObject); - if (!aResult->_is_nil()) return aResult; - } - aFather = aFather->GetFather(); - aFatherID = aFather->GetID(); + //--------------------------------------------------------------- + Result_var + FindResult (SALOMEDS::SObject_ptr theSObject) + { + SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent(); + SALOMEDS::SObject_var aFather = theSObject->GetFather(); + CORBA::String_var aComponentID (aSComponent->GetID()); + CORBA::String_var aFatherID (aFather->GetID()); + Result_var aResult; + while (strcmp(aComponentID, aFatherID) != 0) { + CORBA::Object_var anObject = SObjectToObject(aFather); + if (!CORBA::is_nil(anObject)) { + aResult = Result::_narrow(anObject); + if (!aResult->_is_nil()) return aResult; + } + aFather = aFather->GetFather(); + aFatherID = aFather->GetID(); + } + return aResult; } - return aResult; -} -QString GenerateName (const char* theName) -{ - typedef map TNameMap; - static TNameMap aMap; - TNameMap::const_iterator i = aMap.find(theName); - QString tmp; - if (i == aMap.end()) { - aMap[theName] = 0; - tmp = theName; - } else { - tmp = VISU::GenerateName(theName,++aMap[theName]); + + //--------------------------------------------------------------- + typedef boost::recursive_mutex TMutex; + typedef TMutex::scoped_lock TLock; + + static TMutex myMutex; + + //--------------------------------------------------------------- + struct TGetStudy: public SALOME_Event + { + typedef _PTR(Study) TResult; + TResult myResult; + int myStudyId; + + TGetStudy(const int theStudyId): + myStudyId(theStudyId) + {} + + virtual + void + Execute() + { + SUIT_Session* aSession = SUIT_Session::session(); + QPtrList anApplications = aSession->applications(); + QPtrListIterator anIter (anApplications); + while (SUIT_Application* aSApp = anIter.current()) { + if(SalomeApp_Application* anApp = dynamic_cast(aSApp)){ + if(SalomeApp_Study* aStudy = dynamic_cast(anApp->activeStudy())) { + myResult = aStudy->studyDS(); + break; + } + } + ++anIter; + } + } + }; + + + //--------------------------------------------------------------- + QString + GenerateName (const char* theName) + { + TLock aLock(myMutex); + + typedef map TNameMap; + static TNameMap aMap; + + TNameMap::const_iterator i = aMap.find(theName); + QString tmp; + if (i == aMap.end()) { + aMap[theName] = 0; + tmp = theName; + } else { + tmp = GenerateName(theName,++aMap[theName]); + } + if(MYDEBUG) MESSAGE("GenerateName - "<NewBuilder(); - SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry.c_str()); - SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(aFather); - SALOMEDS::SObject_var aRefSObj = theStudyDocument->FindObjectID(theRefEntry.c_str()); - aStudyBuilder->Addreference(newObj,aRefSObj); -} -string GetComponentDataType (SALOMEDS::SObject_ptr theSObject) -{ - SALOMEDS::SComponent_var aCompRefSObj = theSObject->GetFatherComponent(); - CORBA::String_var aDataType = aCompRefSObj->ComponentDataType(); - return aDataType.in(); + //--------------------------------------------------------------- + string + GetComponentDataType (SALOMEDS::SObject_ptr theSObject) + { + SALOMEDS::SComponent_var aCompRefSObj = theSObject->GetFatherComponent(); + CORBA::String_var aDataType = aCompRefSObj->ComponentDataType(); + return aDataType.in(); + } + + + //--------------------------------------------------------------- + void + CreateReference (SALOMEDS::Study_ptr theStudyDocument, + const string& theFatherEntry, + const string& theRefEntry) + { + SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder(); + SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry.c_str()); + SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(aFather); + SALOMEDS::SObject_var aRefSObj = theStudyDocument->FindObjectID(theRefEntry.c_str()); + aStudyBuilder->Addreference(newObj,aRefSObj); + } + + + //--------------------------------------------------------------- + void + CreateReference (_PTR(Study) theStudyDocument, + const string& theFatherEntry, + const string& theRefEntry) + { + TLock aLock(myMutex); + + _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); + _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry); + _PTR(SObject) aNewObj = aStudyBuilder->NewObject(aFather); + _PTR(SObject) aRefSObj = theStudyDocument->FindObjectID(theRefEntry); + aStudyBuilder->Addreference(aNewObj,aRefSObj); + } + + string + CreateAttributes(_PTR(Study) theStudyDocument, + const string& theFatherEntry, + const string& theIOR, + const string& theName, + const string& thePersistentRef, + const string& theComment, + CORBA::Boolean theCreateNew) + { + TLock aLock(myMutex); + + _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); + _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry); + + _PTR(SObject) aNewObj; + if(theCreateNew) + aNewObj = aStudyBuilder->NewObject(aFather); + else + aNewObj = aFather; + + _PTR(GenericAttribute) anAttr; + if (theIOR != "") { + anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeIOR"); + _PTR(AttributeIOR) anIOR (anAttr); + anIOR->SetValue(theIOR); + } + if (theName != "") { + anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeName"); + _PTR(AttributeName) aName (anAttr); + aName->SetValue(theName); + } + if (thePersistentRef != "") { + anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributePersistentRef"); + _PTR(AttributePersistentRef) aPRef (anAttr); + aPRef->SetValue(thePersistentRef); + } + if (theComment != "") { + anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeComment"); + _PTR(AttributeComment) aCmnt (anAttr); + aCmnt->SetValue(theComment); + } + return aNewObj->GetID(); + } + + //--------------------------------------------------------------- + struct TResultManager + { + Result_i* myResult; + + TResultManager(Result_i* theResult): + myResult(theResult) + { + myResult->Register(); + } + + ~TResultManager() + { + myResult->Destroy(); + } + }; + + + //--------------------------------------------------------------- + struct TTransactionManager + { + _PTR(StudyBuilder) myStudyBuilder; + + TTransactionManager(_PTR(Study) theStudyDocument): + myStudyBuilder(theStudyDocument->NewBuilder()) + { + TLock aLock(myMutex); + myStudyBuilder->NewCommand(); + } + + ~TTransactionManager() + { + TLock aLock(myMutex); + myStudyBuilder->CommitCommand(); + } + }; + + + //--------------------------------------------------------------- + struct TUpdateObjBrowser: public SALOME_Event + { + int myStudyId; + CORBA::Boolean* myIsDone; + TUpdateObjBrowser(const int theStudyId, + CORBA::Boolean* theIsDone): + myStudyId(theStudyId), + myIsDone(theIsDone) + {} + + virtual + void + Execute() + { + TLock aLock(myMutex); + SUIT_Session* aSession = SUIT_Session::session(); + QPtrList anApplications = aSession->applications(); + QPtrListIterator anIter (anApplications); + while (SUIT_Application* aSApp = anIter.current()) { + if(SalomeApp_Application* anApp = dynamic_cast(aSApp)){ + if (SalomeApp_Study* aStudy = dynamic_cast(anApp->activeStudy())) { + if (_PTR(Study) aCStudy = aStudy->studyDS()) { + if (myStudyId == aCStudy->StudyId()) { + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::updateObjectBrowser"); + anApp->updateObjectBrowser(); + *myIsDone = true; + break; + } + } + } + } + ++anIter; + } + } + }; + + + //--------------------------------------------------------------- + void + BuildEntities(Result_i* theResult, + VISU_Convertor* theInput, + CORBA::Boolean* theIsDone, + std::string theResultEntry, + _PTR(Study) theStudy) + { + if(*theIsDone) + return; + + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildEntities"); + TResultManager aResultManager(theResult); + TTransactionManager aTransactionManager(theStudy); + + { + TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildEntities"); + theInput->BuildEntities(); + } + + QString aComment; + const TMeshMap& aMeshMap = theInput->GetMeshMap(); + TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ + const string& aMeshName = aMeshMapIter->first; + const PMesh& aMesh = aMeshMapIter->second; + const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + if(aMeshOnEntityMap.empty()) + continue; + + aComment.sprintf("myComment=MESH;myName=%s;myDim=%d", + aMeshName.c_str(), + aMesh->myDim); + aMesh->myEntry = + CreateAttributes(theStudy, + theResultEntry, + "", + aMeshName, + "", + aComment.latin1(), + true); + + aComment.sprintf("myComment=FAMILIES;myMeshName=%s", + aMeshName.c_str()); + string aSubMeshesEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + "", + "Families", + "", + aComment.latin1(), + true); + //Import entities + TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ + const TEntity& anEntity = aMeshOnEntityMapIter->first; + const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + + string anEntityName; + switch(anEntity){ + case NODE_ENTITY: + anEntityName = "onNodes"; + break; + case EDGE_ENTITY: + anEntityName = "onEdges"; + break; + case FACE_ENTITY: + anEntityName = "onFaces"; + break; + case CELL_ENTITY: + anEntityName = "onCells"; + break; + default: + continue; + } + + aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d", + VISU::TENTITY, + aMeshName.c_str(), + anEntity); + + aMeshOnEntity->myEntry = + CreateAttributes(theStudy, + aSubMeshesEntry, + "", + anEntityName.c_str(), + "", + aComment.latin1(), + true); + } + } + + ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); + } + + //--------------------------------------------------------------- + void + BuildGroups(Result_i* theResult, + VISU_Convertor* theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild, + _PTR(Study) theStudy) + { + if(!theIsBuild || *theIsDone) + return; + + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildGroups"); + TResultManager aResultManager(theResult); + TTransactionManager aTransactionManager(theStudy); + + { + TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildGroups"); + theInput->BuildGroups(); + } + + QString aComment; + const TMeshMap& aMeshMap = theInput->GetMeshMap(); + TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ + const string& aMeshName = aMeshMapIter->first; + const PMesh& aMesh = aMeshMapIter->second; + + const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + if(aMeshOnEntityMap.empty()) + continue; + + TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ + const TEntity& anEntity = aMeshOnEntityMapIter->first; + const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + + const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); + for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ + const string& aFamilyName = aFamilyMapIter->first; + const PFamily& aFamily = aFamilyMapIter->second; + aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", + TFAMILY, + aMeshName.c_str(), + anEntity, + aFamilyName.c_str()); + aFamily->myEntry = + CreateAttributes(theStudy, + aMeshOnEntity->myEntry, + "", + aFamilyName, + "", + aComment.latin1(), + true); + } + } + //Importing groups + const TGroupMap& aGroupMap = aMesh->myGroupMap; + if(!aGroupMap.empty()){ + aComment.sprintf("myComment=GROUPS;myMeshName=%s", + aMeshName.c_str()); + string aGroupsEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + "", + "Groups", + "", + aComment.latin1(), + true); + TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); + for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ + const string& aGroupName = aGroupMapIter->first; + const PGroup& aGroup = aGroupMapIter->second; + aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s", + TGROUP,aMeshName.c_str(),aGroupName.c_str()); + aGroup->myEntry = + CreateAttributes(theStudy, + aGroupsEntry, + "", + aGroupName, + "", + aComment.latin1(), + true); + const TFamilySet& aFamilySet = aGroup->myFamilySet; + TFamilySet::const_iterator aFamilyIter = aFamilySet.begin(); + for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){ + const PFamily& aFamily = *aFamilyIter; + CreateReference(theStudy, + aGroup->myEntry, + aFamily->myEntry); + } + } + } + } + + ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); + } + + + //--------------------------------------------------------------- + void + BuildFields(Result_i* theResult, + VISU_Convertor* theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild, + _PTR(Study) theStudy) + { + if(!theIsBuild || *theIsDone) + return; + + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildFields"); + TResultManager aResultManager(theResult); + TTransactionManager aTransactionManager(theStudy); + + { + TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildFields"); + theInput->BuildFields(); + } + + QString aComment; + const TMeshMap& aMeshMap = theInput->GetMeshMap(); + TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ + const string& aMeshName = aMeshMapIter->first; + const PMesh& aMesh = aMeshMapIter->second; + + const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + if(aMeshOnEntityMap.empty()) + continue; + + //Import fields + string aFieldsEntry; + bool anIsFieldsEntryCreated = false; + + TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ + const TEntity& anEntity = aMeshOnEntityMapIter->first; + const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + const TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); + for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ + if(!anIsFieldsEntryCreated){ + aComment.sprintf("myComment=FIELDS;myMeshName=%s", + aMeshName.c_str()); + aFieldsEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + "", + "Fields", + "", + aComment.latin1(), + true); + anIsFieldsEntryCreated = true; + } + const string& aFieldName = aFieldMapIter->first; + const PField& aField = aFieldMapIter->second; + const TValField& aValField = aField->myValField; + QString aFieldNameWithUnit = GenerateFieldName(aFieldName,aField->myUnitNames[0]); + aComment.sprintf("myComment=FIELD;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d", + TFIELD, + aMeshName.c_str(), + anEntity, + aFieldName.c_str(), + aValField.size(), + aField->myNbComp); + aField->myEntry = + CreateAttributes(theStudy, + aFieldsEntry, + "", + aFieldNameWithUnit.latin1(), + "", + aComment.latin1(), + true); + CreateReference(theStudy, + aField->myEntry, + aMeshOnEntity->myEntry); + TValField::const_iterator aValFieldIter = aValField.begin(); + for(; aValFieldIter != aValField.end(); aValFieldIter++){ + int aTimeStamp = aValFieldIter->first; + const PValForTime& aValForTime = aValFieldIter->second; + aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", + TTIMESTAMP, + aMeshName.c_str(), + anEntity, + aFieldName.c_str(), + aTimeStamp, + aField->myNbComp); + string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime); + aValForTime->myEntry = + CreateAttributes(theStudy, + aField->myEntry, + "", + aTimeStampId, + "", + aComment.latin1(), + true); + } + } + } + } + + ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); + } + + + //--------------------------------------------------------------- + void + BuildMinMax(Result_i* theResult, + VISU_Convertor* theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild) + { + if(!theIsBuild || *theIsDone) + return; + + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildMinMax"); + TResultManager aResultManager(theResult); + + theInput->BuildMinMax(); + *theIsDone = true; + } + + + //--------------------------------------------------------------- + void + BuildFieldDataTree(Result_i* theResult, + VISU_Convertor* theInput, + CORBA::Boolean* theIsFieldsDone, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean* theIsMinMaxDone, + CORBA::Boolean theIsBuildMinMax, + _PTR(Study) theStudy) + { + BuildFields(theResult, + theInput, + theIsFieldsDone, + theIsBuildFields, + theStudy); + + BuildMinMax(theResult, + theInput, + theIsMinMaxDone, + theIsBuildMinMax); + } + + + //--------------------------------------------------------------- + struct TBuildArgs + { + Result_i* myResult; + VISU_Convertor* myInput; + CORBA::Boolean* myIsEntitiesDone; + std::string myResultEntry; + CORBA::Boolean* myIsFieldsDone; + CORBA::Boolean myIsBuildFields; + CORBA::Boolean* myIsMinMaxDone; + CORBA::Boolean myIsBuildMinMax; + CORBA::Boolean* myIsGroupsDone; + CORBA::Boolean myIsBuildGroups; + _PTR(Study) myStudy; + + TBuildArgs(Result_i* theResult, + VISU_Convertor* theInput, + CORBA::Boolean* theIsEntitiesDone, + std::string theResultEntry, + CORBA::Boolean* theIsFieldsDone, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean* theIsMinMaxDone, + CORBA::Boolean theIsBuildMinMax, + CORBA::Boolean* theIsGroupsDone, + CORBA::Boolean theIsBuildGroups, + _PTR(Study) theStudy): + myResult(theResult), + myInput(theInput), + myIsEntitiesDone(theIsEntitiesDone), + myResultEntry(theResultEntry), + myIsFieldsDone(theIsFieldsDone), + myIsBuildFields(theIsBuildFields), + myIsMinMaxDone(theIsMinMaxDone), + myIsBuildMinMax(theIsBuildMinMax), + myIsGroupsDone(theIsGroupsDone), + myIsBuildGroups(theIsBuildGroups), + myStudy(theStudy) + {} + + }; + + //--------------------------------------------------------------- + void + BuildDataTree(TBuildArgs theBuildArgs) + { + BuildEntities(theBuildArgs.myResult, + theBuildArgs.myInput, + theBuildArgs.myIsEntitiesDone, + theBuildArgs.myResultEntry, + theBuildArgs.myStudy); + + { + boost::thread aThread(boost::bind(&BuildFieldDataTree, + theBuildArgs.myResult, + theBuildArgs.myInput, + theBuildArgs.myIsFieldsDone, + theBuildArgs.myIsBuildFields, + theBuildArgs.myIsMinMaxDone, + theBuildArgs.myIsBuildMinMax, + theBuildArgs.myStudy)); + } + + { + boost::thread aThread(boost::bind(&BuildGroups, + theBuildArgs.myResult, + theBuildArgs.myInput, + theBuildArgs.myIsGroupsDone, + theBuildArgs.myIsBuildGroups, + theBuildArgs.myStudy)); + } + } + } -//============================================================================== +//--------------------------------------------------------------- const string VISU::Result_i::myComment = "RESULT"; const char* VISU::Result_i::GetComment() const { return myComment.c_str();} -VISU::Result_i::Result_i (SALOMEDS::Study_ptr theStudy, - const ESourceId& theSourceId, - const ECreationId& theCreationId): +//--------------------------------------------------------------- +VISU::Result_i +::Result_i (SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately): myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)), myCreationId(theCreationId), mySourceId(theSourceId), + myIsBuildImmediately(theIsBuildImmediately), myInput(NULL), - myIsDone(0) + myIsEntitiesDone(false), + myIsFieldsDone(false), + myIsGroupsDone(false), + myIsMinMaxDone(false), + myIsBuildFields(true), + myIsBuildGroups(true), + myIsBuildMinMax(true), + myIsAllDone(false) { + myStudy = ProcessEvent(new TGetStudy(myStudyDocument->StudyId())); } -void VISU::Result_i::RemoveFromStudy() +//--------------------------------------------------------------- +void +VISU::Result_i +::RemoveFromStudy() { // Remove the result with all presentations and other possible sub-objects VISU::RemoveFromStudy(mySObject,false); @@ -144,9 +784,10 @@ void VISU::Result_i::RemoveFromStudy() } +//--------------------------------------------------------------- int -VISU::Result_i:: -IsPossible() +VISU::Result_i +::IsPossible() { try{ float aSize = myInput->GetSize(); @@ -162,13 +803,16 @@ IsPossible() } +//--------------------------------------------------------------- CORBA::Boolean -VISU::Result_i:: -BuildAll() +VISU::Result_i +::BuildAll() { - if(MYDEBUG) MESSAGE("Result_i::Build - myIsDone = "<GetID(); + CORBA::String_var anIOR(GetID()); + QString aComment; + aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s", + GetComment(), + VISU::TRESULT, + myFileInfo.filePath().latin1(), + myInitFileName.c_str()); // Restoring of Python dump + string aResultEntry = + CreateAttributes(myStudy, + aSComponentEntry.in(), + anIOR.in(), + myName, + "", + aComment.latin1(), + true); + mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str()); + if(!CORBA::is_nil(theSObject)){ + CORBA::String_var aString = theSObject->GetID(); + CreateReference(myStudyDocument,aResultEntry,aString.in()); + } + + if(theIsAtOnce){ + BuildEntities(this, + myInput, + &myIsEntitiesDone, + aResultEntry, + myStudy); + + BuildFields(this, + myInput, + &myIsFieldsDone, + myIsBuildFields, + myStudy); + + BuildMinMax(this, + myInput, + &myIsMinMaxDone, + myIsBuildMinMax); + + BuildGroups(this, + myInput, + &myIsGroupsDone, + myIsBuildGroups, + myStudy); + }else{ + TBuildArgs aBuildArgs(this, + myInput, + &myIsEntitiesDone, + aResultEntry, + &myIsFieldsDone, + myIsBuildFields, + &myIsMinMaxDone, + myIsBuildMinMax, + &myIsGroupsDone, + myIsBuildGroups, + myStudy); + boost::thread aThread(boost::bind(&BuildDataTree, + aBuildArgs)); + } + + return this; +} + + +//--------------------------------------------------------------- +VISU::Storable* +VISU::Result_i +::BuildAll(SALOMEDS::SObject_ptr theSObject) { - SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder(); - aStudyBuilder->NewCommand(); // There is a transaction if(MYDEBUG) MESSAGE("Result_i::Build"); try{ - const TMeshMap& aMeshMap = myInput->GetMeshMap(); - if(aMeshMap.empty()) - throw std::runtime_error("Build - There is no any mesh information in the file !!!"); - mySComponent = FindOrCreateVisuComponent(myStudyDocument); - CORBA::String_var aSComponentEntry = mySComponent->GetID(), anIOR(GetID()); - string aRefFatherEntry = GetRefFatherEntry(); - QString aComment; - aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s", - GetComment(), - VISU::TRESULT, - myFileInfo.filePath().latin1(), - myInitFileName.c_str()); // Restoring of Python dump - string aResultEntry = - CreateAttributes(myStudyDocument, - aSComponentEntry, - aRefFatherEntry.c_str(), - anIOR, - myName.c_str(), - "", - aComment.latin1(), - true); - mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str()); - if(mySObject->_is_nil()) throw std::runtime_error("Build - There is no SObject for the Result !!!"); - if(!CORBA::is_nil(theSObject)){ - CORBA::String_var aString = theSObject->GetID(); - CreateReference(myStudyDocument,aResultEntry,aString.in()); - } - TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ - const string& aMeshName = aMeshMapIter->first; - const VISU::PMesh aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; - VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; - aComment.sprintf("myComment=MESH;myName=%s;myDim=%d", - aMeshName.c_str(),aMesh->myDim); - string aMeshEntry = CreateAttributes(myStudyDocument,aResultEntry.c_str(),aRefFatherEntry.c_str(), - "",aMeshName.c_str(),"",aComment.latin1(),true); - if(aMeshOnEntityMap.empty()) continue; - aComment.sprintf("myComment=FAMILIES;myMeshName=%s",aMeshName.c_str()); - string aSubMeshesEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), - "","Families","",aComment.latin1(),true); - //Import entities and according families - aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - typedef std::map TComment2EntryMap; - TComment2EntryMap aComment2EntryMap; - typedef std::map TEntity2EntryMap; - TEntity2EntryMap aEntity2EntryMap; - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d", - VISU::TENTITY, - aMeshName.c_str(), - anEntity); - string anEntityName; - switch(anEntity){ - case VISU::NODE_ENTITY : anEntityName = "onNodes"; break; - case VISU::EDGE_ENTITY : anEntityName = "onEdges"; break; - case VISU::FACE_ENTITY : anEntityName = "onFaces"; break; - case VISU::CELL_ENTITY : anEntityName = "onCells"; break; - default: - throw std::runtime_error("Build >> Value of entity is incorrect!"); - } - aEntity2EntryMap[anEntity] = CreateAttributes - (myStudyDocument, aSubMeshesEntry.c_str(), aRefFatherEntry.c_str(), - "", anEntityName.c_str(), "", aComment.latin1(), true); - const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; - VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); - for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ - const string& aFamilyName = aFamilyMapIter->first; - aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", - VISU::TFAMILY, - aMeshName.c_str(), - anEntity, - aFamilyName.c_str()); - aComment2EntryMap[aComment.latin1()] = - CreateAttributes(myStudyDocument, - aEntity2EntryMap[anEntity].c_str(), - aRefFatherEntry.c_str(), - "", - aFamilyName.c_str(), - "", - aComment.latin1(), - true); - } - } - //Importing groups - const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; - if(aGroupMap.size() > 0){ - aComment.sprintf("myComment=GROUPS;myMeshName=%s", - aMeshName.c_str()); - string aGroupsEntry = - CreateAttributes(myStudyDocument, - aMeshEntry.c_str(), - aRefFatherEntry.c_str(), - "", - "Groups", - "", - aComment.latin1(), - true); - VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); - for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ - const string& aGroupName = aGroupMapIter->first; - aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s", - VISU::TGROUP,aMeshName.c_str(),aGroupName.c_str()); - string aGroupEntry = CreateAttributes(myStudyDocument,aGroupsEntry.c_str(),aRefFatherEntry.c_str(), - "",aGroupName.c_str(),"",aComment.latin1(),true); - const VISU::PGroup aGroup = aGroupMapIter->second; - const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet; - VISU::TFamilySet::const_iterator aFamilyIter = aFamilySet.begin(); - for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){ - const VISU::PFamily& aFamily = *aFamilyIter; - const string& aFamilyName = aFamily->myName; - const VISU::TEntity& anEntity = aFamily->myEntity; - aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", - VISU::TFAMILY, - aMeshName.c_str(), - anEntity, - aFamilyName.c_str()); - TComment2EntryMap::const_iterator anIter = aComment2EntryMap.find(aComment.latin1()); - if(anIter != aComment2EntryMap.end()){ - const std::string& anEntry = anIter->second; - CreateReference(myStudyDocument,aGroupEntry,anEntry); - } - } - } - } - //Import fields - string aFieldsEntry; - bool isFieldEntryCreated = 0; - 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++){ - if(!isFieldEntryCreated){ - aComment.sprintf("myComment=FIELDS;myMeshName=%s", - aMeshName.c_str()); - aFieldsEntry = - CreateAttributes(myStudyDocument, - aMeshEntry.c_str(), - aRefFatherEntry.c_str(), - "", - "Fields", - "", - aComment.latin1(), - true); - isFieldEntryCreated = true; - } - const string& aFieldName = aFieldMapIter->first; - const VISU::PField aField = aFieldMapIter->second; - const VISU::TValField& aValField = aField->myValField; - QString aFieldNameWithUnit = ::GenerateFieldName(aFieldName,aField->myUnitNames[0]); - aComment.sprintf("myComment=FIELD;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d", - VISU::TFIELD,aMeshName.c_str(),anEntity,aFieldName.c_str(),aValField.size(),aField->myNbComp); - string aFieldEntry = CreateAttributes(myStudyDocument,aFieldsEntry.c_str(),aRefFatherEntry.c_str(), - "",aFieldNameWithUnit.latin1(),"",aComment.latin1(),true); - CreateReference(myStudyDocument,aFieldEntry,aEntity2EntryMap[anEntity]); - VISU::TValField::const_iterator aValFieldIter = aValField.begin(); - for(; aValFieldIter != aValField.end(); aValFieldIter++){ - int aTimeStamp = aValFieldIter->first; - const VISU::PValForTime aValForTime = aValFieldIter->second; - aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", - VISU::TTIMESTAMP,aMeshName.c_str(),anEntity,aFieldName.c_str(),aTimeStamp,aField->myNbComp); - string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime); - CreateAttributes(myStudyDocument,aFieldEntry.c_str(),aRefFatherEntry.c_str(), - "",aTimeStampId.c_str(),"",aComment.latin1(),true); - } - } - } - } - bool isBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false); - if(isBuildAll) BuildAll(); + Build(theSObject); + BuildAll(); }catch(std::exception& exc){ INFOS("Follow exception was occured :\n"<CommitCommand(); + return this; } +//--------------------------------------------------------------- VISU::Storable* VISU::Result_i:: Create(const char* theFileName) @@ -461,9 +1026,11 @@ Create(const char* theFileName) myFileInfo.setFile(QString(aTmpDir.c_str()) + myFileInfo.fileName()); } myInput = CreateConvertor(myFileInfo.absFilePath().latin1()); - if(!myInput) - throw std::runtime_error("Create - Cannot create a Convertor for this file!!!"); - return Build(); + if(myInput){ + if(myIsBuildImmediately) + Build(SALOMEDS::SObject::_nil()); + return this; + } }catch(std::exception& exc){ INFOS("Follow exception was occured :\n"<Build(); + string aCompDataType = GetComponentDataType(theMedSObject); myFileInfo.setFile(aCompDataType.c_str()); myInitFileName = aCompDataType; myName = ::GenerateName("aResult").latin1(); - VISU::Storable* aStorable = Build(theMedSObject); - return aStorable; + return Build(theMedSObject); }catch(std::exception& exc){ INFOS("Follow exception was occured :\n"<Build(); + string aCompDataType = "MED"; myFileInfo.setFile(aCompDataType.c_str()); myInitFileName = aCompDataType; @@ -518,8 +1091,7 @@ Create(SALOME_MED::FIELD_ptr theField) CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField); SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR); - VISU::Storable* aStorable = Build(aFieldSObject); - return aStorable; + return Build(aFieldSObject); }catch(std::exception& exc){ INFOS("Follow exception was occured :\n"<NewBuilder(); SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp); aStudyBuilder->LoadWith(aCompRefSObj, aDriver); - if (strcmp(aDataType, "MED") == 0) + if (strcmp(aDataType, "MED") == 0){ myInput = CreateMEDConvertor(aTargetRefSObj); - else + myInput->Build(); + }else throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!"); } else { myFileInfo.setFile(thePrefix.c_str()); @@ -615,6 +1189,7 @@ Restore(SALOMEDS::SObject_ptr theSObject, } if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId); myInput = CreateConvertor(myFileInfo.filePath().latin1()); + myInput->Build(); QString aComment; aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s", GetComment(), VISU::TRESULT, myFileInfo.filePath().latin1(), @@ -637,21 +1212,91 @@ Restore(SALOMEDS::SObject_ptr theSObject, return NULL; } -VISU::Result_i::TInput* VISU::Result_i::GetInput() { +//--------------------------------------------------------------- +VISU::Result_i::TInput* +VISU::Result_i +::GetInput() +{ return myInput; } -void VISU::Result_i::ToStream(std::ostringstream& theStr){ +//--------------------------------------------------------------- +CORBA::Boolean +VISU::Result_i +::IsDone() +{ + return + myIsEntitiesDone && + (myIsBuildFields? myIsFieldsDone: true) && + (myIsBuildMinMax? myIsMinMaxDone: true) && + (myIsBuildGroups? myIsGroupsDone: true); +} + +CORBA::Boolean +VISU::Result_i +::IsEntitiesDone() +{ + return myIsEntitiesDone; +} + +void +VISU::Result_i +::SetBuildFields(CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsCalculateMinMax) +{ + myIsBuildFields = theIsBuildFields; + if(theIsBuildFields) + myIsBuildMinMax = theIsCalculateMinMax; + else + myIsBuildMinMax = false; +} + +void +VISU::Result_i +::SetBuildGroups(CORBA::Boolean theIsBuildGroups) +{ + myIsBuildGroups = theIsBuildGroups; +} + +CORBA::Boolean +VISU::Result_i +::IsFieldsDone() +{ + return myIsFieldsDone; +} + +CORBA::Boolean +VISU::Result_i +::IsGroupsDone() +{ + return myIsGroupsDone; +} + +CORBA::Boolean +VISU::Result_i +::IsMinMaxDone() +{ + return myIsMinMaxDone; +} + +//--------------------------------------------------------------- +void +VISU::Result_i +::ToStream(std::ostringstream& theStr) +{ if(MYDEBUG) MESSAGE(GetComment()); Storable::DataToStream(theStr,"myName",myName.c_str()); Storable::DataToStream(theStr,"myInitFileName",myInitFileName.c_str()); Storable::DataToStream(theStr,"myCreationId",myCreationId); } + +//--------------------------------------------------------------- VISU::Storable* -VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject, - const string& thePrefix, - const Storable::TRestoringMap& theMap) +VISU::Result_i +::Restore(SALOMEDS::SObject_ptr theSObject, + const string& thePrefix, + const Storable::TRestoringMap& theMap) { SALOMEDS::Study_var aStudy = theSObject->GetStudy(); @@ -667,25 +1312,55 @@ VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject, return pResult->Restore(theSObject,theMap,thePrefix); } -string VISU::Result_i::GetRefFatherEntry() { - //return QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry(); + +//--------------------------------------------------------------- +string +VISU::Result_i +::GetRefFatherEntry() +{ return ""; } -string VISU::Result_i::GetEntry(){ +string +VISU::Result_i +::GetEntry() +{ CORBA::String_var anEntry = mySObject->GetID(); return string(anEntry); } -const SALOMEDS::SObject_var& VISU::Result_i::GetSObject() const { return mySObject;} -const SALOMEDS::Study_var& VISU::Result_i::GetStudyDocument() const { return myStudyDocument;} -const SALOMEDS::SComponent_var& VISU::Result_i::GetSComponent() const { return mySComponent;} -std::string VISU::Result_i::GetEntry(const std::string& theComment) +const SALOMEDS::SObject_var& +VISU::Result_i +::GetSObject() const +{ + return mySObject; +} + +const SALOMEDS::Study_var& +VISU::Result_i +::GetStudyDocument() const +{ + return myStudyDocument; +} + +const SALOMEDS::SComponent_var& +VISU::Result_i +::GetSComponent() const +{ + return mySComponent; +} + +std::string +VISU::Result_i +::GetEntry(const std::string& theComment) { return FindEntryWithComment(myStudyDocument,GetEntry().c_str(),theComment.c_str()); } -VISU::Result_i::~Result_i() + +//--------------------------------------------------------------- +VISU::Result_i +::~Result_i() { MESSAGE("Result_i::~Result_i() - this = "<getRenderer(); if (!theData.myActors.empty()) { @@ -353,6 +362,10 @@ void VISU_TimeAnimation::startAnimation() { //************************************************************************ void VISU_TimeAnimation::nextFrame() { + if (!myView) { + MESSAGE("Viewer is not defined for animation"); + return; + } stopAnimation(); if (myFrame < (myFieldsLst[0].myNbFrames-1)) { int i; @@ -372,6 +385,10 @@ void VISU_TimeAnimation::nextFrame() { //************************************************************************ void VISU_TimeAnimation::prevFrame() { + if (!myView) { + MESSAGE("Viewer is not defined for animation"); + return; + } stopAnimation(); if (myFrame > 0) { int i; @@ -391,6 +408,10 @@ void VISU_TimeAnimation::prevFrame() { //************************************************************************ void VISU_TimeAnimation::firstFrame() { + if (!myView) { + MESSAGE("Viewer is not defined for animation"); + return; + } stopAnimation(); int i; for (i = 0; i < getNbFields(); i++) @@ -410,6 +431,10 @@ void VISU_TimeAnimation::firstFrame() { //************************************************************************ void VISU_TimeAnimation::lastFrame() { + if (!myView) { + MESSAGE("Viewer is not defined for animation"); + return; + } stopAnimation(); int i; for (i = 0; i < getNbFields(); i++) @@ -429,6 +454,10 @@ void VISU_TimeAnimation::lastFrame() { //************************************************************************ // For Batchmode using void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame) { + if (!myView) { + MESSAGE("Viewer is not defined for animation"); + return; + } if ((theFrame < 0) || (theFrame > (getNbFrames()-1))) return; stopAnimation(); diff --git a/src/VVTK/VVTK_InteractorStyle.cxx b/src/VVTK/VVTK_InteractorStyle.cxx index 02343e41..87552d7b 100644 --- a/src/VVTK/VVTK_InteractorStyle.cxx +++ b/src/VVTK/VVTK_InteractorStyle.cxx @@ -161,55 +161,10 @@ VVTK_InteractorStyle if ( myIsLeftButtonDown ) OnLeftButtonDown( ctrl, shift, x, y ); } - -//---------------------------------------------------------------------------- -void -VVTK_InteractorStyle -::OnKeyDown() -{ - if( GetSelector()->SelectionMode() != NodeSelection ) - return; - - char key = Interactor->GetKeyCode(); - - if ( key == 'S' ) { - // current mouse position (from last mouse move event or any other event) - int x, y; - Interactor->GetEventPosition( x, y ); - FindPokedRenderer( x, y ); // calls SetCurrentRenderer - - myOtherPoint = myPoint = QPoint(x, y); - //printf ( "--- myPoint[ %d, %d ], myOtherPoint[ %d, %d ] ---\n", - //myPoint.x(), myPoint.y(), myOtherPoint.x(), myOtherPoint.y() ); - - startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT); - onFinishOperation(); - startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); - } -} - //---------------------------------------------------------------------------- void VVTK_InteractorStyle::onFinishOperation() { - int aNbObjWas, aNbObjNow; - // - aNbObjWas=GetSelector()->IObjectCount(); - // - SVTK_InteractorStyle::onFinishOperation(); - // - aNbObjNow=GetSelector()->IObjectCount(); - - if (aNbObjWas+aNbObjNow==1){ - vtkCamera *aCamera = GetCurrentRenderer()->GetActiveCamera(); - float aZoomFactor = myPickingSettings->GetZoomFactor(); - double aScale = aCamera->GetParallelScale(); - if (!aNbObjWas && aNbObjNow) { - aCamera->SetParallelScale(aScale/aZoomFactor); - } - else { - aCamera->SetParallelScale(aScale*aZoomFactor); - } - } + Superclass::onFinishOperation(); } @@ -292,3 +247,58 @@ VVTK_InteractorStyle { Interactor->InvokeEvent(VISU::SetSMIncreaseMagnificationEvent,NULL); } +//============================================================================ +// +// Controllers +// +vtkStandardNewMacro(VVTK_ControllerIncrement); +//---------------------------------------------------------------------------- +VVTK_ControllerIncrement::VVTK_ControllerIncrement() +{ + myIncrement=10; +} +//---------------------------------------------------------------------------- +VVTK_ControllerIncrement::~VVTK_ControllerIncrement() +{ +} +//---------------------------------------------------------------------------- +int VVTK_ControllerIncrement::Increase() +{ + myIncrement*=2; + return myIncrement; +} +//---------------------------------------------------------------------------- +int VVTK_ControllerIncrement::Decrease() +{ + myIncrement/=2; + if (!myIncrement){ + myIncrement=1; + } + return myIncrement; +} +// +vtkStandardNewMacro(VVTK_ControllerOnKeyDown); +//---------------------------------------------------------------------------- +VVTK_ControllerOnKeyDown::VVTK_ControllerOnKeyDown() +{ +} +//---------------------------------------------------------------------------- +VVTK_ControllerOnKeyDown::~VVTK_ControllerOnKeyDown() +{ +} +//---------------------------------------------------------------------------- +bool VVTK_ControllerOnKeyDown::OnKeyDown(vtkInteractorStyle* theIS) +{ + SVTK_InteractorStyle *pIS=dynamic_cast(theIS); + if (pIS){ + if(pIS->GetSelector()->SelectionMode()==GaussPointSelection){ + char key = pIS->GetInteractor()->GetKeyCode(); + // + if (key == 'S') { + pIS->ActionPicking(); + return false; + } + } + } + return Superclass::OnKeyDown(theIS); +} diff --git a/src/VVTK/VVTK_InteractorStyle.h b/src/VVTK/VVTK_InteractorStyle.h index f180b788..2d6ec122 100644 --- a/src/VVTK/VVTK_InteractorStyle.h +++ b/src/VVTK/VVTK_InteractorStyle.h @@ -29,31 +29,80 @@ #ifndef __VVTK_InteractorStyle_h #define __VVTK_InteractorStyle_h + #include "VVTK.h" #include "SVTK_InteractorStyle.h" +// +//------------------------------------------- +//! Control the value of increment in new style of interaction. +/*! + This class controls of value of increment, + for pan/rotate/zoom operations in new style + of interaction +*/ +class VVTK_ControllerIncrement : public SVTK_ControllerIncrement { + public: + vtkTypeMacro(VVTK_ControllerIncrement,SVTK_ControllerIncrement); + static VVTK_ControllerIncrement* New(); + + //! Increace the increment value by multiplying on 2 + virtual int Increase(); -class VISU_PickingSettings; + //! Decreace the increment value by division on 2 + virtual int Decrease(); + + protected: + VVTK_ControllerIncrement(); + virtual ~VVTK_ControllerIncrement(); + // + private: + VVTK_ControllerIncrement(const VVTK_ControllerIncrement&); //Not implemented + void operator=(const VVTK_ControllerIncrement&); //Not implemented +}; +// +//------------------------------------------- +//! Control the behaviour of KeyDown event in new style of interaction. +/*! + This class controls of behaviour of of KeyDown event + in new style of interaction. +*/ +class VVTK_ControllerOnKeyDown : public SVTK_ControllerOnKeyDown{ + public: + vtkTypeMacro(VVTK_ControllerOnKeyDown, SVTK_ControllerOnKeyDown); + static VVTK_ControllerOnKeyDown* New(); + + //! Provides the action on event + virtual bool OnKeyDown(vtkInteractorStyle* ); + + protected: + VVTK_ControllerOnKeyDown(); + virtual ~VVTK_ControllerOnKeyDown(); + + private: + VVTK_ControllerOnKeyDown(const VVTK_ControllerOnKeyDown&);//Not implemented + void operator=(const VVTK_ControllerOnKeyDown&); //Not implemented +}; +class VISU_PickingSettings; +//! Introduce new style of interaction (keyboard free) class VVTK_EXPORT VVTK_InteractorStyle : public SVTK_InteractorStyle { public: - // Description: - // This class must be supplied with a vtkRenderWindowInteractor wrapper or - // parent. This class should not normally be instantiated by application - // programmers. static VVTK_InteractorStyle *New(); vtkTypeMacro(VVTK_InteractorStyle,SVTK_InteractorStyle); - // redefined in order to add an observer (callback) for custorm event (space mouse event) + //! Redefined from SVTK_InteractorStyle::SetInteractor in order to add an observer (callback) for custorm event (space mouse event) virtual void SetInteractor( vtkRenderWindowInteractor* ); + //! To share the VISU_PickingSettings void SetPickingSettings(VISU_PickingSettings* thePickingSettings); - + + protected: VVTK_InteractorStyle(); ~VVTK_InteractorStyle(); @@ -62,14 +111,23 @@ class VVTK_EXPORT VVTK_InteractorStyle : public SVTK_InteractorStyle void operator=(const VVTK_InteractorStyle&); // Not implemented // Generic event bindings must be overridden in subclasses + + //! Redefine SVTK_InteractorStyle::OnLeftButtonDown virtual void OnLeftButtonDown(int ctrl, int shift, int x, int y); + + //! Redefine SVTK_InteractorStyle::OnMiddleButtonDown virtual void OnMiddleButtonDown(int ctrl, int shift, int x, int y); + + //! Redefine SVTK_InteractorStyle::OnLeftButtonUp virtual void OnLeftButtonUp(int ctrl, int shift, int x, int y); + + //! Redefine SVTK_InteractorStyle::OnMiddleButtonUp virtual void OnMiddleButtonUp(int ctrl, int shift, int x, int y); - virtual void OnKeyDown(); + + //! Redefine SVTK_InteractorStyle::onFinishOperation virtual void onFinishOperation(); - // Main process VTK event method + //! Main process VTK event method static void ProcessEvents(vtkObject* object, @@ -77,11 +135,16 @@ class VVTK_EXPORT VVTK_InteractorStyle : public SVTK_InteractorStyle void* clientData, void* callData ); + //! Redefine SVTK_InteractorStyle::onSpaceMouseButton virtual void onSpaceMouseButton( int button ); + + //! To decrease magnification of the Gauss Points void DecreaseGaussPointMagnification(); + + //! To increase magnification of the Gauss Points void IncreaseGaussPointMagnification(); - // SpaceMouse short cuts + //! SpaceMouse short cuts int mySMDecreaseMagnificationBtn; int mySMIncreaseMagnificationBtn; diff --git a/src/VVTK/VVTK_MainWindow.cxx b/src/VVTK/VVTK_MainWindow.cxx index 47e35583..a7c21ee5 100644 --- a/src/VVTK/VVTK_MainWindow.cxx +++ b/src/VVTK/VVTK_MainWindow.cxx @@ -31,6 +31,7 @@ #include "VVTK_Recorder.h" #include "VISU_WidgetCtrl.hxx" #include "VISU_GaussPtsAct.h" +#include "VISU_Event.h" #include "SVTK_RenderWindowInteractor.h" #include "VVTK_Renderer.h" @@ -51,8 +52,16 @@ VVTK_MainWindow const char* theName, SUIT_ResourceMgr* theResourceMgr): SVTK_MainWindow(theParent,theName,theResourceMgr), - myInteractorStyle(VVTK_InteractorStyle::New()) + myInteractorStyle(VVTK_InteractorStyle::New()), + myControllerIncrement(VVTK_ControllerIncrement::New()), + myControllerOnKeyDown(VVTK_ControllerOnKeyDown::New()) { + myInteractorStyle->SetControllerIncrement(myControllerIncrement.GetPointer()); + myControllerIncrement->Delete(); + + myInteractorStyle->SetControllerOnKeyDown(myControllerOnKeyDown.GetPointer()); + myControllerOnKeyDown->Delete(); + myInteractorStyle->Delete(); moveDockWindow(myToolBar,Qt::DockLeft); @@ -102,12 +111,18 @@ VVTK_MainWindow } } +//---------------------------------------------------------------------------- void VVTK_MainWindow ::Initialize(SVTK_RenderWindowInteractor* theInteractor) -{ +{ + vtkInteractorStyle* pVIS=theInteractor->GetInteractorStyle(); + SVTK_InteractorStyle *pInteractorStyle=dynamic_cast(pVIS); + if (pInteractorStyle){ + pInteractorStyle->SetControllerIncrement(myControllerIncrement.GetPointer()); + pInteractorStyle->SetControllerOnKeyDown(myControllerOnKeyDown.GetPointer()); + } SVTK_MainWindow::Initialize(theInteractor); - PushInteractorStyle(myInteractorStyle.GetPointer()); } VVTK_MainWindow::~VVTK_MainWindow() @@ -134,7 +149,7 @@ void VVTK_MainWindow ::OnSelectionModeSwitch(bool theIsSelectionOn) { - SetSelectionMode(theIsSelectionOn? NodeSelection: ActorSelection); + SetSelectionMode(theIsSelectionOn? GaussPointSelection: ActorSelection); } //---------------------------------------------------------------------------- @@ -240,12 +255,14 @@ VVTK_MainWindow1 "VVTK/SVTK StyleSwitch", true); anAction->setToggleAction(true); - anAction->toggle(); anAction->setStatusTip(tr("DSC_VVTK_INTERACTOR_STYLE_SWITCH")); - connect(anAction, SIGNAL(toggled(bool)), this, SLOT(OnInteractorStyleSwitch(bool))); + anAction->addTo( myPtsToolBar ); myStyleSwitchAction = anAction; + if( theResourceMgr->integerValue( "VISU", "mouse_behaviour", true ) == 1 ) + myStyleSwitchAction->toggle(); + aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_SELECTION_MODE_SWITCH")); anAction = new QtxAction(tr("MNU_VVTK_SELECTION_MODE_SWITCH"), aPixmap, @@ -304,6 +321,10 @@ VVTK_MainWindow1 myRenderer = theRenderer; VVTK_MainWindow::Initialize(theInteractor); + if( myStyleSwitchAction->isOn() ) + PushInteractorStyle(myInteractorStyle.GetPointer()); + connect(myStyleSwitchAction, SIGNAL(toggled(bool)), this, SLOT(OnInteractorStyleSwitch(bool))); + mySegmentationCursorDlg->SetWidgetCtrl( theRenderer->GetWidgetCtrl() ); myPickingDlg->SetInteractor( GetInteractor() ); } @@ -326,7 +347,6 @@ VVTK_MainWindow1 theResourceMgr, thePickingSettings, myStyleSwitchAction); - //myMainWindow2->hide(); return myMainWindow2; } diff --git a/src/VVTK/VVTK_MainWindow.h b/src/VVTK/VVTK_MainWindow.h index 95454fd5..608b8cc0 100644 --- a/src/VVTK/VVTK_MainWindow.h +++ b/src/VVTK/VVTK_MainWindow.h @@ -16,6 +16,8 @@ class VISU_InsideCursorSettings; class VISU_OutsideCursorSettings; class VISU_PickingSettings; class VVTK_InteractorStyle; +class VVTK_ControllerIncrement; +class VVTK_ControllerOnKeyDown; class VVTK_PickingDlg; class VVTK_MainWindow2; class VVTK_Renderer1; @@ -23,26 +25,33 @@ class VVTK_Renderer2; class VVTK_Recorder; //---------------------------------------------------------------------------- +//! Customize SVTK_MainWindow to provide VVTK functionality class VVTK_EXPORT VVTK_MainWindow: public SVTK_MainWindow { Q_OBJECT; public: + //! Construct instance of the class VVTK_MainWindow(QWidget* theParent, const char* theName, SUIT_ResourceMgr* theResourceMgr); + + //! Reimplement SVTK_MainWindow::Initialize virtual void Initialize(SVTK_RenderWindowInteractor* theInteractor); + //! Destroy instance of the class virtual ~VVTK_MainWindow(); public slots: + //! To change active interactor style at run-time virtual void OnInteractorStyleSwitch(bool theIsGaussStyleOn); + //! To change active selection mode at run-time virtual void OnSelectionModeSwitch(bool theIsSelectionOn); virtual @@ -67,6 +76,8 @@ public: protected: vtkSmartPointer myInteractorStyle; + vtkSmartPointer myControllerIncrement; + vtkSmartPointer myControllerOnKeyDown; QToolBar* myRecordingToolBar; QtxAction* myStartAction; @@ -79,23 +90,32 @@ public: //---------------------------------------------------------------------------- +//! Extend VVTK_MainWindow to implement functionality for base view class VVTK_EXPORT VVTK_MainWindow1: public VVTK_MainWindow { Q_OBJECT; public: + //! Construct instance of the class VVTK_MainWindow1(QSplitter* theParent, const char* theName, SUIT_ResourceMgr* theResourceMgr); + + //! Reimplement VVTK_MainWindow::Initialize virtual void Initialize(SVTK_RenderWindowInteractor* theInteractor, VVTK_Renderer1* theRenderer); - + //! Destroy instance of the class virtual ~VVTK_MainWindow1(); + //! Create instance of the segmented VVTK_MainWindow + /*! + The two views (VVTK_MainWindow1 and VVTK_MainWindow2) should change its behaviour in the same time. + So, it is necessary to synhronize them through sharing some common pointers. + */ VVTK_MainWindow2* CreateMainWindow2(QWidget* theParent, const char* theName, @@ -107,50 +127,60 @@ public: VISU_InsideCursorSettings* GetInsideCursorSettings(); + //! Get contained VISU_OutsideCursorSettings VISU_OutsideCursorSettings* GetOutsideCursorSettings(); + //! Get contained VISU_PickingSettings VISU_PickingSettings* GetPickingSettings(); public slots: + //! To activate/ deactivate the segementation cursor at run-time void OnSegmentationSwitch();//bool theIsSegmentationOn); + //! Customize VVTK_MainWindow::OnSelectionModeSwitch virtual void OnSelectionModeSwitch(bool theIsSelectionOn); protected: - VVTK_Renderer1* myRenderer; + VVTK_Renderer1* myRenderer; //!< Keeps extended version of SVTK_Renderer + + VVTK_MainWindow2* myMainWindow2; //!< Refer to segmented view - VVTK_MainWindow2* myMainWindow2; + QtxAction* myStyleSwitchAction; //!< Action for switch interactor style + QToolBar* myPtsToolBar; //!< Additional tool bar - QtxAction* myStyleSwitchAction; - QToolBar* myPtsToolBar; - QSplitter* mySplitter; + //! To implement show/hide segmented view on acttivate/ deactivate segementation cursor + QSplitter* mySplitter; - QtxAction* myPlaneSegmentationAction; - QtxAction* mySphereSegmentationAction; + QtxAction* myPlaneSegmentationAction; //!< Action for switch segmentation mode to plane + QtxAction* mySphereSegmentationAction; //!< Action for switch segmentation mode to sphere - VVTK_SegmentationCursorDlg* mySegmentationCursorDlg; - VVTK_PickingDlg* myPickingDlg; + //! Keep reference to VVTK_SegmentationCursorDlg + VVTK_SegmentationCursorDlg* mySegmentationCursorDlg; + VVTK_PickingDlg* myPickingDlg; //!< Keep reference to VVTK_PickingDlg }; //---------------------------------------------------------------------------- +//! Extend VVTK_MainWindow to implement functionality for segmented view class VVTK_EXPORT VVTK_MainWindow2: public VVTK_MainWindow { Q_OBJECT; friend class VVTK_MainWindow1; + //! Construct instance of the class VVTK_MainWindow2(QWidget* theParent, const char* theName, SUIT_ResourceMgr* theResourceMgr, VISU_PickingSettings* thePickingSettings, QtxAction* theStyleSwitchAction); public: + //! Destroy instance of the class virtual ~VVTK_MainWindow2(); }; diff --git a/src/VVTK/VVTK_PickingDlg.cxx b/src/VVTK/VVTK_PickingDlg.cxx index 4bdf4a44..21b8c2e6 100644 --- a/src/VVTK/VVTK_PickingDlg.cxx +++ b/src/VVTK/VVTK_PickingDlg.cxx @@ -28,6 +28,7 @@ #include "utilities.h" #include +#include #include #include #include @@ -76,11 +77,42 @@ VVTK_PickingDlg::VVTK_PickingDlg( QWidget* parent, const char* name ) CursorGroupLayout->setMargin(11); QLabel* PyramidHeightLabel = new QLabel( tr( "PYRAMID_HEIGHT" ), CursorGroup ); - myPyramidHeightSpinBox = new QtxDblSpinBox( 1.0, 100.0, 1.0, CursorGroup ); + double aHeightMin=1.e-7; + double aHeightMax=10.; + double aHeightStep=0.1; + myPyramidHeightSpinBox = new QtxDblSpinBox(aHeightMin, aHeightMax, aHeightStep, CursorGroup ); + myPyramidHeightSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + + QLabel* SelectionColorLabel = new QLabel( tr( "SELECTION_COLOR" ), CursorGroup ); + mySelectionColorButton = new QPushButton( CursorGroup ); + mySelectionColorButton->setPaletteBackgroundColor( Qt::blue ); + mySelectionColorButton->setPaletteForegroundColor( Qt::blue ); + connect( mySelectionColorButton, SIGNAL( clicked() ), this, SLOT( onColorButtonPressed() ) ); CursorGroupLayout->addWidget( PyramidHeightLabel, 0, 0 ); CursorGroupLayout->addWidget( myPyramidHeightSpinBox, 0, 1 ); + CursorGroupLayout->addWidget( SelectionColorLabel, 1, 0 ); + CursorGroupLayout->addWidget( mySelectionColorButton, 1, 1 ); + + // Tolerance + QGroupBox* ToleranceGroup = new QGroupBox( tr( "TOLERANCE_TITLE" ), aBox, "ToleranceGroup" ); + ToleranceGroup->setColumnLayout(0, Qt::Vertical ); + ToleranceGroup->layout()->setSpacing( 0 ); + ToleranceGroup->layout()->setMargin( 0 ); + + QGridLayout* ToleranceGroupLayout = new QGridLayout (ToleranceGroup->layout()); + ToleranceGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + ToleranceGroupLayout->setSpacing(6); + ToleranceGroupLayout->setMargin(11); + + QLabel* PointToleranceLabel = new QLabel( tr( "POINT_TOLERANCE" ), ToleranceGroup ); + myPointToleranceSpinBox = new QtxDblSpinBox( 0.001, 10.0, 0.01, ToleranceGroup ); + myPointToleranceSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + ToleranceGroupLayout->addWidget( PointToleranceLabel, 0, 0 ); + ToleranceGroupLayout->addWidget( myPointToleranceSpinBox, 0, 1 ); // Information window QGroupBox* InfoWindowGroup = new QGroupBox( tr( "INFO_WINDOW_TITLE" ), aBox, "InfoWindowGroup" ); @@ -194,6 +226,8 @@ void VVTK_PickingDlg::RemoveActor( VISU_GaussPtsAct* theActor ) void VVTK_PickingDlg::Update() { float aPyramidHeight = 10.0; + float aPointTolerance = 0.1; + QColor aColor = Qt::yellow; int anInfoWindowTransparency = 50; int anInfoWindowPosition = VISU_PickingSettings::BelowPoint; float aZoomFactor = 1.5; @@ -203,12 +237,19 @@ void VVTK_PickingDlg::Update() if( !myPickingSettings->GetInitial() ) { myPyramidHeightSpinBox->setValue( myPickingSettings->GetPyramidHeight() ); + myPointToleranceSpinBox->setValue( myPickingSettings->GetPointTolerance() ); + myTransparencySpinBox->setValue( myPickingSettings->GetInfoWindowTransparency() * 100.0 ); myTransparencySpinBox->setValue( ( int )myPickingSettings->GetInfoWindowTransparency() * 100 ); myPositionComboBox->setCurrentItem( myPickingSettings->GetInfoWindowPosition() ); myZoomFactorSpinBox->setValue( myPickingSettings->GetZoomFactor() ); myStepNumberSpinBox->setValue( myPickingSettings->GetStepNumber() ); myDisplayParentMeshCheckBox->setChecked( myPickingSettings->GetDisplayParentMesh() ); + float* aColor = myPickingSettings->GetColor(); + mySelectionColorButton->setPaletteBackgroundColor( QColor( ( int )( aColor[0] * 255.0 ), + ( int )( aColor[1] * 255.0 ), + ( int )( aColor[2] * 255.0 ) ) ); + return; } @@ -217,6 +258,12 @@ void VVTK_PickingDlg::Update() aPyramidHeight = aResourceMgr->doubleValue( "VISU", "picking_pyramid_height", aPyramidHeight ); myPyramidHeightSpinBox->setValue( aPyramidHeight ); + aPointTolerance = aResourceMgr->doubleValue( "VISU", "picking_point_tolerance", aPointTolerance ); + myPointToleranceSpinBox->setValue( aPointTolerance ); + + aColor = aResourceMgr->colorValue( "VISU", "picking_selection_color", aColor ); + mySelectionColorButton->setPaletteBackgroundColor( aColor ); + anInfoWindowTransparency = aResourceMgr->integerValue( "VISU", "picking_transparency", anInfoWindowTransparency ); myTransparencySpinBox->setValue( anInfoWindowTransparency ); @@ -285,12 +332,20 @@ void VVTK_PickingDlg::onClickApply() myPickingSettings->SetInitial( false ); myPickingSettings->SetPyramidHeight( myPyramidHeightSpinBox->value() ); + myPickingSettings->SetPointTolerance( myPointToleranceSpinBox->value() ); myPickingSettings->SetInfoWindowTransparency( myTransparencySpinBox->value() / 100.0 ); myPickingSettings->SetInfoWindowPosition( myPositionComboBox->currentItem() ); myPickingSettings->SetZoomFactor( myZoomFactorSpinBox->value() ); myPickingSettings->SetStepNumber( myStepNumberSpinBox->value() ); myPickingSettings->SetDisplayParentMesh( myDisplayParentMeshCheckBox->isChecked() ); + QColor aButtonColor = mySelectionColorButton->paletteBackgroundColor(); + float aColor[3]; + aColor[0] = aButtonColor.red() / 255.0; + aColor[1] = aButtonColor.green() / 255.0; + aColor[2] = aButtonColor.blue() / 255.0; + myPickingSettings->SetColor( aColor ); + myPickingSettings->InvokeEvent(VISU::UpdatePickingSettingsEvent,NULL); } @@ -305,3 +360,10 @@ void VVTK_PickingDlg::done( int r ) myAction->setOn( false ); QDialog::done( r ); } + +void VVTK_PickingDlg::onColorButtonPressed() +{ + QColor aColor = QColorDialog::getColor( mySelectionColorButton->paletteBackgroundColor(), this ); + if( aColor.isValid() ) + mySelectionColorButton->setPaletteBackgroundColor( aColor ); +} diff --git a/src/VVTK/VVTK_PickingDlg.h b/src/VVTK/VVTK_PickingDlg.h index 5f4fb2d9..01ba29cd 100644 --- a/src/VVTK/VVTK_PickingDlg.h +++ b/src/VVTK/VVTK_PickingDlg.h @@ -23,6 +23,7 @@ class vtkImageData; class QLabel; class QComboBox; class QCheckBox; +class QPushButton; class QtxAction; class QtxDblSpinBox; @@ -33,6 +34,11 @@ class VISU_PickingSettings; class SVTK_RenderWindowInteractor; +//! Picking Dialog. +/*! + * Uses for set up picking preferenses and apply + * them to all actors in the current renderer. + */ class VVTK_PickingDlg : public QDialog { Q_OBJECT @@ -41,11 +47,14 @@ public: VVTK_PickingDlg( QWidget* parent = 0, const char* name = 0 ); ~VVTK_PickingDlg(); + //! Used to switch toggle state of the Picking action. void SetAction( QtxAction* theAction ) { myAction = theAction; } + //! Make an actor to listen the event of Update Picking Settings event. void AddActor( VISU_GaussPtsAct* ); void RemoveActor( VISU_GaussPtsAct* ); + //! Update dialog contents. void Update(); VISU_PickingSettings* GetPickingSettings(); @@ -58,6 +67,8 @@ protected slots: void onClickApply(); void onClickClose(); + void onColorButtonPressed(); + private: static void ProcessEvents(vtkObject* theObject, unsigned long theEvent, @@ -68,6 +79,8 @@ private: private: QtxDblSpinBox* myPyramidHeightSpinBox; + QPushButton* mySelectionColorButton; + QtxDblSpinBox* myPointToleranceSpinBox; QtxIntSpinBox* myTransparencySpinBox; QComboBox* myPositionComboBox; QtxDblSpinBox* myZoomFactorSpinBox; diff --git a/src/VVTK/VVTK_Renderer.cxx b/src/VVTK/VVTK_Renderer.cxx index eb315b7f..484eff95 100644 --- a/src/VVTK/VVTK_Renderer.cxx +++ b/src/VVTK/VVTK_Renderer.cxx @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -141,7 +142,10 @@ VVTK_Renderer ::VVTK_Renderer(): myFPSActor(VISU_FPSActor::New()), myInsideCursorSettings(NULL), - myPickingSettings(NULL) + myPickingSettings(NULL), + myGaussPointPicker(vtkPointPicker::New()), + myGaussPreHighlightProperty(vtkProperty::New()), + myGaussHighlightProperty(vtkProperty::New()) { if(MYDEBUG) INFOS("VVTK_Renderer() - "<Delete(); GetDevice()->AddActor2D(myFPSActor.GetPointer()); + + myGaussPointPicker->Delete(); + + myGaussPreHighlightProperty->Delete(); + myGaussPreHighlightProperty->SetColor(0,1,1); + + myGaussHighlightProperty->Delete(); + myGaussHighlightProperty->SetColor(1,1,0); + } VVTK_Renderer @@ -174,10 +187,14 @@ void VVTK_Renderer ::AddActor(VTKViewer_Actor* theActor) { + Superclass::AddActor(theActor); if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)){ + anActor->SetPointPicker(myGaussPointPicker.GetPointer()); + anActor->SetPreHighlightProperty(myGaussPreHighlightProperty.GetPointer()); + anActor->SetHighlightProperty(myGaussHighlightProperty.GetPointer()); + anActor->SetInsideCursorSettings(myInsideCursorSettings); anActor->SetPickingSettings(myPickingSettings); - Superclass::AddActor(anActor); } } @@ -186,11 +203,14 @@ void VVTK_Renderer ::RemoveActor(VTKViewer_Actor* theActor) { - using namespace VISU; + Superclass::RemoveActor(theActor); if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)){ + anActor->SetPointPicker(NULL); + anActor->SetPreHighlightProperty(NULL); + anActor->SetHighlightProperty(NULL); + anActor->SetInsideCursorSettings(NULL); anActor->SetPickingSettings(NULL); - Superclass::RemoveActor(theActor); } } @@ -246,10 +266,10 @@ void VVTK_Renderer1 ::AddActor(VTKViewer_Actor* theActor) { + Superclass::AddActor(theActor); if(VISU_GaussPtsAct1* anActor = dynamic_cast(theActor)){ anActor->SetWidgetCtrl(GetWidgetCtrl()); anActor->SetOutsideCursorSettings(myOutsideCursorSettings); - Superclass::AddActor(anActor); AdjustWidgetCtrl(); } } @@ -259,11 +279,10 @@ void VVTK_Renderer1 ::RemoveActor(VTKViewer_Actor* theActor) { - using namespace VISU; + Superclass::RemoveActor(theActor); if(VISU_GaussPtsAct1* anActor = dynamic_cast(theActor)){ anActor->SetWidgetCtrl(NULL); anActor->SetOutsideCursorSettings(NULL); - Superclass::RemoveActor(theActor); AdjustWidgetCtrl(); } } @@ -371,6 +390,7 @@ VVTK_Renderer2 VVTK_Renderer2* self = reinterpret_cast(theClientData); switch(theEvent){ + case vtkCommand::EnableEvent: case vtkCommand::EndInteractionEvent: self->OnEndInteractionEvent(); break; diff --git a/src/VVTK/VVTK_Renderer.h b/src/VVTK/VVTK_Renderer.h index 5860f4ba..1f566884 100644 --- a/src/VVTK/VVTK_Renderer.h +++ b/src/VVTK/VVTK_Renderer.h @@ -39,23 +39,31 @@ class VISU_OutsideCursorSettings; class VISU_PickingSettings; class VISU_FPSActor; +class vtkPointPicker; class vtkImplicitFunction; //---------------------------------------------------------------------------- +//! To customize SVTK_Renderer according to VVTK functionality class VVTK_EXPORT VVTK_Renderer : public SVTK_Renderer { public: vtkTypeMacro(VVTK_Renderer,SVTK_Renderer); static VVTK_Renderer* New(); + //! Reimplement SVTK_Renderer::AddActor + /*! + Perform an additional action - apply picking settings on the published VISU_GaussPtsAct actors + */ virtual void AddActor(VTKViewer_Actor* theActor); + //! Reimplement SVTK_Renderer::RemoveActor (remove additional settings) virtual void RemoveActor(VTKViewer_Actor* theActor); + //! To set VISU_PickingSettings to share them among all VISU_GaussPtsAct actors published into the view void SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings); @@ -66,32 +74,41 @@ class VVTK_EXPORT VVTK_Renderer : public SVTK_Renderer VVTK_Renderer(); ~VVTK_Renderer(); - VISU_InsideCursorSettings* myInsideCursorSettings; - VISU_PickingSettings* myPickingSettings; - vtkSmartPointer myFPSActor; + VISU_PickingSettings* myPickingSettings; //! Keeps reference of the VISU_PickingSettings + VISU_InsideCursorSettings* myInsideCursorSettings; //! Keeps reference of the VISU_InsideCursorSettings + vtkSmartPointer myFPSActor; //!< To show FPS of the rendering at run-time + + vtkSmartPointer myGaussPointPicker; + vtkSmartPointer myGaussPreHighlightProperty; + vtkSmartPointer myGaussHighlightProperty; }; //---------------------------------------------------------------------------- +//! To extend VVTK_Renderer to implement base view functionality class VVTK_EXPORT VVTK_Renderer1 : public VVTK_Renderer { public: vtkTypeMacro(VVTK_Renderer1,VVTK_Renderer); static VVTK_Renderer1* New(); + //! Reimplement SVTK_Renderer::Initialize virtual void Initialize(vtkRenderWindowInteractor* theInteractor, SVTK_Selector* theSelector); + //! Reimplement VVTK_Renderer::AddActor to apply to the actor additional settings virtual void AddActor(VTKViewer_Actor* theActor); + //! Reimplement VVTK_Renderer::RemoveActor virtual void RemoveActor(VTKViewer_Actor* theActor); + //! To set VISU_PickingSettings to share them among all VISU_GaussPtsAct1 actors published into the view void SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings); @@ -101,6 +118,7 @@ class VVTK_EXPORT VVTK_Renderer1 : public VVTK_Renderer VVTK_Renderer1(); ~VVTK_Renderer1(); + //! Reimplement VVTK_Renderer::OnAdjustActors virtual bool OnAdjustActors(); @@ -120,16 +138,19 @@ class VVTK_EXPORT VVTK_Renderer2 : public VVTK_Renderer vtkTypeMacro(VVTK_Renderer2,VVTK_Renderer); static VVTK_Renderer2* New(); + //! Reimplement VVTK_Renderer::AddActor to apply to the actor additional settings virtual void AddActor(VTKViewer_Actor* theActor); + //! Reimplement VVTK_Renderer::RemoveActor virtual void RemoveActor(VTKViewer_Actor* theActor); void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl); + //! To handle vtkCommand::EndInteractionEvent to redraw the view void OnEndInteractionEvent(); @@ -137,7 +158,7 @@ class VVTK_EXPORT VVTK_Renderer2 : public VVTK_Renderer VVTK_Renderer2(); ~VVTK_Renderer2(); - // Main process VTK event method + //! Main process VTK event method static void ProcessEvents(vtkObject* theObject, @@ -145,10 +166,10 @@ class VVTK_EXPORT VVTK_Renderer2 : public VVTK_Renderer void* theClientData, void* theCallData); - // Used to process VTK events + //! Used to process VTK events vtkSmartPointer myEventCallbackCommand; - // Priority at which events are processed + //! Priority at which events are processed float myPriority; VISU_WidgetCtrl* myWidgetCtrl; diff --git a/src/VVTK/VVTK_SegmentationCursorDlg.cxx b/src/VVTK/VVTK_SegmentationCursorDlg.cxx index 5d4cfe10..fcb7be80 100644 --- a/src/VVTK/VVTK_SegmentationCursorDlg.cxx +++ b/src/VVTK/VVTK_SegmentationCursorDlg.cxx @@ -20,6 +20,7 @@ #include "VISU_SphereWidget.hxx" #include "VISU_GaussPointsPL.hxx" +#include "VISU_OpenGLPointSpriteMapper.hxx" #include "SUIT_ResourceMgr.h" #include "SUIT_Session.h" @@ -410,8 +411,8 @@ void VVTK_SegmentationCursorDlg::UpdateInsideGaussPoints() void VVTK_SegmentationCursorDlg::UpdateOutsideGaussPoints() { + float aClamp = 256.0; int aPrimitiveType = VVTK_PrimitiveBox::PointSprite; - float aClamp = 200.0; QString aMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_texture.bmp"; QString anAlphaTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_alpha.bmp"; float anAlphaThreshold = 0.1; @@ -549,10 +550,16 @@ void VVTK_SegmentationCursorDlg::ApplySegmentationCursor() normal[0] = myDXDirectionSpinBox->value(); normal[1] = myDYDirectionSpinBox->value(); normal[2] = myDZDirectionSpinBox->value(); + + if( normal[0] == 0.0 && normal[1] == 0.0 && normal[2] == 0.0 ) + { + normal[2] = 1.0; + myDZDirectionSpinBox->setValue( 1.0 ); + } pPlanesWidget->SetNormal( normal ); pPlanesWidget->SetDistance( myDepthSpinBox->value() ); - + myWidgetCtrl->InvokeEvent(vtkCommand::EndInteractionEvent,NULL); myWidgetCtrl->GetInteractor()->Render(); } diff --git a/src/VVTK/VVTK_SegmentationCursorDlg.h b/src/VVTK/VVTK_SegmentationCursorDlg.h index 009278b8..39c0c118 100644 --- a/src/VVTK/VVTK_SegmentationCursorDlg.h +++ b/src/VVTK/VVTK_SegmentationCursorDlg.h @@ -39,6 +39,11 @@ class VISU_WidgetCtrl; class VVTK_PrimitiveBox; class VVTK_SizeBox; +//! Segmentation Cursor Dialog. +/*! + * Uses for set up Segmentation and Outside Cursor Gauss Points preferenses + * and apply them to all actors in the current renderer. + */ class VVTK_SegmentationCursorDlg : public QDialog { Q_OBJECT @@ -54,10 +59,14 @@ public: bool GetIsPlaneSegmentation() const { return myIsPlaneSegmentation; } void SetIsPlaneSegmentation( bool on ) { myIsPlaneSegmentation = on; } + //! Update contents of the Segmentation tab. void UpdateSegmentation(); void UpdateInsideGaussPoints(); void UpdateOutsideGaussPoints(); + //! Update contents of the Outside Cursor tab. + void UpdateOutsideCursor(); + VISU_InsideCursorSettings* GetInsideCursorSettings(); VISU_OutsideCursorSettings* GetOutsideCursorSettings(); diff --git a/src/VVTK/VVTK_ViewManager.h b/src/VVTK/VVTK_ViewManager.h index 9e70cbc4..101fa583 100644 --- a/src/VVTK/VVTK_ViewManager.h +++ b/src/VVTK/VVTK_ViewManager.h @@ -6,12 +6,15 @@ class SUIT_Desktop; +//! Extend SUIT_ViewManager to deal with VVTK_Viewer class VVTK_EXPORT VVTK_ViewManager : public SUIT_ViewManager { Q_OBJECT; public: - + //! Construct the view manager VVTK_ViewManager( SUIT_Study* study, SUIT_Desktop* ); + + //! Destroy the view manager virtual ~VVTK_ViewManager(); protected: diff --git a/src/VVTK/VVTK_ViewModel.h b/src/VVTK/VVTK_ViewModel.h index 6c2453b1..0846edcd 100644 --- a/src/VVTK/VVTK_ViewModel.h +++ b/src/VVTK/VVTK_ViewModel.h @@ -11,6 +11,7 @@ class VVTK_ViewWindow; +//! Extends two interfaces #SVTK_ViewModelBase and #SALOME_View class VVTK_EXPORT VVTK_Viewer : public SVTK_ViewModelBase, public SALOME_View { Q_OBJECT; @@ -22,20 +23,32 @@ public: VVTK_Viewer(); virtual ~VVTK_Viewer(); + //! Redefine SUIT_ViewModel::createView virtual SUIT_ViewWindow* createView(SUIT_Desktop*); - virtual void setViewManager(SUIT_ViewManager* theViewManager); - virtual void contextMenuPopup( QPopupMenu* ); - virtual QString getType() const { return Type(); } + //! Redefine SUIT_ViewModel::setViewManager + virtual void setViewManager(SUIT_ViewManager* theViewManager); + //! Redefine SUIT_ViewModel::contextMenuPopup + virtual void contextMenuPopup( QPopupMenu* ); + //! See SUIT_ViewModel::getType + virtual QString getType() const { return Type(); } + //! Redefine SALOME_View::Repaint virtual void Repaint(); - virtual bool isVisible( const Handle(SALOME_InteractiveObject)& ); + //! Redefine SALOME_View::isVisible + virtual bool isVisible( const Handle(SALOME_InteractiveObject)& ); + //! Get background color of the viewer QColor backgroundColor() const; + + //! Set background color to the viewer void setBackgroundColor( const QColor& ); + //! Get size of trihedron of the viewer (see SVTK_Renderer::SetTrihedronSize) int trihedronSize() const; + + //! Set size of trihedron of the viewer (see SVTK_Renderer::SetTrihedronSize) void setTrihedronSize( const int ); protected slots: diff --git a/src/VVTK/VVTK_ViewWindow.h b/src/VVTK/VVTK_ViewWindow.h index a6ddca69..8f952ab9 100755 --- a/src/VVTK/VVTK_ViewWindow.h +++ b/src/VVTK/VVTK_ViewWindow.h @@ -15,63 +15,84 @@ class VVTK_MainWindow2; class SVTK_View; //---------------------------------------------------------------------------- +//! Customize the SVTK_ViewWindow in order to manage two SVTK_View (base and segmented one) class VVTK_EXPORT VVTK_ViewWindow : public SVTK_ViewWindow { Q_OBJECT; public: + //! To construct the class VVTK_ViewWindow(SUIT_Desktop* theDesktop); + //! Destroy virtual ~VVTK_ViewWindow(); + //! To initialize virtual void Initialize(SVTK_ViewModelBase* theModel); //---------------------------------------------------------------------------- + //! Get access to base SVTK_MainWindow VVTK_MainWindow1* getMainWindow1(); + //! Get access to segmented SVTK_MainWindow VVTK_MainWindow2* getMainWindow2(); //---------------------------------------------------------------------------- + //! Redefine SVTK_ViewWindow::AddActor method + /*! + This is an entry point for publication the presentation into the viewer. + Pointed actor published into the basic MainWindow. If the actor is + a Gauss Points one second actor is created from initial actor and + is put into segemented MainWindow. + */ virtual void AddActor(VTKViewer_Actor* theActor, bool theIsUpdate = false); + //! Redefine SVTK_ViewWindow::RemoveActor method virtual void RemoveActor(VTKViewer_Actor* theActor, bool theIsUpdate = false); + //! Redefine SVTK_ViewWindow::Repaint method virtual void Repaint(bool theUpdateTrihedron = true); //---------------------------------------------------------------------------- /* interactive object management */ + //! Redefine SVTK_ViewWindow::highlight method virtual void highlight(const Handle(SALOME_InteractiveObject)& theIO, bool theIsHighlight = true, bool theIsUpdate = true); + + //! Redefine SVTK_ViewWindow::unHighlightAll method virtual void unHighlightAll(); //---------------------------------------------------------------------------- public slots: + //! Redefine SVTK_ViewWindow::onSelectionChanged method virtual void onSelectionChanged(); + //! Redefine SVTK_ViewWindow::onResetView method virtual void onResetView(); + //! Redefine SVTK_ViewWindow::onFitAll method virtual void onFitAll(); @@ -82,11 +103,11 @@ protected: void action( const int ); - VVTK_MainWindow1* myMainWindow1; - SVTK_View* myView1; + VVTK_MainWindow1* myMainWindow1; //!< The manage base view + SVTK_View* myView1; //!< The manage base view - VVTK_MainWindow2* myMainWindow2; - SVTK_View* myView2; + VVTK_MainWindow2* myMainWindow2; //!< The manage segmented view + SVTK_View* myView2; //!< The manage segmented view }; #ifdef WIN32 -- 2.39.2