From: jfa Date: Thu, 30 Aug 2007 12:01:23 +0000 (+0000) Subject: Join modifications from BR_MULTIPR_INDUS X-Git-Tag: mergefrom_BR_MULTIPR_INDUS_30Aug07 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d7f1ce091bca09074e2d4084bd07c638a5ce5984;p=modules%2Fvisu.git Join modifications from BR_MULTIPR_INDUS --- diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 560a870a..f092a2a7 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -57,11 +57,13 @@ module VISU { * This enumeration contains a set of elements defining the * type of the %entity (topological units) constituting a mesh. */ - enum Entity{ NODE, /*!< Node corresponds to a geometrical point. */ - EDGE, /*!< Edge corresponds to a geometrical line connecting two points. */ - FACE, /*!< Face corresponds to a geometrical plane bounded by several lines. */ - CELL /*!< Cell is a volumic element of a mesh */ - }; + enum Entity { + NODE, /*!< Node corresponds to a geometrical point. */ + EDGE, /*!< Edge corresponds to a geometrical line connecting two points. */ + FACE, /*!< Face corresponds to a geometrical plane bounded by several lines. */ + CELL, /*!< Cell is a volumic element of a mesh */ + NONE /*!< Indicates undefined entity value */ + }; /*! * This enumeration contains a set of elements defining the type of the %VISU object. @@ -420,6 +422,13 @@ module VISU { */ long GetScalarMode(); + /*! + * Sets scalar range - min and max boundaries of the scalar bar. + * \param theMin Min boundary of the scalar bar. + * \param theMax Max boundary of the scalar bar. + */ + void SetRange(in double theMin, in double theMax); + /*! * Gets the min boundary of the scalar bar. */ @@ -430,6 +439,11 @@ module VISU { */ double GetMax(); + /*! + * Sets scalar range that corresponds to the source data. + */ + void SetSourceRange(); + /*! * Gets the min boundary of the scalar bar from source data. */ @@ -686,18 +700,6 @@ module VISU { */ Scaling GetScaling(); - /*! - * Sets scalar range - min and max boundaries of the scalar bar. - * \param theMin Min boundary of the scalar bar. - * \param theMax Max boundary of the scalar bar. - */ - void SetRange(in double theMin, in double theMax); - - /*! - * Sets scalar range that corresponds to the source data. - */ - void SetSourceRange(); - /*! * Add group as geometry of presentation. * \param theMeshName - mesh name @@ -719,14 +721,157 @@ module VISU { * Presentation parameters of the Gauss Points presentation. */ //------------------------------------------------------- - interface GaussPoints : ColoredPrs3d { + interface GaussPoints : ColoredPrs3d + { + //! Set flag indicating which scalar bar is active. + void SetIsActiveLocalScalarBar(in boolean theFlag); + + //! Get flag indicating which scalar bar is active. + boolean GetIsActiveLocalScalarBar(); + + //! Set flag indicating visibility of global scalar bar. + void SetIsDispGlobalScalarBar(in boolean theFlag); + + //! Get flag indicating visibility of global scalar bar. + boolean GetIsDispGlobalScalarBar(); + + //! Set value of the distance between global and local scalar bars. + void SetSpacing(in double theSpacing); + + //! Get value of the distance between global and local scalar bars. + double GetSpacing(); + + /*! + * Set the Multicolored mode. + * \param theIsColored is used 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(in boolean theIsColored); + + //! Gets current color mode + boolean GetIsColored(); + + /*! Sets the color of this presentation in case of IsColored switched off. + * \param theColor The color of this presentation. This parameter + * is taken from the Color enumeration. + */ + void SetColor(in SALOMEDS::Color theColor); + + /*! + * 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(in boolean theIsBiColor); + + //! Get the Bicolor mode. + boolean GetBiColor(); + + //! Checks whether the Gauss Points will be deformed or not + boolean GetIsDeformed(); + + //! Apply deformation on the Gauss Points + void SetIsDeformed(in boolean theIsDeformed); + + /*! + * Sets the scale factor for scalar values + * (how much corresponding mesh elements should be translated). + * \param theScaleFactor The scaling factor. + */ + void SetScaleFactor(in double theScaleFactor); + + /*! + * Gets the scale factor for scalar values. + * (how much corresponding mesh elements is translated) + */ + double GetScaleFactor(); + + /*! + * This enumeration contains a set of elements defining the type of representation of the vector head. + */ + enum PrimitiveType { + SPRITE, + POINT, + SPHERE + }; + + //! Set type of the primitives which is used for drawing the Gauss Points + void SetPrimitiveType(in PrimitiveType thePrimitiveType); + + //! Get type of the primitives which is used for drawing the Gauss Points + PrimitiveType GetPrimitiveType(); + + //! Sets Point Sprite clamp + void SetClamp(in double theClamp); + + //! Gets Point Sprite clamp + double GetClamp(); + + //! Sets minimum size of Point Sprites + void SetMinSize(in double theMinSize); + + //! Gets minimum size of Point Sprites + double GetMinSize(); + + //! Sets maximum size of Point Sprites + void SetMaxSize(in double theMaxSize); + + //! Gets maximum size of Point Sprites + double GetMaxSize(); + + //! Sets magnification for Point Sprites + void SetMagnification(in double theMagnification); + + //! Gets magnification for Point Sprites + double GetMagnification(); + + //! Sets the increment of changing Magnification parameter + void SetMagnificationIncrement(in double theIncrement); + + //! Gets the increment of changing Magnification parameter + double GetMagnificationIncrement(); + + //! Sets Point Sprites size + void SetGeomSize(in double theGeomSize); + + //! Sets size of Point Sprite + double GetGeomSize(); + + //! Get path to the image using for Main Point Sprite texture + string GetMainTexture(); + + //! Get path to the image using for Alpha Point Sprite texture + string GetAlphaTexture(); + + //! Points Main and AlphaMask images to be used by Point Sprites + void SetTextures(in string theMainTexture, in string theAlphaTexture); + + //! Sets Point Sprite Alpha threshold + void SetAlphaThreshold(in double theAlphaThreshold); + + //! Gets Point Sprite Alpha threshold + double GetAlphaThreshold(); + + //! Sets resolution of the Geometrical Sphere + void SetResolution(in long theResolution); + + //! Sets resolution of the Geometrical Sphere + long GetResolution(); + + //! Sets how many faces of can be drawn in the Geometrical Sphere primitive mode + void SetFaceLimit(in long theFaceLimit); + + //! Defines how many faces of can be drawn in the Geometrical Sphere primitive mode + long GetFaceLimit(); }; /*! \brief Deformed shape presentation interface * * Presentation parameters of the deformed shape presentation. */ - interface DeformedShape : ScalarMap { + interface DeformedShape : ScalarMap + { /*! * Sets the scale of the presentatable object. * \param theScale Double value defining the scale of this presentable object. @@ -1334,7 +1479,8 @@ module VISU { *
Time stamp represents a subfield: the results * of calculations are taken in one definite moment. */ - interface Animation : Base { + interface Animation : Base + { /*! * This enumeration contains a set of available animation modes. */ @@ -1548,13 +1694,15 @@ module VISU { void ApplyProperties(in long theFieldNum, in ColoredPrs3d thePrs); }; + /*! \brief Interface %Result * * This interface serves for inner representation of data generated * in other sources (MED object or file). This data is needed * for further construction of graphical presentations. */ - interface Result : RemovableObject, SALOME::GenericObj { + interface Result : RemovableObject, SALOME::GenericObj + { /*! Reads all data from the corresponding sources. By default the data is loaded on demand. */ boolean BuildAll(); @@ -1582,6 +1730,61 @@ module VISU { /*! Allow to check is min / max calculation over field's components already perfrormed or not */ boolean IsMinMaxDone(); + + /*! Allow to check is corresponding multi resolution structure already loaded or not */ + boolean IsPartsDone(); + + typedef sequence Entities; + + typedef string EntityName; + + typedef sequence EntityNames; + + typedef long TimeStampNumber; + + typedef sequence TimeStampNumbers; + + enum Resolution { + FULL, + MEDIUM, + LOW, + HIDDEN + }; + + typedef sequence Resolutions; + + /*! Gets existing mesh names */ + EntityNames GetMeshNames(); + + /*! Gets existing mesh entites for the given mesh name */ + Entities GetEntities(in EntityName theMeshName); + + /*! Gets existing families for the given mesh name and entity */ + EntityNames GetFamilies(in EntityName theMeshName, in Entity theEntity); + + /*! Gets existing families for the given mesh name */ + EntityNames GetGroups(in EntityName theMeshName); + + /*! Gets existing fields for the given mesh name and entity */ + EntityNames GetFields(in EntityName theMeshName, in Entity theEntity); + + /*! Gets number of components for the given mesh name, entity and name of field */ + long GetNumberOfComponents(in EntityName theMeshName, in Entity theEntity, in EntityName theFieldName); + + /*! Gets existing numbers of time stamps for the given mesh name, entity and name of field */ + TimeStampNumbers GetTimeStampNumbers(in EntityName theMeshName, in Entity theEntity, in EntityName theFieldName); + + /*! Gets existing parts of multi resolution structure for the given mesh name */ + EntityNames GetPartNames(in EntityName theMeshName); + + /*! Gets available resolutions of multi resolution structure for the given mesh and part names */ + Resolutions GetResolutions(in EntityName theMeshName, in EntityName thePartName); + + /*! Gets current resolution of multi resolution structure for the given mesh and part names */ + Resolution GetResolution(in EntityName theMeshName, in EntityName thePartName); + + /*! Gets current resolution of multi resolution structure for the given mesh and part names */ + void SetResolution(in EntityName theMeshName, in EntityName thePartName, in Resolution theResolution); }; //------------------------------------------------------- @@ -1593,7 +1796,8 @@ module VISU { * post-processing presentations from given %Result and %Table object reference, * using the views provided by %ViewManager. */ - interface VISU_Gen : Engines::Component, SALOMEDS::Driver, Base { + interface VISU_Gen : Engines::Component, SALOMEDS::Driver, Base + { /*! Sets a definite study to be current. */ void SetCurrentStudy(in SALOMEDS::Study theStudy); @@ -1703,11 +1907,11 @@ module VISU { * \param theMeshName One of the meshes presented in MED file * \param theEntity Type of entity where the field is defined * \param theFieldName Group of data attributed to the %MESH. The data can be scalar or vector. - * \param theIteration Number of iteration on the field + * \param theTimeStampNumber Number of iteration on the field */ ScalarMap ScalarMapOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, - in long theIteration); + in long theTimeStampNumber); /*! * Creates a Gauss Points presentation. @@ -1715,11 +1919,11 @@ module VISU { * \param theMeshName One of the meshes presented in MED file * \param theEntity Type of entity where the field is defined * \param theFieldName Group of data attributed to the %MESH. The data can be scalar or vector. - * \param theIteration Number of iteration on the field + * \param theTimeStampNumber Number of iteration on the field */ GaussPoints GaussPointsOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, - in long theIteration); + in long theTimeStampNumber); /*! * Creates a deformed shape presentation. @@ -1727,11 +1931,11 @@ module VISU { * \param theMeshName One of the meshes presented in MED file * \param theEntity Type of entity where the field is defined * \param theFieldName Group of data attributed to the %MESH. The data can be scalar or vector. - * \param theIteration Number of iteration on the field + * \param theTimeStampNumber Number of iteration on the field */ DeformedShape DeformedShapeOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, - in long theIteration); + in long theTimeStampNumber); /*! * Creates a deformed shape presentation. @@ -1739,11 +1943,11 @@ module VISU { * \param theMeshName One of the meshes presented in MED file * \param theEntity Type of entity where the field is defined * \param theFieldName Group of data attributed to the %MESH. The data can be scalar or vector. - * \param theIteration Number of iteration on the field + * \param theTimeStampNumber Number of iteration on the field */ ScalarMapOnDeformedShape ScalarMapOnDeformedShapeOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, - in long theIteration); + in long theTimeStampNumber); /*! * Creates a vector presentation. @@ -1751,11 +1955,11 @@ module VISU { * \param theMeshName One of the meshes presented in MED file * \param theEntity Type of entity where the field is defined * \param theFieldName Group of data attributed to the %MESH. The data can be scalar or vector. - * \param theIteration Number of iteration on the field + * \param theTimeStampNumber Number of iteration on the field */ Vectors VectorsOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, - in long theIteration); + in long theTimeStampNumber); /*! * Creates an iso surface presentation. @@ -1763,11 +1967,11 @@ module VISU { * \param theMeshName One of the meshes presented in MED file * \param theEntity Type of entity where the field is defined * \param theFieldName Group of data attributed to the %MESH. The data can be scalar or vector. - * \param theIteration Number of iteration on the field + * \param theTimeStampNumber Number of iteration on the field */ IsoSurfaces IsoSurfacesOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, - in long theIteration); + in long theTimeStampNumber); /*! * Creates an stream lines presentation. @@ -1775,11 +1979,11 @@ module VISU { * \param theMeshName One of the meshes presented in MED file * \param theEntity Type of entity where the field is defined * \param theFieldName Group of data attributed to the %MESH. The data can be scalar or vector. - * \param theIteration Number of iteration on the field + * \param theTimeStampNumber Number of iteration on the field */ StreamLines StreamLinesOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, - in long theIteration); + in long theTimeStampNumber); /*! * Creates a presentation of cut planes. @@ -1787,11 +1991,11 @@ module VISU { * \param theMeshName One of the meshes presented in MED file * \param theEntity Type of entity where the field is defined * \param theFieldName Group of data attributed to the %MESH. The data can be scalar or vector. - * \param theIteration Number of iteration on the field + * \param theTimeStampNumber Number of iteration on the field */ CutPlanes CutPlanesOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, - in long theIteration); + in long theTimeStampNumber); /*! * Creates a presentation of cut lines. @@ -1799,11 +2003,11 @@ module VISU { * \param theMeshName One of the meshes presented in MED file * \param theEntity Type of entity where the field is defined * \param theFieldName Group of data attributed to the %MESH. The data can be scalar or vector. - * \param theIteration Number of iteration on the field + * \param theTimeStampNumber Number of iteration on the field */ CutLines CutLinesOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, - in long theIteration); + in long theTimeStampNumber); /*! * Creates a Plot3D presentation. @@ -1811,11 +2015,11 @@ module VISU { * \param theMeshName One of the meshes presented in MED file * \param theEntity Type of entity where the field is defined * \param theFieldName Group of data attributed to the %MESH. The data can be scalar or vector. - * \param theIteration Number of iteration on the field + * \param theTimeStampNumber Number of iteration on the field */ Plot3D Plot3DOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, - in long theIteration); + in long theTimeStampNumber); /*! * Creates a table presentation. diff --git a/src/CONVERTOR/VISU_Convertor.cxx b/src/CONVERTOR/VISU_Convertor.cxx index 1c6fd8d8..2526962b 100644 --- a/src/CONVERTOR/VISU_Convertor.cxx +++ b/src/CONVERTOR/VISU_Convertor.cxx @@ -32,6 +32,30 @@ #include +//--------------------------------------------------------------- +VISU_Convertor +::VISU_Convertor(): + myIsDone(false) +{} + + +//--------------------------------------------------------------- +const std::string& +VISU_Convertor +::GetName() +{ + return myName; +} + + +//--------------------------------------------------------------- +int +VISU_Convertor +::IsDone() const +{ + return myIsDone; +} + //--------------------------------------------------------------- const VISU::TMeshMap& VISU_Convertor diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index 45edc030..c5819c08 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -52,19 +52,15 @@ class VISU_CONVERTOR_EXPORT VISU_Convertor { public: - virtual - ~VISU_Convertor() - {}; - //! Get brief name of the corresponding source MED file virtual const std::string& - GetName(){ return myName;} + GetName(); //! Let known whether the source MED file parsed or not virtual int - IsDone() const { return myIsDone; } + IsDone() const; //! This method perform first parsing of MED file to get known what MED entities are pressent in it virtual @@ -205,6 +201,8 @@ public: GenerateName(const std::string& theName, unsigned int theTimeId); protected: + VISU_Convertor(); + std::string myName; VISU::TMeshMap myMeshMap; int myIsDone; @@ -212,8 +210,8 @@ protected: extern "C" { -VISU_CONVERTOR_EXPORT //! Instatiate proper VISU_Convertor subclass + VISU_CONVERTOR_EXPORT VISU_Convertor* CreateConvertor(const std::string& theFileName); }; diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index c2cd8893..66f53771 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -563,10 +563,8 @@ namespace //--------------------------------------------------------------- VISU_Convertor_impl -::VISU_Convertor_impl() -{ - myIsDone = false; -} +::VISU_Convertor_impl() +{} //--------------------------------------------------------------- @@ -601,6 +599,7 @@ VISU_Convertor* VISU_Convertor_impl ::BuildFields() { + BuildEntities(); return this; } @@ -608,6 +607,7 @@ VISU_Convertor* VISU_Convertor_impl ::BuildMinMax() { + BuildFields(); return this; } diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 31cf0d9d..62166ee3 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -1328,8 +1328,7 @@ VISU_MedConvertor myIsMinMaxDone(false), myMed(theMed) { - myFileInfo.setFile(QString(theFileName.c_str())); - myName = myFileInfo.baseName().latin1(); + myName = theFileName; } @@ -1455,6 +1454,8 @@ VISU_MedConvertor if(myIsFieldsDone) return this; + VISU_Convertor_impl::BuildFields(); + TSetIsDone aSetIsDone(myIsFieldsDone); VISU::TTimerLog aTimerLog(MYDEBUG,"BuildFields"); @@ -1581,6 +1582,8 @@ VISU_MedConvertor if(myIsMinMaxDone) return this; + VISU_Convertor_impl::BuildMinMax(); + TSetIsDone aSetIsDone(myIsMinMaxDone); VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax"); diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index e3834ab2..7b2c6b80 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -31,7 +31,6 @@ #include "MED_GaussUtils.hxx" #include -#include namespace VISU { @@ -357,7 +356,6 @@ public: BuildGroups(); protected: - QFileInfo myFileInfo; MED::PWrapper myMed; // mpv : bug 13568: one med per converter virtual diff --git a/src/PIPELINE/VISU_ColoredPL.cxx b/src/PIPELINE/VISU_ColoredPL.cxx index d067adde..49600e84 100644 --- a/src/PIPELINE/VISU_ColoredPL.cxx +++ b/src/PIPELINE/VISU_ColoredPL.cxx @@ -57,11 +57,28 @@ VISU_ColoredPL } +//---------------------------------------------------------------------------- VISU_ColoredPL ::~VISU_ColoredPL() {} +//---------------------------------------------------------------------------- +unsigned long int +VISU_ColoredPL +::GetMTime() +{ + unsigned long int aTime = Superclass::GetMTime(); + + aTime = std::max(aTime, myMapperTable->GetMTime()); + aTime = std::max(aTime, myBarTable->GetMTime()); + aTime = std::max(aTime, myExtractor->GetMTime()); + aTime = std::max(aTime, myFieldTransform->GetMTime()); + + return aTime; +} + + //---------------------------------------------------------------------------- void VISU_ColoredPL @@ -135,6 +152,9 @@ VISU_ColoredPL { if(theRange[0] > theRange[1]) return; + + if(VISU::CheckIsSameRange(GetScalarRange(), theRange)) + return; myFieldTransform->SetScalarRange(theRange); myBarTable->SetRange(theRange); @@ -232,9 +252,11 @@ VISU_ColoredPL vtkFloatingPointType *aRange = GetScalarRange(); vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]}; if(myBarTable->GetScale() == VTK_SCALE_LOG10) - VISU_LookupTable::ComputeLogRange(aRange,aScalarRange); - myMapperTable->SetRange(aScalarRange); + VISU_LookupTable::ComputeLogRange(aRange, aScalarRange); + if(!VISU::CheckIsSameRange(myMapperTable->GetRange(), aScalarRange)) + myMapperTable->SetRange(aScalarRange); + myMapperTable->Build(); myBarTable->Build(); diff --git a/src/PIPELINE/VISU_ColoredPL.hxx b/src/PIPELINE/VISU_ColoredPL.hxx index 045db348..3743750a 100644 --- a/src/PIPELINE/VISU_ColoredPL.hxx +++ b/src/PIPELINE/VISU_ColoredPL.hxx @@ -43,6 +43,10 @@ class VISU_ColoredPL : public VISU_PipeLine public: vtkTypeMacro(VISU_ColoredPL, VISU_PipeLine); + virtual + unsigned long int + GetMTime(); + //---------------------------------------------------------------------------- virtual int diff --git a/src/PIPELINE/VISU_CutLinesPL.hxx b/src/PIPELINE/VISU_CutLinesPL.hxx index 6a1d391b..58116834 100644 --- a/src/PIPELINE/VISU_CutLinesPL.hxx +++ b/src/PIPELINE/VISU_CutLinesPL.hxx @@ -122,7 +122,6 @@ public: protected: VISU_CutLinesPL(); - VISU_CutLinesPL(const VISU_CutLinesPL&); virtual void @@ -135,6 +134,10 @@ protected: vtkFloatingPointType myBasePnt[3]; vtkFloatingPointType myPosition; int myCondition; + +private: + VISU_CutLinesPL(const VISU_CutLinesPL&); // Not implemented. + void operator=(const VISU_CutLinesPL&); // Not implemented. }; diff --git a/src/PIPELINE/VISU_CutPlanesPL.cxx b/src/PIPELINE/VISU_CutPlanesPL.cxx index 3abaeeea..22493a10 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.cxx +++ b/src/PIPELINE/VISU_CutPlanesPL.cxx @@ -70,6 +70,19 @@ VISU_CutPlanesPL } +//---------------------------------------------------------------------------- +unsigned long int +VISU_CutPlanesPL +::GetMTime() +{ + unsigned long int aTime = Superclass::GetMTime(); + + aTime = std::max(aTime, myAppendPolyData->GetMTime()); + + return aTime; +} + + //---------------------------------------------------------------------------- void VISU_CutPlanesPL diff --git a/src/PIPELINE/VISU_CutPlanesPL.hxx b/src/PIPELINE/VISU_CutPlanesPL.hxx index f59d3eb1..27d377fd 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.hxx +++ b/src/PIPELINE/VISU_CutPlanesPL.hxx @@ -40,11 +40,16 @@ class VISU_PIPELINE_EXPORT VISU_CutPlanesPL : public VISU_ScalarMapPL { public: vtkTypeMacro(VISU_CutPlanesPL, VISU_ScalarMapPL); - static VISU_CutPlanesPL* New(); + + static + VISU_CutPlanesPL* + New(); virtual - ~VISU_CutPlanesPL(); + unsigned long int + GetMTime(); + //---------------------------------------------------------------------------- enum PlaneOrientation {XY, YZ, ZX}; virtual @@ -176,9 +181,12 @@ public: const std::vector& thePlanePosition, const std::vector& thePlaneCondition, vtkFloatingPointType theDisplacement); + protected: VISU_CutPlanesPL(); - VISU_CutPlanesPL(const VISU_CutPlanesPL&); + + virtual + ~VISU_CutPlanesPL(); virtual vtkDataSet* @@ -198,6 +206,10 @@ protected: vtkAppendPolyData *myAppendPolyData; std::vector myPartPosition; std::vector myPartCondition; + +private: + VISU_CutPlanesPL(const VISU_CutPlanesPL&); // Not implemented. + void operator=(const VISU_CutPlanesPL&); // Not implemented. }; #endif diff --git a/src/PIPELINE/VISU_DeformedShapePL.cxx b/src/PIPELINE/VISU_DeformedShapePL.cxx index 16896392..6631af08 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.cxx +++ b/src/PIPELINE/VISU_DeformedShapePL.cxx @@ -58,6 +58,20 @@ VISU_DeformedShapePL } +//---------------------------------------------------------------------------- +unsigned long int +VISU_DeformedShapePL +::GetMTime() +{ + unsigned long int aTime = Superclass::GetMTime(); + + aTime = std::max(aTime, myWarpVector->GetMTime()); + aTime = std::max(aTime, myCellDataToPointData->GetMTime()); + + return aTime; +} + + //---------------------------------------------------------------------------- void VISU_DeformedShapePL diff --git a/src/PIPELINE/VISU_DeformedShapePL.hxx b/src/PIPELINE/VISU_DeformedShapePL.hxx index e09b4cf7..6011e501 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.hxx +++ b/src/PIPELINE/VISU_DeformedShapePL.hxx @@ -44,6 +44,11 @@ public: VISU_DeformedShapePL* New(); + virtual + unsigned long int + GetMTime(); + + //---------------------------------------------------------------------------- virtual void SetScale(vtkFloatingPointType theScale); @@ -80,7 +85,6 @@ public: protected: VISU_DeformedShapePL(); - VISU_DeformedShapePL(const VISU_DeformedShapePL&); virtual ~VISU_DeformedShapePL(); @@ -97,6 +101,10 @@ protected: vtkFloatingPointType myScaleFactor; vtkWarpVector *myWarpVector; vtkCellDataToPointData* myCellDataToPointData; + +private: + VISU_DeformedShapePL(const VISU_DeformedShapePL&); // Not implemented. + void operator=(const VISU_DeformedShapePL&); // Not implemented. }; diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index 12a895b6..5cda7ebb 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -91,6 +91,24 @@ VISU_GaussPointsPL } +//---------------------------------------------------------------------------- +unsigned long int +VISU_GaussPointsPL +::GetMTime() +{ + unsigned long int aTime = Superclass::GetMTime(); + + aTime = std::max(aTime, myWarpVector->GetMTime()); + aTime = std::max(aTime, myGlyph->GetMTime()); + aTime = std::max(aTime, mySphereSource->GetMTime()); + + for(int i = 0; i < 3; i++) + aTime = std::max(aTime, myPassFilter[i]->GetMTime()); + + return aTime; +} + + //---------------------------------------------------------------------------- void VISU_GaussPointsPL diff --git a/src/PIPELINE/VISU_GaussPointsPL.hxx b/src/PIPELINE/VISU_GaussPointsPL.hxx index d489362c..cdb2378e 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.hxx +++ b/src/PIPELINE/VISU_GaussPointsPL.hxx @@ -64,6 +64,10 @@ public: VISU_GaussPointsPL* New(); + virtual + unsigned long int + GetMTime(); + //---------------------------------------------------------------------------- void SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper); @@ -304,6 +308,10 @@ private: vtkFloatingPointType myMagnificationIncrement; int myPrimitiveType; + +private: + VISU_GaussPointsPL(const VISU_GaussPointsPL&); // Not implemented. + void operator=(const VISU_GaussPointsPL&); // Not implemented. }; #endif diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.cxx b/src/PIPELINE/VISU_IsoSurfacesPL.cxx index 8f92a1cb..bea9854f 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.cxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.cxx @@ -62,6 +62,20 @@ VISU_IsoSurfacesPL } +//---------------------------------------------------------------------------- +unsigned long int +VISU_IsoSurfacesPL +::GetMTime() +{ + unsigned long int aTime = Superclass::GetMTime(); + + aTime = std::max(aTime, myCellDataToPointData->GetMTime()); + aTime = std::max(aTime, myContourFilter->GetMTime()); + + return aTime; +} + + //---------------------------------------------------------------------------- void VISU_IsoSurfacesPL diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.hxx b/src/PIPELINE/VISU_IsoSurfacesPL.hxx index d53aeb35..83a646dd 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.hxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.hxx @@ -44,6 +44,11 @@ public: VISU_IsoSurfacesPL* New(); + virtual + unsigned long int + GetMTime(); + + //---------------------------------------------------------------------------- virtual int GetNbParts(); @@ -92,7 +97,6 @@ public: protected: VISU_IsoSurfacesPL(); - VISU_IsoSurfacesPL(const VISU_IsoSurfacesPL&); virtual ~VISU_IsoSurfacesPL(); @@ -106,6 +110,11 @@ protected: vtkFloatingPointType myRange[2]; vtkCellDataToPointData* myCellDataToPointData; vtkContourFilter *myContourFilter; + +private: + VISU_IsoSurfacesPL(const VISU_IsoSurfacesPL&);; // Not implemented. + void operator=(const VISU_IsoSurfacesPL&); // Not implemented. + }; diff --git a/src/PIPELINE/VISU_MapperHolder.cxx b/src/PIPELINE/VISU_MapperHolder.cxx index dc025499..d64efa6c 100644 --- a/src/PIPELINE/VISU_MapperHolder.cxx +++ b/src/PIPELINE/VISU_MapperHolder.cxx @@ -135,6 +135,8 @@ VISU_MapperHolder myPipeLine->Init(); myPipeLine->Update(); } + + Modified(); } diff --git a/src/PIPELINE/VISU_PipeLine.cxx b/src/PIPELINE/VISU_PipeLine.cxx index 06661f01..ea165bc0 100644 --- a/src/PIPELINE/VISU_PipeLine.cxx +++ b/src/PIPELINE/VISU_PipeLine.cxx @@ -274,7 +274,11 @@ void VISU_PipeLine ::SetIsShrinkable(bool theIsShrinkable) { + if(myIsShrinkable == theIsShrinkable) + return; + myIsShrinkable = theIsShrinkable; + Modified(); } diff --git a/src/PIPELINE/VISU_Plot3DPL.cxx b/src/PIPELINE/VISU_Plot3DPL.cxx index 60244568..7696d62e 100644 --- a/src/PIPELINE/VISU_Plot3DPL.cxx +++ b/src/PIPELINE/VISU_Plot3DPL.cxx @@ -75,7 +75,23 @@ VISU_Plot3DPL //---------------------------------------------------------------------------- VISU_Plot3DPL ::~VISU_Plot3DPL() +{} + + +//---------------------------------------------------------------------------- +unsigned long int +VISU_Plot3DPL +::GetMTime() { + unsigned long int aTime = Superclass::GetMTime(); + + aTime = std::max(aTime, myCellDataToPointData->GetMTime()); + aTime = std::max(aTime, myAppendPolyData->GetMTime()); + aTime = std::max(aTime, myGeometryFilter->GetMTime()); + aTime = std::max(aTime, myContourFilter->GetMTime()); + aTime = std::max(aTime, myWarpScalar->GetMTime()); + + return aTime; } diff --git a/src/PIPELINE/VISU_Plot3DPL.hxx b/src/PIPELINE/VISU_Plot3DPL.hxx index 82d0855f..2cb63767 100644 --- a/src/PIPELINE/VISU_Plot3DPL.hxx +++ b/src/PIPELINE/VISU_Plot3DPL.hxx @@ -47,9 +47,11 @@ public: VISU_Plot3DPL* New(); - virtual - ~VISU_Plot3DPL(); + virtual + unsigned long int + GetMTime(); + //---------------------------------------------------------------------------- VISU_CutPlanesPL::PlaneOrientation GetPlaneOrientation(); @@ -126,7 +128,8 @@ public: protected: VISU_Plot3DPL(); - VISU_Plot3DPL(const VISU_Plot3DPL&); + virtual + ~VISU_Plot3DPL(); virtual vtkDataSet* @@ -147,6 +150,10 @@ protected: vtkSmartPointer myGeometryFilter; vtkSmartPointer myContourFilter; vtkSmartPointer myWarpScalar; + +private: + VISU_Plot3DPL(const VISU_Plot3DPL&);; // Not implemented. + void operator=(const VISU_Plot3DPL&); // Not implemented. }; #endif diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index a4df7b39..55352b8e 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -69,6 +69,20 @@ VISU_ScalarMapPL {} +//---------------------------------------------------------------------------- +unsigned long int +VISU_ScalarMapPL +::GetMTime() +{ + unsigned long int aTime = Superclass::GetMTime(); + + aTime = std::max(aTime, myAppendFilter->GetMTime()); + aTime = std::max(aTime, myMergeFilter->GetMTime()); + + return aTime; +} + + //---------------------------------------------------------------------------- void VISU_ScalarMapPL diff --git a/src/PIPELINE/VISU_ScalarMapPL.hxx b/src/PIPELINE/VISU_ScalarMapPL.hxx index eda0bea1..c23e95a6 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.hxx +++ b/src/PIPELINE/VISU_ScalarMapPL.hxx @@ -48,6 +48,11 @@ public: VISU_ScalarMapPL* New(); + virtual + unsigned long int + GetMTime(); + + //---------------------------------------------------------------------------- virtual void Update(); @@ -83,7 +88,6 @@ public: protected: //---------------------------------------------------------------------------- VISU_ScalarMapPL(); - VISU_ScalarMapPL(const VISU_ScalarMapPL&); virtual ~VISU_ScalarMapPL(); @@ -106,6 +110,9 @@ protected: bool theIsCopyInput); private: + VISU_ScalarMapPL(const VISU_ScalarMapPL&); // Not implemented. + void operator=(const VISU_ScalarMapPL&); // Not implemented. + vtkSmartPointer myAppendFilter; vtkSmartPointer myMergeFilter; }; diff --git a/src/PIPELINE/VISU_StreamLinesPL.cxx b/src/PIPELINE/VISU_StreamLinesPL.cxx index 375d99ac..2f3ae2bb 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.cxx +++ b/src/PIPELINE/VISU_StreamLinesPL.cxx @@ -90,6 +90,23 @@ VISU_StreamLinesPL } +//---------------------------------------------------------------------------- +unsigned long int +VISU_StreamLinesPL +::GetMTime() +{ + unsigned long int aTime = Superclass::GetMTime(); + + aTime = std::max(aTime, myStream->GetMTime()); + aTime = std::max(aTime, mySource->GetMTime()); + aTime = std::max(aTime, myCenters->GetMTime()); + aTime = std::max(aTime, myGeomFilter->GetMTime()); + aTime = std::max(aTime, myPointsFilter->GetMTime()); + + return aTime; +} + + //---------------------------------------------------------------------------- void VISU_StreamLinesPL diff --git a/src/PIPELINE/VISU_StreamLinesPL.hxx b/src/PIPELINE/VISU_StreamLinesPL.hxx index 7909b760..6bff1d61 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.hxx +++ b/src/PIPELINE/VISU_StreamLinesPL.hxx @@ -48,6 +48,11 @@ public: VISU_StreamLinesPL* New(); + virtual + unsigned long int + GetMTime(); + + //---------------------------------------------------------------------------- virtual size_t SetParams(vtkFloatingPointType theIntStep, @@ -192,7 +197,6 @@ public: protected: VISU_StreamLinesPL(); - VISU_StreamLinesPL(const VISU_StreamLinesPL&); virtual ~VISU_StreamLinesPL(); @@ -238,6 +242,10 @@ protected: VTKViewer_GeometryFilter *myGeomFilter; VISU_MaskPointsFilter *myPointsFilter; vtkFloatingPointType myPercents; + +private: + VISU_StreamLinesPL(const VISU_StreamLinesPL&); // Not implemented. + void operator=(const VISU_StreamLinesPL&); // Not implemented. }; diff --git a/src/PIPELINE/VISU_VectorsPL.cxx b/src/PIPELINE/VISU_VectorsPL.cxx index 73153dfc..5192eefb 100644 --- a/src/PIPELINE/VISU_VectorsPL.cxx +++ b/src/PIPELINE/VISU_VectorsPL.cxx @@ -100,6 +100,25 @@ VISU_VectorsPL } +//---------------------------------------------------------------------------- +unsigned long int +VISU_VectorsPL +::GetMTime() +{ + unsigned long int aTime = Superclass::GetMTime(); + + aTime = std::max(aTime, myBaseGlyph->GetMTime()); + aTime = std::max(aTime, myTransformedGlyph->GetMTime()); + aTime = std::max(aTime, myCenters->GetMTime()); + aTime = std::max(aTime, myGlyphSource->GetMTime()); + aTime = std::max(aTime, myConeSource->GetMTime()); + aTime = std::max(aTime, myLineSource->GetMTime()); + aTime = std::max(aTime, myTransformFilter->GetMTime()); + + return aTime; +} + + //---------------------------------------------------------------------------- void VISU_VectorsPL diff --git a/src/PIPELINE/VISU_VectorsPL.hxx b/src/PIPELINE/VISU_VectorsPL.hxx index 9bf2a43c..09fe54cb 100644 --- a/src/PIPELINE/VISU_VectorsPL.hxx +++ b/src/PIPELINE/VISU_VectorsPL.hxx @@ -52,6 +52,11 @@ public: VISU_VectorsPL* New(); + virtual + unsigned long int + GetMTime(); + + //---------------------------------------------------------------------------- virtual void SetScale(vtkFloatingPointType theScale); @@ -115,7 +120,6 @@ public: protected: VISU_VectorsPL(); - VISU_VectorsPL(const VISU_VectorsPL&); virtual ~VISU_VectorsPL(); @@ -142,6 +146,10 @@ protected: VTKViewer_TransformFilter *myTransformFilter; VISU_UsedPointsFilter* myUsedPointsFilter; + +private: + VISU_VectorsPL(const VISU_VectorsPL&); // Not implemented. + void operator=(const VISU_VectorsPL&); // Not implemented. }; diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 9e512fe4..170aff64 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -215,7 +215,6 @@ VisuGUI application()->putInfo( anInfo ); QApplication::setOverrideCursor(Qt::waitCursor); - // MULTIPR: CreateResult VISU::Result_var aResult = GetVisuGen(this)->CreateResult( aFileInfo.filePath() ); if (CORBA::is_nil(aResult.in())) { @@ -2341,8 +2340,6 @@ VisuGUI tr("MEN_CACHE_PROPERTIES"), "", 0, aParent, false, this, SLOT(OnCacheProperties())); -#ifdef ENABLE_MULTIPR - // MULTIPR aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_MULTIPR_VIEW_FULL")); createAction( VISU_MULTIPR_FULL_RES, tr("MEN_MULTIPR_VIEW_FULL_RES"), QIconSet(aPixmap), tr("MEN_MULTIPR_VIEW_FULL_RES"), "", 0, aParent, false, @@ -2362,7 +2359,6 @@ VisuGUI createAction( VISU_MULTIPR_HIDE, tr("MEN_MULTIPR_VIEW_HIDE"), QIconSet(aPixmap), tr("MEN_MULTIPR_VIEW_HIDE"), "", 0, aParent, false, this, SLOT(OnMultiprViewHide())); -#endif } void @@ -2540,14 +2536,10 @@ VisuGUI mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info -#ifdef ENABLE_MULTIPR - // MULTIPR mgr->insert( action( VISU_MULTIPR_FULL_RES ), -1, -1, -1 ); mgr->insert( action( VISU_MULTIPR_MED_RES ), -1, -1, -1 ); mgr->insert( action( VISU_MULTIPR_LOW_RES ), -1, -1, -1 ); mgr->insert( action( VISU_MULTIPR_HIDE ), -1, -1, -1 ); -#endif - // Rules @@ -2651,7 +2643,8 @@ VisuGUI mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'" " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) " "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true ); - mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true ); + mgr->setRule( action( VISU_OPACITY ), aRule + " and hasActor=1", true ); + mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true ); // rename command @@ -2723,14 +2716,23 @@ VisuGUI //aRule = "client='ObjectBrowser' and type='MEDFIELD'"; //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true ); -#ifdef ENABLE_MULTIPR - // MULTIPR - aRule = "client='ObjectBrowser' and $type in {'VISU::TPART'}"; - mgr->setRule( action( VISU_MULTIPR_FULL_RES ), aRule + " and selcount>=1", true ); - mgr->setRule( action( VISU_MULTIPR_MED_RES ), aRule + " and selcount>=1", true ); - mgr->setRule( action( VISU_MULTIPR_LOW_RES ), aRule + " and selcount>=1", true ); - mgr->setRule( action( VISU_MULTIPR_HIDE), aRule + " and selcount>=1", true ); -#endif + aRule = "client='ObjectBrowser' and selcount>=1 and $type in {'VISU::TPART'} and "; + { + QString aCustomRule = aRule + "fullResolution=1 and resolutionState!='F'"; + mgr->setRule( action( VISU_MULTIPR_FULL_RES ), aCustomRule, true ); + } + { + QString aCustomRule = aRule + "mediumResolution=1 and resolutionState!='M'"; + mgr->setRule( action( VISU_MULTIPR_MED_RES ), aCustomRule, true ); + } + { + QString aCustomRule = aRule + "lowResolution=1 and resolutionState!='L'"; + mgr->setRule( action( VISU_MULTIPR_LOW_RES ), aCustomRule, true ); + } + { + QString aCustomRule = aRule + "resolutionState!='H'"; + mgr->setRule( action( VISU_MULTIPR_HIDE), aCustomRule, true ); + } } //*************************************************************************** @@ -3521,42 +3523,38 @@ void VisuGUI::OnCacheProperties() aDlg->exec(); } -// MULTIPR + +//--------------------------------------------------------------- void VisuGUI::OnMultiprViewFullRes() { -#ifdef ENABLE_MULTIPR - OnMultiprChangeRes('F'); -#endif + OnMultiprChangeRes(VISU::Result::FULL); } -// MULTIPR + +//--------------------------------------------------------------- void VisuGUI::OnMultiprViewMediumRes() { -#ifdef ENABLE_MULTIPR - OnMultiprChangeRes('M'); -#endif + OnMultiprChangeRes(VISU::Result::MEDIUM); } -// MULTIPR + +//--------------------------------------------------------------- void VisuGUI::OnMultiprViewLowRes() { -#ifdef ENABLE_MULTIPR - OnMultiprChangeRes('L'); -#endif + OnMultiprChangeRes(VISU::Result::LOW); } -// MULTIPR + +//--------------------------------------------------------------- void VisuGUI::OnMultiprViewHide() { -#ifdef ENABLE_MULTIPR - OnMultiprChangeRes('H'); -#endif + OnMultiprChangeRes(VISU::Result::HIDDEN); } -// MULTIPR -void VisuGUI::OnMultiprChangeRes(char resolution) + +//--------------------------------------------------------------- +void VisuGUI::OnMultiprChangeRes(VISU::Result::Resolution theResolution) { -#ifdef ENABLE_MULTIPR _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); if (CheckLock(aCStudy,GetDesktop(this))) return; @@ -3565,10 +3563,13 @@ void VisuGUI::OnMultiprChangeRes(char resolution) if(aSelectionInfo.empty()) return; - //cout << "selection: #=" << aSelectionInfo.size() << endl; + QApplication::setOverrideCursor(Qt::waitCursor); - for (int i=0; i TResultPtr; + typedef std::map TResult2SObject; + TResult2SObject aResult2SObject; + + for (int i=0; i < aSelectionInfo.size(); i++) { VISU::TSelectionItem aSelectionItem = aSelectionInfo[i]; _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject; @@ -3576,48 +3577,35 @@ void VisuGUI::OnMultiprChangeRes(char resolution) continue; VISU::Result_var aResult = FindResult( VISU::GetSObject( aSObject ).in() ); - VISU::Result_i* result = dynamic_cast(VISU::GetServant(aResult).in()); + if(CORBA::is_nil(aResult.in())) + continue; + + VISU::Result_i* aCResult = dynamic_cast(VISU::GetServant(aResult).in()); + if(!aCResult) + continue; - _PTR(GenericAttribute) anAttr; - if (aSObject->FindAttribute(anAttr, "AttributePixMap")) - { - _PTR(AttributePixMap) aPixMap(anAttr); - if ( aPixMap->HasPixMap() ) - { - const char* oldIcon = aPixMap->GetPixMap().c_str(); - if ( (strcmp(oldIcon, "ICON_MULTIPR_VIEW_FULL") == 0) || - (strcmp(oldIcon, "ICON_MULTIPR_VIEW_MEDIUM") == 0) || - (strcmp(oldIcon, "ICON_MULTIPR_VIEW_LOW") == 0) || - (strcmp(oldIcon, "ICON_MULTIPR_VIEW_HIDE") == 0) ) - { - bool hasMediumOrLow = (strstr(aSObject->GetComment().c_str(), "res=FML") != NULL); - - if (resolution == 'F') - { - if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'F'); - aPixMap->SetPixMap("ICON_MULTIPR_VIEW_FULL"); - } - else if ((resolution == 'M') && hasMediumOrLow) - { - if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'M'); - aPixMap->SetPixMap("ICON_MULTIPR_VIEW_MEDIUM"); - } - else if ((resolution == 'L') && hasMediumOrLow) - { - if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'L'); - aPixMap->SetPixMap("ICON_MULTIPR_VIEW_LOW"); - } - else if (resolution == 'H') - { - if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'H'); - aPixMap->SetPixMap("ICON_MULTIPR_VIEW_HIDE"); - } - } - } - } + Storable::TRestoringMap aRestoringMap = Storable::GetStorableMap(aSObject); + bool anIsFound = false; + QString aMeshName = Storable::FindValue(aRestoringMap, "myMeshName", &anIsFound); + if(!anIsFound) + continue; + + std::string aPartName = aSObject->GetName(); + + aCResult->SetResolution(aMeshName.latin1(), aPartName.c_str(), theResolution); + + aResult2SObject[TResultPtr(aCResult)] = aSObject; } - UpdateObjBrowser(this, false); -#endif + // To update all result observers + TResult2SObject::const_iterator anIter = aResult2SObject.begin(); + for(; anIter != aResult2SObject.end(); anIter++){ + const TResultPtr& aResultPtr = anIter->first; + const _PTR(SObject)& aSObject = anIter->second; + aResultPtr->UpdateObservers(); + VISU::UpdateObjBrowser(this, false, aSObject); + } + + QApplication::restoreOverrideCursor(); } diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index b5a5bfeb..c672c5d8 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -172,7 +172,7 @@ protected slots: void OnMultiprViewMediumRes(); void OnMultiprViewLowRes(); void OnMultiprViewHide(); - void OnMultiprChangeRes(char resolution); + void OnMultiprChangeRes(VISU::Result::Resolution theResolution); protected: virtual LightApp_Selection* createSelection() const; diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx index d7122e5f..a7fc9d93 100644 --- a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx @@ -250,8 +250,6 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule) aMainLayout->addWidget(aBtnBox); - myCutLines = NULL; - // signals and slots connections connect(mySelPlane , SIGNAL(clicked(int)) , this, SLOT(onPlaneSelect(int))); connect(myCBSetDef , SIGNAL(toggled(bool)) , this, SLOT(setBaseDefault())); @@ -273,10 +271,6 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule) connect(aOkBtn, SIGNAL(clicked()), this, SLOT(accept())); connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject())); connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp())); - //connect(myMgr, SIGNAL(closeAllViews()), this, SLOT(reject())); - //connect(VisuGUI::application()->desktop(), - // SIGNAL(windowActivated(SUIT_ViewWindow*)), - // this, SLOT(onWindowActivated(SUIT_ViewWindow*))); } /*! @@ -284,10 +278,7 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule) */ VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg() { - cout<<"### VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg"<Destroy(); if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) vf->Repaint(); } @@ -314,7 +305,8 @@ void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool hasInit = true; myCutLines = VISU::TSameAsFactory().Create(myPrsCopy, VISU::ColoredPrs3d_i::EDoNotPublish); myCutLines->CopyCurvesInverted(myPrsCopy->GetCurvesInverted()); - if (myCutLines->IsAllCurvesInverted()) myAllCurvesInvertedCheck->setChecked(true); + if (myCutLines->IsAllCurvesInverted()) + myAllCurvesInvertedCheck->setChecked(true); myBasePlanePos->setText( QString::number(myCutLines->GetBasePlanePosition()) ); myCBSetDef->setChecked(myPrsCopy->IsDefault()); DrawTable(); @@ -363,7 +355,7 @@ int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) if (myAllCurvesInvertedCheck->isChecked()) myPrsCopy->SetAllCurvesInverted(true); - VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); return anIsOk; } @@ -373,7 +365,7 @@ void VisuGUI_CutLinesDlg::createPlanes() { SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView == NULL) return; - if (myCutLines == NULL) return; + if (!myCutLines) return; if (myPreviewActor != 0) return; storeToPrsObject(myCutLines); @@ -473,15 +465,9 @@ void VisuGUI_CutLinesDlg::onCutSelect (int theId, bool theUpdate) } SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { - if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) { - /*myCutLines->SetOrientation2(getOrientaion(false), - myRotXSpn2->value()*PI/180., - myRotYSpn2->value()*PI/180.); - myCutLines->SetDisplacement2(myPosSpn2->value());*/ - //myCutLines->GetPipeLine()->Update(); + if (theUpdate && myPreviewCheck->isChecked() && myCutLines) { deletePlanes(); createPlanes(); - //aView->Repaint(); } } } @@ -493,22 +479,12 @@ void VisuGUI_CutLinesDlg::setBaseDefault (bool theUpdate) if (myCBSetDef->isChecked()) { if (!myCutLines->IsDefault()) myCutLines->SetDefault(); - /*myCutLines->SetOrientation(getOrientaion(), - myRotXSpn->value()*PI/180., - myRotYSpn->value()*PI/180.); - myCutLines->SetDisplacement(myPosSpn->value());*/ - /* float aPos = myCutLines->GetBasePlanePosition(); - myBasePlanePos->setText( QString::number(aPos) ); - myBasePlanePos->setEnabled(false);*/ myCutLines->SetDisplacement(myPosSpn->value()); SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { - if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) { - //myCutLines->SetBasePlanePosition(aPos); - // myCutLines->GetPipeLine()->Update(); + if (theUpdate && myPreviewCheck->isChecked() && myCutLines) { deletePlanes(); createPlanes(); - //aView->Repaint(); } } vtkFloatingPointType aPos = myCutLines->GetBasePlanePosition(); @@ -576,10 +552,8 @@ void VisuGUI_CutLinesDlg::DrawTable() SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { if (myPreviewCheck->isChecked()) { - // myCutLines->GetPipeLine()->Update(); deletePlanes(); createPlanes(); - //aView->Repaint(); } } } @@ -744,27 +718,18 @@ void VisuGUI_CutLinesDlg::onValueChanged (int theRow, int theCol) SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { if (myPreviewCheck->isChecked()) { - //Update Preview - //myCutLines->SetLinePosition( theRow, aTxt.toDouble()); - // myCutLines->GetPipeLine()->Update(); deletePlanes(); createPlanes(); - //aView->Repaint(); } } } else if (theCol == 1){ bool isDefault = ((QCheckTableItem*)myPosTable->item(theRow, theCol))->isChecked(); if (isDefault) { - //myCutLines->SetDefaultPosition(theRow); - // myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow))); SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { if (myPreviewCheck->isChecked()) { - //Update Preview - // myCutLines->GetPipeLine()->Update(); deletePlanes(); createPlanes(); - //aView->Repaint(); } } myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow))); @@ -775,87 +740,6 @@ void VisuGUI_CutLinesDlg::onValueChanged (int theRow, int theCol) void VisuGUI_CutLinesDlg::accept() { - //if ( !VisuGUI::CheckActiveStudyLock() ) { - // reject(); - // return; - //} - // if (myScalarPane->check()) { - /*jfa tmp:((QWidget*)sender())->setDisabled(true); - storeToPrsObject(myPrsCopy); - if (myIsCreation) { - if (isGenerateTable()) { - visuGUI->GetVisuGen()->CreateTable(myPrsCopy->GetEntry()); - if (isGenerateCurves()) { - SALOMEDSClient_Study* aStudy = study()->studyDS(); - SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrsCopy->GetEntry()); - if( aSObject ) { - SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject ); - SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder(); - for ( ;aIter->More(); aIter->Next()) { - SALOMEDSClient_SObject* aTblObj = aIter->Value(); - if ( aTblObj ) { - SALOMEDSClient_GenericAttribute* anAttr; - if (aTblObj->FindAttribute(anAttr, "AttributeName")) { - visuGUI->CreatePlot(aTblObj); - } - } - } - } - } - } - if (GET_VTK_VIEWWINDOW(myMgr)) { - try { - visuGUI->CreateActor(myPrsCopy); - } catch (...) { - reject(); - return; - } - GET_VTK_VIEWWINDOW(myMgr)->onFitAll(); - } - } else { - visuGUI->RecreateActor(myPrsCopy); - if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) { - if (vf->getRenderer()->GetActors()->GetNumberOfItems() > 0) { - vf->getRenderer()->ResetCameraClippingRange(); - vf->Repaint(); - } - } - // Remove old Table - SALOMEDSClient_Study* aStudy = study()->studyDS(); - SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrsCopy->GetEntry()); - if( aSObject ) { - SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject ); - SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder(); - for ( ;aIter->More(); aIter->Next()) { - SALOMEDSClient_SObject* aTblObj = aIter->Value(); - if ( aTblObj ) { - SALOMEDSClient_GenericAttribute* anAttr; - if (aTblObj->FindAttribute(anAttr, "AttributeName")) { - aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child - break; - } - } - } - if (isGenerateTable()) { - visuGUI->GetVisuGen()->CreateTable(aSObject->GetID().c_str()); - if (isGenerateCurves()) { - SALOMEDSClient_Study* aStudy = study()->studyDS(); - SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject ); - SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder(); - for ( ;aIter->More(); aIter->Next()) { - SALOMEDSClient_SObject* aTblObj = aIter->Value(); - if ( aTblObj ) { - SALOMEDSClient_GenericAttribute* anAttr; - if (aTblObj->FindAttribute(anAttr, "AttributeName")) { - visuGUI->CreatePlot(aTblObj); - } - } - } - } - } - } - } - VisuGUI::application()->objectBrowser()->updateTree();*/ myScalarPane->deletePreview(); deletePlanes(); QDialog::accept(); @@ -863,10 +747,6 @@ void VisuGUI_CutLinesDlg::accept() void VisuGUI_CutLinesDlg::reject() { - /*jfa tmp:if (myIsCreation) { - myPrsCopy->RemoveFromStudy(); - VisuGUI::application()->objectBrowser()->updateTree(); - }*/ myScalarPane->deletePreview(); deletePlanes(); QDialog::reject(); @@ -876,10 +756,7 @@ void VisuGUI_CutLinesDlg::onPreviewCheck (bool thePreview) { if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { if (thePreview) { - //storeToPrsObject(myCutLines); - // myCutLines->GetPipeLine()->Update(); createPlanes(); - //vf->onFitAll(); } else { deletePlanes(); vf->Repaint(); @@ -904,36 +781,24 @@ void VisuGUI_CutLinesDlg::onAllCurvesInvertedCheck(bool theInvert) void VisuGUI_CutLinesDlg::onRotation (double theValue) { - if (myCutLines == NULL) return; + if (!myCutLines) return; SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { if (myPreviewCheck->isChecked()) { - - /*myCutLines->SetOrientation(getOrientaion(), - myRotXSpn->value()*PI/180., - myRotYSpn->value()*PI/180.); - myCutLines->SetOrientation2(getOrientaion(false), - myRotXSpn2->value()*PI/180., - myRotYSpn2->value()*PI/180.);*/ - // myCutLines->GetPipeLine()->Update(); deletePlanes(); createPlanes(); - //aView->Repaint(); } } } void VisuGUI_CutLinesDlg::onPlanePos (const QString& theValue) { - if (myCutLines == NULL) return; + if (!myCutLines) return; SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { if (myPreviewCheck->isChecked()) { - //myCutLines->SetBasePlanePosition(theValue.toDouble()); - // myCutLines->GetPipeLine()->Update(); deletePlanes(); createPlanes(); - //aView->Repaint(); } } } diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.h b/src/VISUGUI/VisuGUI_CutLinesDlg.h index 9e7405e7..52142bdf 100644 --- a/src/VISUGUI/VisuGUI_CutLinesDlg.h +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.h @@ -104,7 +104,7 @@ private: bool hasInit; QDoubleValidator *mydvalidator; - VISU::CutLines_i* myCutLines; + SALOME::GenericObjPtr myCutLines; QTabWidget* myTabBox; VisuGUI_ScalarBarPane* myScalarPane; diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index 591a413b..8006fd48 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -166,7 +166,6 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent) connect( th, SIGNAL( clicked(int)), this, SLOT( setDefault(int) ) ); // default values - myCutPlanes = NULL; hasInit = false; X1 = 0; X2 = 0; Y1 = 0; Y2 = 0; @@ -178,8 +177,6 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent) VisuGUI_CutPlanesPane::~VisuGUI_CutPlanesPane() { deletePlanes(); - if (myCutPlanes) - myCutPlanes->Destroy(); if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) vf->Repaint(); } @@ -205,7 +202,7 @@ void VisuGUI_CutPlanesPane::initFromPrsObject (VISU::CutPlanes_i* thePrs) void VisuGUI_CutPlanesPane::createPlanes() { if (VISU::GetActiveViewWindow() == NULL) return; - if (myCutPlanes == NULL) return; + if (!myCutPlanes) return; if (myPreviewActor != 0) return; vtkAppendPolyData* aPolyData = myCutPlanes->GetSpecificPL()->GetAppendPolyData(); @@ -311,7 +308,7 @@ void VisuGUI_CutPlanesPane::setRotation (const double r1, const double r2) */ void VisuGUI_CutPlanesPane::DrawTable() { - if (myCutPlanes == NULL) return; + if (!myCutPlanes) return; if (!hasInit) return; int aNbRows = myPosTable->numRows(); @@ -441,7 +438,7 @@ void VisuGUI_CutPlanesPane::deletePlanes() void VisuGUI_CutPlanesPane::onRotation (double theValue) { - if (myCutPlanes == NULL) return; + if (!myCutPlanes) return; if (myPreviewCheck->isChecked()) { if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.); @@ -561,7 +558,7 @@ int VisuGUI_CutPlanesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) anIsOk &= myScalarPane->storeToPrsObject(myPrsCopy); anIsOk &= myCutPane->storeToPrsObject(myPrsCopy); - VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); return anIsOk; } diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.h b/src/VISUGUI/VisuGUI_CutPlanesDlg.h index e94a7bf6..9f2ad6cc 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.h +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.h @@ -87,7 +87,7 @@ private: QRadioButton* RBxy; QtxDblSpinBox* myPosSpn; QTable* myPosTable; - VISU::CutPlanes_i* myCutPlanes; + SALOME::GenericObjPtr myCutPlanes; QCheckBox* myPreviewCheck; double X1, X2; double Y1, Y2; @@ -132,7 +132,6 @@ private: VisuGUI_CutPlanesPane* myCutPane; VisuGUI_ScalarBarPane* myScalarPane; VisuGUI_InputPane* myInputPane; - VISU::CutPlanes_i* myPrs; SALOME::GenericObjPtr myPrsCopy; }; diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx index ad81e44c..3f06d6a1 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx @@ -166,7 +166,7 @@ int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) myPrsCopy->SetScale(getFactor()); myPrsCopy->ShowColored(isColored()); - VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); return anIsOk; } diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index b996cc3a..6a66425d 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -125,7 +125,34 @@ VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent, bool S RangeGroupLayout->addWidget( myModeLbl, 0, 0 ); RangeGroupLayout->addWidget( myModeCombo, 0, 1 ); - //TopLayout->addWidget( RangeGroup ); + RBFieldRange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFieldRange"); + RBImposedRange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBImposedRange"); + RBFieldRange->setChecked( true ); + + MinEdit = new QLineEdit( RangeGroup, "MinEdit" ); + MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MinEdit->setMinimumWidth( 70 ); + MinEdit->setValidator( new QDoubleValidator(this) ); + MinEdit->setText( "0.0" ); + QLabel* MinLabel = new QLabel (tr("LBL_MIN"), RangeGroup, "MinLabel"); + MinLabel->setBuddy(MinEdit); + + MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" ); + MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MaxEdit->setMinimumWidth( 70 ); + MaxEdit->setValidator( new QDoubleValidator(this) ); + MaxEdit->setText( "0.0" ); + QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), RangeGroup, "MaxLabel"); + MaxLabel->setBuddy(MaxEdit); + + RangeGroupLayout->addWidget( myModeLbl, 0, 0 ); + RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3); + RangeGroupLayout->addMultiCellWidget( RBFieldRange, 1, 1, 0, 1); + RangeGroupLayout->addMultiCellWidget( RBImposedRange, 1, 1, 2, 3); + RangeGroupLayout->addWidget( MinLabel, 2, 0 ); + RangeGroupLayout->addWidget( MinEdit, 2, 1 ); + RangeGroupLayout->addWidget( MaxLabel, 2, 2 ); + RangeGroupLayout->addWidget( MaxEdit, 2, 3 ); // Colors and Labels ======================================================== QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup"); @@ -263,8 +290,14 @@ VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent, bool S myTextDlg->setTitleVisible(!SetPref); // signals and slots connections =========================================== - connect( myRBLocal, SIGNAL( toggled( bool ) ), myCBDisplayed, SLOT( setEnabled( bool ) ) ); - connect( myRBGlobal, SIGNAL( clicked() ), this, SLOT( onSetDisplayGlobal() ) ); + connect( RBFieldRange, SIGNAL( clicked() ), this, SLOT( fieldRangeClicked() ) ); + connect( RBImposedRange, SIGNAL( clicked() ), this, SLOT( imposedRangeClicked() ) ); + + connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) ); + + connect( myRBLocal, SIGNAL( clicked() ), this, SLOT( onLocalScalarBar() ) ); + connect( myRBGlobal, SIGNAL( clicked() ), this, SLOT( onGlobalScalarBar() ) ); + 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 ) ) ); @@ -278,17 +311,113 @@ VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent, bool S myIsStoreTextProp = false; } -void VisuGUI_GaussScalarBarPane::onSetDisplayGlobal() +void VisuGUI_GaussScalarBarPane::onGlobalScalarBar() { myCBDisplayed->setChecked( true ); + + RBImposedRange->setEnabled( false ); + RBFieldRange->setEnabled( false ); + MinEdit->setEnabled( false ); + MaxEdit->setEnabled( false ); + + myPrsCopy->SetIsActiveLocalScalarBar(false); +} + + +void VisuGUI_GaussScalarBarPane::onLocalScalarBar() +{ + myCBDisplayed->setEnabled( true ); + + RBImposedRange->setEnabled( true ); + RBFieldRange->setEnabled( true ); + + if ( RBImposedRange->isChecked() ) { + MinEdit->setEnabled( true ); + MaxEdit->setEnabled( true ); + } + + myPrsCopy->SetIsActiveLocalScalarBar(true); +} + + +/*! + Called when Range mode is changed to FieldRange +*/ +void VisuGUI_GaussScalarBarPane::fieldRangeClicked() +{ + RBImposedRange->setChecked( false ); + MinEdit->setEnabled( false ); + MaxEdit->setEnabled( false ); + + MinEdit->setText( QString::number( myPrsCopy->GetSourceMin() ) ); + MaxEdit->setText( QString::number( myPrsCopy->GetSourceMax() ) ); + + myPrsCopy->SetSourceRange(); +} + + +/*! + Called when Range mode is changed to FieldRange +*/ +void VisuGUI_GaussScalarBarPane::imposedRangeClicked() +{ + RBFieldRange->setChecked( false ); + MinEdit->setEnabled( true ); + MaxEdit->setEnabled( true ); + + myPrsCopy->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble()); } +/*! + Called when scalar mode is changed +*/ +void VisuGUI_GaussScalarBarPane::changeScalarMode( int theMode ) +{ + myPrsCopy->SetScalarMode( theMode ); + if ( RBFieldRange->isChecked() ) { + CORBA::Double aRange[2] = {myPrsCopy->GetSourceMin(), myPrsCopy->GetSourceMax()}; + MinEdit->setText( QString::number( aRange[0] ) ); + MaxEdit->setText( QString::number( aRange[1] ) ); + } +} + /** * Initialise dialog box from presentation object */ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs) { + myPrsCopy = thePrs; + myModeCombo->setCurrentItem(thePrs->GetScalarMode()); + + bool activeLocal = thePrs->GetIsActiveLocalScalarBar(); + if ( activeLocal ) { + if ( thePrs->IsRangeFixed() ) { + RBImposedRange->setChecked( true ); + RBFieldRange->setChecked( false ); + MinEdit->setEnabled( true ); + MaxEdit->setEnabled( true ); + } else { + RBImposedRange->setChecked( false ); + RBFieldRange->setChecked( true ); + MinEdit->setEnabled( false ); + MaxEdit->setEnabled( false ); + } + } else { + RBImposedRange->setEnabled( false ); + RBFieldRange->setEnabled( false ); + MinEdit->setEnabled( false ); + MaxEdit->setEnabled( false ); + } + + if ( RBFieldRange->isChecked() ) { + MinEdit->setText( QString::number( thePrs->GetSourceMin() ) ); + MaxEdit->setText( QString::number( thePrs->GetSourceMax() ) ); + } else { + MinEdit->setText( QString::number( thePrs->GetMin() ) ); + MaxEdit->setText( QString::number( thePrs->GetMax() ) ); + } + setPosAndSize( thePrs->GetPosX(), thePrs->GetPosY(), thePrs->GetWidth(), @@ -297,7 +426,6 @@ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs) SpacingSpin->setValue(thePrs->GetSpacing()); - bool activeLocal = thePrs->GetIsActiveLocalScalarBar(); myRBLocal->setChecked( activeLocal ); myRBGlobal->setChecked( !activeLocal ); @@ -377,17 +505,24 @@ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs) */ int VisuGUI_GaussScalarBarPane::storeToPrsObject(VISU::GaussPoints_i* thePrs) { thePrs->SetScalarMode(myModeCombo->currentItem()); - thePrs->SetPosition(XSpin->value(), YSpin->value()); - thePrs->SetSize(WidthSpin->value(), HeightSpin->value()); + + if (RBFieldRange->isChecked()) { + thePrs->SetSourceRange(); + } else { + thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble()); + } + thePrs->SetSpacing(SpacingSpin->value()); - thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3d::VERTICAL : VISU::ColoredPrs3d::HORIZONTAL); thePrs->SetIsActiveLocalScalarBar(myRBLocal->isChecked()); thePrs->SetIsDispGlobalScalarBar(myCBDisplayed->isChecked()); + thePrs->SetBiColor(BicolorButton->isChecked()); + + thePrs->SetPosition(XSpin->value(), YSpin->value()); + thePrs->SetSize(WidthSpin->value(), HeightSpin->value()); + thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3d::VERTICAL : VISU::ColoredPrs3d::HORIZONTAL); thePrs->SetNbColors(ColorSpin->value()); thePrs->SetLabels(LabelSpin->value()); - thePrs->GetSpecificPL()->SetBicolor(BicolorButton->isChecked()); - //if (isToSave()) storeToResources(); if (myIsStoreTextProp) { @@ -673,8 +808,8 @@ void VisuGUI_GaussPointsDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, boo myPrimitiveBox->setPrimitiveType( myPrsCopy->GetPrimitiveType() ); myPrimitiveBox->setClampMaximum( myPrsCopy->GetMaximumSupportedSize() ); myPrimitiveBox->setClamp( myPrsCopy->GetClamp() ); - myPrimitiveBox->setMainTexture( myPrsCopy->GetMainTexture() ); - myPrimitiveBox->setAlphaTexture( myPrsCopy->GetAlphaTexture() ); + myPrimitiveBox->setMainTexture( myPrsCopy->GetQMainTexture() ); + myPrimitiveBox->setAlphaTexture( myPrsCopy->GetQAlphaTexture() ); myPrimitiveBox->setAlphaThreshold( myPrsCopy->GetAlphaThreshold() ); myPrimitiveBox->setResolution( myPrsCopy->GetResolution() ); myPrimitiveBox->setFaceLimit( myPrsCopy->GetFaceLimit() ); @@ -685,7 +820,7 @@ void VisuGUI_GaussPointsDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, boo mySizeBox->setMaxSize( myPrsCopy->GetMaxSize() ); mySizeBox->setMagnification( myPrsCopy->GetMagnification() ); mySizeBox->setIncrement( myPrsCopy->GetMagnificationIncrement() ); - mySizeBox->setColor( myPrsCopy->GetColor() ); + mySizeBox->setColor( myPrsCopy->GetQColor() ); if( !theInit ) return; @@ -705,15 +840,16 @@ int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) myPrsCopy->SetIsDeformed( myDefShapeButton->isChecked() ); myPrsCopy->SetScaleFactor( myScaleSpinBox->value() ); - myPrsCopy->SetPrimitiveType( myPrimitiveBox->getPrimitiveType() ); + int aPrimitiveType = myPrimitiveBox->getPrimitiveType(); + myPrsCopy->SetPrimitiveType( VISU::GaussPoints::PrimitiveType( aPrimitiveType ) ); myPrsCopy->SetClamp( myPrimitiveBox->getClamp() ); QString aMainTexture = myPrimitiveBox->getMainTexture(); QString anAlphaTexture = myPrimitiveBox->getAlphaTexture(); - aMainTexture = aMainTexture.isNull() ? myPrsCopy->GetMainTexture() : aMainTexture; - anAlphaTexture = anAlphaTexture.isNull() ? myPrsCopy->GetAlphaTexture() : anAlphaTexture; + aMainTexture = aMainTexture.isNull() ? myPrsCopy->GetQMainTexture() : aMainTexture; + anAlphaTexture = anAlphaTexture.isNull() ? myPrsCopy->GetQAlphaTexture() : anAlphaTexture; myPrsCopy->SetTextures( aMainTexture, anAlphaTexture ); @@ -732,14 +868,14 @@ int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) else { myPrsCopy->SetIsColored( false ); - myPrsCopy->SetColor( mySizeBox->getColor() ); + myPrsCopy->SetQColor( mySizeBox->getColor() ); myPrsCopy->SetGeomSize( mySizeBox->getGeomSize() ); } myPrsCopy->SetMagnification( mySizeBox->getMagnification() ); myPrsCopy->SetMagnificationIncrement( mySizeBox->getIncrement() ); - VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); return anIsOk; } diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.h b/src/VISUGUI/VisuGUI_GaussPointsDlg.h index bf117d7c..e0962e51 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.h +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.h @@ -29,6 +29,7 @@ #define VISUGUI_GAUSSPOINTSDLS_H #include "VisuGUI_Prs3dDlg.h" +#include "VISU_GaussPoints_i.hh" #include @@ -40,10 +41,6 @@ class VVTK_SizeBox; class VisuGUI_TextPrefDlg; class VisuGUI_InputPane; -namespace VISU -{ - class GaussPoints_i; -} //! Specific Scalar Bar tab. /*! Uses for set up Gauss Points Scalar Bars preferenses. */ @@ -71,6 +68,11 @@ class VisuGUI_GaussScalarBarPane : public QVBox protected: QButtonGroup* RangeGroup; + QRadioButton* RBFieldRange; + QRadioButton* RBImposedRange; + QLineEdit* MinEdit; + QLineEdit* MaxEdit; + SALOME::GenericObjPtr myPrsCopy; QRadioButton* RBhori; QRadioButton* RBvert; @@ -105,11 +107,16 @@ class VisuGUI_GaussScalarBarPane : public QVBox bool myIsStoreTextProp; private slots: + void onGlobalScalarBar(); + void onLocalScalarBar(); + + void fieldRangeClicked(); + void imposedRangeClicked(); + void changeScalarMode( int ); + void changeDefaults( int ); -//VSR: 08/06/06: void changeRange( int ); void XYChanged( double ); void onTextPref(); - void onSetDisplayGlobal(); }; //! Create Gauss Points Presentation Dialog. diff --git a/src/VISUGUI/VisuGUI_InputPane.cxx b/src/VISUGUI/VisuGUI_InputPane.cxx index 4f7379bb..90915b17 100644 --- a/src/VISUGUI/VisuGUI_InputPane.cxx +++ b/src/VISUGUI/VisuGUI_InputPane.cxx @@ -197,7 +197,9 @@ VisuGUI_InputPane::VisuGUI_InputPane( VISU::VISUType theType, } } + connect( myTimeStamps, SIGNAL( activated( int ) ), this, SLOT( changeTimeStamp( int ) ) ); connect( myReInit, SIGNAL( toggled( bool ) ), SLOT( onReInitialize( bool ) ) ); + connect( myUseGroupsGroupBox, SIGNAL( toggled( bool ) ), this, SLOT( onTypeChanged() ) ); connect( myAllGroups, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onListDoubleClicked( QListBoxItem* ) ) ); connect( mySelectedGroups, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onListDoubleClicked( QListBoxItem* ) ) ); @@ -420,6 +422,15 @@ void VisuGUI_InputPane::onSelectionChanged() } +//--------------------------------------------------------------- +void VisuGUI_InputPane::changeTimeStamp( int theTimeStamp ) +{ + myPrs->SetTimeStampNumber( myPrs->GetTimeStampNumberByIndex( theTimeStamp ) ); + myPrs->Apply( true ); + myDialog->initFromPrsObject( myPrs, false ); +} + + //--------------------------------------------------------------- void VisuGUI_InputPane::onReInitialize( bool on ) { @@ -485,7 +496,7 @@ void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs ) VISU::GetSelectionMgr( myModule )->installFilter( myFieldFilter ); // type of presentation and groups - VISU_Convertor* anInput = aResult->GetInput(); + VISU::Result_i::PInput anInput = aResult->GetInput(); const VISU::TMeshMap& aMeshMap = anInput->GetMeshMap(); std::string aMeshName = thePrs->GetCMeshName(); VISU::TMeshMap::const_iterator aMeshIter = aMeshMap.find(aMeshName); diff --git a/src/VISUGUI/VisuGUI_InputPane.h b/src/VISUGUI/VisuGUI_InputPane.h index 47a0cf8c..eea4df64 100644 --- a/src/VISUGUI/VisuGUI_InputPane.h +++ b/src/VISUGUI/VisuGUI_InputPane.h @@ -75,6 +75,7 @@ public: public slots: virtual void onSelectionChanged(); virtual void onReInitialize( bool ); + virtual void changeTimeStamp( int ); private slots: void onTypeChanged(); diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx index e043866a..13a32591 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx @@ -261,7 +261,7 @@ int VisuGUI_IsoSurfacesDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy ); anIsOk &= myIsoPane->storeToPrsObject( myPrsCopy ); - VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); return anIsOk; } diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx index 3c20b0a1..ead3d4af 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx @@ -661,7 +661,7 @@ int VisuGUI_Plot3DDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy ); anIsOk &= myIsoPane->storeToPrsObject( myPrsCopy ); - VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); return anIsOk; } diff --git a/src/VISUGUI/VisuGUI_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx index 043db8bd..84a63267 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ b/src/VISUGUI/VisuGUI_PopupTools.cxx @@ -45,6 +45,8 @@ using namespace VISU; // Class: VisuGUI_Selection ////////////////////////////////////////////////// + +//--------------------------------------------------------------- QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const { QtxValue val( LightApp_Selection::param( ind, p ) ); @@ -63,11 +65,18 @@ QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const else if ( p == "isShading" ) val = QtxValue( isShading( ind ) ); else if ( p == "isScalarMapAct" ) val = QtxValue( isScalarMapAct( ind ) ); else if ( p == "isVisuComponent") val = QtxValue( isVisuComponent( ind ) ); + + else if ( p == "fullResolution" ) val = QtxValue( fullResolution( ind ) ); + else if ( p == "mediumResolution" ) val = QtxValue( mediumResolution( ind ) ); + else if ( p == "lowResolution" ) val = QtxValue( lowResolution( ind ) ); + else if ( p == "resolutionState" ) val = QtxValue( resolutionState( ind ) ); } return val; } + +//--------------------------------------------------------------- // Macro for converting VISU enumeration items into corresponding strings #define ENUM2STRING( x, y ) \ case y: \ @@ -134,6 +143,8 @@ QString VisuGUI_Selection::type( const int ind ) const return aResStr; } + +//--------------------------------------------------------------- QString VisuGUI_Selection::nbComponents( const int ind ) const { QString aResStr; @@ -151,6 +162,95 @@ QString VisuGUI_Selection::nbComponents( const int ind ) const return aResStr; } + +//--------------------------------------------------------------- +QString VisuGUI_Selection::resolutions( const int ind ) const +{ + QString aResStr; + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return aResStr; + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind )); + VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject); + + bool isExist; + QString aVal = VISU::Storable::FindValue(aMap,"myResolutions",&isExist); + if ( isExist ) + aResStr = aVal; + + return aResStr; +} + + +//--------------------------------------------------------------- +QString VisuGUI_Selection::resolution( const int ind, char theResoltuion ) const +{ + QString aResStr; + + QString aResolutions = resolutions( ind ); + if(aResolutions.isEmpty()) + return aResStr; + + if(aResolutions.find(theResoltuion) != -1) + aResStr = "1"; + else + aResStr = "0"; + + return aResStr; +} + + +//--------------------------------------------------------------- +QString VisuGUI_Selection::fullResolution( const int ind ) const +{ + return resolution( ind, 'F'); +} + + +//--------------------------------------------------------------- +QString VisuGUI_Selection::mediumResolution( const int ind ) const +{ + return resolution( ind, 'M'); +} + + +//--------------------------------------------------------------- +QString VisuGUI_Selection::lowResolution( const int ind ) const +{ + return resolution( ind, 'L'); +} + + +//--------------------------------------------------------------- +QString VisuGUI_Selection::resolutionState( const int ind ) const +{ + QString aResStr; + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return aResStr; + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind )); + VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject); + + bool isExist; + QString aVal = VISU::Storable::FindValue(aMap,"myState",&isExist); + if ( isExist ) { + if ( aVal.toInt() == VISU::Result::FULL ) + aResStr = "F"; + if ( aVal.toInt() == VISU::Result::MEDIUM ) + aResStr = "M"; + if ( aVal.toInt() == VISU::Result::LOW ) + aResStr = "L"; + if ( aVal.toInt() == VISU::Result::HIDDEN ) + aResStr = "H"; + } + + return aResStr; +} + + +//--------------------------------------------------------------- QString VisuGUI_Selection::medEntity( const int ind ) const { SalomeApp_Study* aStudy = GetStudy(); @@ -451,6 +551,8 @@ struct TIsScalarMapActFunctor: TViewFunctor } }; + +//--------------------------------------------------------------- QString VisuGUI_Selection::isScalarMapAct( const int ind ) const { return TPopupDispatcher()(myModule, entry(ind)); diff --git a/src/VISUGUI/VisuGUI_PopupTools.h b/src/VISUGUI/VisuGUI_PopupTools.h index 536ef59a..61a59250 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.h +++ b/src/VISUGUI/VisuGUI_PopupTools.h @@ -61,10 +61,18 @@ private: QString isScalarMapAct( const int ) const; bool isVisuComponent( const int ) const; + QString fullResolution( const int ) const; + QString mediumResolution( const int ) const; + QString lowResolution( const int ) const; + QString resolutionState( const int ) const; + private: int nbChild( const int, const bool ) const; SalomeApp_Study* GetStudy() const; + QString resolutions( const int ) const; + QString resolution( const int, char theResoltuion ) const; + private: SalomeApp_Module* myModule; }; diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 76e5dcaf..e26a102e 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -186,7 +186,7 @@ int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) int anIsOk = myInputPane->storeToPrsObject( myPrsCopy ); anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy ); - VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); return anIsOk; } diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx index 13c8046d..d6f303e9 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx @@ -296,7 +296,7 @@ VisuGUI_ScalarMapOnDeformedShapeDlg if(myUpdateScalars) SetScalarField( false ); - VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); return anIsOk; } @@ -460,7 +460,7 @@ VisuGUI_ScalarMapOnDeformedShapeDlg QString aTime(""); VISU::TEntity anEntity = VISU::TEntity(theEntity); VISU::Result_i* theResult = myPrsCopy->GetCResult(); - VISU::Result_i::TInput* anInput = theResult->GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(); VISU::PField aField = anInput->GetField(myPrsCopy->GetCMeshName(), anEntity, theFieldName); diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx index d58995ee..8d30b5fe 100644 --- a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx @@ -439,7 +439,7 @@ int VisuGUI_StreamLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) // tr("ERR_CANT_BUILD_PRESENTATION"), // tr("BUT_OK")); - VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); return anIsOk; } diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.cxx b/src/VISUGUI/VisuGUI_VectorsDlg.cxx index 4a77ad49..612271da 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.cxx +++ b/src/VISUGUI/VisuGUI_VectorsDlg.cxx @@ -256,7 +256,7 @@ int VisuGUI_VectorsDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) } else myPrsCopy->SetGlyphType(VISU::Vectors::NONE); - VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); return anIsOk; } diff --git a/src/VISU_I/Makefile.am b/src/VISU_I/Makefile.am index f75be372..184ad65a 100644 --- a/src/VISU_I/Makefile.am +++ b/src/VISU_I/Makefile.am @@ -31,6 +31,7 @@ salomeinclude_HEADERS = \ VISUConfig.hh \ VISU_Gen_i.hh \ VISU_Result_i.hh \ + VISU_MultiResult_i.hh \ VISU_PrsObject_i.hh \ VISU_Table_i.hh \ VISU_Prs3d_i.hh \ @@ -53,10 +54,15 @@ salomeinclude_HEADERS = \ SALOME_GenericObjPointer.hh libVISUEngineImpl_la_SOURCES = \ - VISU_Result_i.cc \ VISUConfig.cc \ + VISU_Result_i.cc \ + VISU_ResultUtils.cc \ + VISU_MultiResult_i.cc \ + VISU_Gen_i.cc \ + VISU_CorbaMedConvertor.cxx \ VISU_PrsObject_i.cc \ VISU_Prs3d_i.cc \ + VISU_Prs3dUtils.cc \ VISU_ColoredPrs3d_i.cc \ VISU_ScalarMap_i.cc \ VISU_GaussPoints_i.cc \ @@ -76,8 +82,6 @@ libVISUEngineImpl_la_SOURCES = \ VISU_TimeAnimation.cxx \ VISU_View_i.cc \ VISU_Table_i.cc \ - VISU_Gen_i.cc \ - VISU_CorbaMedConvertor.cxx \ VISU_DumpPython.cc \ SALOME_GenericObjPointer.cc @@ -98,7 +102,11 @@ libVISUEngineImpl_la_CPPFLAGS= \ $(MED_CXXFLAGS) \ $(GUI_CXXFLAGS) \ $(CORBA_CXXFLAGS) $(CORBA_INCLUDES) \ - -I$(srcdir)/../CONVERTOR -I$(srcdir)/../PIPELINE -I$(srcdir)/../OBJECT -I$(srcdir)/../VVTK -I$(srcdir)/../GUITOOLS \ + -I$(srcdir)/../CONVERTOR \ + -I$(srcdir)/../PIPELINE \ + -I$(srcdir)/../OBJECT \ + -I$(srcdir)/../VVTK \ + -I$(srcdir)/../GUITOOLS \ -I$(top_builddir)/idl \ -I$(top_builddir)/salome_adm/unix @@ -113,7 +121,9 @@ libVISUEngineImpl_la_LDFLAGS= \ $(MED_LDFLAGS) \ ../../idl/libSalomeIDLVISU.la -libVISUEngineImpl_la_LIBADD= -lboost_signals@BOOST_LIBSUFFIX@ -lboost_thread@BOOST_LIBSUFFIX@ \ +libVISUEngineImpl_la_LIBADD= \ + -lboost_signals@BOOST_LIBSUFFIX@ \ + -lboost_thread@BOOST_LIBSUFFIX@ \ -lSalomeHDFPersist \ -lSalomeGenericObj \ -lSalomeContainer \ @@ -142,7 +152,9 @@ endif bin_PROGRAMS = VISU_I dist_VISU_I_SOURCES=VISU_I.cxx VISU_I_CPPFLAGS=$(libVISUEngineImpl_la_CPPFLAGS) -VISU_I_LDADD=$(libVISUEngineImpl_la_LIBADD) $(libVISUEngineImpl_la_LDFLAGS) \ +VISU_I_LDADD=\ + $(libVISUEngineImpl_la_LIBADD) \ + $(libVISUEngineImpl_la_LDFLAGS) \ $(KERNEL_LDFLAGS) \ -lSALOMEBasics \ -lSalomeCatalog \ diff --git a/src/VISU_I/SALOME_GenericObjPointer.hh b/src/VISU_I/SALOME_GenericObjPointer.hh index e710a4f0..83cd2545 100644 --- a/src/VISU_I/SALOME_GenericObjPointer.hh +++ b/src/VISU_I/SALOME_GenericObjPointer.hh @@ -101,7 +101,8 @@ namespace SALOME GenericObjPtr& operator=(TGenericObj* thePointer) { - GenericObjPtr(thePointer).swap(*this); + GenericObjPtr aTmp(thePointer); + aTmp.swap(*this); return *this; } @@ -112,7 +113,8 @@ namespace SALOME GenericObjPtr& operator=(const GenericObjPtr& thePointer) { - GenericObjPtr(thePointer).swap(*this); + GenericObjPtr aTmp(thePointer); + aTmp.swap(*this); return *this; } @@ -153,6 +155,14 @@ namespace SALOME }; } +template +inline +bool +operator<(SALOME::GenericObjPtr const & a, SALOME::GenericObjPtr const & b) +{ + return a.get() < b.get(); +} + template inline bool diff --git a/src/VISU_I/VISUConfig.cc b/src/VISU_I/VISUConfig.cc index 0b7bad1f..8e7eb323 100644 --- a/src/VISU_I/VISUConfig.cc +++ b/src/VISU_I/VISUConfig.cc @@ -33,9 +33,13 @@ #include "SALOMEDSClient_AttributeIOR.hxx" #include "SalomeApp_Application.h" +#include "SalomeApp_Study.h" + +#include "SALOME_Event.hxx" + #include -using namespace std; +#include #ifdef _DEBUG_ static int MYDEBUG = 0; @@ -43,7 +47,9 @@ static int MYDEBUG = 0; static int MYDEBUG = 0; #endif -namespace VISU{ + +namespace VISU +{ SUIT_Session* GetSession() @@ -57,7 +63,7 @@ namespace VISU{ return GetSession()->resourceMgr(); } - //=========================================================================== + //--------------------------------------------------------------------------- QMutex* Base_i::myMutex = NULL; //apo - &VISUMutex; CORBA::ORB_var Base_i::myOrb; @@ -79,7 +85,7 @@ namespace VISU{ return CORBA::string_dup(myID.c_str()); } - //=========================================================================== + //--------------------------------------------------------------------------- static int mySCnt = 0; static QMutex aMutex(TRUE); @@ -98,8 +104,8 @@ namespace VISU{ } - //=========================================================================== - static Storable::TCallbackMap VisuStoreMap; + //--------------------------------------------------------------------------- + Storable::TStorableEngineMap Storable::myStorableEngineMap; std::string Storable @@ -114,16 +120,74 @@ namespace VISU{ } + //--------------------------------------------------------------- + CORBA::Boolean + Storable + ::CanCopy(SALOMEDS::SObject_ptr theObject) + { + return false; + } + + + //--------------------------------------------------------------- + bool + Storable + ::CopyFrom(SALOMEDS::SObject_ptr theObject, + CORBA::Long& theObjectID, + const std::string& theTmpDir, + TFileNames& theFileNames) + { + TFileName aFileName("copy_persistent"); + std::string aCopyPersist = theTmpDir + aFileName; + std::ofstream anOutputFileStream(aCopyPersist.c_str(), ios::out); + anOutputFileStream<> dupliacte registring !!!"); + if(!myStorableEngineMap.insert(TStorableEngineMap::value_type(theComment, theEngine)).second) throw std::logic_error("Storable::Registry >> dupliacte registring !!!"); + } + + + //--------------------------------------------------------------- + Storable* + Storable + ::Create(SALOMEDS::SObject_ptr theSObject, + const std::string& theLocalPersistentID, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile) + { + try{ + QString aString( CorrectPersistentString( theLocalPersistentID ) ); + TRestoringMap aRestoringMap; + StringToMap(aString, aRestoringMap); + bool anIsExists; + QString aComment = VISU::Storable::FindValue(aRestoringMap, "myComment", &anIsExists); + if ( anIsExists ) { + TStorableEngineMap::const_iterator anIter = myStorableEngineMap.find(aComment.latin1()); + if(MYDEBUG) MESSAGE("Storable::Create - "<second; + return aStorableEngine(theSObject, aRestoringMap, thePrefix, theIsMultiFile); + } + }catch(std::exception& exc){ + INFOS("Follow exception was occured :\n"<second; - return aStorableEngine(theSObject, thePrefix, aRestoringMap); - } - }catch(std::exception& exc){ - INFOS("Follow exception was occured :\n"<reference_to_servant(theObject); @@ -464,7 +522,7 @@ namespace VISU{ } - //=========================================================================== + //--------------------------------------------------------------------------- CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject) { @@ -486,7 +544,7 @@ namespace VISU{ return anObject; } - //=========================================================================== + //--------------------------------------------------------------------------- CORBA::Object_var ClientSObjectToObject(_PTR(SObject) theSObject) { @@ -509,8 +567,7 @@ namespace VISU{ } - //=========================================================================== - //=========================================================================== + //--------------------------------------------------------------------------- std::string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument, const std::string& theFatherEntry, @@ -529,27 +586,27 @@ namespace VISU{ else aNewSObject = aFather; SALOMEDS::GenericAttribute_var anAttr; - if(theIOR != ""){ + if(theIOR != NO_IOR){ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeIOR"); SALOMEDS::AttributeIOR_var aCustomAttr = SALOMEDS::AttributeIOR::_narrow(anAttr); aCustomAttr->SetValue(theIOR.c_str()); } - if(theName != ""){ + if(theName != NO_NAME){ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeName"); SALOMEDS::AttributeName_var aCustomAttr = SALOMEDS::AttributeName::_narrow(anAttr); aCustomAttr->SetValue(theName.c_str()); } - if(thePersistentRef != ""){ + if(thePersistentRef != NO_PERFSITENT_REF){ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePersistentRef"); SALOMEDS::AttributePersistentRef_var aCustomAttr = SALOMEDS::AttributePersistentRef::_narrow(anAttr); aCustomAttr->SetValue(thePersistentRef.c_str()); } - if(theComment != ""){ + if(theComment != NO_COMMENT){ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeString"); SALOMEDS::AttributeString_var aCustomAttr = SALOMEDS::AttributeString::_narrow(anAttr); aCustomAttr->SetValue(theComment.c_str()); } - if(theIconName != ""){ + if(theIconName != NO_ICON){ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePixMap"); SALOMEDS::AttributePixMap_var aCustomAttr = SALOMEDS::AttributePixMap::_narrow(anAttr); aCustomAttr->SetPixMap(theIconName.c_str()); @@ -580,27 +637,27 @@ namespace VISU{ aNewSObject = aFather; _PTR(GenericAttribute) anAttr; - if (theIOR != "") { + if (theIOR != NO_IOR) { anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeIOR"); _PTR(AttributeIOR) aCustomAttr (anAttr); aCustomAttr->SetValue(theIOR); } - if (theName != "") { + if (theName != NO_NAME) { anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeName"); _PTR(AttributeName) aCustomAttr (anAttr); aCustomAttr->SetValue(theName); } - if (thePersistentRef != "") { + if (thePersistentRef != NO_PERFSITENT_REF) { anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePersistentRef"); _PTR(AttributePersistentRef) aCustomAttr (anAttr); aCustomAttr->SetValue(thePersistentRef); } - if (theComment != "") { + if (theComment != NO_COMMENT) { anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeString"); _PTR(AttributeString) aCustomAttr (anAttr); aCustomAttr->SetValue(theComment); } - if (theIconName != "") { + if (theIconName != NO_ICON) { anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePixMap"); _PTR(AttributePixMap) aCustomAttr (anAttr); aCustomAttr->SetPixMap(theIconName); @@ -612,18 +669,21 @@ namespace VISU{ return aRet; } + + //--------------------------------------------------------------- QString - GenerateName(const string& theFmt, int theId) + GenerateName(const std::string& theFmt, int theId) { - static QString aName; + QString aName; if(theId > 0) - aName.sprintf("%s:%d",theFmt.c_str(),theId); + aName.sprintf("%s:%d", theFmt.c_str(), theId); else - aName.sprintf("%s",theFmt.c_str()); + aName.sprintf("%s", theFmt.c_str()); return aName; } + //--------------------------------------------------------------- SALOMEDS::StudyManager_var GetStudyManager() { @@ -637,15 +697,76 @@ namespace VISU{ } + //--------------------------------------------------------------- SALOMEDS::Study_var GetDSStudy(_PTR(Study) theStudy) { - //std::string aStudyName = theStudy->Name(); - //return GetStudyManager()->GetStudyByName(aStudyName.c_str()); int aStudyID = theStudy->StudyId(); return GetStudyManager()->GetStudyByID(aStudyID); } + + //--------------------------------------------------------------- + struct TGetStudyEvent: public SALOME_Event + { + SALOMEDS::Study_var myStudy; + + typedef SalomeApp_Study* TResult; + TResult myResult; + + TGetStudyEvent(SALOMEDS::Study_ptr theStudy): + myStudy(SALOMEDS::Study::_duplicate(theStudy)), + myResult(NULL) + {} + + virtual + void + Execute() + { + if(CORBA::is_nil(myStudy)) + return; + + int aStudyId = myStudy->StudyId(); + SUIT_Session* aSession = SUIT_Session::session(); + QPtrList anApplications = aSession->applications(); + QPtrListIterator anIter (anApplications); + while (SUIT_Application* anApp = anIter.current()) { + ++anIter; + if (SUIT_Study* aSStudy = anApp->activeStudy()) { + if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { + if (_PTR(Study) aCStudy = aStudy->studyDS()) { + if (aStudyId == aCStudy->StudyId()) { + myResult = aStudy; + break; + } + } + } + } + } + } + }; + + + //--------------------------------------------------------------- + SalomeApp_Study* + GetGUIStudy(SALOMEDS::Study_ptr theStudy) + { + return ProcessEvent(new TGetStudyEvent(theStudy)); + } + + + //--------------------------------------------------------------- + _PTR(Study) + GetStudy(SALOMEDS::Study_ptr theStudy) + { + if(SalomeApp_Study* aStudy = ProcessEvent(new TGetStudyEvent(theStudy))) + return aStudy->studyDS(); + + return _PTR(Study)(); + } + + + //--------------------------------------------------------------- SALOMEDS::SObject_var GetSObject( _PTR(SObject) obj ) { @@ -655,15 +776,17 @@ namespace VISU{ return aSalomeDSStudy->FindObjectID( id.c_str() ); } + //--------------------------------------------------------------- _PTR(SObject) - GetClientSObject( SALOMEDS::SObject_var obj, - _PTR(Study) study ) + GetClientSObject(SALOMEDS::SObject_ptr theSObject, + _PTR(Study) theStudy) { - return study->FindObjectID( obj->GetID() ); - + CORBA::String_var anEntry = theSObject->GetID(); + return theStudy->FindObjectID( anEntry.in() ); } + //--------------------------------------------------------------- void RemoveFromStudy (SALOMEDS::SObject_ptr theSObject, bool theIsAttrOnly, @@ -707,6 +830,8 @@ namespace VISU{ aStudyBuilder->RemoveObjectWithChildren(theSObject); } + + //--------------------------------------------------------------- void RemoveFromStudy (_PTR(SObject) theSObject, bool theIsAttrOnly, diff --git a/src/VISU_I/VISUConfig.hh b/src/VISU_I/VISUConfig.hh index ef3ff038..94f11eec 100644 --- a/src/VISU_I/VISUConfig.hh +++ b/src/VISU_I/VISUConfig.hh @@ -63,6 +63,8 @@ class SUIT_Session; class SUIT_ResourceMgr; +class SalomeApp_Study; + namespace VISU { @@ -119,8 +121,6 @@ namespace VISU //=========================================================================== class VISU_I_EXPORT Storable : public virtual Base_i { - protected: - virtual void ToStream(std::ostringstream& theStr) = 0; public: std::string ToString(); @@ -129,13 +129,31 @@ namespace VISU const char* GetComment() const = 0; + + //--------------------------------------------------------------- typedef std::map TRestoringMap; typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject, + const TRestoringMap& theMap, const std::string& thePrefix, - const TRestoringMap& theMap); - typedef std::map TCallbackMap; + CORBA::Boolean theIsMultiFile); + + typedef std::map TStorableEngineMap; + + static + void + RegistryStorableEngine(const std::string& theComment, + TStorableEngine theEngine); + + static + Storable* + Create(SALOMEDS::SObject_ptr theSObject, + const std::string& theLocalPersistentID, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile); + + //--------------------------------------------------------------- static VISU::VISUType Comment2Type(const std::string& theComment); @@ -163,17 +181,6 @@ namespace VISU const TRestoringMap& theRestoringMap, int IsAllLevels = true); - static - void - Registry(const std::string& theComment, - TStorableEngine theEngine); - - static - Storable* - Create(SALOMEDS::SObject_ptr, - const std::string& thePrefix, - const std::string& theString); - static QString FindValue(const TRestoringMap& theMap, @@ -209,20 +216,47 @@ namespace VISU void DataToStream(std::ostringstream& theStr, const QString& theName, - const int theVal); + int theVal); + + static + void + DataToStream(std::ostringstream& theStr, + const QString& theName, + long theVal); static void DataToStream(std::ostringstream& theStr, const QString& theName, - const double theVal); + double theVal); + + //--------------------------------------------------------------- + virtual + CORBA::Boolean + CanCopy(SALOMEDS::SObject_ptr theObject); + + typedef std::string TFileName; + typedef std::vector TFileNames; + + virtual + bool + CopyFrom(SALOMEDS::SObject_ptr theObject, + CORBA::Long& theObjectID, + const std::string& theTmpDir, + TFileNames& theFileNames); + + + //--------------------------------------------------------------- + protected: + virtual + void + ToStream(std::ostringstream& theStr) = 0; + + private: + static TStorableEngineMap myStorableEngineMap; }; //=========================================================================== - VISU_I_EXPORT - const CORBA::Boolean - IsMultifile(); - VISU_I_EXPORT QString GenerateName(const std::string& theFmt, int theId); @@ -247,6 +281,12 @@ namespace VISU SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument); + const char* const NO_ICON = ""; + const char* const NO_IOR = ""; + const char* const NO_NAME = ""; + const char* const NO_PERFSITENT_REF = ""; + const char* const NO_COMMENT = ""; + VISU_I_EXPORT std::string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument, @@ -275,11 +315,20 @@ namespace VISU VISU_I_EXPORT _PTR(SObject) - GetClientSObject(SALOMEDS::SObject_var, _PTR(Study)); + GetClientSObject(SALOMEDS::SObject_ptr theSObject, + _PTR(Study) theStudy); VISU_I_EXPORT SALOMEDS::Study_var - GetDSStudy(_PTR(Study)); + GetDSStudy(_PTR(Study) theStudy); + + VISU_I_EXPORT + SalomeApp_Study* + GetGUIStudy(SALOMEDS::Study_ptr theStudy); + + VISU_I_EXPORT + _PTR(Study) + GetStudy(SALOMEDS::Study_ptr theStudy); VISU_I_EXPORT void diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 2485fe3b..d6bbf477 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -420,6 +420,7 @@ VISU::ColoredPrs3dCache_i } myMemoryMode = theMode; + GetStudyDocument()->Modified(); } VISU::ColoredPrs3dCache::MemoryMode @@ -447,6 +448,7 @@ VISU::ColoredPrs3dCache_i ClearCache(theMemorySize); myLimitedMemory = theMemorySize; + GetStudyDocument()->Modified(); } CORBA::Float @@ -806,23 +808,23 @@ VISU::ColoredPrs3dCache_i VISU::Storable* VISU::ColoredPrs3dCache_i ::Restore(SALOMEDS::SObject_ptr theSObject, - const Storable::TRestoringMap& theMap, - const string& thePrefix) + const Storable::TRestoringMap& theMap) { SetMemoryMode( (VISU::ColoredPrs3dCache::MemoryMode)VISU::Storable::FindValue( theMap, "myMemoryMode" ).toInt() ); SetLimitedMemory( VISU::Storable::FindValue( theMap, "myLimitedMemory" ).toInt() ); - + return this; } //--------------------------------------------------------------- VISU::Storable* VISU::ColoredPrs3dCache_i -::Restore(SALOMEDS::SObject_ptr theSObject, - const string& thePrefix, - const Storable::TRestoringMap& theMap) +::StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile) { SALOMEDS::Study_var aStudy = theSObject->GetStudy(); VISU::ColoredPrs3dCache_i* aCache = new VISU::ColoredPrs3dCache_i(aStudy, false); - return aCache->Restore(theSObject,theMap,thePrefix); + return aCache->Restore(theSObject, theMap); } diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh index 56ab4a22..ead20807 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh @@ -189,14 +189,14 @@ namespace VISU virtual Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const Storable::TRestoringMap& theMap, - const std::string& thePrefix); + const Storable::TRestoringMap& theMap); static Storable* - Restore(SALOMEDS::SObject_ptr theSObject, - const std::string& thePrefix, - const Storable::TRestoringMap& theMap); + StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile); //---------------------------------------------------------------------------- //! Finds or creates instance of the ColoredPrs3dCache in the given SALOMEDS::Study diff --git a/src/VISU_I/VISU_ColoredPrs3dFactory.hh b/src/VISU_I/VISU_ColoredPrs3dFactory.hh index f77b0d22..1852297c 100644 --- a/src/VISU_I/VISU_ColoredPrs3dFactory.hh +++ b/src/VISU_I/VISU_ColoredPrs3dFactory.hh @@ -32,6 +32,7 @@ #include CORBA_SERVER_HEADER(SALOMEDS) #include "VISU_I.hxx" +#include "SALOME_GenericObjPointer.hh" #include "VISU_ScalarMapOnDeformedShape_i.hh" #include "VISU_Plot3D_i.hh" #include "VISU_GaussPoints_i.hh" @@ -274,7 +275,7 @@ namespace VISU typedef typename TL::TColoredEnum2Type::TResult TColoredPrs3d; void - Copy(ColoredPrs3d_i* theColoredPrs3dTo, ColoredPrs3d_i* theColoredPrs3dFrom) + Copy(ColoredPrs3d_i* theColoredPrs3dFrom, ColoredPrs3d_i* theColoredPrs3dTo) { theColoredPrs3dTo->SetCResult(theColoredPrs3dFrom->GetCResult()); theColoredPrs3dTo->SetMeshName(theColoredPrs3dFrom->GetCMeshName().c_str()); @@ -284,12 +285,13 @@ namespace VISU theColoredPrs3dTo->SameAs(theColoredPrs3dFrom); } - TColoredPrs3d* + SALOME::GenericObjPtr Create(ColoredPrs3d_i* theColoredPrs3d, ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode) { - TColoredPrs3d* aSameColoredPrs3d = new TColoredPrs3d(thePublishInStudyMode); - Copy(aSameColoredPrs3d, theColoredPrs3d); + SALOME::GenericObjPtr aSameColoredPrs3d(new TColoredPrs3d(thePublishInStudyMode)); + Copy(theColoredPrs3d, aSameColoredPrs3d); + aSameColoredPrs3d->Destroy(); return aSameColoredPrs3d; } }; diff --git a/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc b/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc index 1adcba4d..8ee44542 100644 --- a/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc @@ -150,7 +150,11 @@ VISU::ColoredPrs3d_i* VISU::ColoredPrs3dHolder_i ::GetPrs3dDevice() { - return myCache.GetLastVisitedPrs(this); + try{ + return myCache.GetLastVisitedPrs(this); + }catch(...){} + + return NULL; } @@ -158,7 +162,10 @@ VISU::ColoredPrs3d_ptr VISU::ColoredPrs3dHolder_i ::GetDevice() { - return GetPrs3dDevice()->_this(); + if( VISU::ColoredPrs3d_i* aDevice = GetPrs3dDevice() ) + return aDevice->_this(); + + return VISU::ColoredPrs3d::_nil(); } @@ -240,9 +247,10 @@ VISU::ColoredPrs3dHolder_i //--------------------------------------------------------------- VISU::Storable* VISU::ColoredPrs3dHolder_i -::Restore(SALOMEDS::SObject_ptr theSObject, - const string& thePrefix, - const Storable::TRestoringMap& theMap) +::StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile) { using namespace VISU; SALOMEDS::Study_var aStudy = theSObject->GetStudy(); diff --git a/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh b/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh index bdf2c2da..840d537e 100644 --- a/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh @@ -125,9 +125,10 @@ namespace VISU static Storable* - Restore(SALOMEDS::SObject_ptr theSObject, - const std::string& thePrefix, - const Storable::TRestoringMap& theMap); + StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile); virtual QString diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 13246cfc..2998dd50 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -25,6 +25,7 @@ // Module : VISU #include "VISU_ColoredPrs3d_i.hh" +#include "VISU_Prs3dUtils.hh" #include "VISU_Result_i.hh" #include "VISU_ColoredPL.hxx" @@ -114,6 +115,25 @@ VISU::ColoredPrs3d_i ProcessVoidEvent(new TRemoveFromStudy(this)); } + +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::UpdateFromResult(Result_i* theResult) +{ + try{ + if(theResult == GetCResult()){ + DoSetInput(false, false); + UpdateActors(); + } + }catch(std::exception& exc){ + INFOS("Follow exception was occured :\n"<Init(); + + // To update scalar range according to the new input + if(!IsRangeFixed() || theReInit) + SetSourceRange(); + + GetCResult()->ConnectObserver(this, myResultConnection); + myPreviousEntity = myEntity; myPreviousFieldName = myFieldName; myPreviousTimeStampNumber = myTimeStampNumber; @@ -185,10 +215,13 @@ void VISU::ColoredPrs3d_i ::SetEntity(VISU::Entity theEntity) { - if(myEntity != theEntity){ - myEntity = theEntity; - myParamsTime.Modified(); - } + if(myEntity == theEntity) + return; + + VISU::TSetModified aModified(this); + + myEntity = theEntity; + myParamsTime.Modified(); } @@ -215,10 +248,13 @@ void VISU::ColoredPrs3d_i ::SetFieldName(const char* theFieldName) { - if(myFieldName != theFieldName){ - myFieldName = theFieldName; - myParamsTime.Modified(); - } + if(myFieldName == theFieldName) + return; + + VISU::TSetModified aModified(this); + + myFieldName = theFieldName; + myParamsTime.Modified(); } @@ -263,10 +299,13 @@ void VISU::ColoredPrs3d_i ::SetTimeStampNumber(CORBA::Long theTimeStampNumber) { - if(myTimeStampNumber != theTimeStampNumber){ - myTimeStampNumber = theTimeStampNumber; - myParamsTime.Modified(); - } + if(myTimeStampNumber == theTimeStampNumber) + return; + + VISU::TSetModified aModified(this); + + myTimeStampNumber = theTimeStampNumber; + myParamsTime.Modified(); } @@ -486,6 +525,13 @@ VISU::ColoredPrs3d_i SetNbColors(anOrigin->GetNbColors()); SetBarOrientation(anOrigin->GetBarOrientation()); + // "SetRange" function changes "myIsFixedRange" attribute, + // so, it is necessary pay a special attention if "this" equal to "theOrigin" + if(anOrigin->IsRangeFixed()) + SetRange(anOrigin->GetMin(), anOrigin->GetMax()); + else + SetSourceRange(); + SetPosition(anOrigin->GetPosX(), anOrigin->GetPosY()); SetSize(anOrigin->GetWidth(), anOrigin->GetHeight()); SetLabels(anOrigin->GetLabels()); @@ -506,7 +552,6 @@ VISU::ColoredPrs3d_i anOrigin->GetLabelColor(&r,&g,&b); SetLabelColor(r,g,b); - UseFixedRange( anOrigin->IsRangeFixed() ); myIsTimeStampFixed = anOrigin->IsTimeStampFixed(); SetHolderEntry( anOrigin->GetHolderEntry() ); @@ -521,6 +566,7 @@ VISU::ColoredPrs3d_i return myColoredPL->GetScalarMode(); } + //---------------------------------------------------------------------------- void VISU::ColoredPrs3d_i @@ -532,6 +578,8 @@ VISU::ColoredPrs3d_i else if(theScalarMode > aNbComp) theScalarMode = 0; + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_ColoredPL::SetScalarMode, theScalarMode)); } @@ -557,6 +605,8 @@ void VISU::ColoredPrs3d_i ::SetRange(CORBA::Double theMin, CORBA::Double theMax) { + VISU::TSetModified aModified(this); + vtkFloatingPointType aScalarRange[2] = {theMin, theMax}; ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange)); @@ -570,6 +620,8 @@ void VISU::ColoredPrs3d_i ::SetSourceRange() { + VISU::TSetModified aModified(this); + if(IsTimeStampFixed()){ GetSpecificPL()->SetSourceRange(); ProcessVoidEvent(new TVoidMemFunEvent @@ -618,6 +670,8 @@ void VISU::ColoredPrs3d_i ::SetNbColors(CORBA::Long theNbColors) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_ColoredPL::SetNbColors, theNbColors)); } @@ -635,10 +689,13 @@ void VISU::ColoredPrs3d_i ::SetBarOrientation(VISU::ColoredPrs3d::Orientation theOrientation) { - if(myOrientation != theOrientation){ - myOrientation = theOrientation; - myParamsTime.Modified(); - } + if(myOrientation == theOrientation) + return; + + VISU::TSetModified aModified(this); + + myOrientation = theOrientation; + myParamsTime.Modified(); } //---------------------------------------------------------------------------- @@ -659,6 +716,8 @@ VISU::ColoredPrs3d_i if(anIsSameValue) return; + VISU::TSetModified aModified(this); + myPosition[0] = theX; myPosition[1] = theY; myParamsTime.Modified(); @@ -690,6 +749,8 @@ VISU::ColoredPrs3d_i if(anIsSameValue) return; + VISU::TSetModified aModified(this); + myWidth = theWidth; myHeight = theHeight; myParamsTime.Modified(); @@ -716,10 +777,13 @@ void VISU::ColoredPrs3d_i ::SetLabels(CORBA::Long theNbLabels) { - if(myNumberOfLabels != theNbLabels){ - myNumberOfLabels = theNbLabels; - myParamsTime.Modified(); - } + if(myNumberOfLabels == theNbLabels) + return; + + VISU::TSetModified aModified(this); + + myNumberOfLabels = theNbLabels; + myParamsTime.Modified(); } //---------------------------------------------------------------------------- @@ -747,6 +811,8 @@ VISU::ColoredPrs3d_i aStream<integerValue("VISU", "scalar_bar_mode", 0); SetScalarMode(aScalarMode); + // Scalar Range + int aRangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0); + if(aRangeType == 1){ + float aMin = aResourceMgr->doubleValue("VISU", "scalar_range_min", 0); + float aMax = aResourceMgr->doubleValue("VISU", "scalar_range_max", 0); + SetRange(aMin, aMax); + } + UseFixedRange(aRangeType == 1); + int aNumberOfColors = aResourceMgr->integerValue( "VISU", "scalar_bar_num_colors", 64 ); SetNbColors(aNumberOfColors); @@ -1173,6 +1276,12 @@ VISU::ColoredPrs3d_i Build(ERestore); SetScalarMode(VISU::Storable::FindValue(theMap,"myScalarMode").toInt()); + float aMin = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble(); + float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble(); + SetRange(aMin, aMax); + + UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange", "0").toInt()); + SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt()); SetBarOrientation((VISU::ColoredPrs3d::Orientation)VISU::Storable::FindValue(theMap,"myOrientation").toInt()); @@ -1215,6 +1324,10 @@ VISU::ColoredPrs3d_i Storable::DataToStream( theStr, "myIsTimeStampFixed", int(myIsTimeStampFixed) ); Storable::DataToStream( theStr, "myScalarMode", int(GetScalarMode()) ); + Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() ); + Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() ); + Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() ); + Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) ); Storable::DataToStream( theStr, "myOrientation", myOrientation ); diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 72ddb6fd..d1e64283 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -28,6 +28,8 @@ #define VISU_ColoredPrs3d_i_HeaderFile #include "VISU_Prs3d_i.hh" +#include "VISU_Result_i.hh" +#include "VISU_BoostSignals.h" class VISU_ColoredPL; @@ -35,6 +37,7 @@ namespace VISU { //---------------------------------------------------------------------------- class VISU_I_EXPORT ColoredPrs3d_i : public virtual POA_VISU::ColoredPrs3d, + public virtual TResultObserver, public virtual Prs3d_i { ColoredPrs3d_i(const ColoredPrs3d_i&); @@ -59,6 +62,12 @@ namespace VISU void RemoveFromStudy(); + //---------------------------------------------------------------------------- + //! To update the presentation from result in automatic way + virtual + void + UpdateFromResult(Result_i* theResult); + //---------------------------------------------------------------------------- virtual void @@ -468,6 +477,8 @@ namespace VISU CORBA::Long myTimeStampNumber; CORBA::Long myPreviousTimeStampNumber; + boost::signalslib::connection myResultConnection; + bool myIsTimeStampFixed; PField myField; @@ -502,9 +513,10 @@ namespace VISU //---------------------------------------------------------------------------- template Storable* - Restore(SALOMEDS::SObject_ptr theSObject, - const std::string& thePrefix, - const Storable::TRestoringMap& theMap) + StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile) { TColoredPrs3d* aColoredPrs3d = new TColoredPrs3d(ColoredPrs3d_i::EDoNotPublish); return aColoredPrs3d->Restore(theSObject, theMap); diff --git a/src/VISU_I/VISU_CutLines_i.cc b/src/VISU_I/VISU_CutLines_i.cc index ede2fea6..88d83cd6 100644 --- a/src/VISU_I/VISU_CutLines_i.cc +++ b/src/VISU_I/VISU_CutLines_i.cc @@ -25,6 +25,7 @@ // Module : VISU #include "VISU_CutLines_i.hh" +#include "VISU_Prs3dUtils.hh" #include "VISU_Result_i.hh" #include "VISU_Actor.h" @@ -272,8 +273,9 @@ VISU::CutLines_i } }; - ProcessVoidEvent(new TEvent(myCutLinesPL, theOrient, theXAngle, theYAngle)); + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TEvent(myCutLinesPL, theOrient, theXAngle, theYAngle)); } //--------------------------------------------------------------- @@ -309,6 +311,8 @@ VISU::CutLines_i } }; + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TEvent(myCutLinesPL, theOrient, theXAngle, theYAngle)); } @@ -367,6 +371,8 @@ void VISU::CutLines_i ::SetDisplacement(CORBA::Double theDisp) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun2ArgEvent (GetSpecificPL(), &VISU_CutLinesPL::SetDisplacement, theDisp, 0)); } @@ -376,6 +382,8 @@ void VISU::CutLines_i ::SetDisplacement2(CORBA::Double theDisp) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun2ArgEvent (GetSpecificPL(), &VISU_CutLinesPL::SetDisplacement, theDisp, 1)); } @@ -403,6 +411,8 @@ void VISU::CutLines_i ::SetBasePlanePosition(CORBA::Double thePlanePosition) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_CutLinesPL::SetPosition, thePlanePosition)); } @@ -421,6 +431,8 @@ VISU::CutLines_i ::SetLinePosition(CORBA::Long thePlaneNumber, CORBA::Double thePlanePosition) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun2ArgEvent (GetSpecificPL(), &VISU_CutLinesPL::SetPartPosition, thePlaneNumber, thePlanePosition)); } @@ -439,6 +451,8 @@ void VISU::CutLines_i ::SetDefault() { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFunEvent (GetSpecificPL(), &VISU_CutLinesPL::SetDefault)); } @@ -456,6 +470,8 @@ void VISU::CutLines_i ::SetDefaultPosition(CORBA::Long thePlaneNumber) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_CutLinesPL::SetPartDefault, thePlaneNumber)); } @@ -506,6 +522,8 @@ VISU::CutLines_i if(myMapCurvesInverted[theCurveNumber] == theInvert) return; + VISU::TSetModified aModified(this); + myMapCurvesInverted[theCurveNumber] = theInvert; myParamsTime.Modified(); } @@ -533,6 +551,8 @@ VISU::CutLines_i if(myUseAbsLength == theAbsLength) return; + VISU::TSetModified aModified(this); + myUseAbsLength = theAbsLength; myParamsTime.Modified(); } @@ -550,6 +570,8 @@ void VISU::CutLines_i ::SetNbLines(CORBA::Long theNb) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_CutLinesPL::SetNbParts, theNb)); } diff --git a/src/VISU_I/VISU_CutPlanes_i.cc b/src/VISU_I/VISU_CutPlanes_i.cc index f899ee38..a0f724b7 100644 --- a/src/VISU_I/VISU_CutPlanes_i.cc +++ b/src/VISU_I/VISU_CutPlanes_i.cc @@ -25,8 +25,10 @@ // Module : VISU #include "VISU_CutPlanesPL.hxx" -#include "VISU_Result_i.hh" +#include "VISU_Prs3dUtils.hh" #include "VISU_CutPlanes_i.hh" + +#include "VISU_Result_i.hh" #include "VISU_Actor.h" #include "SUIT_ResourceMgr.h" @@ -195,6 +197,8 @@ VISU::CutPlanes_i } }; + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TEvent(GetSpecificPL(), VISU_CutPlanesPL::PlaneOrientation(theOrient), theXAngle, @@ -231,6 +235,8 @@ void VISU::CutPlanes_i ::SetDisplacement(CORBA::Double theDisp) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun2ArgEvent (GetSpecificPL(), &VISU_CutPlanesPL::SetDisplacement, theDisp, 0)); } @@ -250,6 +256,8 @@ VISU::CutPlanes_i ::SetPlanePosition(CORBA::Long thePlaneNumber, CORBA::Double thePlanePosition) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun2ArgEvent (GetSpecificPL(), &VISU_CutPlanesPL::SetPartPosition, thePlaneNumber, thePlanePosition)); } @@ -268,6 +276,8 @@ void VISU::CutPlanes_i ::SetDefault(CORBA::Long thePlaneNumber) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_CutPlanesPL::SetPartDefault, thePlaneNumber)); } @@ -286,6 +296,8 @@ void VISU::CutPlanes_i ::SetNbPlanes(CORBA::Long theNb) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_CutPlanesPL::SetNbParts, theNb)); } diff --git a/src/VISU_I/VISU_DeformedShape_i.cc b/src/VISU_I/VISU_DeformedShape_i.cc index 805cbd60..5e8ae25d 100644 --- a/src/VISU_I/VISU_DeformedShape_i.cc +++ b/src/VISU_I/VISU_DeformedShape_i.cc @@ -25,6 +25,7 @@ // Module : VISU #include "VISU_DeformedShape_i.hh" +#include "VISU_Prs3dUtils.hh" #include "VISU_Result_i.hh" #include "VISU_ScalarMapAct.h" @@ -63,7 +64,10 @@ VISU::DeformedShape_i theTimeStampNumber, theIsMemoryCheck); if(aResult){ - VISU::Result_i::TInput* anInput = theResult->GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName, + theEntity, + theFieldName, + theTimeStampNumber); VISU::PField aField = anInput->GetField(theMeshName, (VISU::TEntity)theEntity, theFieldName); @@ -201,6 +205,8 @@ void VISU::DeformedShape_i ::SetScale(CORBA::Double theScale) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_DeformedShapePL::SetScale, theScale)); } @@ -255,6 +261,8 @@ VISU::DeformedShape_i if(anIsSameValue) return; + VISU::TSetModified aModified(this); + myColor = theColor; myParamsTime.Modified(); } @@ -295,6 +303,8 @@ void VISU::DeformedShape_i ::SetMapScale(double theMapScale) { + VISU::TSetModified aModified(this); + myDeformedShapePL->SetMapScale(theMapScale); } diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index d40749fd..0495c377 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -59,13 +59,14 @@ using namespace std; namespace VISU { + //--------------------------------------------------------------------------- static std::string PREFIX(" "); - static std::string aResultName; - typedef std::map TName2EntryMap; typedef std::map TEntry2NameMap; + + //--------------------------------------------------------------------------- inline std::string GenerateName(std::string theName, @@ -86,13 +87,18 @@ namespace VISU return theName; } - struct TReplacePredicate{ + + //--------------------------------------------------------------------------- + struct TReplacePredicate + { bool operator()(char theChar) const { return !(isdigit(theChar) || isalpha(theChar) || theChar == '_'); } }; + + //--------------------------------------------------------------------------- inline std::string GetName(SALOMEDS::SObject_ptr theSObject) @@ -110,6 +116,8 @@ namespace VISU return aName; } + + //--------------------------------------------------------------------------- inline std::string GenerateName(SALOMEDS::SObject_ptr theSObject, @@ -118,7 +126,30 @@ namespace VISU { std::string aName = GetName(theSObject); - return GenerateName(aName,theSObject,theName2EntryMap,theEntry2NameMap,'X'); + return GenerateName(aName, theSObject, theName2EntryMap, theEntry2NameMap, 'X'); + } + + + //--------------------------------------------------------------------------- + inline + std::string + GetBoolean(bool theArgument) + { + if(theArgument) + return "True"; + + return "False"; + } + + + //--------------------------------------------------------------------------- + inline + std::string + GetColor(const SALOMEDS::Color& theColor) + { + std::ostringstream aStream; + aStream<<"SALOMEDS.Color("<GetScalarMode()<<")"<IsRangeFixed()) + theStr<GetMin()<<", "<GetMax()<<")"<GetIsActiveLocalScalarBar(); + theStr<GetIsDispGlobalScalarBar(); + theStr<GetSpacing()<<")"<GetBiColor(); + theStr<GetIsDeformed(); + theStr<GetScaleFactor()<<")"<GetPrimitiveType()){ + case VISU::GaussPoints::SPRITE : + aParam = "VISU.GaussPoints.SPRITE"; + break; + case VISU::GaussPoints::POINT : + aParam = "VISU.GaussPoints.POINT"; + break; + case VISU::GaussPoints::SPHERE : + aParam = "VISU.GaussPoints.SPHERE"; + break; + } + theStr<GetClamp()<<")"<GetQMainTexture(); + QString anAlphaTexture = theServant->GetQAlphaTexture(); + theStr<GetAlphaThreshold()<<")"<GetResolution()<<")"<GetFaceLimit()<<")"<GetIsColored(); + theStr<GetMinSize()<<")"<GetMaxSize()<<")"<GetColor())<<")"<GetGeomSize()<<")"<GetMagnification()<<")"<GetMagnificationIncrement()<<")"<GetScaling()){ @@ -293,7 +404,6 @@ namespace VISU break; } theStr<GetMin()<<", "<GetMax()<<")"<GetGroupNames(); VISU::ScalarMap_i::TGroupNames::const_iterator anIter = aGroupNames.begin(); @@ -315,11 +425,11 @@ namespace VISU std::string thePrefix) { thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix); + theStr<GetScale()<<")"<IsColored()<<")"<GetColor(); - theStr<IsColored())<<")"<GetColor())<<")"<GetDirection()){ @@ -386,6 +497,7 @@ namespace VISU std::string thePrefix) { thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix); + theStr<GetMin()<<", "<GetMax()<<")"<GetScale()<<")"<GetLineWidth()<<")"<GetNbSurfaces()<<")"<GetOrientationType()){ @@ -531,6 +647,7 @@ namespace VISU std::string thePrefix) { thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix); + theStr<GetOrientationType()){ @@ -589,6 +706,7 @@ namespace VISU std::string thePrefix) { thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix); + theStr<GetOrientationType()){ @@ -734,7 +852,7 @@ namespace VISU << aName << "_cTitles )" << endl; if(theSObject->FindAttribute(anAttr,"AttributeIOR")){ - theStr<GetType(); switch(aType){ case VISU::TRESULT: if(Result_i* aServant = dynamic_cast(GetServant(anObj).in())){ - aResultName = aName; - std::string aFileName = aServant->GetFileName(); + std::string aFileName = aServant->GetInitFileName(); Result_i::ECreationId anId = aServant->GetCreationId(); if(anId == Result_i::eImportFile || anId == Result_i::eCopyAndImportFile){ switch(anId){ case Result_i::eImportFile: - //theStr<IsGroupsDone()<<")"<< + GetBoolean(aServant->IsGroupsDone())<<")"<< endl; theStr<IsFieldsDone()<<", "<< - aServant->IsMinMaxDone()<<")"<< + GetBoolean(aServant->IsFieldsDone())<<", "<< + GetBoolean(aServant->IsMinMaxDone())<<")"<< endl; - theStr<GetMeshNames(); + if (aMeshNames->length() > 0) { + for(size_t aMeshId = 0; aMeshId < aMeshNames->length(); aMeshId++){ + CORBA::String_var aMeshName = aMeshNames[aMeshId]; + VISU::Result::EntityNames_var aParts = aServant->GetPartNames(aMeshName); + if (aParts->length() > 0) { + for(size_t aPartId = 0; aPartId < aParts->length(); aPartId++){ + CORBA::String_var aPart = aParts[aPartId]; + VISU::Result::Resolution aResolution = aServant->GetResolution(aMeshName, aPart); + std::string aParam; + switch(aResolution){ + case VISU::Result::FULL: + aParam = "VISU.Result.FULL"; + break; + case VISU::Result::MEDIUM: + aParam = "VISU.Result.MEDIUM"; + break; + case VISU::Result::LOW: + aParam = "VISU.Result.LOW"; + break; + case VISU::Result::HIDDEN: + aParam = "VISU.Result.HIDDEN"; + break; + } + theStr<(GetServant(anObj).in())){ TCreateFromResult aPrsFactory(theSObject, aServant, aName, "GaussPointsOnField", theArgumentName); - thePrefix = ColoredPrs3dToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix); + thePrefix = GaussPointsToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix); theStr<NewChildIterator(theSObject); - for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){ - SALOMEDS::SObject_var aSObject = aChildItet->Value(); - CORBA::Object_var anObject = SObjectToObject(aSObject); - if (CORBA::is_nil(anObject)) - continue; - if(ColoredPrs3dHolder_i* aServant = dynamic_cast(GetServant(anObject).in())){ - ColoredPrs3dHolder::BasicInput_var anInput = aServant->GetBasicInput(); - std::string anEntity; - switch(anInput->myEntity){ - case VISU::NODE : anEntity = "VISU.NODE"; break; - case VISU::EDGE : anEntity = "VISU.EDGE"; break; - case VISU::FACE : anEntity = "VISU.FACE"; break; - case VISU::CELL : anEntity = "VISU.CELL"; break; - } - - ColoredPrs3d_var aDevice = aServant->GetDevice(); - theStr<myMeshName<<"', "<< - anEntity<<", '"<< - anInput->myFieldName<<"', "<< - anInput->myTimeStampNumber<<")"<< - endl; - - if(Prs3d_i* aPrs3d = dynamic_cast(GetServant(aDevice).in())){ - std::string aComment = aPrs3d->GetComment(); - theStr<GetName(); - theStr<GetType()){ - case VISU::TSCALARMAP: - if(ScalarMap_i* aServant = dynamic_cast(aPrs3d)){ - aPrefix = ScalarMapToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix); - break; - } - case VISU::TDEFORMEDSHAPE: - if(DeformedShape_i* aServant = dynamic_cast(aPrs3d)){ - aPrefix = DeformedShapeToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix); - break; - } - case VISU::TSTREAMLINES: - if(StreamLines_i* aServant = dynamic_cast(aPrs3d)){ - aPrefix = StreamLinesToPython(aSObject, aServant, theStr, theEntry2NameMap, "aDevice", aPrsFactory, aPrefix); - break; - } - case VISU::TSCALARMAPONDEFORMEDSHAPE: - if(ScalarMapOnDeformedShape_i* aServant = dynamic_cast(aPrs3d)){ - aPrefix = ScalarMapOnDeformedShapeToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix); - break; - } - case VISU::TVECTORS: - if(Vectors_i* aServant = dynamic_cast(aPrs3d)){ - aPrefix = VectorsToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix); - break; - } - case VISU::TISOSURFACES: - if(IsoSurfaces_i* aServant = dynamic_cast(aPrs3d)){ - aPrefix = IsoSurfacesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix); - break; - } - case VISU::TCUTPLANES: - if(CutPlanes_i* aServant = dynamic_cast(aPrs3d)){ - aPrefix = CutPlanesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix); - break; - } - case VISU::TCUTLINES: - if(CutLines_i* aServant = dynamic_cast(aPrs3d)){ - aPrefix = CutLinesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix); - break; - } - case VISU::TPLOT3D: - if (Plot3D_i* aServant = dynamic_cast(aPrs3d)) { - aPrefix = Plot3DToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix); - break; - } - case VISU::TGAUSSPOINTS: - if(GaussPoints_i* aServant = dynamic_cast(aPrs3d)){ - aPrefix = ColoredPrs3dToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix); - break; - } - } - theStr<GetType() == VISU::TCONTAINER){ - theStr<NewChildIterator(theSObject); + for(anIter->InitEx(false); anIter->More(); anIter->Next()){ + SALOMEDS::SObject_var aSObject = anIter->Value(); + CORBA::Object_var anObj = SObjectToObject(aSObject); + if(CORBA::is_nil(anObj)) + continue; + + VISU::Base_var aBase = VISU::Base::_narrow(anObj); + if(CORBA::is_nil(aBase)) + continue; + + if(aBase->GetType() == VISU::TCOLOREDPRS3DCACHE){ + ColoredPrs3dCache_i* aCache = dynamic_cast(GetServant(aBase).in()); + theStr<GetMemoryMode(); + switch(aMode){ + case VISU::ColoredPrs3dCache::MINIMAL : anArgument = "VISU.ColoredPrs3dCache.MINIMAL"; break; + case VISU::ColoredPrs3dCache::LIMITED : anArgument = "VISU.ColoredPrs3dCache.LIMITED"; break; + } + theStr<GetLimitedMemory()<<") # (Mb)"<NewChildIterator(aSObject); + for(aChildIter->InitEx(false); aChildIter->More(); aChildIter->Next()){ + SALOMEDS::SObject_var aSObject = aChildIter->Value(); + CORBA::Object_var anObject = SObjectToObject(aSObject); + if (CORBA::is_nil(anObject)) + continue; + + ColoredPrs3dHolder_i* aServant = dynamic_cast(GetServant(anObject).in()); + if(!aServant) + continue; + + ColoredPrs3d_i* aDevice = aServant->GetPrs3dDevice(); + if(!aDevice) + continue; + + Result_i* aResult = aDevice->GetCResult(); + std::string aResultEntry = aResult->GetEntry(); + std::string aResultName = theEntry2NameMap[aResultEntry]; + + ColoredPrs3dHolder::BasicInput_var anInput = aServant->GetBasicInput(); + std::string anEntity; + switch(anInput->myEntity){ + case VISU::NODE : anEntity = "VISU.NODE"; break; + case VISU::EDGE : anEntity = "VISU.EDGE"; break; + case VISU::FACE : anEntity = "VISU.FACE"; break; + case VISU::CELL : anEntity = "VISU.CELL"; break; + } + + + theStr<myMeshName<<"', "<< + anEntity<<", '"<< + anInput->myFieldName<<"', "<< + anInput->myTimeStampNumber<<")"<< + endl; + + std::string aComment = aDevice->GetComment(); + theStr<GetName(); + theStr<GetType()){ + case VISU::TSCALARMAP: + if(ScalarMap_i* aServant = dynamic_cast(aDevice)){ + ScalarMapToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TDEFORMEDSHAPE: + if(DeformedShape_i* aServant = dynamic_cast(aDevice)){ + DeformedShapeToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TSTREAMLINES: + if(StreamLines_i* aServant = dynamic_cast(aDevice)){ + StreamLinesToPython(aSObject, aServant, theStr, theEntry2NameMap, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TSCALARMAPONDEFORMEDSHAPE: + if(ScalarMapOnDeformedShape_i* aServant = dynamic_cast(aDevice)){ + ScalarMapOnDeformedShapeToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TVECTORS: + if(Vectors_i* aServant = dynamic_cast(aDevice)){ + VectorsToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TISOSURFACES: + if(IsoSurfaces_i* aServant = dynamic_cast(aDevice)){ + IsoSurfacesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TCUTPLANES: + if(CutPlanes_i* aServant = dynamic_cast(aDevice)){ + CutPlanesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TCUTLINES: + if(CutLines_i* aServant = dynamic_cast(aDevice)){ + CutLinesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TPLOT3D: + if(Plot3D_i* aServant = dynamic_cast(aDevice)){ + Plot3DToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TGAUSSPOINTS: + if(GaussPoints_i* aServant = dynamic_cast(aDevice)){ + GaussPointsToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + } + theStr<GetName(); theStr< #include -#ifdef ENABLE_MULTIPR -#include "MULTIPR_API.hxx" -#endif - #ifdef _DEBUG_ static int MYDEBUG = 0; #else @@ -74,9 +71,12 @@ VISU::GaussPoints_i return aResult; try{ bool anIsEstimated = true; - VISU::Result_i::TInput* anInput = theResult->GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName, + theEntity, + theFieldName, + theTimeStampNumber); size_t aSize = anInput->GetTimeStampOnGaussPtsSize(theMeshName, - (VISU::TEntity)theEntity, + VISU::TEntity(theEntity), theFieldName, theTimeStampNumber, anIsEstimated); @@ -169,7 +169,7 @@ VISU::GaussPoints_i SetScaleFactor( aScaleFactor ); int aPrimitiveType = aResourceMgr->integerValue( "VISU", "point_sprite_primitive_type", GetPrimitiveType() ); - SetPrimitiveType( aPrimitiveType ); + SetPrimitiveType( VISU::GaussPoints::PrimitiveType(aPrimitiveType) ); vtkFloatingPointType aClamp = aResourceMgr->doubleValue( "VISU", "point_sprite_clamp", GetClamp() ); SetClamp( aClamp ); @@ -192,8 +192,8 @@ VISU::GaussPoints_i bool isColored = aResourceMgr->booleanValue( "VISU", "point_sprite_results", GetIsColored() ); SetIsColored( isColored ); - QColor aColor = aResourceMgr->colorValue( "VISU", "point_sprite_color", GetColor() ); - SetColor( aColor ); + QColor aColor = aResourceMgr->colorValue( "VISU", "point_sprite_color", GetQColor() ); + SetQColor( aColor ); vtkFloatingPointType anAlphaThreshold = aResourceMgr->doubleValue( "VISU", "point_sprite_alpha_threshold", GetAlphaThreshold() ); SetAlphaThreshold( anAlphaThreshold ); @@ -225,9 +225,6 @@ VISU::GaussPoints_i if(const GaussPoints_i* aPrs3d = dynamic_cast(theOrigin)){ GaussPoints_i* anOrigin = const_cast(aPrs3d); - // To restore the range after shallow copy of the pipeline mapper - // in the parent class - SetSourceRange(); SetIsActiveLocalScalarBar(anOrigin->GetIsActiveLocalScalarBar()); SetIsDispGlobalScalarBar(anOrigin->GetIsDispGlobalScalarBar()); @@ -275,7 +272,8 @@ VISU::GaussPoints_i SetBiColor(Storable::FindValue(theMap,"myIsBiColor").toInt()); SetSpacing(Storable::FindValue(theMap,"mySpacing").toDouble()); - SetPrimitiveType(Storable::FindValue(theMap,"myPrimitiveType").toInt()); + int aPrimitiveType = Storable::FindValue(theMap,"myPrimitiveType").toInt(); + SetPrimitiveType(VISU::GaussPoints::PrimitiveType(aPrimitiveType)); SetClamp(Storable::FindValue(theMap,"myClamp").toDouble()); SetMinSize(Storable::FindValue(theMap,"myMinSize").toDouble()); SetMaxSize(Storable::FindValue(theMap,"myMaxSize").toDouble()); @@ -293,7 +291,7 @@ VISU::GaussPoints_i int aRed = Storable::FindValue(theMap,"myColor.R").toInt(); int aGreen = Storable::FindValue(theMap,"myColor.G").toInt(); int aBlue = Storable::FindValue(theMap,"myColor.B").toInt(); - SetColor( QColor(aRed,aGreen,aBlue) ); + SetQColor( QColor(aRed, aGreen, aBlue) ); SetAlphaThreshold(Storable::FindValue(theMap,"myAlphaThreshold").toDouble()); @@ -333,14 +331,14 @@ VISU::GaussPoints_i Storable::DataToStream( theStr, "myFaceLimit", GetFaceLimit() ); Storable::DataToStream( theStr, "myIsColored", GetIsColored() ); - QColor aColor = GetColor(); + QColor aColor = GetQColor(); Storable::DataToStream( theStr, "myColor.R", aColor.red() ); Storable::DataToStream( theStr, "myColor.G", aColor.green() ); Storable::DataToStream( theStr, "myColor.B", aColor.blue() ); Storable::DataToStream( theStr, "myAlphaThreshold", GetAlphaThreshold() ); - Storable::DataToStream( theStr, "myMainTexture", GetMainTexture() ); - Storable::DataToStream( theStr, "myAlphaTexture", GetAlphaTexture() ); + Storable::DataToStream( theStr, "myMainTexture", GetQMainTexture() ); + Storable::DataToStream( theStr, "myAlphaTexture", GetQAlphaTexture() ); Storable::DataToStream( theStr, "myResolution", GetResolution() ); } @@ -354,7 +352,7 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- -int +CORBA::Long VISU::GaussPoints_i ::GetFaceLimit() { @@ -364,23 +362,28 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetFaceLimit( int theFaceLimit ) +::SetFaceLimit( CORBA::Long theFaceLimit ) { - if( myFaceLimit != theFaceLimit ){ - myFaceLimit = theFaceLimit; - myParamsTime.Modified(); - } + if( myFaceLimit == theFaceLimit ) + return; + + VISU::TSetModified aModified(this); + + myFaceLimit = theFaceLimit; + myParamsTime.Modified(); } //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetIsDeformed( bool theIsDeformed ) +::SetIsDeformed( CORBA::Boolean theIsDeformed ) { + VISU::TSetModified aModified(this); + myGaussPointsPL->SetIsDeformed( theIsDeformed ); } -bool +CORBA::Boolean VISU::GaussPoints_i ::GetIsDeformed() { @@ -390,12 +393,14 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetScaleFactor( vtkFloatingPointType theScaleFactor ) +::SetScaleFactor( CORBA::Double theScaleFactor ) { + VISU::TSetModified aModified(this); + myGaussPointsPL->SetScale( theScaleFactor ); } -vtkFloatingPointType +CORBA::Double VISU::GaussPoints_i ::GetScaleFactor() { @@ -405,24 +410,52 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- QColor VISU::GaussPoints_i -::GetColor() +::GetQColor() { return myColor; } +SALOMEDS::Color +VISU::GaussPoints_i +::GetColor() +{ + SALOMEDS::Color aColor; + aColor.R = myColor.red(); + aColor.G = myColor.green(); + aColor.B = myColor.blue(); + return aColor; +} + + +//---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetColor( const QColor& theColor ) +::SetQColor( const QColor& theColor ) { + if(myColor == theColor) + return; + + VISU::TSetModified aModified(this); + myColor = theColor; myParamsTime.Modified(); } +void +VISU::GaussPoints_i +::SetColor( const SALOMEDS::Color& theColor ) +{ + SetQColor(QColor(int(theColor.R), int(theColor.G), int(theColor.B))); +} + + //---------------------------------------------------------------------------- void VISU::GaussPoints_i ::SetIsColored( bool theIsColored ) { + VISU::TSetModified aModified(this); + myGaussPointsPL->SetIsColored( theIsColored ); } @@ -438,44 +471,74 @@ bool VISU::GaussPoints_i ::SetMainTexture( const QString& theMainTexture ) { - bool update = myMainTexture != theMainTexture; - myMainTexture = theMainTexture; - return update; + if(myMainTexture != theMainTexture){ + VISU::TSetModified aModified(this); + + myMainTexture = theMainTexture; + myParamsTime.Modified(); + return true; + } + + return false; } -const QString& +QString VISU::GaussPoints_i -::GetMainTexture() +::GetQMainTexture() { return myMainTexture; } +char* +VISU::GaussPoints_i +::GetMainTexture() +{ + return CORBA::string_dup(myMainTexture.latin1()); +} + + //---------------------------------------------------------------------------- bool VISU::GaussPoints_i ::SetAlphaTexture( const QString& theAlphaTexture ) { - bool update = myAlphaTexture != theAlphaTexture; - myAlphaTexture = theAlphaTexture; - return update; + if(myAlphaTexture != theAlphaTexture){ + VISU::TSetModified aModified(this); + + myAlphaTexture = theAlphaTexture; + myParamsTime.Modified(); + return true; + } + + return false; } -const QString& +QString VISU::GaussPoints_i -::GetAlphaTexture() +::GetQAlphaTexture() { return myAlphaTexture; } +char* +VISU::GaussPoints_i +::GetAlphaTexture() +{ + return CORBA::string_dup(myAlphaTexture.latin1()); +} + + //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetAlphaThreshold( vtkFloatingPointType theAlphaThreshold ) +::SetAlphaThreshold( CORBA::Double theAlphaThreshold ) { + VISU::TSetModified aModified(this); + myGaussPointsPL->SetAlphaThreshold( theAlphaThreshold ); } -vtkFloatingPointType +CORBA::Double VISU::GaussPoints_i ::GetAlphaThreshold() { @@ -485,12 +548,14 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetResolution( int theResolution ) +::SetResolution( CORBA::Long theResolution ) { + VISU::TSetModified aModified(this); + myGaussPointsPL->SetResolution( theResolution ); } -int +CORBA::Long VISU::GaussPoints_i ::GetResolution() { @@ -500,16 +565,26 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetPrimitiveType(int thePrimitiveType) +::SetPrimitiveType(VISU::GaussPoints::PrimitiveType thePrimitiveType) { + VISU::TSetModified aModified(this); + myGaussPointsPL->SetPrimitiveType( thePrimitiveType ); } -int +VISU::GaussPoints::PrimitiveType VISU::GaussPoints_i ::GetPrimitiveType() { - return myGaussPointsPL->GetPrimitiveType(); + int aPrimitiveType = myGaussPointsPL->GetPrimitiveType(); + + if(aPrimitiveType == VISU_OpenGLPointSpriteMapper::OpenGLPoint) + return VISU::GaussPoints::POINT; + + if(aPrimitiveType == VISU_OpenGLPointSpriteMapper::GeomSphere) + return VISU::GaussPoints::SPHERE; + + return VISU::GaussPoints::SPRITE; } //---------------------------------------------------------------------------- @@ -523,12 +598,14 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetClamp(vtkFloatingPointType theClamp) +::SetClamp(CORBA::Double theClamp) { + VISU::TSetModified aModified(this); + myGaussPointsPL->SetClamp( theClamp ); } -vtkFloatingPointType +CORBA::Double VISU::GaussPoints_i ::GetClamp() { @@ -538,12 +615,14 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetGeomSize( vtkFloatingPointType theGeomSize ) +::SetGeomSize( CORBA::Double theGeomSize ) { + VISU::TSetModified aModified(this); + myGaussPointsPL->SetSize( theGeomSize ); } -vtkFloatingPointType +CORBA::Double VISU::GaussPoints_i ::GetGeomSize() { @@ -553,12 +632,14 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetMinSize( vtkFloatingPointType theMinSize ) +::SetMinSize( CORBA::Double theMinSize ) { + VISU::TSetModified aModified(this); + myGaussPointsPL->SetMinSize( theMinSize ); } -vtkFloatingPointType +CORBA::Double VISU::GaussPoints_i ::GetMinSize() { @@ -568,12 +649,14 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetMaxSize( vtkFloatingPointType theMaxSize ) +::SetMaxSize( CORBA::Double theMaxSize ) { + VISU::TSetModified aModified(this); + myGaussPointsPL->SetMaxSize( theMaxSize ); } -vtkFloatingPointType +CORBA::Double VISU::GaussPoints_i ::GetMaxSize() { @@ -583,12 +666,14 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetMagnification( vtkFloatingPointType theMagnification ) +::SetMagnification( CORBA::Double theMagnification ) { + VISU::TSetModified aModified(this); + myGaussPointsPL->SetMagnification( theMagnification ); } -vtkFloatingPointType +CORBA::Double VISU::GaussPoints_i ::GetMagnification() { @@ -598,12 +683,14 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetMagnificationIncrement( vtkFloatingPointType theIncrement ) +::SetMagnificationIncrement( CORBA::Double theIncrement ) { + VISU::TSetModified aModified(this); + myGaussPointsPL->SetMagnificationIncrement( theIncrement ); } -vtkFloatingPointType +CORBA::Double VISU::GaussPoints_i ::GetMagnificationIncrement() { @@ -615,72 +702,28 @@ void VISU::GaussPoints_i ::DoSetInput(bool theIsInitilizePipe, bool theReInit) { - static string aStrPrev = ""; - static VISU::Result_i::TInput* anInputPrev = NULL; - - // MULTIPR - VISU::Result_i::TInput* anInput = NULL; -#ifdef ENABLE_MULTIPR - if (GetCResult()->IsDistributedMEDMultipr()) - { - vector aListMEDFiles = GetCResult()->GetCurrentRepresentationMultipr(); - - string aStrCurrent = ""; - for (unsigned i = 0 ; i < aListMEDFiles.size() ; i++) - { - aStrCurrent +=aListMEDFiles[i]; - } - aStrCurrent += GetCMeshName(); - aStrCurrent += GetCFieldName(); - if (aStrPrev != aStrCurrent) - { - if (anInputPrev != NULL) delete anInputPrev; - - char aTmpFilename[256]; - sprintf(aTmpFilename, "__tmp.med"); - - int res = multipr::merge(aListMEDFiles, GetCMeshName().c_str(), GetCFieldName().c_str(), aTmpFilename); - if (res == 0) throw std::runtime_error("empty mesh"); - - anInput = CreateConvertor(aTmpFilename); - anInput->Build(); - anInputPrev = anInput; - - aStrPrev = aStrCurrent; - } - else - { - anInput = anInputPrev; - } - } - else -#endif - { - anInput = GetCResult()->GetInput(); - } - + VISU::Result_i::PInput anInput = GetCResult()->GetInput(GetCMeshName(), + GetEntity(), + GetCFieldName(), + GetTimeStampNumber()); if(!anInput) throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!"); - SetField(anInput->GetField(GetCMeshName(),GetTEntity(),GetCFieldName())); + SetField(anInput->GetField(GetCMeshName(), + GetTEntity(), + GetCFieldName())); if(!GetField()) throw std::runtime_error("There is no Field with the parameters !!!"); VISU::PGaussPtsIDMapper aGaussPtsIDMapper = - anInput->GetTimeStampOnGaussPts(GetCMeshName(),GetTEntity(),GetCFieldName(),GetTimeStampNumber()); - + anInput->GetTimeStampOnGaussPts(GetCMeshName(), + GetTEntity(), + GetCFieldName(), + GetTimeStampNumber()); if(!aGaussPtsIDMapper) throw std::runtime_error("There is no TimeStamp with the parameters !!!"); GetSpecificPL()->SetGaussPtsIDMapper(aGaussPtsIDMapper); - if(theIsInitilizePipe){ - GetSpecificPL()->Init(); - } - GetCResult()->MinMaxConnect(this); - - // To update scalar range according to the new input - if(!IsTimeStampFixed() || theReInit) - SetSourceRange(); } @@ -829,10 +872,15 @@ VISU::GaussPoints_i anActor->SetBarVisibility(true); GetPipeLine()->GetMapper()->SetScalarVisibility(1); - vtkFloatingPointType aRange[2]; - GetSpecificPL()->GetSourceRange(aRange); - aScalarBarCtrl->SetRangeLocal(aRange); - + if(IsRangeFixed()){ + vtkFloatingPointType* aRange = GetSpecificPL()->GetScalarRange(); + aScalarBarCtrl->SetRangeLocal(aRange); + }else{ + vtkFloatingPointType aRange[2]; + GetSpecificPL()->GetSourceRange(aRange); + aScalarBarCtrl->SetRangeLocal(aRange); + } + TMinMax aTMinMax(-VTK_LARGE_FLOAT,VTK_LARGE_FLOAT); bool anIsMinMaxDone = IsGlobalRangeDefined(); if(anIsMinMaxDone) @@ -913,46 +961,62 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetTextures( const QString& theMainTexture, - const QString& theAlphaTexture ) +::SetQTextures( const QString& theMainTexture, + const QString& theAlphaTexture ) { bool updateMainTexture = SetMainTexture( theMainTexture ); bool updateAlphaTexture = SetAlphaTexture( theAlphaTexture ); if( !updateMainTexture && !updateAlphaTexture ) return; + VISU::TSetModified aModified(this); + using namespace VISU; - TTextureValue aTextureValue = GetTexture(theMainTexture,theAlphaTexture); + TTextureValue aTextureValue = GetTexture(theMainTexture, theAlphaTexture); myGaussPointsPL->SetImageData( aTextureValue.GetPointer() ); } +void +VISU::GaussPoints_i +::SetTextures( const char* theMainTexture, + const char* theAlphaTexture ) +{ + SetQTextures(theMainTexture, theAlphaTexture); +} + //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::SetIsActiveLocalScalarBar(const bool theIsActiveLocalScalarBar) +::SetIsActiveLocalScalarBar(CORBA::Boolean theIsActiveLocalScalarBar) { - if(myIsActiveLocalScalarBar != theIsActiveLocalScalarBar){ - myIsActiveLocalScalarBar = theIsActiveLocalScalarBar; - myParamsTime.Modified(); - } + if(myIsActiveLocalScalarBar == theIsActiveLocalScalarBar) + return; + + VISU::TSetModified aModified(this); + + myIsActiveLocalScalarBar = theIsActiveLocalScalarBar; + myParamsTime.Modified(); } -bool +CORBA::Boolean VISU::GaussPoints_i -::GetIsActiveLocalScalarBar() const +::GetIsActiveLocalScalarBar() { return myIsActiveLocalScalarBar; } void VISU::GaussPoints_i -::SetIsDispGlobalScalarBar(const bool theIsDispGlobalScalarBar) +::SetIsDispGlobalScalarBar(CORBA::Boolean theIsDispGlobalScalarBar) { - if(myIsDispGlobalScalarBar != theIsDispGlobalScalarBar){ - myIsDispGlobalScalarBar = theIsDispGlobalScalarBar; - myParamsTime.Modified(); - } + if(myIsDispGlobalScalarBar == theIsDispGlobalScalarBar) + return; + + VISU::TSetModified aModified(this); + + myIsDispGlobalScalarBar = theIsDispGlobalScalarBar; + myParamsTime.Modified(); } bool @@ -967,13 +1031,18 @@ void VISU::GaussPoints_i ::SetSourceRange() { + VISU::TSetModified aModified(this); + if(IsTimeStampFixed() || GetIsActiveLocalScalarBar()) - GetSpecificPL()->SetSourceRange(); + ProcessVoidEvent(new TVoidMemFunEvent + (GetSpecificPL(), &VISU_ColoredPL::SetSourceRange)); else{ TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode()); vtkFloatingPointType aScalarRange[2] = {aTMinMax.first, aTMinMax.second}; - GetSpecificPL()->SetScalarRange(aScalarRange); + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange)); } + UseFixedRange(false); } CORBA::Double @@ -1006,9 +1075,9 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- -bool +CORBA::Boolean VISU::GaussPoints_i -::GetIsDispGlobalScalarBar() const +::GetIsDispGlobalScalarBar() { return myIsDispGlobalScalarBar; } @@ -1016,12 +1085,14 @@ VISU::GaussPoints_i void VISU::GaussPoints_i -::SetBiColor(bool theIsBiColor) +::SetBiColor(CORBA::Boolean theIsBiColor) { + VISU::TSetModified aModified(this); + GetSpecificPL()->SetBicolor(theIsBiColor); } -bool +CORBA::Boolean VISU::GaussPoints_i ::GetBiColor() { @@ -1030,26 +1101,20 @@ VISU::GaussPoints_i void VISU::GaussPoints_i -::SetSpacing(const vtkFloatingPointType theSpacing) +::SetSpacing(CORBA::Double theSpacing) { - if(!VISU::CheckIsSameValue(mySpacing, theSpacing)){ - mySpacing = theSpacing; - myParamsTime.Modified(); - } -} + if(VISU::CheckIsSameValue(mySpacing, theSpacing)) + return; -vtkFloatingPointType -VISU::GaussPoints_i -::GetSpacing() const -{ - return mySpacing; + VISU::TSetModified aModified(this); + + mySpacing = theSpacing; + myParamsTime.Modified(); } -//---------------------------------------------------------------------------- -void +CORBA::Double VISU::GaussPoints_i -::UpdateMinMax() +::GetSpacing() { - MinMaxCunsomer::UpdateMinMax(); - UpdateActors(); + return mySpacing; } diff --git a/src/VISU_I/VISU_GaussPoints_i.hh b/src/VISU_I/VISU_GaussPoints_i.hh index b4b150ec..767e4c52 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -27,7 +27,6 @@ #ifndef VISU_GaussPoints_i_HeaderFile #define VISU_GaussPoints_i_HeaderFile -#include "VISU_Result_i.hh" #include "VISU_ColoredPrs3d_i.hh" #include "VISU_GaussPtsActorFactory.h" @@ -40,9 +39,8 @@ namespace VISU { //! Class of the Gauss Points presentation. class VISU_I_EXPORT GaussPoints_i : public virtual POA_VISU::GaussPoints, - public virtual VISU::TGaussPtsActorFactory, - public virtual MinMaxCunsomer, - public virtual ColoredPrs3d_i + public virtual TGaussPtsActorFactory, + public virtual ColoredPrs3d_i { static int myNbPresent; GaussPoints_i(const GaussPoints_i&); @@ -72,31 +70,37 @@ namespace VISU GetMemorySize(); //---------------------------------------------------------------------------- - int + CORBA::Long GetFaceLimit(); void - SetFaceLimit( int theFaceLimit ); + SetFaceLimit( CORBA::Long theFaceLimit ); - bool + CORBA::Boolean GetIsDeformed(); void - SetIsDeformed( bool theIsDeformed ); + SetIsDeformed( CORBA::Boolean theIsDeformed ); - vtkFloatingPointType + CORBA::Double GetScaleFactor(); void - SetScaleFactor( vtkFloatingPointType theScaleFactor ); + SetScaleFactor( CORBA::Double theScaleFactor ); //! Get color for Geometry mode of the presentation. - QColor + SALOMEDS::Color GetColor(); + QColor + GetQColor(); + //! Set color for Geometry mode of the presentation. void - SetColor( const QColor& theColor ); + SetColor( const SALOMEDS::Color& theColor ); + + void + SetQColor( const QColor& theColor ); //! Get flag indicating which mode of the presentation is active. /*! When Results mode is active, returns true. Geometry - false. */ @@ -112,7 +116,10 @@ namespace VISU SetMainTexture( const QString& theMainTexture ); //! Get path to the image using for Main Point Sprite texture. - const QString& + QString + GetQMainTexture(); + + char* GetMainTexture(); //! Set path to the image using for Alpha Point Sprite texture. @@ -120,34 +127,41 @@ namespace VISU SetAlphaTexture( const QString& theAlphaTexture ); //! Get path to the image using for Alpha Point Sprite texture. - const QString& + QString + GetQAlphaTexture(); + + char* GetAlphaTexture(); //! Convert Main and AlphaMask images to VTI format and set them to pipeline. void - SetTextures( const QString& theMainTexture, - const QString& theAlphaTexture ); + SetQTextures( const QString& theMainTexture, + const QString& theAlphaTexture ); + + void + SetTextures( const char* theMainTexture, + const char* theAlphaTexture ); //! Redirect the request to VISU_GaussPointsPL::SetAlphaThreshold. void - SetAlphaThreshold(vtkFloatingPointType theAlphaThreshold); + SetAlphaThreshold(CORBA::Double theAlphaThreshold); //! Redirect the request to VISU_GaussPointsPL::GetAlphaThreshold. - vtkFloatingPointType + CORBA::Double GetAlphaThreshold(); //! Redirect the request to VISU_GaussPointsPL::SetResolution. void - SetResolution(int theResolution); + SetResolution(CORBA::Long theResolution); //! Redirect the request to VISU_GaussPointsPL::GetResolution. - int + CORBA::Long GetResolution(); void - SetPrimitiveType(int thePrimitiveType); + SetPrimitiveType(VISU::GaussPoints::PrimitiveType thePrimitiveType); - int + VISU::GaussPoints::PrimitiveType GetPrimitiveType(); //! Redirect the request to VISU_GaussPointsPL::GetMaximumSupportedSize. @@ -156,83 +170,83 @@ namespace VISU //! Redirect the request to VISU_GaussPointsPL::SetClamp. void - SetClamp(vtkFloatingPointType theClamp); + SetClamp(CORBA::Double theClamp); //! Redirect the request to VISU_GaussPointsPL::GetClamp. - vtkFloatingPointType + CORBA::Double GetClamp(); //! Redirect the request to VISU_GaussPointsPL::SetSize. void - SetGeomSize(vtkFloatingPointType theGeomSize); + SetGeomSize(CORBA::Double theGeomSize); //! Redirect the request to VISU_GaussPointsPL::GetSize. - vtkFloatingPointType + CORBA::Double GetGeomSize(); //! Redirect the request to VISU_GaussPointsPL::SetMinSize. void - SetMinSize(vtkFloatingPointType theMinSize); + SetMinSize(CORBA::Double theMinSize); //! Redirect the request to VISU_GaussPointsPL::GetMinSize. - vtkFloatingPointType + CORBA::Double GetMinSize(); //! Redirect the request to VISU_GaussPointsPL::SetMaxSize. void - SetMaxSize(vtkFloatingPointType theMaxSize); + SetMaxSize(CORBA::Double theMaxSize); //! Redirect the request to VISU_GaussPointsPL::GetMaxSize. - vtkFloatingPointType + CORBA::Double GetMaxSize(); //! Redirect the request to VISU_GaussPointsPL::SetMagnification. void - SetMagnification(vtkFloatingPointType theMagnification); + SetMagnification(CORBA::Double theMagnification); //! Redirect the request to VISU_GaussPointsPL::GetMagnification. - vtkFloatingPointType + CORBA::Double GetMagnification(); //! Redirect the request to VISU_GaussPointsPL::SetMagnificationIncrement. void - SetMagnificationIncrement(vtkFloatingPointType theIncrement); + SetMagnificationIncrement(CORBA::Double theIncrement); //! Redirect the request to VISU_GaussPointsPL::GetMagnificationIncrement. - vtkFloatingPointType + CORBA::Double GetMagnificationIncrement(); //! Set flag indicating which scalar bar is active. void - SetIsActiveLocalScalarBar(const bool theFlag); + SetIsActiveLocalScalarBar(CORBA::Boolean theIsActiveLocalScalarBar); //! Get flag indicating which scalar bar is active. - bool - GetIsActiveLocalScalarBar() const; + CORBA::Boolean + GetIsActiveLocalScalarBar(); //! Set flag indicating visibility of global scalar bar. void - SetIsDispGlobalScalarBar(const bool theFlag); + SetIsDispGlobalScalarBar(CORBA::Boolean theIsDispGlobalScalarBar); //! Get flag indicating visibility of global scalar bar. - bool - GetIsDispGlobalScalarBar() const; + CORBA::Boolean + GetIsDispGlobalScalarBar(); //! Redirect the request to VISU_GaussPointsPL::SetBicolor. void - SetBiColor(bool theIsBiColor); + SetBiColor(CORBA::Boolean theIsBiColor); //! Redirect the request to VISU_GaussPointsPL::GetBicolor. - bool + CORBA::Boolean GetBiColor(); //! Set value of the distance between global and local scalar bars. void - SetSpacing(const vtkFloatingPointType theSpacing); + SetSpacing(CORBA::Double theSpacing); //! Get value of the distance between global and local scalar bars. - vtkFloatingPointType - GetSpacing() const; + CORBA::Double + GetSpacing(); //! Let know is the global range is already calculated bool @@ -250,11 +264,6 @@ namespace VISU void SetSourceRange(); - //! To update the min / max automatically - virtual - void - UpdateMinMax(); - VISU_GaussPointsPL* GetSpecificPL() const { diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index dcd5ae50..034644e1 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -82,9 +82,10 @@ UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception); // STL Includes #include -using namespace std; +#include +#include +namespace filesystem = boost::filesystem; -static QFileInfo aFileInfo; #ifdef _DEBUG_ static int MYDEBUG = 0; @@ -108,10 +109,13 @@ GetImpl(CORBA::ORB_ptr theORB, namespace VISU { //---------------------------------------------------------------------------- - static string VisuTmpDir; + static std::string VISU_TMP_DIR; static CORBA::Boolean myIsMultiFile; - const CORBA::Boolean IsMultifile() { return myIsMultiFile;} + const CORBA::Boolean IsMultiFile() + { + return myIsMultiFile; + } //---------------------------------------------------------------------------- _PTR(SComponent) @@ -192,23 +196,41 @@ namespace VISU void RegistryStorable() { - Storable::Registry(Result_i::myComment.c_str(),&(Result_i::Restore)); - Storable::Registry(Mesh_i::myComment.c_str(),&(Mesh_i::Restore)); - Storable::Registry(ScalarMap_i::myComment.c_str(),&(Restore)); - Storable::Registry(GaussPoints_i::myComment.c_str(),&(Restore)); - Storable::Registry(DeformedShape_i::myComment.c_str(),&(Restore)); - Storable::Registry(CutPlanes_i::myComment.c_str(),&(Restore)); - Storable::Registry(CutLines_i::myComment.c_str(),&(Restore)); - Storable::Registry(IsoSurfaces_i::myComment.c_str(),&(Restore)); - Storable::Registry(StreamLines_i::myComment.c_str(),&(Restore)); - Storable::Registry(Plot3D_i::myComment.c_str(),&(Restore)); - Storable::Registry(Vectors_i::myComment.c_str(),&(Restore)); - Storable::Registry(Table_i::myComment.c_str(),&(Table_i::Restore)); - Storable::Registry(Curve_i::myComment.c_str(),&(Curve_i::Restore)); - Storable::Registry(Container_i::myComment.c_str(),&(Container_i::Restore)); - Storable::Registry(ScalarMapOnDeformedShape_i::myComment.c_str(),&(Restore)); - Storable::Registry(ColoredPrs3dHolder_i::myComment.c_str(),&(ColoredPrs3dHolder_i::Restore)); - Storable::Registry(ColoredPrs3dCache_i::myComment.c_str(),&(ColoredPrs3dCache_i::Restore)); + Storable::RegistryStorableEngine(Result_i::myComment.c_str(),&(Result_i::StorableEngine)); + + Storable::RegistryStorableEngine(Mesh_i::myComment.c_str(),&(Mesh_i::StorableEngine)); + + Storable::RegistryStorableEngine(ScalarMap_i::myComment.c_str(),&(StorableEngine)); + Storable::RegistryStorableEngine(GaussPoints_i::myComment.c_str(),&(StorableEngine)); + Storable::RegistryStorableEngine(DeformedShape_i::myComment.c_str(),&(StorableEngine)); + Storable::RegistryStorableEngine(CutPlanes_i::myComment.c_str(),&(StorableEngine)); + Storable::RegistryStorableEngine(CutLines_i::myComment.c_str(),&(StorableEngine)); + Storable::RegistryStorableEngine(IsoSurfaces_i::myComment.c_str(),&(StorableEngine)); + Storable::RegistryStorableEngine(StreamLines_i::myComment.c_str(),&(StorableEngine)); + Storable::RegistryStorableEngine(Plot3D_i::myComment.c_str(),&(StorableEngine)); + Storable::RegistryStorableEngine(Vectors_i::myComment.c_str(),&(StorableEngine)); + Storable::RegistryStorableEngine(ScalarMapOnDeformedShape_i::myComment.c_str(),&(StorableEngine)); + + Storable::RegistryStorableEngine(ColoredPrs3dHolder_i::myComment.c_str(),&(ColoredPrs3dHolder_i::StorableEngine)); + Storable::RegistryStorableEngine(ColoredPrs3dCache_i::myComment.c_str(),&(ColoredPrs3dCache_i::StorableEngine)); + + Storable::RegistryStorableEngine(Table_i::myComment.c_str(),&(Table_i::StorableEngine)); + Storable::RegistryStorableEngine(Curve_i::myComment.c_str(),&(Curve_i::StorableEngine)); + Storable::RegistryStorableEngine(Container_i::myComment.c_str(),&(Container_i::StorableEngine)); + } + + + //---------------------------------------------------------------------------- + SALOMEDS::ListOfFileNames* + GetListOfFileNames(const Result_i::TFileNames& theFileNames) + { + SALOMEDS::ListOfFileNames_var aListOfFileNames = new SALOMEDS::ListOfFileNames; + if(!theFileNames.empty()){ + aListOfFileNames->length(theFileNames.size()); + for(int aCounter = theFileNames.size(); aCounter > 0; aCounter--) + aListOfFileNames[aCounter-1] = theFileNames[aCounter-1].c_str(); + } + return aListOfFileNames._retn(); } @@ -296,7 +318,7 @@ namespace VISU ::Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile & theStream, const char* theURL, - bool isMultiFile) + CORBA::Boolean theIsMultiFile) { Mutex mt(myMutex); SALOMEDS::Study_var aStudy = theComponent->GetStudy(); @@ -310,12 +332,10 @@ namespace VISU } - string aDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir(); - TCollection_AsciiString aTmpDir (const_cast(aDir.c_str())); - VisuTmpDir = aTmpDir.ToCString(); + VISU_TMP_DIR = theIsMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir(); SALOMEDS::ListOfFileNames_var aSeq = - SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.ToCString(),isMultiFile); - myIsMultiFile = isMultiFile; + SALOMEDS_Tool::PutStreamToFiles(theStream, VISU_TMP_DIR, theIsMultiFile); + myIsMultiFile = theIsMultiFile; return true; } @@ -326,9 +346,9 @@ namespace VISU ::LoadASCII(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile & theStream, const char* theURL, - bool isMultiFile) + bool theIsMultiFile) { - return Load(theComponent, theStream, theURL, isMultiFile); + return Load(theComponent, theStream, theURL, theIsMultiFile); } @@ -336,16 +356,18 @@ namespace VISU char* VISU_Gen_i ::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, - const char* aLocalPersistentID, - CORBA::Boolean isMultiFile, - CORBA::Boolean isASCII) + const char* theLocalPersistentID, + CORBA::Boolean theIsMultiFile, + CORBA::Boolean theIsASCII) { CORBA::String_var aString(""); - if(strcmp(aLocalPersistentID,"") != 0) { - Mutex mt(myMutex); - Storable* aStorable = - Storable::Create(theSObject,VisuTmpDir.c_str(),aLocalPersistentID); - if(aStorable != NULL) aString = aStorable->GetID(); + if(strcmp(theLocalPersistentID,"") != 0) { + Storable* aStorable = Storable::Create(theSObject, + theLocalPersistentID, + VISU_TMP_DIR, + theIsMultiFile); + if(aStorable != NULL) + aString = aStorable->GetID(); } return aString._retn(); } @@ -358,64 +380,36 @@ namespace VISU const char* theURL, bool theIsMultiFile) { - Mutex mt(myMutex); - string aTmpDir = theURL; - if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "< TFileNames; - TFileNames aFileNames; - TFileNames aFiles; + if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - theURL = '"<GetStudy(); SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent); for (; anIter->More(); anIter->Next()) { - SALOMEDS::SObject_var gotBranch = anIter->Value(); - CORBA::Object_var anObj = SObjectToObject(gotBranch); - if(CORBA::is_nil(anObj)) continue; + SALOMEDS::SObject_var aSObject = anIter->Value(); + CORBA::Object_var anObj = SObjectToObject(aSObject); if(Result_i* aResult = dynamic_cast(GetServant(anObj).in())){ - switch(aResult->GetCreationId()){ - case Result_i::eImportFile: - case Result_i::eCopyAndImportFile: { - const QFileInfo& aFileInfo = aResult->GetFileInfo(); - const std::string& aName = aResult->GetName(); - std::string aFileName = std::string("_") + aName; - std::string aFile = aFileInfo.filePath().latin1(); - if(theIsMultiFile){ - aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()) + aFileName; - - std::ostringstream aStream; - aStream<<"cp "<Save(theComponent, + theURL, + theIsMultiFile, + false, + aFileNames, + aFiles); } } - if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.size() - "<length(aFileNames.size()); - for(int aCounter = aFileNames.size(); aCounter > 0; aCounter--) - aListOfFileNames[aCounter-1] = aFileNames[aCounter-1].c_str(); - } - - SALOMEDS::ListOfFileNames_var aListOfFiles = new SALOMEDS::ListOfFileNames; - aListOfFiles->length(aFiles.size()); - if(!aFiles.empty()){ - for(int aCounter = aFileNames.size(); aCounter > 0; aCounter--) - aListOfFiles[aCounter-1] = aFiles[aCounter-1].c_str(); - } - SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0); + if(aFileNames.empty()) + return aStreamFile._retn(); + + SALOMEDS::ListOfFileNames_var aListOfFileNames = GetListOfFileNames(aFileNames); + SALOMEDS::ListOfFileNames_var aListOfFiles = GetListOfFileNames(aFiles); + if(theIsMultiFile) - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aListOfFiles.in(), theIsMultiFile); + aStreamFile = SALOMEDS_Tool::PutFilesToStream(theURL, aListOfFiles.in(), theIsMultiFile); else aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFiles.in(), aListOfFileNames.in()); @@ -428,60 +422,40 @@ namespace VISU VISU_Gen_i ::SaveASCII(SALOMEDS::SComponent_ptr theComponent, const char* theURL, - bool isMultiFile) + bool theIsMultiFile) { - Mutex mt(myMutex); - string aDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir(); - TCollection_AsciiString aTmpDir (const_cast(aDir.c_str())); - if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<GetStudy(); - SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent); - for (; itBig->More(); itBig->Next()) { - SALOMEDS::SObject_var gotBranch = itBig->Value(); - CORBA::Object_var anObj = SObjectToObject(gotBranch); - if(CORBA::is_nil(anObj)) continue; - if(Result_i* pResult = dynamic_cast(GetServant(anObj).in())){ - switch(pResult->GetCreationId()){ - case Result_i::eImportFile: - case Result_i::eCopyAndImportFile: { - const QFileInfo& aFileInfo = pResult->GetFileInfo(); - QString aPrefix(""); - if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()).c_str(); - QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str(); - QString tmpDir = QDir::convertSeparators( QString(aTmpDir.ToCString()) );; - static QString aCommand; - aCommand.sprintf(" %s %s%s",aFileInfo.filePath().latin1(),tmpDir.latin1(),aFileName.latin1()); - aCommand = QDir::convertSeparators( aCommand ); - aCommand.prepend( COPY_COMMAND ); - - if(system(aCommand.latin1())){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Can't execute the command :"<NewChildIterator(theComponent); + for (; anIter->More(); anIter->Next()) { + SALOMEDS::SObject_var aSObject = anIter->Value(); + CORBA::Object_var anObj = SObjectToObject(aSObject); + if(Result_i* aResult = dynamic_cast(GetServant(anObj).in())){ + aResult->Save(theComponent, + anURL, + theIsMultiFile, + true, + aFileNames, + aFiles); } } + if(MYDEBUG) MESSAGE("VISU_Gen_i::SaveASCII - aFileNames.size() - "< 0){ - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - aSeq->length(aFileNames.Length()); - for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--) - aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString()); - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile); - if(!isMultiFile) - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true); - } + if(aFileNames.empty()) + return aStreamFile._retn(); + + SALOMEDS::ListOfFileNames_var aListOfFileNames = GetListOfFileNames(aFileNames); + aStreamFile = SALOMEDS_Tool::PutFilesToStream(anURL, aListOfFileNames.in(), theIsMultiFile); + + if(!theIsMultiFile) + SALOMEDS_Tool::RemoveTemporaryFiles(anURL, aListOfFileNames, true); + return aStreamFile._retn(); } @@ -490,20 +464,16 @@ namespace VISU char* VISU_Gen_i ::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, - const char* IORString, - CORBA::Boolean isMultiFile, - CORBA::Boolean isASCII) + const char* theIORString, + CORBA::Boolean theIsMultiFile, + CORBA::Boolean theIsASCII) { - CORBA::String_var aString(IORString); - if(strcmp(IORString,"") != 0){ - CORBA::ORB_ptr anORB = GetORB(); - CORBA::Object_var anObj = anORB->string_to_object(aString); - if(!CORBA::is_nil(anObj)){ - if(Storable* pStorable = dynamic_cast(GetServant(anObj).in())){ - Mutex mt(myMutex); - aString = pStorable->ToString().c_str(); - return aString._retn(); - } + CORBA::String_var aString(""); + if(strcmp(theIORString, "") != 0){ + CORBA::Object_var anObj = GetORB()->string_to_object(theIORString); + if(Storable* aStorable = dynamic_cast(GetServant(anObj).in())){ + aString = aStorable->ToString().c_str(); + return aString._retn(); } } return aString._retn(); @@ -621,7 +591,6 @@ namespace VISU { if(myStudyDocument->GetProperties()->IsLocked()) return SALOMEDS::SObject::_nil(); - Mutex mt(myMutex); SALOMEDS::SObject_var aRes = VISU::ImportTables(theFileName,myStudyDocument); return aRes._retn(); } @@ -644,17 +613,21 @@ namespace VISU { 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); - if(pResult->Create(theFileName) != NULL) - return pResult->_this(); - else{ - pResult->_remove_ref(); - return VISU::Result::_nil(); - } + + Result_i* aResult = Result_i::New(myStudyDocument, + Result_i::eFile, + Result_i::eImportFile, + true, + true, + true, + true); + + if(aResult->Create(theFileName) != NULL) + return aResult->_this(); + else + aResult->_remove_ref(); + + return VISU::Result::_nil(); } @@ -665,18 +638,21 @@ namespace VISU { 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_i* aResult = Result_i::New(myStudyDocument, + Result_i::eFile, + Result_i::eImportFile, + false, + true, + true, + true); + + if(aResult->Create(theFileName) != NULL) + return aResult->_this(); + else + aResult->_remove_ref(); + + return VISU::Result::_nil(); } @@ -687,15 +663,20 @@ namespace VISU { if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); - Mutex mt(myMutex); - VISU::Result_var aResult; - aFileInfo.setFile(theFileName); - Result_i* pResult = new Result_i(myStudyDocument, - Result_i::eRestoredFile, - Result_i::eCopyAndImportFile); - if(pResult->Create(theFileName) != NULL) - aResult = pResult->_this(); - return aResult._retn(); + + Result_i* aResult = Result_i::New(myStudyDocument, + Result_i::eRestoredFile, + Result_i::eCopyAndImportFile, + true, + true, + true, + true); + if(aResult->Create(theFileName) != NULL) + return aResult->_this(); + else + aResult->_remove_ref(); + + return VISU::Result::_nil(); } @@ -706,16 +687,20 @@ namespace VISU { if (myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); - Mutex mt(myMutex); - Result_i* pResult = new Result_i(myStudyDocument, - Result_i::eComponent, - Result_i::eImportMed); - if (pResult->Create(theMedSObject) != NULL) { - return pResult->_this(); - } else { - pResult->_remove_ref(); - return VISU::Result::_nil(); - } + + Result_i* aResult = Result_i::New(myStudyDocument, + Result_i::eComponent, + Result_i::eImportMed, + true, + true, + true, + true); + if (aResult->Create(theMedSObject) != NULL) + return aResult->_this(); + else + aResult->_remove_ref(); + + return VISU::Result::_nil(); } @@ -726,16 +711,21 @@ namespace VISU { if (myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); - Mutex mt(myMutex); - Result_i* pResult = new Result_i(myStudyDocument, - Result_i::eComponent, - Result_i::eImportMedField); - if (pResult->Create(theField) != NULL) { - return pResult->_this(); - } else { - pResult->_remove_ref(); - return VISU::Result::_nil(); - } + + Result_i* aResult = Result_i::New(myStudyDocument, + Result_i::eComponent, + Result_i::eImportMedField, + true, + true, + true, + true); + + if (aResult->Create(theField) != NULL) + return aResult->_this(); + else + aResult->_remove_ref(); + + return VISU::Result::_nil(); } void @@ -746,13 +736,15 @@ namespace VISU const std::string& theSubMeshName, // Family or Group name const std::string& theNewName) { - if (myStudyDocument->GetProperties()->IsLocked()) - return; - Result_i* aResult = dynamic_cast(GetServant(theResult).in()); if (!aResult) return; + SALOMEDS::Study_var aStudyDocument = aResult->GetStudyDocument(); + if (aStudyDocument->GetProperties()->IsLocked()) + return; + + QString aComment; VISU::VISUType aType; if (theEntity >= 0) @@ -786,9 +778,9 @@ namespace VISU if (anEntry == "") return; - SALOMEDS::SObject_ptr aSObject = myStudyDocument->FindObjectID(anEntry.c_str()); + SALOMEDS::SObject_ptr aSObject = aStudyDocument->FindObjectID(anEntry.c_str()); - SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder(); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDocument->NewBuilder(); aStudyBuilder->NewCommand(); // There is a transaction SALOMEDS::GenericAttribute_var anAttr = @@ -844,17 +836,20 @@ namespace VISU const char* theMeshName, VISU::Entity theEntity) { - if(myStudyDocument->GetProperties()->IsLocked()) - return Mesh::_nil(); + Result_i* aResult = dynamic_cast(GetServant(theResult).in()); + if (!aResult) + return VISU::Mesh::_nil(); + + SALOMEDS::Study_var aStudyDocument = aResult->GetStudyDocument(); + if (aStudyDocument->GetProperties()->IsLocked()) + return VISU::Mesh::_nil(); + + Mesh_i* aPresent = new Mesh_i(); + if(aPresent->Create(aResult, theMeshName, theEntity)) + return aPresent->_this(); + else + aPresent->_remove_ref(); - if(Result_i* aResult = dynamic_cast(GetServant(theResult).in())){ - Mesh_i* aPresent = new Mesh_i(); - if(aPresent->Create(aResult, theMeshName, theEntity)) - return aPresent->_this(); - else{ - aPresent->_remove_ref(); - } - } return VISU::Mesh::_nil(); } @@ -867,17 +862,20 @@ namespace VISU VISU::Entity theEntity, const char* theFamilyName) { - if(myStudyDocument->GetProperties()->IsLocked()) - return Mesh::_nil(); + Result_i* aResult = dynamic_cast(GetServant(theResult).in()); + if (!aResult) + return VISU::Mesh::_nil(); + + SALOMEDS::Study_var aStudyDocument = aResult->GetStudyDocument(); + if (aStudyDocument->GetProperties()->IsLocked()) + return VISU::Mesh::_nil(); + + Mesh_i* aPresent = new Mesh_i(); + if(aPresent->Create(aResult, theMeshName, theEntity, theFamilyName)) + return aPresent->_this(); + else + aPresent->_remove_ref(); - if(Result_i* aResult = dynamic_cast(GetServant(theResult).in())){ - Mesh_i* aPresent = new Mesh_i(); - if(aPresent->Create(aResult, theMeshName, theEntity, theFamilyName)) - return aPresent->_this(); - else{ - aPresent->_remove_ref(); - } - } return VISU::Mesh::_nil(); } @@ -889,17 +887,20 @@ namespace VISU const char* theMeshName, const char* theGroupName) { - if(myStudyDocument->GetProperties()->IsLocked()) - return Mesh::_nil(); + Result_i* aResult = dynamic_cast(GetServant(theResult).in()); + if (!aResult) + return VISU::Mesh::_nil(); + + SALOMEDS::Study_var aStudyDocument = aResult->GetStudyDocument(); + if (aStudyDocument->GetProperties()->IsLocked()) + return VISU::Mesh::_nil(); + + Mesh_i* aPresent = new Mesh_i(); + if(aPresent->Create(aResult, theMeshName, theGroupName)) + return aPresent->_this(); + else + aPresent->_remove_ref(); - if(Result_i* aResult = dynamic_cast(GetServant(theResult).in())){ - Mesh_i* aPresent = new Mesh_i(); - if(aPresent->Create(aResult, theMeshName, theGroupName)) - return aPresent->_this(); - else{ - aPresent->_remove_ref(); - } - } return VISU::Mesh::_nil(); } @@ -937,6 +938,8 @@ namespace VISU theIteration)._retn(); } + + //--------------------------------------------------------------- DeformedShape_ptr VISU_Gen_i ::DeformedShapeOnField(Result_ptr theResult, @@ -952,6 +955,8 @@ namespace VISU theIteration)._retn(); } + + //--------------------------------------------------------------- ScalarMapOnDeformedShape_ptr VISU_Gen_i ::ScalarMapOnDeformedShapeOnField(Result_ptr theResult, @@ -967,6 +972,8 @@ namespace VISU theIteration)._retn(); } + + //--------------------------------------------------------------- Vectors_ptr VISU_Gen_i ::VectorsOnField(Result_ptr theResult, @@ -982,6 +989,8 @@ namespace VISU theIteration)._retn(); } + + //--------------------------------------------------------------- IsoSurfaces_ptr VISU_Gen_i ::IsoSurfacesOnField(Result_ptr theResult, @@ -997,6 +1006,8 @@ namespace VISU theIteration)._retn(); } + + //--------------------------------------------------------------- StreamLines_ptr VISU_Gen_i ::StreamLinesOnField(Result_ptr theResult, @@ -1012,6 +1023,8 @@ namespace VISU theIteration)._retn(); } + + //--------------------------------------------------------------- Plot3D_ptr VISU_Gen_i ::Plot3DOnField(Result_ptr theResult, @@ -1027,11 +1040,15 @@ namespace VISU theIteration)._retn(); } - CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult, - const char* theMeshName, - VISU::Entity theEntity, - const char* theFieldName, - CORBA::Long theIteration) + + //--------------------------------------------------------------- + CutPlanes_ptr + VISU_Gen_i + ::CutPlanesOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Long theIteration) { return Prs3dOnField(theResult, theMeshName, @@ -1040,11 +1057,15 @@ namespace VISU theIteration)._retn(); } - CutLines_ptr VISU_Gen_i::CutLinesOnField(Result_ptr theResult, - const char* theMeshName, - VISU::Entity theEntity, - const char* theFieldName, - CORBA::Long theIteration) + + //--------------------------------------------------------------- + CutLines_ptr + VISU_Gen_i + ::CutLinesOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Long theIteration) { return Prs3dOnField(theResult, theMeshName, @@ -1053,6 +1074,8 @@ namespace VISU theIteration)._retn(); } + + //--------------------------------------------------------------- struct CreateTableEvent: public SALOME_Event { SALOMEDS::Study_var myStudyDocument; @@ -1082,7 +1105,10 @@ namespace VISU }; - Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry) + //--------------------------------------------------------------- + Table_ptr + VISU_Gen_i + ::CreateTable(const char* theTableEntry) { if(myStudyDocument->GetProperties()->IsLocked()) return Table::_nil(); @@ -1090,17 +1116,25 @@ namespace VISU return ProcessEvent(new CreateTableEvent(myStudyDocument, theTableEntry)); } - Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable, - CORBA::Long theHRow, - CORBA::Long theVRow) + + //--------------------------------------------------------------- + Curve_ptr + VISU_Gen_i + ::CreateCurve(Table_ptr theTable, + CORBA::Long theHRow, + CORBA::Long theVRow) { return CreateCurveWithZ( theTable, theHRow, theVRow, 0 ); } - Curve_ptr VISU_Gen_i::CreateCurveWithZ(Table_ptr theTable, - CORBA::Long theHRow, - CORBA::Long theVRow, - CORBA::Long theZRow) + + //--------------------------------------------------------------- + Curve_ptr + VISU_Gen_i + ::CreateCurveWithZ(Table_ptr theTable, + CORBA::Long theHRow, + CORBA::Long theVRow, + CORBA::Long theZRow) { if(myStudyDocument->GetProperties()->IsLocked()) return Curve::_nil(); @@ -1116,7 +1150,13 @@ namespace VISU } } - Container_ptr VISU_Gen_i::CreateContainer(){ + + + //--------------------------------------------------------------- + Container_ptr + VISU_Gen_i + ::CreateContainer() + { if(myStudyDocument->GetProperties()->IsLocked()) return Container::_nil(); Mutex mt(myMutex); @@ -1129,7 +1169,12 @@ namespace VISU } } - Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){ + + //--------------------------------------------------------------- + Animation_ptr + VISU_Gen_i + ::CreateAnimation(View3D_ptr theView3D) + { if(myStudyDocument->GetProperties()->IsLocked()) return Animation::_nil(); Mutex mt(myMutex); @@ -1139,32 +1184,58 @@ namespace VISU return VISU::Animation::_nil(); } - void VISU_Gen_i::DeleteResult (Result_ptr theResult) + + //--------------------------------------------------------------- + void + VISU_Gen_i + ::DeleteResult (Result_ptr theResult) { theResult->RemoveFromStudy(); } - void VISU_Gen_i::DeletePrs3d (Prs3d_ptr thePrs3d) + + //--------------------------------------------------------------- + void + VISU_Gen_i + ::DeletePrs3d(Prs3d_ptr thePrs3d) { thePrs3d->RemoveFromStudy(); } - void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){ - } - char* VISU_Gen_i::ComponentDataType(){ + //--------------------------------------------------------------- + void + VISU_Gen_i + ::Close(SALOMEDS::SComponent_ptr theComponent) + {} + + + //--------------------------------------------------------------- + char* + VISU_Gen_i + ::ComponentDataType() + { return CORBA::string_dup("VISU"); } - bool VISU_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) { + + //--------------------------------------------------------------- + bool + VISU_Gen_i + ::CanPublishInStudy(CORBA::Object_ptr theIOR) + { Result_var aResultObj = Result::_narrow(theIOR); return !(aResultObj->_is_nil()); } - SALOMEDS::SObject_ptr VISU_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, - SALOMEDS::SObject_ptr theSObject, - CORBA::Object_ptr theObject, - const char* theName) + + //--------------------------------------------------------------- + SALOMEDS::SObject_ptr + VISU_Gen_i + ::PublishInStudy(SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject, + const char* theName) throw (SALOME::SALOME_Exception) { Unexpect aCatch(SalomeException); @@ -1172,180 +1243,133 @@ namespace VISU Mutex mt(myMutex); SALOMEDS::SObject_var aResultSO; Result_i* aResultObj = dynamic_cast(GetServant(theObject).in()); - if (!aResultObj) return aResultSO._retn(); + if (!aResultObj) + return aResultSO._retn(); const QFileInfo& aFileInfo = aResultObj->GetFileInfo(); CORBA::String_var anEntry = aResultObj->Create(aFileInfo.filePath().latin1())->GetID(); aResultSO = theStudy->FindObjectID(anEntry); return aResultSO._retn(); } - CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) { - Mutex mt(myMutex); - SALOMEDS::GenericAttribute_var anAttr; - if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false; - try { - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - CORBA::String_var aValue = anIOR->Value(); - if(strcmp(aValue,"") != 0){ - CORBA::Object_ptr anObj = GetORB()->string_to_object(aValue); - if (!CORBA::is_nil(anObj)){ - Result_var aResultObj = Result::_narrow(anObj); - if(!aResultObj->_is_nil()){ - if(Result_i* pResult = dynamic_cast(GetServant(aResultObj).in())){ - switch(pResult->GetCreationId()){ - case Result_i::eImportFile: - case Result_i::eCopyAndImportFile: - return true; - } - } - } - } - } - }catch(std::exception& exc){ - INFOS("Follow exception was occured :\n"<(GetServant(anObj).in())) + return aStorable->CanCopy(theObject); + return false; } - SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) { - Mutex mt(myMutex); + + //--------------------------------------------------------------- + SALOMEDS::TMPFile* + VISU_Gen_i + ::CopyFrom(SALOMEDS::SObject_ptr theObject, + CORBA::Long& theObjectID) + { theObjectID = 0; SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile; - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - PortableServer::POA_ptr aPOA = GetPOA(); - - SALOMEDS::GenericAttribute_var anAttr; - if (!theObject->FindAttribute(anAttr,"AttributeIOR")) return NULL; - SALOMEDS::AttributeIOR_var anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr); - CORBA::Object_var aCorbaObj; - try { - aCorbaObj = GetORB()->string_to_object(anIORAttr->Value()); - } catch(...) { + CORBA::Object_var anObj = SObjectToObject(theObject); + if (CORBA::is_nil(anObj)) { aStreamFile->length(1); - aStreamFile[0] = strdup("E")[0]; - return aStreamFile._retn(); - } - if (CORBA::is_nil(aCorbaObj)) { - return NULL; - } + aStreamFile[0] = CORBA::string_dup("E")[0]; + } else if (Storable* aStorable = dynamic_cast(GetServant(anObj).in())) { + std::string aTmpDir = SALOMEDS_Tool::GetTmpDir(); + Storable::TFileNames aFileNames; + bool anIsDone = aStorable->CopyFrom(theObject, theObjectID, aTmpDir, aFileNames); - Storable* pStorable = dynamic_cast(GetServant(aCorbaObj).in()); - if (!pStorable) { - return NULL; - } - - string aTmpDir = SALOMEDS_Tool::GetTmpDir(); - string aCopyPersist = aTmpDir + "copy_persistent"; - - ofstream stmOut2(aCopyPersist.c_str(),ios::out); - string aStr = pStorable->ToString().c_str(); - stmOut2<(aPOA->reference_to_servant(aCorbaObj))) { - string aFileName = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + "_"; - if(strlen(aFileName.c_str()) == 1) aFileName=""; - const QFileInfo& aFileInfo = aResultObj->GetFileInfo(); - aFileName += aFileInfo.fileName().latin1(); - static QString aCommand; - string aFullFileName = aTmpDir + aFileName; - aCommand.sprintf(" %s %s",aFileInfo.filePath().latin1(), aFullFileName.c_str() ); - aCommand = QDir::convertSeparators( aCommand ); - aCommand.prepend( COPY_COMMAND ); - - if(system(aCommand.latin1()) == -1) { - if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<length(2); - aSeq[0] = "copy_persistent"; - aSeq[1] = aFileName.c_str(); - } else { - aSeq->length(1); - aSeq[0] = "copy_persistent"; - } - - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), false); - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); + SALOMEDS::ListOfFileNames_var aListOfFileNames = new SALOMEDS::ListOfFileNames; + aListOfFileNames->length(aFileNames.size()); + for(size_t anId = 0; anId < aFileNames.size(); anId++) + aListOfFileNames[anId] = aFileNames[anId].c_str(); - // Assign an ID = 1 the the type VISU::Result - theObjectID = 1; + if(anIsDone) + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aListOfFileNames.in(), false); - SALOMEDS::SComponent_var aSComponent = theObject->GetStudy()->FindComponent("VISU"); + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aListOfFileNames.in(), true); + } return aStreamFile._retn(); } - CORBA::Boolean VISU_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) { + + //--------------------------------------------------------------- + CORBA::Boolean + VISU_Gen_i + ::CanPaste(const char* theComponentName, CORBA::Long theObjectID) { // The VISU component can paste only objects copied by VISU component - // and with the object type = 1 - if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1) - return false; - return true; + CORBA::String_var aString = ComponentDataType(); + if (strcmp(theComponentName, aString.in()) == 0 && theObjectID == 1) + return true; + return false; } - SALOMEDS::SObject_ptr VISU_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream, - CORBA::Long theObjectID, - SALOMEDS::SObject_ptr theObject) + + //--------------------------------------------------------------- + SALOMEDS::SObject_ptr + VISU_Gen_i + ::PasteInto(const SALOMEDS::TMPFile& theStream, + CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theSObject) { - Mutex mt(myMutex); - SALOMEDS::SObject_var aResultSO; if (theObjectID != 1) - return aResultSO._retn(); - - string aTmpDir = SALOMEDS_Tool::GetTmpDir(); - SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.c_str(), false); - - ifstream stmIn((aTmpDir + string("copy_persistent")).c_str()); - stmIn.seekg(0, ios::end); - int aLength = stmIn.tellg(); - stmIn.seekg(0, ios::beg); - char* aString = new char[aLength+1]; - stmIn.read(aString, aLength); - stmIn.close(); - aString[aLength] = 0; - myIsMultiFile = false; - - string aFileName(aTmpDir); - string aBasicFileName; - if(aSeq->length() > 1) { - aBasicFileName = aSeq[1].in(); - aFileName += aBasicFileName; - } + return SALOMEDS::SObject::_nil(); - SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent(); - SALOMEDS::Study_var aStudy = theObject->GetStudy(); + SALOMEDS::SComponent_var aComponent = theSObject->GetFatherComponent(); + SALOMEDS::Study_var aStudy = theSObject->GetStudy(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - CORBA::String_var aComponentID(aComponent->GetID()), aSObjID(theObject->GetID()); - - if (strcmp(aComponentID, aSObjID) == 0) //create the new result SObject - aResultSO = aStudyBuilder->NewObject(aComponent); + CORBA::String_var aComponentID(aComponent->GetID()); + CORBA::String_var aSObjectID(theSObject->GetID()); + + SALOMEDS::SObject_var aSObject; + if (strcmp(aComponentID, aSObjectID) == 0) //create the new result SObject + aSObject = aStudyBuilder->NewObject(aComponent); else - aResultSO = SALOMEDS::SObject::_duplicate(theObject); - + aSObject = SALOMEDS::SObject::_duplicate(theSObject); + + std::string aTmpDir = SALOMEDS_Tool::GetTmpDir(); + SALOMEDS::ListOfFileNames_var aListOfFileNames = + SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false); + if(MYDEBUG) MESSAGE("Result_i::PasteInto - aListOfFileNames->length() = "<length()); + + std::string aLocalPersistentID; + { + std::string aCopyPersist = aTmpDir + "copy_persistent"; + std::ifstream anInputFileStream(aCopyPersist.c_str()); + anInputFileStream>>aLocalPersistentID; + anInputFileStream.close(); + } + //Just for Result::Restore to find the Comment attribute :( - SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeString"); - - Storable* aStorable = Storable::Create(aResultSO,aFileName,aString); - - SALOMEDS::ListOfFileNames_var aSeqToRm = new SALOMEDS::ListOfFileNames; - aSeqToRm->length(1); - aSeqToRm[0] = "copy_persistent"; - - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeqToRm.in(), true); - - anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR"); + SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeString"); + + std::string aFileName(aTmpDir); + if(aListOfFileNames->length() > 1) + aFileName += aListOfFileNames[1].in(); + Storable* aStorable = Storable::Create(aSObject, aLocalPersistentID, aFileName, false); + + SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames; + aFilesToRemove->length(1); + aFilesToRemove[0] = aListOfFileNames[0]; + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aFilesToRemove.in(), true); + + anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeIOR"); SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); CORBA::String_var anIORValue(aStorable->GetID()); anIOR->SetValue(anIORValue); - return aResultSO._retn(); + + return aSObject._retn(); } + + //--------------------------------------------------------------- VISU::ColoredPrs3dCache_ptr - VISU_Gen_i:: - GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy) + VISU_Gen_i + ::GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy) { return ColoredPrs3dCache_i::GetInstance(theStudy); } diff --git a/src/VISU_I/VISU_IsoSurfaces_i.cc b/src/VISU_I/VISU_IsoSurfaces_i.cc index 769e48de..96377ac7 100644 --- a/src/VISU_I/VISU_IsoSurfaces_i.cc +++ b/src/VISU_I/VISU_IsoSurfaces_i.cc @@ -24,9 +24,11 @@ // Author : Alexey PETROV // Module : VISU +#include "VISU_IsoSurfaces_i.hh" +#include "VISU_Prs3dUtils.hh" + #include "VISU_IsoSurfacesPL.hxx" #include "VISU_Result_i.hh" -#include "VISU_IsoSurfaces_i.hh" #include "VISU_Actor.h" #include "SUIT_ResourceMgr.h" @@ -152,6 +154,8 @@ void VISU::IsoSurfaces_i ::SetNbSurfaces(CORBA::Long theNb) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_IsoSurfacesPL::SetNbParts, theNb)); } @@ -170,6 +174,8 @@ void VISU::IsoSurfaces_i ::SetSubRange(CORBA::Double theMin, CORBA::Double theMax) { + VISU::TSetModified aModified(this); + vtkFloatingPointType aRange[2] = {theMin, theMax}; ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_IsoSurfacesPL::SetRange, aRange)); diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index 46f3b151..6b9f8660 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -25,6 +25,7 @@ // Module : VISU #include "VISU_Mesh_i.hh" +#include "VISU_Prs3dUtils.hh" #include "VISU_Result_i.hh" @@ -214,7 +215,7 @@ VISU::Mesh_i aRestoringMap["myMeshName"] = GetCMeshName(); VISU::PUnstructuredGridIDMapper anIDMapper; - VISU::Result_i::TInput* anInput = GetCResult()->GetInput(); + VISU::Result_i::PInput anInput = GetCResult()->GetInput(); switch(myType){ case VISU::TENTITY : anIDMapper = anInput->GetMeshOnEntity(aMeshName, @@ -323,6 +324,8 @@ VISU::Mesh_i if(IsSameColor(myCellColor, theColor)) return; + VISU::TSetModified aModified(this); + myCellColor = theColor; myParamsTime.Modified(); } @@ -345,6 +348,8 @@ VISU::Mesh_i if(IsSameColor(myNodeColor, theColor)) return; + VISU::TSetModified aModified(this); + myNodeColor = theColor; myParamsTime.Modified(); } @@ -367,6 +372,8 @@ VISU::Mesh_i if(IsSameColor(myLinkColor, theColor)) return; + VISU::TSetModified aModified(this); + myLinkColor = theColor; myParamsTime.Modified(); } @@ -389,6 +396,8 @@ VISU::Mesh_i if(myPresentType == theType) return; + VISU::TSetModified aModified(this); + myPresentType = theType; myParamsTime.Modified(); } @@ -454,9 +463,10 @@ VISU::Mesh_i //---------------------------------------------------------------------------- VISU::Storable* VISU::Mesh_i -::Restore(SALOMEDS::SObject_ptr theSObject, - const string& thePrefix, - const Storable::TRestoringMap& theMap) +::StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile) { Mesh_i* aMesh = new Mesh_i(); return aMesh->Restore(theSObject, theMap); diff --git a/src/VISU_I/VISU_Mesh_i.hh b/src/VISU_I/VISU_Mesh_i.hh index a6b45221..6576b7be 100644 --- a/src/VISU_I/VISU_Mesh_i.hh +++ b/src/VISU_I/VISU_Mesh_i.hh @@ -167,9 +167,10 @@ namespace VISU static Storable* - Restore(SALOMEDS::SObject_ptr theSObject, - const std::string& thePrefix, - const Storable::TRestoringMap& theMap); + StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile); virtual VISU_Actor* diff --git a/src/VISU_I/VISU_MultiResult_i.cc b/src/VISU_I/VISU_MultiResult_i.cc new file mode 100644 index 00000000..7639c4e2 --- /dev/null +++ b/src/VISU_I/VISU_MultiResult_i.cc @@ -0,0 +1,1129 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_MultiResult_i.cc +// Author : Alexey PETROV +// Module : VISU + +#ifdef ENABLE_MULTIPR + +#include "VISU_MultiResult_i.hh" +#include "VISU_ResultUtils.hh" + +#include "VISU_Convertor.hxx" +#include "VISU_ConvertorUtils.hxx" + +#include "MULTIPR_Obj.hxx" +#include "MULTIPR_API.hxx" +#include "MULTIPR_Exceptions.hxx" + +#include "SALOMEDS_Tool.hxx" +#include "HDFascii.hxx" + +#include +#include + +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +static int MYTIMEDEBUG = 0; +#else +static int MYDEBUG = 0; +static int MYTIMEDEBUG = 0; +#endif + + +namespace VISU +{ + //--------------------------------------------------------------- + class TSubString: public std::string + { + public: + typedef std::string::size_type size_type; + + TSubString(std::string& theSource, + const std::string& theTarget): + mySource(theSource), + myPosition(theSource.find(theTarget)), + mySize(theTarget.length()) + {} + + TSubString& + operator = (const std::string& theTarget) + { + if(myPosition != std::string::npos) + mySource.replace(myPosition, mySize, theTarget); + return *this; + } + + private: + std::string& mySource; + size_type myPosition; + size_type mySize; + }; + + + //--------------------------------------------------------------- + inline + std::ostream& + operator<<(std::ostream& theStream, + const MultiResult_i::TPartInfo& thePartInfo) + { + theStream<<(thePartInfo.myMeshName)<<" "; + theStream<<(thePartInfo.myPartID)<<" "; + theStream<<(thePartInfo.myName)<<" "; + theStream<<(thePartInfo.myPath)<<" "; + theStream<<(thePartInfo.myFileName); + return theStream; + } + + + //--------------------------------------------------------------- + inline + std::istream& + operator>>(std::istream& theStream, + MultiResult_i::TPartInfo& thePartInfo) + { + theStream>>(thePartInfo.myMeshName); + theStream>>(thePartInfo.myPartID); + theStream>>(thePartInfo.myName); + theStream>>(thePartInfo.myPath); + theStream>>(thePartInfo.myFileName); + return theStream; + } + + + //--------------------------------------------------------------- + inline + MultiResult_i::TPartInfo + GetPartInfo(const std::string theInfoString) + { + MultiResult_i::TPartInfo aPartInfo; + std::istrstream anOutputStream(theInfoString.c_str()); + anOutputStream>>aPartInfo; + return aPartInfo; + } + + + //--------------------------------------------------------------- + inline + MultiResult_i::TPartInfo + GetPartInfo(multipr::Obj& theMultiprObj, + const MultiResult_i::TPartName& thePartName) + { + return GetPartInfo(theMultiprObj.getPartInfo(thePartName.c_str())); + } + + + //--------------------------------------------------------------- + inline + std::string + ExtractMainPart(const std::string& thePartName) + { + size_t aPos = thePartName.rfind('_'); + if(aPos == std::string::npos) + return thePartName; + + std::string aSuffix = thePartName.substr(aPos); + if(aSuffix == "_MED" || aSuffix == "_LOW") + return thePartName.substr(0, aPos); + + return thePartName; + } + + + //--------------------------------------------------------------- + inline + bool + IsSubString(const std::string& theSource, + const std::string& theSubString) + { + return theSource.rfind(theSubString) != std::string::npos; + } + + + //--------------------------------------------------------------- + inline + bool + IsMediumResolution(const std::string& thePartName) + { + return IsSubString(thePartName, "_MED"); + } + + + //--------------------------------------------------------------- + inline + bool + IsLowResolution(const std::string& thePartName) + { + return IsSubString(thePartName, "_LOW"); + } + + + //--------------------------------------------------------------- + inline + bool + IsFullResolution(const std::string& thePartName) + { + return !IsMediumResolution(thePartName) && !IsLowResolution(thePartName); + } + + + //--------------------------------------------------------------- + inline + MultiResult_i::TResolutions + GetResolutions(const MultiResult_i::TMainPart2SubPartNames& theMainPart2SubPartNames, + const std::string& thePartName) + { + MultiResult_i::TResolutions aResolutions; + aResolutions.insert(VISU::Result::FULL); + + MultiResult_i::TPartName aMainPart = ExtractMainPart(thePartName); + MultiResult_i::TMainPart2SubPartNames::const_iterator anIter = theMainPart2SubPartNames.find(aMainPart); + if(anIter != theMainPart2SubPartNames.end()){ + const MultiResult_i::TSubPartNames& aSubPartNames = anIter->second; + + if(aSubPartNames.find(aMainPart + "_LOW") != aSubPartNames.end()) + aResolutions.insert(VISU::Result::LOW); + + if(aSubPartNames.find(aMainPart + "_MED") != aSubPartNames.end()) + aResolutions.insert(VISU::Result::MEDIUM); + } + return aResolutions; + } + + + std::string + Resolutions2String(const MultiResult_i::TResolutions& theResolutions) + { + std::string aResult; + MultiResult_i::TResolutions::const_iterator anIter = theResolutions.begin(); + for(; anIter != theResolutions.end(); anIter++){ + VISU::Result::Resolution aResolution = *anIter; + if(aResolution == VISU::Result::FULL) + aResult += "F"; + if(aResolution == VISU::Result::LOW) + aResult += "L"; + if(aResolution == VISU::Result::MEDIUM) + aResult += "M"; + } + return aResult; + } + + + //--------------------------------------------------------------- + inline + VISU::Result::Resolution + GetResolution(const MultiResult_i::TMainPart2SubPartNames& theMainPart2SubPartNames, + const std::string& thePartName) + { + MultiResult_i::TResolutions aResolutions = GetResolutions(theMainPart2SubPartNames, thePartName); + + if(aResolutions.find(VISU::Result::LOW) != aResolutions.end()) + return VISU::Result::LOW; + + if(aResolutions.find(VISU::Result::MEDIUM) != aResolutions.end()) + return VISU::Result::MEDIUM; + + return VISU::Result::FULL; + } + + + //--------------------------------------------------------------- + inline + std::string + GetIconName(const MultiResult_i::TMainPart2SubPartNames& theMainPart2SubPartNames, + const std::string& thePartName) + { + VISU::Result::Resolution aResolution = GetResolution(theMainPart2SubPartNames, + thePartName); + if(aResolution == VISU::Result::LOW) + return "ICON_MULTIPR_VIEW_LOW"; + + if(aResolution == VISU::Result::MEDIUM) + return "ICON_MULTIPR_VIEW_MEDIUM"; + + return "ICON_MULTIPR_VIEW_FULL"; + } + + + //---------------------------------------------------------------------------- + void + BuildParts(Result_i* theResult, + Result_i::PInput theInput, + multipr::Obj* theMultiprObj, + MultiResult_i::TPartInfos* thePartInfos, + MultiResult_i::TPartName2FileName* thePartName2FileName, + MultiResult_i::TPartName2Resolution* thePartName2Resolution, + MultiResult_i::TMainPart2SubPartNames* theMainPart2SubPartNames, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild, + _PTR(Study) theStudy, + bool thePublishInStudy) + { + if(!theIsBuild || *theIsDone) + return; + + TTimerLog aTimerLog(MYTIMEDEBUG, "BuildParts"); + TResultManager aResultManager(theResult); + TTransactionManager aTransactionManager(theStudy); + + try { + multipr::Obj& aMultiprObj = *theMultiprObj; + const VISU::TMeshMap& aMeshMap = theInput->GetMeshMap(); + VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + const VISU::PMesh& aMesh = aMeshMapIter->second; + + MultiResult_i::TPartNames aPartNames = aMultiprObj.getParts(); + + if(thePublishInStudy){ + QString aComment = "Sub-parts: #"; + aComment += QString::number(aPartNames.size()); + + CreateAttributes(theStudy, + aMesh->myPartsEntry, + NO_ICON, + NO_IOR, + "Parts", + NO_PERFSITENT_REF, + aComment.latin1(), + false); + } + + MultiResult_i::TPartInfos& aPartInfos = *thePartInfos; + MultiResult_i::TPartName2FileName& aPartName2FileName = *thePartName2FileName; + MultiResult_i::TPartName2Resolution& aPartName2Resolution = *thePartName2Resolution; + + MultiResult_i::TMainPart2SubPartNames& aMainPart2SubPartNames = *theMainPart2SubPartNames; + + for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) { + const MultiResult_i::TPartName& aPartName = aPartNames[aPartID]; + MultiResult_i::TPartName aMainPart = ExtractMainPart(aPartName); + aMainPart2SubPartNames[aMainPart].insert(aPartName); + } + + for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) { + const MultiResult_i::TPartName& aPartName = aPartNames[aPartID]; + MultiResult_i::TPartInfo aPartInfo = GetPartInfo(aMultiprObj, aPartName); + + QFileInfo aFileInfo(aPartInfo.myFileName.c_str()); + aPartInfos[aFileInfo.fileName()] = aPartInfo; + + aPartName2FileName[aPartInfo.myName] = aPartInfo.myFileName; + + if(!thePublishInStudy) + continue; + + QString aComment = ""; + MultiResult_i::TResolutions aResoltutions = GetResolutions(aMainPart2SubPartNames, aPartInfo.myName); + std::string aResoltutionsString = Resolutions2String(aResoltutions); + if ( IsFullResolution(aPartInfo.myName) ) { + std::string anIconName = GetIconName(aMainPart2SubPartNames, aPartInfo.myName); + VISU::Result::Resolution aResolution = GetResolution(aMainPart2SubPartNames, aPartInfo.myName); + aComment.sprintf("myComment=PART;myMeshName=%s;myName=%s;myResolutions=%s;myState=%d", + aPartInfo.myMeshName.c_str(), aPartInfo.myName.c_str(), aResoltutionsString.c_str(), aResolution); + CreateAttributes(theStudy, + aMesh->myPartsEntry, + anIconName, + NO_IOR, + aPartInfo.myName, + NO_PERFSITENT_REF, + aComment.latin1(), + true); + aPartName2Resolution[aPartInfo.myName] = aResolution; + } + } + + *theIsDone = true; + }catch(std::exception& exc){ + INFOS("Follow exception was occured :\n"<StudyId(), theIsDone)); + } + + + //--------------------------------------------------------------- + struct TBuildPartsArgs + { + Result_i* myResult; + Result_i::PInput myInput; + multipr::Obj* myMultiprObj; + MultiResult_i::TPartInfos* myPartInfos; + MultiResult_i::TPartName2FileName* myPartName2FileName; + MultiResult_i::TPartName2Resolution* myPartName2Resolution; + MultiResult_i::TMainPart2SubPartNames* myMainPart2SubPartNames; + CORBA::Boolean* myIsDone; + CORBA::Boolean myIsBuild; + _PTR(Study) myStudy; + bool myPublishInStudy; + + TBuildPartsArgs(Result_i* theResult, + Result_i::PInput theInput, + multipr::Obj* theMultiprObj, + MultiResult_i::TPartInfos* thePartInfos, + MultiResult_i::TPartName2FileName* thePartName2FileName, + MultiResult_i::TPartName2Resolution* thePartName2Resolution, + MultiResult_i::TMainPart2SubPartNames* theMainPart2SubPartNames, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild, + _PTR(Study) theStudy, + bool thePublishInStudy): + myResult(theResult), + myInput(theInput), + myMultiprObj(theMultiprObj), + myPartInfos(thePartInfos), + myPartName2FileName(thePartName2FileName), + myPartName2Resolution(thePartName2Resolution), + myMainPart2SubPartNames(theMainPart2SubPartNames), + myIsDone(theIsDone), + myIsBuild(theIsBuild), + myStudy(theStudy), + myPublishInStudy(thePublishInStudy) + {} + }; + + + //---------------------------------------------------------------------------- + void + BuildParts(const TBuildPartsArgs& theArgs) + { + BuildParts(theArgs.myResult, + theArgs.myInput, + theArgs.myMultiprObj, + theArgs.myPartInfos, + theArgs.myPartName2FileName, + theArgs.myPartName2Resolution, + theArgs.myMainPart2SubPartNames, + theArgs.myIsDone, + theArgs.myIsBuild, + theArgs.myStudy, + theArgs.myPublishInStudy); + } + + + //--------------------------------------------------------------- +} + + +//--------------------------------------------------------------- +VISU::MultiResult_i +::MultiResult_i(SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildMinMax, + CORBA::Boolean theIsBuildGroups): + Result_i(theStudy, + theSourceId, + theCreationId, + theIsBuildImmediately, + theIsBuildFields, + theIsBuildMinMax, + theIsBuildGroups) +{} + + +//--------------------------------------------------------------- +VISU::MultiResult_i +::MultiResult_i() +{} + + +//--------------------------------------------------------------- +size_t +VISU::MultiResult_i +::IsPossible() +{ + return TSuperClass::IsPossible(); +} + + +//--------------------------------------------------------------- +VISU::Storable* +VISU::MultiResult_i +::Build(SALOMEDS::SObject_ptr theSObject, + CORBA::Boolean theIsAtOnce) +{ + if(!TSuperClass::Build(theSObject, theIsAtOnce)) + return NULL; + + if(IsDone()) + return this; + + if(theIsAtOnce){ + BuildParts(this, + GetInput(), + &myMultiprObj, + &myPartInfos, + &myPartName2FileName, + &myPartName2Resolution, + &myMainPart2SubPartNames, + &myIsPartsDone, + myIsBuildParts, + myStudy, + true); + } + + return this; +} + + +//--------------------------------------------------------------- +void +VISU::MultiResult_i +::BuildDataTree(const std::string& theResultEntry) +{ + BuildEntities(this, + GetInput(), + &myIsEntitiesDone, + theResultEntry, + false, + myIsBuildGroups, + myIsBuildFields, + myIsBuildParts, + myStudy); + { + TBuildPartsArgs anArgs(this, + GetInput(), + &myMultiprObj, + &myPartInfos, + &myPartName2FileName, + &myPartName2Resolution, + &myMainPart2SubPartNames, + &myIsPartsDone, + myIsBuildParts, + myStudy, + true); + + boost::thread aThread(boost::bind(&BuildParts, anArgs)); + } + { + boost::thread aThread(boost::bind(&BuildGroups, + this, + GetInput(), + &myIsGroupsDone, + myIsBuildGroups, + false, + myStudy)); + } + { + boost::thread aThread(boost::bind(&BuildFieldDataTree, + this, + GetInput(), + &myIsFieldsDone, + myIsBuildFields, + &myIsMinMaxDone, + myIsBuildMinMax, + myStudy)); + } +} + + +//--------------------------------------------------------------- +VISU::Storable* +VISU::MultiResult_i +::Create(const char* theFileName) +{ + QFileInfo aFileInfo(theFileName); + QString aTargetFileName = aFileInfo.filePath(); + if(aTargetFileName.endsWith("_grains_maitre.med")){ + myMultiprObj.create(theFileName); + if (myMultiprObj.isValidDistributedMEDFile()) { + aTargetFileName = myMultiprObj.getSequentialMEDFilename(); + SetInitFileName(aFileInfo.filePath().latin1()); + SetName(VISU::GenerateName(aFileInfo.fileName()).latin1(), false); + myIsBuildParts = true; + } + } + + return TSuperClass::Create(aTargetFileName); +} + + +//--------------------------------------------------------------- +bool +VISU::MultiResult_i +::Save(SALOMEDS::SComponent_ptr theComponent, + const std::string& theURL, + bool theIsMultiFile, + bool theIsASCII, + TFileNames& theFileNames, + TFileNames& theFiles) +{ + bool anIsDone = Result_i::Save(theComponent, + theURL, + theIsMultiFile, + theIsASCII, + theFileNames, + theFiles); + if(!anIsDone) + return false; + + if(!myMultiprObj.isValidDistributedMEDFile()) + return true; + + INITMSG(MYDEBUG, "MultiResult_i::Save - this = "<URL(); + aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in()); + } + + std::string aBase, aSuffix; + SplitName(GetFileName(), aBase, aSuffix); + BEGMSG(MYDEBUG, "aBase = '"<(aPathToCopy.c_str()), true); + } + + theFileNames.push_back(aFileName); + theFiles.push_back(aFile); + } + + return true; +} + + +//--------------------------------------------------------------- +CORBA::Boolean +VISU::MultiResult_i +::CanCopy(SALOMEDS::SObject_ptr theObject) +{ + if(!myIsPartsDone) + return Result_i::CanCopy(theObject); + + return false; +} + + +//--------------------------------------------------------------- +void +VISU::MultiResult_i +::ToStream(std::ostringstream& theStr) +{ + INITMSG(MYDEBUG, "MultiResult_i::ToStream - this = "<first; + aPartNames<second; + aResolutions<length(aMeshParts.size()); + for (size_t aPartID = 0 ; aPartID < aMeshParts.size() ; aPartID++) { + const MultiResult_i::TPartName& aPartName = aMeshParts[aPartID]; + aResult[aPartID] = aPartName.c_str(); + } + + return aResult._retn(); +} + +VISU::Result::Resolutions* +VISU::MultiResult_i +::GetResolutions(const char* theMeshName, + const char* thePartName) +{ + VISU::Result::Resolutions_var aResult = new VISU::Result::Resolutions(); + if(!myIsBuildParts) + return aResult._retn(); + + MultiResult_i::TPartNames aPartNames = myMultiprObj.getParts(); + for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) { + const MultiResult_i::TPartName& aPartName = aPartNames[aPartID]; + MultiResult_i::TPartName aMainPart = ExtractMainPart(thePartName); + if(aMainPart != thePartName) + continue; + + MultiResult_i::TPartInfo aPartInfo = GetPartInfo(myMultiprObj, aPartName); + if(aPartInfo.myMeshName != theMeshName) + continue; + + MultiResult_i::TResolutions aResolutions = VISU::GetResolutions(myMainPart2SubPartNames, thePartName); + if(aResolutions.empty()) + return aResult._retn(); + + aResult->length(aResolutions.size()); + MultiResult_i::TResolutions::const_iterator anIter = aResolutions.end(); + for(size_t anId = 0; anIter != aResolutions.end(); anIter++, anId++){ + const VISU::Result::Resolution& aResolution = *anIter; + aResult[anId] = aResolution; + } + + break; + } + + return aResult._retn(); +} + +VISU::Result::Resolution +VISU::MultiResult_i +::GetResolution(const char* theMeshName, + const char* thePartName) +{ + TPartName2Resolution::iterator anIter = myPartName2Resolution.find(thePartName); + if(anIter == myPartName2Resolution.end()) + return VISU::Result::HIDDEN; + + const VISU::Result::Resolution& aResolution = anIter->second; + return aResolution; +} + +void +VISU::MultiResult_i +::SetResolution(const char* theMeshName, + const char* thePartName, + VISU::Result::Resolution theResolution) +{ + if(!IsFullResolution(thePartName)) + return; + + TPartName2Resolution::iterator anIter = myPartName2Resolution.find(thePartName); + if(anIter == myPartName2Resolution.end()) + return; + + VISU::Result::Resolution& aResolution = anIter->second; + if(aResolution == theResolution) + return; + + if(theResolution != VISU::Result::HIDDEN){ + MultiResult_i::TResolutions aResolutions = VISU::GetResolutions(myMainPart2SubPartNames, thePartName); + MultiResult_i::TResolutions::iterator anIter = aResolutions.find(theResolution); + if(anIter == aResolutions.end()) + return; + } + + VISU::Storable::TRestoringMap aRestoringMap; + aRestoringMap["myComment"] = "PART"; + aRestoringMap["myMeshName"] = theMeshName; + aRestoringMap["myName"] = thePartName; + + const VISU::TMeshMap& aMeshMap = Result_i::GetInput()->GetMeshMap(); + VISU::TMeshMap::const_iterator aMeshIter = aMeshMap.find(theMeshName); + if(aMeshIter == aMeshMap.end()) + return; + + std::string aFatherEntry; + const VISU::PMesh& aMesh = aMeshIter->second; + if(aMesh->myPartsEntry != "") + aFatherEntry = Storable::FindEntry(GetStudyDocument(), + aMesh->myPartsEntry, + aRestoringMap); + else + aFatherEntry = Result_i::GetEntry(aRestoringMap); + + std::string anIconName = "ICON_MULTIPR_VIEW_HIDE"; + if(theResolution == VISU::Result::FULL) + anIconName = "ICON_MULTIPR_VIEW_FULL"; + else if(theResolution == VISU::Result::MEDIUM) + anIconName = "ICON_MULTIPR_VIEW_MEDIUM"; + else if(theResolution == VISU::Result::LOW) + anIconName = "ICON_MULTIPR_VIEW_LOW"; + + _PTR(Study) aStudy = GetStudy(); + _PTR(SObject) aSObject = aStudy->FindObjectID(aFatherEntry); + aRestoringMap = Storable::GetStorableMap(aSObject); + + std::ostrstream anOutputStream; + anOutputStream<<"myComment=PART;"; + anOutputStream<<"myName="<second; + std::string aFileName = anInput->GetName(); + INITMSG(MYDEBUG, "RemoveFile - aFileName = '"<second; + theRepresentationKey.insert(aFileName); + } + } + + + //--------------------------------------------------------------- + MultiResult_i::TRepresentationKey + GetRepresentation(const MultiResult_i::TPartName2FileName& thePartName2FileName, + const MultiResult_i::TPartName2Resolution& thePartName2Resolution) + { + // name of selected parts + MultiResult_i::TRepresentationKey aRepresentationKey; + + // for each part of the mesh + MultiResult_i::TPartName2Resolution::const_iterator anIter = thePartName2Resolution.begin(); + for ( ; anIter != thePartName2Resolution.end() ; anIter++) { + const MultiResult_i::TPartName& aPartName = anIter->first; + if(IsFullResolution(aPartName)){ + const VISU::Result::Resolution& aResolution = anIter->second; + if(aResolution == VISU::Result::FULL) + UpdateRepresentationKey(thePartName2FileName, aRepresentationKey, aPartName); + if(aResolution == VISU::Result::MEDIUM) + UpdateRepresentationKey(thePartName2FileName, aRepresentationKey, aPartName + "_MED"); + else if(aResolution == VISU::Result::LOW) + UpdateRepresentationKey(thePartName2FileName, aRepresentationKey, aPartName + "_LOW"); + } + } + return aRepresentationKey; + } + + + //--------------------------------------------------------------- + bool + UseInitialInput(const MultiResult_i::TPartName2FileName& thePartName2FileName, + const MultiResult_i::TPartName2Resolution& thePartName2Resolution) + { + bool aResult = true; + MultiResult_i::TPartName2FileName::const_iterator anIter = thePartName2FileName.begin(); + for ( ; anIter != thePartName2FileName.end() ; anIter++) { + const MultiResult_i::TPartName& aPartName = anIter->first; + if(IsFullResolution(aPartName)){ + MultiResult_i::TPartName2Resolution::const_iterator anIter2 = thePartName2Resolution.find(aPartName); + if(anIter2 != thePartName2Resolution.end()){ + const VISU::Result::Resolution& aResolution = anIter2->second; + if(aResolution == VISU::Result::FULL) + continue; + } + aResult = false; + break; + } + } + return aResult; + } +} + + +//--------------------------------------------------------------- +VISU::Result_i::PInput +VISU::MultiResult_i +::GetInput(const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber) +{ + if(theEntity == NONE) // If client wants use initial behaviour + return TSuperClass::GetInput(); + + if(!myIsPartsDone) // If corresponding data is not ready yet + return TSuperClass::GetInput(); + + //if(UseInitialInput(myPartName2FileName, myPartName2Resolution)) + // return TSuperClass::GetInput(); + + MultiResult_i::TRepresentationKey aRepresentationKey = + GetRepresentation(myPartName2FileName, myPartName2Resolution); + + typedef std::vector TFileNames; + TFileNames aFileNames(aRepresentationKey.begin(), aRepresentationKey.end()); + + aRepresentationKey.insert( theMeshName ); + aRepresentationKey.insert( theFieldName ); + + TRepresentation2Input::iterator anIter = myRepresentation2Input.find(aRepresentationKey); + if(anIter == myRepresentation2Input.end()){ + INITMSG(MYDEBUG, "MultiResult_i::GetInput - this = "<BuildFields(); + if(myIsBuildMinMax) + anInput->BuildMinMax(); + myRepresentation2Input[aRepresentationKey] = anInput; + return anInput; + } + + return anIter->second; +} + + +#endif // ENABLE_MULTIPR diff --git a/src/VISU_I/VISU_MultiResult_i.hh b/src/VISU_I/VISU_MultiResult_i.hh new file mode 100644 index 00000000..18598c86 --- /dev/null +++ b/src/VISU_I/VISU_MultiResult_i.hh @@ -0,0 +1,181 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_MultiResult_i.hh +// Author : Alexey PETROV +// Module : VISU + +#ifndef __VISU_MULTI_RESULT_I_H__ +#define __VISU_MULTI_RESULT_I_H__ + +#ifndef ENABLE_MULTIPR +# define RESULT_CLASS_NAME Result_i +#else +# define RESULT_CLASS_NAME MultiResult_i + +#include "VISU_Result_i.hh" +#include "MULTIPR_Obj.hxx" + +#include + +namespace VISU +{ + //---------------------------------------------------------------------------- + class MultiResult_i : public virtual Result_i + { + MultiResult_i(const MultiResult_i&); + + public: + typedef Result_i TSuperClass; + + MultiResult_i(SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildMinMax, + CORBA::Boolean theIsBuildGroups); + + MultiResult_i(); + + virtual + ~MultiResult_i(); + + virtual + CORBA::Boolean + IsDone(); + + virtual + VISU::Result::EntityNames* + GetPartNames(const char* theMeshName); + + virtual + VISU::Result::Resolutions* + GetResolutions(const char* theMeshName, + const char* thePartName); + + virtual + VISU::Result::Resolution + GetResolution(const char* theMeshName, + const char* thePartName); + + virtual + void + SetResolution(const char* theMeshName, + const char* thePartName, + VISU::Result::Resolution theResolution); + + + typedef std::string TPartName; + typedef std::vector TPartNames; + + typedef size_t TPartID; + typedef std::string TPath; + typedef std::string TMeshName; + + struct TPartInfo + { + TMeshName myMeshName; + TPartName myName; + TPartID myPartID; + TPath myPath; + TFileName myFileName; + }; + + typedef std::map TPartInfos; + TPartInfos myPartInfos; + + typedef std::map TPartName2FileName; + typedef std::map TPartName2Resolution; + typedef std::set TResolutions; + + typedef std::set TRepresentationKey; + typedef std::map TRepresentation2Input; + + typedef std::set TSubPartNames; + typedef std::map TMainPart2SubPartNames; + + private: + multipr::Obj myMultiprObj; + TPartName2FileName myPartName2FileName; + TPartName2Resolution myPartName2Resolution; + TMainPart2SubPartNames myMainPart2SubPartNames; + + TRepresentation2Input myRepresentation2Input; + + protected: + virtual + Storable* + Build(SALOMEDS::SObject_ptr theSObject, + CORBA::Boolean theIsAtOnce = true) ; + + virtual + void + BuildDataTree(const std::string& theResultEntry); + + public: + virtual + size_t + IsPossible(); + + virtual + Storable* + Create(const char* theFileName); + + virtual + Storable* + Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile); + + //--------------------------------------------------------------- + virtual + bool + Save(SALOMEDS::SComponent_ptr theComponent, + const std::string& theURL, + bool theIsMultiFile, + bool theIsASCII, + TFileNames& theFileNames, + TFileNames& theFiles); + + virtual + CORBA::Boolean + CanCopy(SALOMEDS::SObject_ptr theObject); + + virtual + void + ToStream(std::ostringstream& theStr); + + virtual + PInput + GetInput(const std::string& theMeshName = "", + VISU::Entity theEntity = VISU::NONE, + const std::string& theFieldName = "", + CORBA::Long theTimeStampNumber = -1); + }; + +} + +#endif // ENABLE_MULTIPR + +#endif // __VISU_MULTI_RESULT_I_H__ diff --git a/src/VISU_I/VISU_Plot3D_i.cc b/src/VISU_I/VISU_Plot3D_i.cc index cf2b8ebb..a8de05e6 100644 --- a/src/VISU_I/VISU_Plot3D_i.cc +++ b/src/VISU_I/VISU_Plot3D_i.cc @@ -19,6 +19,7 @@ // #include "VISU_Plot3D_i.hh" +#include "VISU_Prs3dUtils.hh" #include "VISU_Result_i.hh" #include "VISU_Plot3DPL.hxx" @@ -188,6 +189,8 @@ VISU::Plot3D_i } }; + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TEvent(GetSpecificPL(), VISU_CutPlanesPL::PlaneOrientation(theOrient), theXAngle, @@ -228,6 +231,8 @@ VISU::Plot3D_i ::SetPlanePosition(CORBA::Double thePlanePosition, CORBA::Boolean theIsRelative) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun2ArgEvent (GetSpecificPL(), &VISU_Plot3DPL::SetPlanePosition, thePlanePosition, theIsRelative)); } @@ -256,6 +261,8 @@ void VISU::Plot3D_i ::SetScaleFactor(CORBA::Double theScaleFactor) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_Plot3DPL::SetScaleFactor, theScaleFactor)); } @@ -275,6 +282,8 @@ void VISU::Plot3D_i ::SetNbOfContours(CORBA::Long theNb) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_Plot3DPL::SetNumberOfContours, theNb)); } @@ -294,6 +303,8 @@ void VISU::Plot3D_i ::SetContourPrs(CORBA::Boolean theIsContourPrs) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_Plot3DPL::SetContourPrs, theIsContourPrs)); } diff --git a/src/VISU_I/VISU_Prs3dUtils.cc b/src/VISU_I/VISU_Prs3dUtils.cc new file mode 100644 index 00000000..f99e7843 --- /dev/null +++ b/src/VISU_I/VISU_Prs3dUtils.cc @@ -0,0 +1,75 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_Prs3dUtils.cc +// Author : Alexey PETROV +// Module : VISU + +#include "VISU_Prs3dUtils.hh" +#include "SalomeApp_Study.h" +#include "SALOME_Event.hxx" + + +namespace VISU +{ + //---------------------------------------------------------------------------- + TSetModified + ::TSetModified(VISU::Prs3d_i* thePrs3d): + myPrs3d(thePrs3d) + { + this->Modified(); + } + + + //---------------------------------------------------------------------------- + TSetModified + ::~TSetModified() + { + struct TEvent: public SALOME_Event + { + VISU::TSetModified* mySetModified; + TEvent(VISU::TSetModified* theSetModified): + mySetModified(theSetModified) + {} + + virtual + void + Execute() + { + VISU::Prs3d_i* aPrs3d = mySetModified->myPrs3d; + + if(!aPrs3d || aPrs3d->GetActorEntry() == "") + return; + + if(aPrs3d->GetMTime() > mySetModified->GetMTime()){ + if(SalomeApp_Study* aStudy = aPrs3d->GetGUIStudy()) + aStudy->Modified(); + } + } + }; + + ProcessVoidEvent(new TEvent(this)); + } + + + //---------------------------------------------------------------------------- +}; diff --git a/src/VISU_I/VISU_Prs3dUtils.hh b/src/VISU_I/VISU_Prs3dUtils.hh new file mode 100644 index 00000000..2f4bf8b9 --- /dev/null +++ b/src/VISU_I/VISU_Prs3dUtils.hh @@ -0,0 +1,52 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_Prs3dUtils.hh +// Author : Alexey PETROV +// Module : VISU + +#ifndef __VISU_PRS3D_UTILS_H__ +#define __VISU_PRS3D_UTILS_H__ + +#include "VISU_Prs3d_i.hh" + +#include + + +namespace VISU +{ + //---------------------------------------------------------------------------- + struct TSetModified: vtkTimeStamp + { + VISU::Prs3d_i* myPrs3d; + + TSetModified(VISU::Prs3d_i* thePrs3d); + + ~TSetModified(); + }; + + + //---------------------------------------------------------------------------- +} + + +#endif // __VISU_PRS3D_UTILS_H__ diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index b8edb3a7..0c2acd0b 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -24,8 +24,9 @@ // Author : Alexey PETROV // Module : VISU -#include "VISU_PipeLine.hxx" #include "VISU_Prs3d_i.hh" +#include "VISU_Prs3dUtils.hh" +#include "VISU_PipeLine.hxx" #include "VISU_Result_i.hh" #include "VISU_Actor.h" @@ -65,6 +66,8 @@ VISU::Prs3d_i ::SameAs(const Prs3d_i* theOrigin) { if(Prs3d_i* anOrigin = const_cast(theOrigin)){ + VISU::TSetModified aModified(this); + GetPipeLine()->SameAs(anOrigin->GetPipeLine()); anOrigin->GetOffset(myOffset); } @@ -153,17 +156,16 @@ void VISU::Prs3d_i ::SetCResult(VISU::Result_i* theResult) { - VISU::Result_i* aResult = GetCResult(); - if(aResult != theResult){ - if(aResult) - aResult->Destroy(); - if(theResult){ - theResult->Register(); - SetStudyDocument(theResult->GetStudyDocument()); - } - myResult = theResult; - myParamsTime.Modified(); - } + if(GetCResult() == theResult) + return; + + if(theResult) + SetStudyDocument(theResult->GetStudyDocument()); + + VISU::TSetModified aModified(this); + + myResult = theResult; + myParamsTime.Modified(); } //---------------------------------------------------------------------------- @@ -216,10 +218,13 @@ void VISU::Prs3d_i ::SetMeshName(const char* theMeshName) { - if(myMeshName != theMeshName){ - myMeshName = theMeshName; - myParamsTime.Modified(); - } + if(myMeshName == theMeshName) + return; + + VISU::TSetModified aModified(this); + + myMeshName = theMeshName; + myParamsTime.Modified(); } @@ -248,7 +253,7 @@ VISU::Prs3d_i { unsigned long int aTime = myParamsTime.GetMTime(); if(IsPipeLineExists()) - aTime = std::max(aTime,GetPipeLine()->GetMTime()); + aTime = std::max(aTime, GetPipeLine()->GetMTime()); return aTime; } diff --git a/src/VISU_I/VISU_Prs3d_i.hh b/src/VISU_I/VISU_Prs3d_i.hh index 6419d111..5471eef6 100644 --- a/src/VISU_I/VISU_Prs3d_i.hh +++ b/src/VISU_I/VISU_Prs3d_i.hh @@ -50,8 +50,19 @@ class vtkDataSet; namespace VISU { + //---------------------------------------------------------------------------- class Result_i; + + //---------------------------------------------------------------------------- + struct TResultObserver: public virtual boost::signalslib::trackable + { + virtual + void + UpdateFromResult(Result_i* theResult) = 0; + }; + + //---------------------------------------------------------------------------- //! Base class for all VTK 3D presentations. /*! @@ -63,11 +74,10 @@ namespace VISU - implement basic actor management (CreateActor, UpdateActor, UpdateActors, RemoveActor and RemoveActors); - implement common 3D functionality like "clipping planes" and offset. */ - class VISU_I_EXPORT Prs3d_i : - public virtual POA_VISU::Prs3d, - public virtual SALOME::GenericObj_i, - public virtual TActorFactory, - public virtual PrsObject_i + class VISU_I_EXPORT Prs3d_i : public virtual POA_VISU::Prs3d, + public virtual SALOME::GenericObj_i, + public virtual TActorFactory, + public virtual PrsObject_i { Prs3d_i(const Prs3d_i&); @@ -267,6 +277,11 @@ namespace VISU Handle(SALOME_InteractiveObject) GetIO(); + //! Used in derived classes to initilize the IO for actors + virtual + std::string + GetActorEntry(); + protected: /*! Used in Apply method to get know whether it is possible to create presentation @@ -304,11 +319,6 @@ namespace VISU vtkTimeStamp myUpdateTime; vtkTimeStamp myParamsTime; - //! Used in derived classes to initilize the IO for actors - virtual - std::string - GetActorEntry(); - private: void SetResultEntry(const std::string& theResultEntry); diff --git a/src/VISU_I/VISU_PrsObject_i.cc b/src/VISU_I/VISU_PrsObject_i.cc index 2ebbadd5..b6ab264c 100644 --- a/src/VISU_I/VISU_PrsObject_i.cc +++ b/src/VISU_I/VISU_PrsObject_i.cc @@ -56,9 +56,9 @@ VISU::RemovableObject_i { myName = theName; if(theIsUpdateStudyAttr){ - SALOMEDS::SObject_var aSObject = myStudy->FindObjectID(GetEntry().c_str()); + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(GetEntry().c_str()); if(!aSObject->_is_nil()){ - SALOMEDS::StudyBuilder_var aBuilder = myStudy->NewBuilder(); + SALOMEDS::StudyBuilder_var aBuilder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr = aBuilder->FindOrCreateAttribute( aSObject, "AttributeName" ); SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow( anAttr ); aNameAttr->SetValue( theName.c_str() ); @@ -68,7 +68,7 @@ VISU::RemovableObject_i //--------------------------------------------------------------- -const std::string& +std::string VISU::RemovableObject_i ::GetName() const { @@ -77,11 +77,20 @@ VISU::RemovableObject_i //--------------------------------------------------------------- -const SALOMEDS::Study_var& +SALOMEDS::Study_var VISU::RemovableObject_i ::GetStudyDocument() const { - return myStudy; + return myStudyDocument; +} + + +//--------------------------------------------------------------- +SalomeApp_Study* +VISU::RemovableObject_i +::GetGUIStudy() const +{ + return myGUIStudy; } @@ -90,7 +99,8 @@ void VISU::RemovableObject_i ::SetStudyDocument(SALOMEDS::Study_ptr theStudy) { - myStudy = SALOMEDS::Study::_duplicate(theStudy); + myStudyDocument = SALOMEDS::Study::_duplicate(theStudy); + myGUIStudy = VISU::GetGUIStudy(theStudy); } @@ -100,7 +110,7 @@ VISU::RemovableObject_i ::GetEntry() { CORBA::String_var anIOR = GetID(); - SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(anIOR.in()); + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectIOR(anIOR.in()); CORBA::String_var anEntry(""); if(!CORBA::is_nil(aSObject.in())) anEntry = aSObject->GetID(); diff --git a/src/VISU_I/VISU_PrsObject_i.hh b/src/VISU_I/VISU_PrsObject_i.hh index de524352..08e95ef8 100644 --- a/src/VISU_I/VISU_PrsObject_i.hh +++ b/src/VISU_I/VISU_PrsObject_i.hh @@ -41,15 +41,18 @@ namespace VISU virtual ~RemovableObject_i(); - const SALOMEDS::Study_var& + SALOMEDS::Study_var GetStudyDocument() const; + SalomeApp_Study* + GetGUIStudy() const; + virtual std::string GetEntry(); virtual - const std::string& + std::string GetName() const; virtual @@ -65,7 +68,8 @@ namespace VISU private: std::string myName; - SALOMEDS::Study_var myStudy; + SalomeApp_Study* myGUIStudy; + SALOMEDS::Study_var myStudyDocument; RemovableObject_i(const RemovableObject_i&); }; diff --git a/src/VISU_I/VISU_ResultUtils.cc b/src/VISU_I/VISU_ResultUtils.cc new file mode 100644 index 00000000..9f8d37d0 --- /dev/null +++ b/src/VISU_I/VISU_ResultUtils.cc @@ -0,0 +1,673 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_ResultUtils.cc +// Author : Alexey PETROV +// Module : VISU + +#include "VISU_ResultUtils.hh" + +#include "SUIT_Session.h" +#include "SALOME_Event.hxx" +#include "SalomeApp_Study.h" +#include "SalomeApp_Application.h" + +#include "VISU_Convertor.hxx" +#include "VISU_ConvertorUtils.hxx" + +#include +#include +#include + +#include +#include +#include + +#ifdef _DEBUG_ +static int MYTIMEDEBUG = 0; +#else +static int MYTIMEDEBUG = 0; +#endif + +namespace VISU +{ + //---------------------------------------------------------------------------- + typedef boost::recursive_mutex TMutex; + typedef TMutex::scoped_lock TLock; + + static TMutex myMutex; + + //---------------------------------------------------------------------------- + TResultManager + ::TResultManager(Result_i* theResult): + myResult(theResult) + { + myResult->Register(); + } + + + //---------------------------------------------------------------------------- + TResultManager + ::~TResultManager() + { + myResult->Destroy(); + } + + + //---------------------------------------------------------------------------- + TTransactionManager + ::TTransactionManager(_PTR(Study) theStudyDocument): + myStudyBuilder(theStudyDocument->NewBuilder()) + { + TLock aLock(myMutex); + myStudyBuilder->NewCommand(); + } + + + //---------------------------------------------------------------------------- + TTransactionManager + ::~TTransactionManager() + { + TLock aLock(myMutex); + myStudyBuilder->CommitCommand(); + } + + + //---------------------------------------------------------------------------- + TUpdateObjBrowser + ::TUpdateObjBrowser(const int theStudyId, CORBA::Boolean* theIsDone): + myStudyId(theStudyId), + myIsDone(theIsDone) + {} + + + //---------------------------------------------------------------------------- + void + TUpdateObjBrowser + ::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; + } + } + + + //---------------------------------------------------------------------------- + QString + GenerateName(const std::string& theName) + { + TLock aLock(myMutex); + + typedef std::map TNameMap; + static TNameMap aMap; + + TNameMap::const_iterator anIter = aMap.find(theName); + QString aResult; + if (anIter == aMap.end()) { + aMap[theName] = 0; + aResult = theName; + } else { + aResult = GenerateName(theName,++aMap[theName]); + } + return aResult; + } + + + //---------------------------------------------------------------------------- + bool + SplitName(const std::string& theName, + std::string& theBase, + std::string& theSuffix, + char theDelimeter) + { + size_t aPosition = theName.rfind(theDelimeter); + if(aPosition == std::string::npos){ + theBase = theName; + theSuffix = ""; + return false; + } + + theBase = theName.substr(0, aPosition); + theSuffix = theName.substr(aPosition); + return true; + } + + + //---------------------------------------------------------------------------- + std::string + MakeFileName(const std::string& theName, + const void* thePointer) + { + std::ostringstream aStream; + aStream<NewBuilder(); + _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry); + _PTR(SObject) aNewObj = aStudyBuilder->NewObject(aFather); + _PTR(SObject) aRefSObj = theStudyDocument->FindObjectID(theRefEntry); + aStudyBuilder->Addreference(aNewObj,aRefSObj); + } + + + //---------------------------------------------------------------------------- + void + RemoveSObject(_PTR(Study) theStudyDocument, + const string& theEntry) + { + _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); + _PTR(SObject) aSObject = theStudyDocument->FindObjectID(theEntry); + aStudyBuilder->RemoveObject(aSObject); + } + + + //---------------------------------------------------------------------------- + void + BuildEntities(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + const std::string& theResultEntry, + CORBA::Boolean theIsAtOnce, + CORBA::Boolean theIsBuildGroups, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildParts, + _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,aTmp; + 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, + NO_ICON, + NO_IOR, + aMeshName, + NO_PERFSITENT_REF, + aComment.latin1(), + true); + + aComment.sprintf("myComment=FAMILIES;myMeshName=%s", + aMeshName.c_str()); + std::string aSubMeshesEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + NO_ICON, + NO_IOR, + "Families", + NO_PERFSITENT_REF, + aComment.latin1(), + true); + + if(theIsBuildGroups){ + aMesh->myGroupsEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + NO_ICON, + NO_IOR, + NO_NAME, + NO_PERFSITENT_REF, + NO_COMMENT, + true); + } + + if(theIsBuildFields){ + aMesh->myFieldsEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + NO_ICON, + NO_IOR, + NO_NAME, + NO_PERFSITENT_REF, + NO_COMMENT, + true); + } + + if(theIsBuildParts){ + aMesh->myPartsEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + NO_ICON, + NO_IOR, + NO_NAME, + NO_PERFSITENT_REF, + NO_COMMENT, + 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;myMeshName=%s;myId=%d", + aMeshName.c_str(), + anEntity); + + aMeshOnEntity->myEntry = + CreateAttributes(theStudy, + aSubMeshesEntry, + NO_ICON, + NO_IOR, + anEntityName.c_str(), + NO_PERFSITENT_REF, + aComment.latin1(), + true); + } + } + + ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); + } + + + //---------------------------------------------------------------------------- + void + BuildGroups(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild, + CORBA::Boolean theIsAtOnce, + _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,aTmp; + 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;myMeshName=%s;myEntityId=%d;myName=%s", + aMeshName.c_str(), + anEntity, + aFamilyName.c_str()); + + aFamily->myEntry = + CreateAttributes(theStudy, + aMeshOnEntity->myEntry, + NO_ICON, + NO_IOR, + aFamilyName, + NO_PERFSITENT_REF, + aComment.latin1(), + true); + } + } + //Importing groups + const TGroupMap& aGroupMap = aMesh->myGroupMap; + if(!aGroupMap.empty()){ + aComment.sprintf("myComment=GROUPS;myMeshName=%s", + aMeshName.c_str()); + + CreateAttributes(theStudy, + aMesh->myGroupsEntry, + NO_ICON, + NO_IOR, + "Groups", + NO_PERFSITENT_REF, + aComment.latin1(), + false); + + 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;myMeshName=%s;myName=%s", + aMeshName.c_str(), + aGroupName.c_str()); + aGroup->myEntry = + CreateAttributes(theStudy, + aMesh->myGroupsEntry, + NO_ICON, + NO_IOR, + aGroupName, + NO_PERFSITENT_REF, + 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); + } + } + }else if(!theIsAtOnce) + RemoveSObject(theStudy, + aMesh->myGroupsEntry); + } + + ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); + } + + + //---------------------------------------------------------------------------- + void + BuildFields(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild, + CORBA::Boolean theIsAtOnce, + _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,aTmp; + 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 + bool anIsFieldsEntryUpdated = 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(!anIsFieldsEntryUpdated) + { + aComment = ""; + aComment.append("myComment=FIELDS;"); + aComment.append("myMeshName=");aComment.append(aMeshName); + + CreateAttributes(theStudy, + aMesh->myFieldsEntry, + NO_ICON, + NO_IOR, + "Fields", + NO_PERFSITENT_REF, + aComment.latin1(), + false); + + anIsFieldsEntryUpdated = 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;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d", + aMeshName.c_str(), + anEntity, + aFieldName.c_str(), + aValField.size(), + aField->myNbComp); + + aField->myEntry = CreateAttributes(theStudy, + aMesh->myFieldsEntry, + NO_ICON, + NO_IOR, + aFieldNameWithUnit.latin1(), + NO_PERFSITENT_REF, + 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;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", + aMeshName.c_str(), + anEntity, + aFieldName.c_str(), + aTimeStamp, + aField->myNbComp); + + string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime); + + aValForTime->myEntry = CreateAttributes(theStudy, + aField->myEntry, + NO_ICON, + NO_IOR, + aTimeStampId, + NO_PERFSITENT_REF, + aComment.latin1(), + true); + } + } + } + + if(!anIsFieldsEntryUpdated && !theIsAtOnce) + RemoveSObject(theStudy, aMesh->myFieldsEntry); + } + + ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); + } + + + //---------------------------------------------------------------------------- + void + BuildMinMax(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild) + { + if(!theIsBuild || *theIsDone) + return; + + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildMinMax"); + TResultManager aResultManager(theResult); + + theInput->BuildMinMax(); + + *theIsDone = true; + + theResult->UpdateObservers(); + } + + + //---------------------------------------------------------------------------- + void + BuildFieldDataTree(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsFieldsDone, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean* theIsMinMaxDone, + CORBA::Boolean theIsBuildMinMax, + _PTR(Study) theStudy) + { + BuildFields(theResult, + theInput, + theIsFieldsDone, + theIsBuildFields, + false, + theStudy); + + BuildMinMax(theResult, + theInput, + theIsMinMaxDone, + theIsBuildMinMax); + } + + + //---------------------------------------------------------------------------- + bool + RemoveFile(const std::string& theFileName, + bool theRemoveEmptyDir) + { + QFileInfo aFileInfo(theFileName); + QFile(aFileInfo.absFilePath()).remove(); + + if(theRemoveEmptyDir) + QDir().rmdir(aFileInfo.dirPath(TRUE)); + + return aFileInfo.exists(); + } + + + //---------------------------------------------------------------------------- + bool + CopyFile(const std::string& theSourceFileName, + const std::string& theTargetFileName) + { + QFileInfo aSourceFileInfo(theSourceFileName); + QFileInfo aTargetFileInfo(theTargetFileName); + if(aSourceFileInfo.absFilePath() == aTargetFileInfo.absFilePath()) + return true; + + QString aCommand; + aCommand.sprintf("%s %s %s", + COPY_COMMAND, + aSourceFileInfo.filePath().latin1(), + aTargetFileInfo.filePath().latin1()); + + return system(aCommand.latin1()) == 0; + } + + + //---------------------------------------------------------------------------- +} diff --git a/src/VISU_I/VISU_ResultUtils.hh b/src/VISU_I/VISU_ResultUtils.hh new file mode 100644 index 00000000..357dfd49 --- /dev/null +++ b/src/VISU_I/VISU_ResultUtils.hh @@ -0,0 +1,156 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_ResultUtils.hh +// Author : Alexey PETROV +// Module : VISU + +#ifndef __VISU_RESULT_UTILS_H__ +#define __VISU_RESULT_UTILS_H__ + +#include "VISU_Result_i.hh" +#include "SALOME_Event.hxx" + +#include + +namespace VISU +{ + //---------------------------------------------------------------------------- + struct TUpdateObjBrowser: public SALOME_Event + { + int myStudyId; + CORBA::Boolean* myIsDone; + TUpdateObjBrowser(const int theStudyId, CORBA::Boolean* theIsDone); + + virtual + void + Execute(); + }; + + + //---------------------------------------------------------------------------- + struct TResultManager + { + Result_i* myResult; + + TResultManager(Result_i* theResult); + + ~TResultManager(); + }; + + + //---------------------------------------------------------------------------- + struct TTransactionManager + { + _PTR(StudyBuilder) myStudyBuilder; + + TTransactionManager(_PTR(Study) theStudyDocument); + + ~TTransactionManager(); + }; + + + //---------------------------------------------------------------------------- + QString + GenerateName(const std::string& theName); + + + //---------------------------------------------------------------------------- + bool + SplitName(const std::string& theName, + std::string& theBase, + std::string& theSuffix, + char theDelimeter = ':'); + + + //---------------------------------------------------------------------------- + std::string + MakeFileName(const std::string& theName, + const void* thePointer); + + + //---------------------------------------------------------------------------- + void + BuildEntities(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + const std::string& theResultEntry, + CORBA::Boolean theIsAtOnce, + CORBA::Boolean theIsBuildGroups, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildParts, + _PTR(Study) theStudy); + + + //---------------------------------------------------------------------------- + void + BuildGroups(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild, + CORBA::Boolean theIsAtOnce, + _PTR(Study) theStudy); + + + //---------------------------------------------------------------------------- + void + BuildFields(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild, + CORBA::Boolean theIsAtOnce, + _PTR(Study) theStudy); + + + //---------------------------------------------------------------------------- + void + BuildMinMax(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild); + + + //---------------------------------------------------------------------------- + void + BuildFieldDataTree(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsFieldsDone, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean* theIsMinMaxDone, + CORBA::Boolean theIsBuildMinMax, + _PTR(Study) theStudy); + + //---------------------------------------------------------------------------- + bool + RemoveFile(const std::string& theFileName, + bool theRemoveEmptyDir = true); + + //---------------------------------------------------------------------------- + bool + CopyFile(const std::string& theSourceFileName, + const std::string& theTargetFileName); + + //---------------------------------------------------------------------------- +} + + +#endif // __VISU_RESULT_UTILS_H__ diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index 162842b9..d7af2d03 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -24,7 +24,9 @@ // Author : Alexey PETROV // Module : VISU -#include "VISU_Result_i.hh" +#include "VISU_MultiResult_i.hh" +#include "VISU_ResultUtils.hh" +#include "VISU_Prs3d_i.hh" #include "VISU_Convertor_impl.hxx" #include "VISU_CorbaMedConvertor.hxx" @@ -41,10 +43,7 @@ #include "SalomeApp_Study.h" #include "SalomeApp_Application.h" -#include #include - -#include #include // QT Includes @@ -61,20 +60,10 @@ // OCCT Includes #include -#ifdef ENABLE_MULTIPR -// MULTIPR -#include "MULTIPR_Obj.hxx" -#endif - -using namespace VISU; -using namespace std; - #ifdef _DEBUG_ -static int MYDEBUG = 1; -static int MYTIMEDEBUG = 0; +static int MYDEBUG = 0; #else static int MYDEBUG = 0; -static int MYTIMEDEBUG = 0; #endif @@ -82,7 +71,7 @@ namespace VISU { //--------------------------------------------------------------- Result_var - FindResult (SALOMEDS::SObject_ptr theSObject) + FindResult(SALOMEDS::SObject_ptr theSObject) { SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent(); SALOMEDS::SObject_var aFather = theSObject->GetFather(); @@ -117,85 +106,7 @@ namespace VISU //--------------------------------------------------------------- - 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())) { - if(_PTR(Study) aStudyDS = aStudy->studyDS()){ - if(aStudyDS->StudyId() == myStudyId){ - myResult = aStudy->studyDS(); - break; - } - } - } - } - ++anIter; - } - } - }; - - - //--------------------------------------------------------------- - QString - GenerateName (const std::string& 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 - "<GetFatherComponent(); @@ -218,858 +129,7 @@ namespace VISU } - //--------------------------------------------------------------- - 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); - } - - - //--------------------------------------------------------------- - inline - std::string - CreateAttributes(_PTR(Study) theStudyDocument, - const string& theFatherEntry, - const string& theIOR, - const string& theName, - const string& theComment, - CORBA::Boolean theCreateNew, - const string& theIcon = "") - { - 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 (theComment != "") { - anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeString"); - _PTR(AttributeString) aCmnt (anAttr); - aCmnt->SetValue(theComment); - } - // MULTIPR - if (theIcon != "") { - anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributePixMap"); - _PTR(AttributePixMap) aPixmap (anAttr); - aPixmap->SetPixMap(theIcon.c_str()); - } - return aNewObj->GetID(); - } - - - //--------------------------------------------------------------- - inline - void - UpdateAttributes(_PTR(Study) theStudyDocument, - const string& theEntry, - const string& theIOR, - const string& theName, - const string& theComment) - { - TLock aLock(myMutex); - - _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); - _PTR(SObject) aSObject = theStudyDocument->FindObjectID(theEntry); - - _PTR(GenericAttribute) anAttr; - if (theIOR != "") { - anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeIOR"); - _PTR(AttributeIOR) anIOR (anAttr); - anIOR->SetValue(theIOR); - } - if (theName != "") { - anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeName"); - _PTR(AttributeName) aName (anAttr); - aName->SetValue(theName); - } - if (theComment != "") { - anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeString"); - _PTR(AttributeString) aCmnt (anAttr); - aCmnt->SetValue(theComment); - } - } - - - //--------------------------------------------------------------- - inline - void - RemoveSObject(_PTR(Study) theStudyDocument, - const string& theEntry) - { - TLock aLock(myMutex); - - _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); - _PTR(SObject) aSObject = theStudyDocument->FindObjectID(theEntry); - aStudyBuilder->RemoveObject(aSObject); - } - - - //--------------------------------------------------------------- - 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, - CORBA::Boolean theIsAtOnce, - CORBA::Boolean theIsBuildGroups, - CORBA::Boolean theIsBuildFields, - _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,aTmp; - 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); - - if(theIsBuildGroups){ - aMesh->myGroupsEntry = - CreateAttributes(theStudy, - aMesh->myEntry, - "", - "", - "", - true); - } - - if(theIsBuildFields){ - aMesh->myFieldsEntry = - CreateAttributes(theStudy, - aMesh->myEntry, - "", - "", - "", - true); - } - -#ifdef ENABLE_MULTIPR - // MULTIPR - aMesh->myPartsEntry = - CreateAttributes(theStudy, - aMesh->myEntry, - "", - "", - "", - true); -#endif - - //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;myMeshName=%s;myId=%d", - 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, - CORBA::Boolean theIsAtOnce, - _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,aTmp; - 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;myMeshName=%s;myEntityId=%d;myName=%s", - 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()); - - UpdateAttributes(theStudy, - aMesh->myGroupsEntry, - "", - "Groups", - aComment.latin1()); - - 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;myMeshName=%s;myName=%s", - aMeshName.c_str(), - aGroupName.c_str()); - aGroup->myEntry = - CreateAttributes(theStudy, - aMesh->myGroupsEntry, - "", - 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); - } - } - }else if(!theIsAtOnce) - RemoveSObject(theStudy, - aMesh->myGroupsEntry); - } - - ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); - } - - - //--------------------------------------------------------------- - void BuildFields( - Result_i* theResult, - VISU_Convertor* theInput, - CORBA::Boolean* theIsDone, - CORBA::Boolean theIsBuild, - CORBA::Boolean theIsAtOnce, - _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,aTmp; - 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 - bool anIsFieldsEntryUpdated = 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(!anIsFieldsEntryUpdated) - { - aComment = ""; - aComment.append("myComment=FIELDS;"); - aComment.append("myMeshName=");aComment.append(aMeshName); - - UpdateAttributes( - theStudy, - aMesh->myFieldsEntry, - "", - "Fields", - aComment.latin1()); - - anIsFieldsEntryUpdated = 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;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d", - aMeshName.c_str(), - anEntity, - aFieldName.c_str(), - aValField.size(), - aField->myNbComp); - - aField->myEntry = CreateAttributes( - theStudy, - aMesh->myFieldsEntry, - "", - 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;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", - 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); - } - } - } - - if(!anIsFieldsEntryUpdated && !theIsAtOnce) - RemoveSObject(theStudy, aMesh->myFieldsEntry); - } - - ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); - } - - -#ifdef ENABLE_MULTIPR - // MULTIPR - void BuildParts (Result_i* theResult, - VISU_Convertor* theInput, - CORBA::Boolean* theIsDone, - CORBA::Boolean theIsBuild, - CORBA::Boolean theIsAtOnce, - _PTR(Study) theStudy) - { - if(!theIsBuild || *theIsDone) - return; - - // if MED file is not a distributed MED file (created with MULTIPR), - // then it is not necessary to build parts - if (theResult->GetFileInfoMultipr().filePath().isEmpty()) - return; - - try - { - multipr::Obj multiprObj; - multiprObj.create(theResult->GetFileInfoMultipr().filePath().latin1()); - if (multiprObj.isValidDistributedMEDFile()) - { - theResult->SetIsDistributedMEDMultipr(true); - - const TMeshMap& aMeshMap = theInput->GetMeshMap(); - TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - const PMesh& aMesh = aMeshMapIter->second; - - vector listParts = multiprObj.getParts(); - - QString aComment = "Sub-parts: #"; - aComment += QString::number(listParts.size()); - - UpdateAttributes( - theStudy, - aMesh->myPartsEntry, - "", - "Parts", - aComment.latin1()); - - string lastEntry; - - for (unsigned i = 0 ; i < listParts.size() ; i++) - { - const char* strItem = listParts[i].c_str(); - const char* strPartInfo = multiprObj.getPartInfo(strItem).c_str(); - - char lMeshName[256]; - int lId; - char lPartName[256]; - char lPath[256]; - char lMEDFileName[256]; - - // parse infos - sscanf(strPartInfo, "%s %d %s %s %s", - lMeshName, - &lId, - lPartName, - lPath, - lMEDFileName); - - if ((strstr(lPartName,"_MED") != NULL) || (strstr(lPartName,"_LOW") != NULL)) - { - QString aComment = ""; - aComment.append("myComment=PART;"); - aComment.append("res=ML;"); - aComment.append("file="); - aComment.append(lMEDFileName); - - CreateAttributes( - theStudy, - lastEntry, // father - "", - lPartName, - aComment.latin1(), - true); - } - else - { - QString aComment = ""; - QString icon = ""; - - if (i != listParts.size()-1) - { - const char* strItemNext = listParts[i+1].c_str(); - const char* strPartInfoNext = multiprObj.getPartInfo(strItemNext).c_str(); - if ((strstr(strPartInfoNext,"_MED") != NULL) || (strstr(strPartInfoNext,"_LOW") != NULL)) - { - // next part is MED or LOW resolution - icon = "ICON_MULTIPR_VIEW_LOW"; - theResult->SetResolutionMultipr(lPartName, 'L'); - - aComment.append("myComment=PART;"); - aComment.append("res=FML;"); - aComment.append("file="); - aComment.append(lMEDFileName); - } - else - { - // no resolution associated with this part - icon = "ICON_MULTIPR_VIEW_FULL"; - theResult->SetResolutionMultipr(lPartName, 'F'); - - aComment.append("myComment=PART;"); - aComment.append("res=F;"); - aComment.append("file="); - aComment.append(lMEDFileName); - } - } - else - { - // last part - icon = "ICON_MULTIPR_VIEW_FULL"; - theResult->SetResolutionMultipr(lPartName, 'F'); - - aComment.append("myComment=PART;"); - aComment.append("res=FML;"); - aComment.append("file="); - aComment.append(lMEDFileName); - } - - lastEntry = CreateAttributes( - theStudy, - aMesh->myPartsEntry, // father - "", - lPartName, - aComment.latin1(), - true, - icon.latin1()); - } - - theResult->AddPartMultipr(lPartName, lMEDFileName); - } - } - else - { - // invalid distributed MED file - return; - } - } - catch (...) - { - throw std::runtime_error("error while reading distributed MED file"); - } - - ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); - } -#endif - - - //--------------------------------------------------------------- - void - BuildMinMax(Result_i* theResult, - VISU_Convertor* theInput, - CORBA::Boolean* theIsDone, - CORBA::Boolean theIsBuild, - Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal) - { - if(!theIsBuild || *theIsDone) - return; - - TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildMinMax"); - TResultManager aResultManager(theResult); - - theInput->BuildMinMax(); - - *theIsDone = true; - - (*theUpdateMinMaxSignal)(); - } - - - //--------------------------------------------------------------- - void - BuildFieldDataTree(Result_i* theResult, - VISU_Convertor* theInput, - CORBA::Boolean* theIsFieldsDone, - CORBA::Boolean theIsBuildFields, - CORBA::Boolean* theIsMinMaxDone, - CORBA::Boolean theIsBuildMinMax, - Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal, - _PTR(Study) theStudy) - { - BuildFields(theResult, - theInput, - theIsFieldsDone, - theIsBuildFields, - false, - theStudy); - - BuildMinMax(theResult, - theInput, - theIsMinMaxDone, - theIsBuildMinMax, - theUpdateMinMaxSignal); - } - - - //--------------------------------------------------------------- - 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; - Result_i::TUpdateMinMaxSignal* myUpdateMinMaxSignal; - CORBA::Boolean* myIsGroupsDone; - CORBA::Boolean myIsBuildGroups; -#ifdef ENABLE_MULTIPR - CORBA::Boolean* myIsPartsDone; - CORBA::Boolean myIsBuildParts; -#endif - _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, - Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal, - CORBA::Boolean* theIsGroupsDone, - CORBA::Boolean theIsBuildGroups, -#ifdef ENABLE_MULTIPR - CORBA::Boolean* theIsPartsDone, - CORBA::Boolean theIsBuildParts, -#endif - _PTR(Study) theStudy): - myResult(theResult), - myInput(theInput), - myIsEntitiesDone(theIsEntitiesDone), - myResultEntry(theResultEntry), - myIsFieldsDone(theIsFieldsDone), - myIsBuildFields(theIsBuildFields), - myIsMinMaxDone(theIsMinMaxDone), - myIsBuildMinMax(theIsBuildMinMax), - myUpdateMinMaxSignal(theUpdateMinMaxSignal), - myIsGroupsDone(theIsGroupsDone), - myIsBuildGroups(theIsBuildGroups), -#ifdef ENABLE_MULTIPR - myIsPartsDone(theIsPartsDone), - myIsBuildParts(theIsBuildParts), -#endif - myStudy(theStudy) - {} - }; - - //--------------------------------------------------------------- - void - BuildDataTree(TBuildArgs theBuildArgs) - { - BuildEntities(theBuildArgs.myResult, - theBuildArgs.myInput, - theBuildArgs.myIsEntitiesDone, - theBuildArgs.myResultEntry, - false, - theBuildArgs.myIsBuildGroups, - theBuildArgs.myIsBuildFields, - theBuildArgs.myStudy); - - { - boost::thread aThread(boost::bind(&BuildGroups, - theBuildArgs.myResult, - theBuildArgs.myInput, - theBuildArgs.myIsGroupsDone, - theBuildArgs.myIsBuildGroups, - false, - theBuildArgs.myStudy)); - } - { - boost::thread aThread(boost::bind(&BuildFieldDataTree, - theBuildArgs.myResult, - theBuildArgs.myInput, - theBuildArgs.myIsFieldsDone, - theBuildArgs.myIsBuildFields, - theBuildArgs.myIsMinMaxDone, - theBuildArgs.myIsBuildMinMax, - theBuildArgs.myUpdateMinMaxSignal, - theBuildArgs.myStudy)); - } - - /* - // MULTIPR - BuildParts(theBuildArgs.myResult, - theBuildArgs.myInput, - theBuildArgs.myIsPartsDone, - theBuildArgs.myIsBuildParts, - false, - theBuildArgs.myStudy); - */ - } -} - - //--------------------------------------------------------------- -VISU::MinMaxCunsomer -::MinMaxCunsomer(): - myMinMaxIsInitilized(false) -{} - -bool -VISU::MinMaxCunsomer -::IsMinMaxInitilized() -{ - return myMinMaxIsInitilized; -} - -void -VISU::MinMaxCunsomer -::UpdateMinMax() -{ - myMinMaxIsInitilized = true; } @@ -1079,13 +139,13 @@ 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, - CORBA::Boolean theIsBuildImmediately, - CORBA::Boolean theIsBuildFields, - CORBA::Boolean theIsBuildMinMax, - CORBA::Boolean theIsBuildGroups): +::Result_i(SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildMinMax, + CORBA::Boolean theIsBuildGroups): myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)), myCreationId(theCreationId), mySourceId(theSourceId), @@ -1093,23 +153,38 @@ VISU::Result_i myIsBuildFields(theIsBuildFields), myIsBuildMinMax(theIsBuildMinMax), myIsBuildGroups(theIsBuildGroups), -#ifdef ENABLE_MULTIPR - myIsBuildParts(true), -#endif myIsEntitiesDone(false), myIsFieldsDone(false), myIsGroupsDone(false), myIsMinMaxDone(false), -#ifdef ENABLE_MULTIPR - myIsPartsDone(false), -#endif myIsAllDone(false), - myInput(NULL) + myIsBuildParts(false), + myIsPartsDone(false) { - myStudy = ProcessEvent(new TGetStudy(myStudyDocument->StudyId())); -#ifdef ENABLE_MULTIPR - myIsDistributedMEDMultipr = false; -#endif + myStudy = VISU::GetStudy(myStudyDocument); +} + + +//--------------------------------------------------------------- +VISU::Result_i +::Result_i(): + myIsEntitiesDone(false), + myIsFieldsDone(false), + myIsGroupsDone(false), + myIsMinMaxDone(false), + myIsAllDone(false), + myIsBuildParts(false), + myIsPartsDone(false) +{} + + +//--------------------------------------------------------------- +VISU::Result_i +::~Result_i() +{ + MESSAGE("Result_i::~Result_i() - this = "<NewBuilder(); @@ -1303,18 +395,20 @@ VISU::Result_i aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s", GetComment(), myFileInfo.filePath().latin1(), - myInitFileName.c_str()); // Restoring of Python dump - string aResultEntry = + GetInitFileName().c_str()); // Restoring of Python dump + std::string aResultEntry = CreateAttributes(myStudy, aSComponentEntry.in(), + NO_ICON, anIOR.in(), - myName, + GetName(), + NO_PERFSITENT_REF, 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()); + CreateReference(myStudyDocument, aResultEntry, aString.in()); } if(theIsAtOnce){ @@ -1325,6 +419,7 @@ VISU::Result_i theIsAtOnce, myIsBuildGroups, myIsBuildFields, + myIsBuildParts, myStudy); BuildGroups(this, @@ -1334,101 +429,58 @@ VISU::Result_i theIsAtOnce, myStudy); - BuildFields(this, + BuildFieldDataTree(this, + myInput, + &myIsFieldsDone, + myIsBuildFields, + &myIsMinMaxDone, + myIsBuildMinMax, + myStudy); + } else { + boost::thread aThread(boost::bind(boost::bind(&Result_i::BuildDataTree, this, _1), + aResultEntry)); + } + + return this; +} + + +//--------------------------------------------------------------- +void +VISU::Result_i +::BuildDataTree(const std::string& theResultEntry) +{ + BuildEntities(this, myInput, - &myIsFieldsDone, + &myIsEntitiesDone, + theResultEntry, + false, + myIsBuildGroups, myIsBuildFields, - theIsAtOnce, + myIsBuildParts, myStudy); - - BuildMinMax(this, - myInput, - &myIsMinMaxDone, - myIsBuildMinMax, - &myUpdateMinMaxSignal); - -#ifdef ENABLE_MULTIPR - // MULTIPR - BuildParts(this, - myInput, - &myIsPartsDone, - myIsBuildParts, - theIsAtOnce, - myStudy); -#endif - } - else { -#ifdef ENABLE_MULTIPR - if (strlen(GetFileInfoMultipr().filePath().latin1()) == 0) -#endif - { - // sequential MED file - TBuildArgs aBuildArgs(this, - myInput, - &myIsEntitiesDone, - aResultEntry, - &myIsFieldsDone, - myIsBuildFields, - &myIsMinMaxDone, - myIsBuildMinMax, - &myUpdateMinMaxSignal, - &myIsGroupsDone, - myIsBuildGroups, -#ifdef ENABLE_MULTIPR - &myIsPartsDone, - myIsBuildParts, -#endif - myStudy); - boost::thread aThread(boost::bind(&BuildDataTree, aBuildArgs)); - } -#ifdef ENABLE_MULTIPR - else - { - // distributed MED file - BuildEntities(this, - myInput, - &myIsEntitiesDone, - aResultEntry, - theIsAtOnce, - myIsBuildGroups, - myIsBuildFields, - myStudy); - - BuildGroups(this, - myInput, - &myIsGroupsDone, - myIsBuildGroups, - theIsAtOnce, - myStudy); - BuildFields(this, - myInput, - &myIsFieldsDone, - myIsBuildFields, - theIsAtOnce, - myStudy); - - BuildMinMax(this, - myInput, - &myIsMinMaxDone, - myIsBuildMinMax, - &myUpdateMinMaxSignal); - - // MULTIPR - BuildParts(this, - myInput, - &myIsPartsDone, - myIsBuildParts, - theIsAtOnce, - myStudy); - } -#endif + { + boost::thread aThread(boost::bind(&BuildGroups, + this, + myInput, + &myIsGroupsDone, + myIsBuildGroups, + false, + myStudy)); + } + { + boost::thread aThread(boost::bind(&BuildFieldDataTree, + this, + myInput, + &myIsFieldsDone, + myIsBuildFields, + &myIsMinMaxDone, + myIsBuildMinMax, + myStudy)); } - - return this; } - //--------------------------------------------------------------- VISU::Storable* VISU::Result_i @@ -1452,67 +504,30 @@ VISU::Result_i //--------------------------------------------------------------- VISU::Storable* -VISU::Result_i:: -Create(const char* theFileName) +VISU::Result_i +::Create(const char* theFileName) { try { myFileInfo.setFile(theFileName); + myFileName = myFileInfo.fileName().latin1(); -#ifdef ENABLE_MULTIPR - // MULTIPR - if (myFileInfo.filePath().endsWith("_grains_maitre.med")) - { - // retrieve source MED file (sequential MED file) - QString originalMEDFileName = ""; - FILE* aFile = fopen(theFileName, "rt"); - char aBuf[1024]; - while (!feof(aFile)) - { - fgets(aBuf, 1024, aFile); - char* strTag = NULL; - if ((aBuf[0] == '#') && ((strTag = strstr(aBuf, "[SOURCE]=")) != NULL)) - { - char strSequentialMEDFilename[256]; - int ret = sscanf(strTag, "[SOURCE]=%s", strSequentialMEDFilename); - if (ret == 1) - { - originalMEDFileName = strSequentialMEDFilename; - break; - } - } - } - fclose(aFile); - if (originalMEDFileName == "") - throw std::runtime_error("distributed MED file; bad format"); - - //cout << "MULTIPR: original med file=" << originalMEDFileName << endl; - myFileInfoMultipr.setFile(myFileInfo.filePath()); - myFileInfo.setFile(originalMEDFileName); + if(!myIsBuildParts){ + SetInitFileName(myFileInfo.filePath().latin1()); + SetName(VISU::GenerateName(myFileInfo.fileName()).latin1(), false); } - else - { - myFileInfoMultipr.setFile(""); - } -#endif - myInitFileName = myFileInfo.filePath().latin1(); - myName = ::GenerateName(myFileInfo.fileName()).latin1(); if(mySourceId == eRestoredFile){ - std::string aTmpDir(SALOMEDS_Tool::GetTmpDir()); - static QString aCommand; - aCommand.sprintf(" %s %s", myFileInfo.absFilePath().latin1(), aTmpDir.c_str() ); - aCommand = QDir::convertSeparators( aCommand ); - aCommand.prepend( COPY_COMMAND ); - - if(system(aCommand.latin1()) == -1){ - MESSAGE("Create - Can't execute the command :"<Build(); string aCompDataType = GetComponentDataType(theMedSObject); myFileInfo.setFile(aCompDataType.c_str()); - myInitFileName = aCompDataType; + SetInitFileName(aCompDataType); - myName = ::GenerateName("aResult").latin1(); + myFileName = VISU::GenerateName("aResult").latin1(); return Build(theMedSObject); }catch(std::exception& exc){ @@ -1564,17 +579,17 @@ VISU::Result_i { if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOME_MED::FIELD_ptr"); try{ - myInput = CreateMEDFieldConvertor(theField); - if(myInput == NULL) + myInput.reset(CreateMEDFieldConvertor(theField)); + if(!myInput) return NULL; myInput->Build(); string aCompDataType = "MED"; myFileInfo.setFile(aCompDataType.c_str()); - myInitFileName = aCompDataType; + SetInitFileName(aCompDataType); - myName = ::GenerateName("aResult").latin1(); + myFileName = VISU::GenerateName("aResult").latin1(); CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField); SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR); @@ -1585,7 +600,106 @@ VISU::Result_i }catch(...){ INFOS("Unknown exception was occured!!!"); } - return NULL; + return NULL; +} + + +//--------------------------------------------------------------- +bool +VISU::Result_i +::Save(SALOMEDS::SComponent_ptr theComponent, + const std::string& theURL, + bool theIsMultiFile, + bool theIsASCII, + TFileNames& theFileNames, + TFileNames& theFiles) +{ + switch(GetCreationId()){ + case Result_i::eImportFile: + case Result_i::eCopyAndImportFile: { + INITMSG(MYDEBUG, "Result::Save - this = "<URL(); + aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in()); + } + + std::string aFileName = aPrefix + "_" + GetFileName(); + BEGMSG(MYDEBUG, "aFileName = '"<(aPathToCopy.c_str()), true); + } + + theFileNames.push_back(aFileName); + theFiles.push_back(aFile); + + return true; + }} + + return false; +} + + +//--------------------------------------------------------------- +CORBA::Boolean +VISU::Result_i +::CanCopy(SALOMEDS::SObject_ptr theObject) +{ + switch(GetCreationId()){ + case Result_i::eImportFile: + case Result_i::eCopyAndImportFile: + return true; + } + + return false; +} + + +//--------------------------------------------------------------- +bool +VISU::Result_i +::CopyFrom(SALOMEDS::SObject_ptr theObject, + CORBA::Long& theObjectID, + const std::string& theTmpDir, + TFileNames& theFileNames) +{ + if(!Storable::CopyFrom(theObject, theObjectID, theTmpDir, theFileNames)) + return false; + + SALOMEDS::Study_var aStudy = theObject->GetStudy(); + CORBA::String_var anURL = aStudy->URL(); + std::string aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in()); + std::string aFileName = aPrefix + GetFileInfo().fileName().latin1(); + + static QString aCommand; + std::string aFilePath = theTmpDir + aFileName; + aCommand.sprintf(" %s %s", GetFileInfo().filePath().latin1(), aFilePath.c_str()); + aCommand = QDir::convertSeparators( aCommand ); + aCommand.prepend( COPY_COMMAND ); + + if(system(aCommand.latin1()) != 0) { + if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<FindComponent("VISU"); + + theFileNames.push_back(aFileName); + + return true; } @@ -1594,20 +708,32 @@ VISU::Storable* VISU::Result_i ::Restore(SALOMEDS::SObject_ptr theSObject, const Storable::TRestoringMap& theMap, - const string& thePrefix) + const string& thePrefix, + CORBA::Boolean theIsMultiFile) { if(MYDEBUG) MESSAGE("Result_i::Restore - " << thePrefix); + mySObject = SALOMEDS::SObject::_duplicate(theSObject); + mySComponent = mySObject->GetFatherComponent(); + myStudyDocument = theSObject->GetStudy(); + myStudy = VISU::GetStudy(myStudyDocument); + + myCreationId = ECreationId(Storable::FindValue(theMap, "myCreationId").toInt()); + mySourceId = eRestoredFile; + if(myCreationId == eImportMed || myCreationId == eImportMedField) + mySourceId = eRestoredComponent; + + myIsBuildFields = Storable::FindValue(theMap, "myIsBuildFields", "1").toInt(); + myIsBuildMinMax = Storable::FindValue(theMap, "myIsBuildMinMax", "1").toInt(); + myIsBuildGroups = Storable::FindValue(theMap, "myIsBuildGroups", "1").toInt(); + + myIsBuildImmediately = true; + try { - mySObject = SALOMEDS::SObject::_duplicate(theSObject); - myStudyDocument = mySObject->GetStudy(); - mySComponent = mySObject->GetFatherComponent(); - myName = VISU::Storable::FindValue(theMap, "myName").latin1(); - myInitFileName = VISU::Storable::FindValue(theMap, "myInitFileName").latin1(); + myFileName = VISU::Storable::FindValue(theMap, "myName").latin1(); + SetInitFileName(VISU::Storable::FindValue(theMap, "myInitFileName").latin1()); SALOMEDS::SObject_var aRefSObj, aTargetRefSObj; - if (mySObject->FindSubObject(1, aRefSObj) && - aRefSObj->ReferencedObject(aTargetRefSObj)) - { + if (theSObject->FindSubObject(1, aRefSObj) && aRefSObj->ReferencedObject(aTargetRefSObj)) { if(MYDEBUG) MESSAGE("Result_i::GetInput - There is some reference."); SALOMEDS::SComponent_var aCompRefSObj = aTargetRefSObj->GetFatherComponent(); CORBA::String_var aDataType = aCompRefSObj->ComponentDataType(); @@ -1620,31 +746,17 @@ VISU::Result_i SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder(); SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp); aStudyBuilder->LoadWith(aCompRefSObj, aDriver); - /* - if (strcmp(aDataType, "MED") == 0){ - // create field or MED converter - CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj); - SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(aMedObject); - if(!CORBA::is_nil(aField)) - myInput = CreateMEDFieldConvertor(aField); - else - myInput = CreateMEDConvertor(aTargetRefSObj); - myInput->Build(); - }else - throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!"); - //*/ - // create field or MED converter CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj); SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(aMedObject); if (!CORBA::is_nil(aField)) { // create field converter - myInput = CreateMEDFieldConvertor(aField); + myInput.reset(CreateMEDFieldConvertor(aField)); myInput->Build(); } else if (strcmp(aDataType, "MED") == 0) { // create MED converter - myInput = CreateMEDConvertor(aTargetRefSObj); + myInput.reset(CreateMEDConvertor(aTargetRefSObj)); myInput->Build(); } else { @@ -1653,11 +765,13 @@ VISU::Result_i } else { myFileInfo.setFile(thePrefix.c_str()); - string aStudyPrefix (""); - if (IsMultifile()) - aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(myStudyDocument->URL()); + std::string aStudyPrefix (""); + if (theIsMultiFile) { + CORBA::String_var anURL(GetStudyDocument()->URL()); + aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in()); + } if (!myFileInfo.isFile()) { - string aFileName = thePrefix + aStudyPrefix + "_" + myName; + std::string aFileName = thePrefix + aStudyPrefix + "_" + myFileName; myFileInfo.setFile(aFileName.c_str()); } if(MYDEBUG) @@ -1671,7 +785,7 @@ VISU::Result_i char* aHDFFileName = new char[strlen(aResultPath) + 19]; sprintf(aHDFFileName, "%shdf_from_ascii.hdf", aResultPath); - if (IsMultifile()) { // set this file as new - temporary + if (theIsMultiFile) { // set this file as new - temporary static QString aCommand; aCommand.sprintf(" %s %s%s",aHDFFileName, aResultPath, myFileInfo.baseName().latin1()); aCommand = QDir::convertSeparators( aCommand ); @@ -1702,13 +816,13 @@ VISU::Result_i mySourceId = eRestoredFile; delete(aResultPath); delete(aHDFFileName); - } else if (!IsMultifile()) { + } else if (!theIsMultiFile) { mySourceId = eRestoredFile; } else { - mySourceId = eFile; + mySourceId = eSavedFile; } if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId); - myInput = CreateConvertor(myFileInfo.filePath().latin1()); + myInput.reset(CreateConvertor(myFileInfo.filePath().latin1())); myInput->BuildEntities(); if(myIsBuildFields){ @@ -1728,7 +842,7 @@ VISU::Result_i aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s", GetComment(), myFileInfo.filePath().latin1(), - myInitFileName.c_str()); // Restoring of Python dump + GetInitFileName().c_str()); // Restoring of Python dump SALOMEDS::GenericAttribute_var anAttr; if (!theSObject->FindAttribute(anAttr, "AttributeString")) throw std::runtime_error("Build - There is no AttributeString for the SObject !!!"); @@ -1747,14 +861,19 @@ VISU::Result_i return NULL; } + //--------------------------------------------------------------- -VISU::Result_i::TInput* +VISU::Result_i::PInput VISU::Result_i -::GetInput() +::GetInput(const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber) { return myInput; } + //--------------------------------------------------------------- CORBA::Boolean VISU::Result_i @@ -1814,60 +933,437 @@ VISU::Result_i return myIsMinMaxDone; } +CORBA::Boolean +VISU::Result_i +::IsPartsDone() +{ + return myIsPartsDone; +} + + +//--------------------------------------------------------------- +VISU::Result::EntityNames* +VISU::Result_i +::GetMeshNames() +{ + VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames(); + const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap(); + if(aMeshMap.empty()) + return aResult._retn(); + + aResult->length(aMeshMap.size()); + VISU::TMeshMap::const_iterator anIter = aMeshMap.begin(); + for(size_t anId = 0; anIter != aMeshMap.end(); anIter++, anId++){ + const std::string& aName = anIter->first; + aResult[anId] = aName.c_str(); + } + + return aResult._retn(); +} + + +//--------------------------------------------------------------- +VISU::Result::Entities* +VISU::Result_i +::GetEntities(const char* theMeshName) +{ + VISU::Result::Entities_var anEntities = new VISU::Result::Entities(); + const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap(); + if(aMeshMap.empty()) + return anEntities._retn(); + + VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName); + if(anIter == aMeshMap.end()) + return anEntities._retn(); + + const VISU::PMesh& aMesh = anIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + if(aMeshOnEntityMap.empty()) + return anEntities._retn(); + + { + anEntities->length(aMeshOnEntityMap.size()); + VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.end(); + for(size_t anId = 0; anIter != aMeshOnEntityMap.end(); anIter++, anId++){ + const VISU::TEntity& anEntity = anIter->first; + anEntities[anId] = VISU::Entity(anEntity); + } + } + + return anEntities._retn(); +} + + +//--------------------------------------------------------------- +VISU::Result::EntityNames* +VISU::Result_i +::GetFamilies(const char* theMeshName, + VISU::Entity theEntity) +{ + VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames(); + const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap(); + if(aMeshMap.empty()) + return aResult._retn(); + + VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName); + if(anIter == aMeshMap.end()) + return aResult._retn(); + + const VISU::PMesh& aMesh = anIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + if(aMeshOnEntityMap.empty()) + return aResult._retn(); + + { + VISU::TEntity anEntity = VISU::TEntity(theEntity); + VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity); + if(anIter == aMeshOnEntityMap.end()) + return aResult._retn(); + + const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + if(aFamilyMap.empty()) + return aResult._retn(); + + { + aResult->length(aFamilyMap.size()); + VISU::TFamilyMap::const_iterator anIter = aFamilyMap.end(); + for(size_t anId = 0; anIter != aFamilyMap.end(); anIter++, anId++){ + const std::string& aName = anIter->first; + aResult[anId] = aName.c_str(); + } + } + } + + return aResult._retn(); +} + + +//--------------------------------------------------------------- +VISU::Result::EntityNames* +VISU::Result_i +::GetGroups(const char* theMeshName) +{ + VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames(); + const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap(); + if(aMeshMap.empty()) + return aResult._retn(); + + VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName); + if(anIter == aMeshMap.end()) + return aResult._retn(); + + const VISU::PMesh& aMesh = anIter->second; + const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; + if(aGroupMap.empty()) + return aResult._retn(); + + { + aResult->length(aGroupMap.size()); + VISU::TGroupMap::const_iterator anIter = aGroupMap.end(); + for(size_t anId = 0; anIter != aGroupMap.end(); anIter++, anId++){ + const std::string& aName = anIter->first; + aResult[anId] = aName.c_str(); + } + } + + return aResult._retn(); +} + + +//--------------------------------------------------------------- +VISU::Result::EntityNames* +VISU::Result_i +::GetFields(const char* theMeshName, + VISU::Entity theEntity) +{ + VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames(); + const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap(); + if(aMeshMap.empty()) + return aResult._retn(); + + VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName); + if(anIter == aMeshMap.end()) + return aResult._retn(); + + const VISU::PMesh& aMesh = anIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + if(aMeshOnEntityMap.empty()) + return aResult._retn(); + + { + VISU::TEntity anEntity = VISU::TEntity(theEntity); + VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity); + if(anIter == aMeshOnEntityMap.end()) + return aResult._retn(); + + const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + if(aFieldMap.empty()) + return aResult._retn(); + + { + aResult->length(aFieldMap.size()); + VISU::TFieldMap::const_iterator anIter = aFieldMap.end(); + for(size_t anId = 0; anIter != aFieldMap.end(); anIter++, anId++){ + const std::string& aName = anIter->first; + aResult[anId] = aName.c_str(); + } + } + } + + return aResult._retn(); +} + + +//--------------------------------------------------------------- +VISU::Result::TimeStampNumbers* +VISU::Result_i +::GetTimeStampNumbers(const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName) +{ + VISU::Result::TimeStampNumbers_var aResult = new VISU::Result::TimeStampNumbers(); + const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap(); + if(aMeshMap.empty()) + return aResult._retn(); + + VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName); + if(anIter == aMeshMap.end()) + return aResult._retn(); + + const VISU::PMesh& aMesh = anIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + if(aMeshOnEntityMap.empty()) + return aResult._retn(); + + { + VISU::TEntity anEntity = VISU::TEntity(theEntity); + VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity); + if(anIter == aMeshOnEntityMap.end()) + return aResult._retn(); + + const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + if(aFieldMap.empty()) + return aResult._retn(); + + { + VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName); + if(anIter == aFieldMap.end()) + return aResult._retn(); + + { + const VISU::PField& aField = anIter->second; + const VISU::TValField& aValField = aField->myValField; + if(aValField.empty()) + return aResult._retn(); + + { + aResult->length(aValField.size()); + VISU::TValField::const_iterator anIter = aValField.end(); + for(size_t anId = 0; anIter != aValField.end(); anIter++, anId++){ + const vtkIdType& aTimeStampNumber = anIter->first; + aResult[anId] = aTimeStampNumber; + } + } + } + } + } + + return aResult._retn(); +} + + +//--------------------------------------------------------------- +CORBA::Long +VISU::Result_i +::GetNumberOfComponents(const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName) +{ + CORBA::Long aResult = 0; + const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap(); + if(aMeshMap.empty()) + return aResult; + + VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName); + if(anIter == aMeshMap.end()) + return aResult; + + const VISU::PMesh& aMesh = anIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + if(aMeshOnEntityMap.empty()) + return aResult; + + { + VISU::TEntity anEntity = VISU::TEntity(theEntity); + VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity); + if(anIter == aMeshOnEntityMap.end()) + return aResult; + + const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + if(aFieldMap.empty()) + return aResult; + + { + VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName); + if(anIter == aFieldMap.end()) + return aResult; + + { + const VISU::PField& aField = anIter->second; + aResult = aField->myNbComp; + } + } + } + + return aResult; +} + + +//--------------------------------------------------------------- +VISU::Result::EntityNames* +VISU::Result_i +::GetPartNames(const char* theMeshName) +{ + VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames(); + return aResult._retn(); +} + + +//--------------------------------------------------------------- +VISU::Result::Resolutions* +VISU::Result_i +::GetResolutions(const char* theMeshName, + const char* thePartName) +{ + VISU::Result::Resolutions_var aResult = new VISU::Result::Resolutions(); + return aResult._retn(); +} + + +//--------------------------------------------------------------- +VISU::Result::Resolution +VISU::Result_i +::GetResolution(const char* theMeshName, + const char* thePartName) +{ + return VISU::Result::HIDDEN; +} + + //--------------------------------------------------------------- void VISU::Result_i -::ToStream(std::ostringstream& theStr) +::SetResolution(const char* theMeshName, + const char* thePartName, + VISU::Result::Resolution theResolution) +{} + + +//--------------------------------------------------------------- +VISU::Result_i* +VISU::Result_i +::New(SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildMinMax, + CORBA::Boolean theIsBuildGroups) { - if(MYDEBUG) MESSAGE(GetComment()); - Storable::DataToStream(theStr,"myName",myName.c_str()); - Storable::DataToStream(theStr,"myInitFileName",myInitFileName.c_str()); - Storable::DataToStream(theStr,"myCreationId",myCreationId); - Storable::DataToStream(theStr,"myIsBuildFields",myIsFieldsDone); - Storable::DataToStream(theStr,"myIsBuildMinMax",myIsMinMaxDone); - Storable::DataToStream(theStr,"myIsBuildGroups",myIsGroupsDone); + return new RESULT_CLASS_NAME(theStudy, + theSourceId, + theCreationId, + theIsBuildImmediately, + theIsBuildFields, + theIsBuildMinMax, + theIsBuildGroups); } //--------------------------------------------------------------- VISU::Storable* VISU::Result_i -::Restore(SALOMEDS::SObject_ptr theSObject, - const string& thePrefix, - const Storable::TRestoringMap& theMap) +::StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile) { - SALOMEDS::Study_var aStudy = theSObject->GetStudy(); - - ECreationId aCreationId = ECreationId(Storable::FindValue(theMap, "myCreationId").toInt()); - ESourceId aSourceId = eRestoredFile; - if(aCreationId == eImportMed || aCreationId == eImportMedField) - aSourceId = eRestoredComponent; - - CORBA::Boolean anIsBuildFields = Storable::FindValue(theMap,"myIsBuildFields","1").toInt(); - CORBA::Boolean anIsBuildMinMax = Storable::FindValue(theMap,"myIsBuildMinMax","1").toInt(); - CORBA::Boolean anIsBuildGroups = Storable::FindValue(theMap,"myIsBuildGroups","1").toInt(); - - VISU::Result_i* aResult = new VISU::Result_i(aStudy, - aSourceId, - aCreationId, - anIsBuildFields, - anIsBuildMinMax, - anIsBuildGroups); - if (aResult == NULL) - return NULL; + VISU::Result_i* aResult = new RESULT_CLASS_NAME(); + return aResult->Restore(theSObject, theMap, thePrefix, theIsMultiFile); +} + + +//--------------------------------------------------------------- +void +VISU::Result_i +::ToStream(std::ostringstream& theStr) +{ + Storable::DataToStream(theStr,"myName", GetFileName().c_str()); + Storable::DataToStream(theStr,"myInitFileName", GetInitFileName().c_str()); + Storable::DataToStream(theStr,"myCreationId", myCreationId); + Storable::DataToStream(theStr,"myIsBuildFields", myIsFieldsDone); + Storable::DataToStream(theStr,"myIsBuildMinMax", myIsMinMaxDone); + Storable::DataToStream(theStr,"myIsBuildGroups", myIsGroupsDone); +} + + +//--------------------------------------------------------------- +std::string +VISU::Result_i +::GetInitFileName() const +{ + return myInitFileName; +} + - return aResult->Restore(theSObject,theMap,thePrefix); +void +VISU::Result_i +::SetInitFileName(const std::string& theFileName) +{ + myInitFileName = theFileName; } //--------------------------------------------------------------- -string +std::string +VISU::Result_i +::GetFileName() const +{ + if(GetSourceId() == eFile) + return VISU::MakeFileName(myFileName, this); + + return myFileName; +} + + +QFileInfo +VISU::Result_i +::GetFileInfo() const +{ + return myFileInfo; +} + +VISU::Result_i::ECreationId +VISU::Result_i +::GetCreationId() const +{ + return myCreationId; +} + + +VISU::Result_i::ESourceId VISU::Result_i -::GetRefFatherEntry() +::GetSourceId() const { - return ""; + return mySourceId; } + +//--------------------------------------------------------------- std::string VISU::Result_i ::GetEntry() @@ -1876,21 +1372,28 @@ VISU::Result_i return anEntry.in(); } -const SALOMEDS::SObject_var& +SALOMEDS::SObject_var VISU::Result_i ::GetSObject() const { return mySObject; } -const SALOMEDS::Study_var& +SALOMEDS::Study_var VISU::Result_i ::GetStudyDocument() const { return myStudyDocument; } -const SALOMEDS::SComponent_var& +_PTR(Study) +VISU::Result_i +::GetStudy() const +{ + return myStudy; +} + +SALOMEDS::SComponent_var VISU::Result_i ::GetSComponent() const { @@ -1906,40 +1409,13 @@ VISU::Result_i theRestoringMap); } -#include -//--------------------------------------------------------------- -VISU::Result_i -::~Result_i() -{ - MESSAGE("Result_i::~Result_i() - this = "< #include #include #include @@ -42,164 +44,337 @@ class VISU_Convertor; namespace VISU { //---------------------------------------------------------------------------- - class VISU_I_EXPORT MinMaxCunsomer: public virtual boost::signalslib::trackable + class TResultObserver; + + + //---------------------------------------------------------------------------- + class VISU_I_EXPORT Result_i : public virtual POA_VISU::Result, + public virtual RemovableObject_i, + public virtual SALOME::GenericObj_i { - protected: - bool myMinMaxIsInitilized; - MinMaxCunsomer(); + Result_i(const Result_i &); public: + enum ESourceId { + eRestoredComponent = -2, + eRestoredFile = -1, + eSavedFile = 0, + eFile = 1, + eComponent = 2 + }; + + enum ECreationId { + eImportFile, + eCopyAndImportFile, + eImportMed, + eImportMedField + }; + + static + Result_i* + New(SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildMinMax, + CORBA::Boolean theIsBuildGroups); + virtual - bool - IsMinMaxInitilized(); + void + RemoveFromStudy(); + + virtual + VISU::VISUType + GetType() + { + return VISU::TRESULT; + } + + virtual + CORBA::Boolean + BuildAll(); + + virtual + CORBA::Boolean + Build(CORBA::Boolean theIsBuildAll, + CORBA::Boolean theIsAtOnce); + + virtual + CORBA::Boolean + IsDone(); + + virtual + CORBA::Boolean + IsEntitiesDone(); virtual void - UpdateMinMax(); - }; + SetBuildFields(CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsCalculateMinMax); + virtual + CORBA::Boolean + IsFieldsDone(); - //---------------------------------------------------------------------------- - class VISU_I_EXPORT Result_i : public virtual POA_VISU::Result, - public virtual RemovableObject_i, - public virtual SALOME::GenericObj_i - { - Result_i(const Result_i &); + virtual + void + SetBuildGroups(CORBA::Boolean theIsBuildGroups); - public: - enum ESourceId {eRestoredComponent = -2, eRestoredFile = -1, eFile = 1, eComponent = 2}; - enum ECreationId {eImportFile, eCopyAndImportFile, eImportMed, eImportMedField}; + virtual + CORBA::Boolean + IsGroupsDone(); - Result_i(SALOMEDS::Study_ptr theStudy, - const ESourceId& theSourceId, - const ECreationId& theCreationId, - CORBA::Boolean theIsBuildImmediately = true, - CORBA::Boolean theIsBuildFields = true, - CORBA::Boolean theIsBuildMinMax = true, - CORBA::Boolean theIsBuildGroups = true); + virtual + CORBA::Boolean + IsMinMaxDone(); - virtual ~Result_i(); - virtual void RemoveFromStudy(); + virtual + CORBA::Boolean + IsPartsDone(); - virtual VISU::VISUType GetType() { return VISU::TRESULT;} - virtual CORBA::Boolean BuildAll(); + virtual + VISU::Result::EntityNames* + GetMeshNames(); - virtual CORBA::Boolean Build(CORBA::Boolean theIsBuildAll, - CORBA::Boolean theIsAtOnce); - virtual CORBA::Boolean IsDone(); + virtual + VISU::Result::Entities* + GetEntities(const char* theMeshName); - virtual CORBA::Boolean IsEntitiesDone(); + virtual + VISU::Result::EntityNames* + GetFamilies(const char* theMeshName, + Entity theEntity); - virtual void SetBuildFields(CORBA::Boolean theIsBuildFields, - CORBA::Boolean theIsCalculateMinMax); - virtual CORBA::Boolean IsFieldsDone(); + virtual + VISU::Result::EntityNames* + GetGroups(const char* theMeshName); - virtual void SetBuildGroups(CORBA::Boolean theIsBuildGroups); - virtual CORBA::Boolean IsGroupsDone(); + virtual + VISU::Result::EntityNames* + GetFields(const char* theMeshName, + Entity theEntity); - virtual CORBA::Boolean IsMinMaxDone(); + virtual + VISU::Result::TimeStampNumbers* + GetTimeStampNumbers(const char* theMeshName, + Entity theEntity, + const char* theFieldName); + + virtual + CORBA::Long + GetNumberOfComponents(const char* theMeshName, + Entity theEntity, + const char* theFieldName); + + virtual + VISU::Result::EntityNames* + GetPartNames(const char* theMeshName); + + virtual + VISU::Result::Resolutions* + GetResolutions(const char* theMeshName, + const char* thePartName); + + virtual + VISU::Result::Resolution + GetResolution(const char* theMeshName, + const char* thePartName); + + virtual + void + SetResolution(const char* theMeshName, + const char* thePartName, + VISU::Result::Resolution theResolution); + + virtual + void + UpdateObservers(); virtual void - MinMaxConnect(MinMaxCunsomer* theMinMaxCunsomer); + ConnectObserver(TResultObserver* theObserver, + boost::signalslib::connection& theConnection); - typedef boost::signal0 TUpdateMinMaxSignal; + typedef boost::signal0 TUpdateObserverSignal; typedef VISU_Convertor TInput; + typedef boost::shared_ptr PInput; private: ESourceId mySourceId; ECreationId myCreationId; - TInput *myInput; - std::string myName, myInitFileName; + PInput myInput; + std::string myFileName; QFileInfo myFileInfo; - -#ifdef ENABLE_MULTIPR - // MULTIPR - QFileInfo myFileInfoMultipr; - std::map myMapPartNameToMEDFilename; - std::map mySelectedResolutionMultipr; - bool myIsDistributedMEDMultipr; -#endif + std::string myInitFileName; protected: - virtual Storable* Build(SALOMEDS::SObject_ptr theSObject, - CORBA::Boolean theIsAtOnce = true) ; - virtual Storable* BuildAll(SALOMEDS::SObject_ptr theSObject) ; + Result_i(SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildMinMax, + CORBA::Boolean theIsBuildGroups); + + Result_i(); + + virtual + ~Result_i(); + + virtual + Storable* + Build(SALOMEDS::SObject_ptr theSObject, + CORBA::Boolean theIsAtOnce = true) ; + virtual + void + BuildDataTree(const std::string& theResultEntry); + + virtual + Storable* + BuildAll(SALOMEDS::SObject_ptr theSObject) ; + + ESourceId + GetSourceId() const; + _PTR(Study) myStudy; CORBA::Boolean myIsBuildImmediately; CORBA::Boolean myIsEntitiesDone; - CORBA::Boolean myIsFieldsDone; - CORBA::Boolean myIsGroupsDone; - CORBA::Boolean myIsMinMaxDone; -#ifdef ENABLE_MULTIPR - CORBA::Boolean myIsPartsDone; // MULTIPR -#endif + CORBA::Boolean myIsFieldsDone; CORBA::Boolean myIsBuildFields; + + CORBA::Boolean myIsGroupsDone; CORBA::Boolean myIsBuildGroups; + CORBA::Boolean myIsPartsDone; + CORBA::Boolean myIsBuildParts; + + CORBA::Boolean myIsMinMaxDone; CORBA::Boolean myIsBuildMinMax; -#ifdef ENABLE_MULTIPR - CORBA::Boolean myIsBuildParts; // MULTIPR -#endif - TUpdateMinMaxSignal myUpdateMinMaxSignal; + TUpdateObserverSignal myUpdateObserverSignal; CORBA::Boolean myIsAllDone; public: - virtual size_t IsPossible(); + virtual + size_t + IsPossible(); + + virtual + Storable* + Create(const char* theFileName); + + virtual + Storable* + Create(SALOMEDS::SObject_ptr theMedSObject); + + virtual + Storable* + Create(SALOME_MED::FIELD_ptr theField); + + virtual + Storable* + Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile); + + static + Storable* + StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile); - virtual Storable* Create(const char* theFileName); - virtual Storable* Create(SALOMEDS::SObject_ptr theMedSObject); - virtual Storable* Create(SALOME_MED::FIELD_ptr theField); + virtual + void + ToStream(std::ostringstream& theStr); - virtual Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const Storable::TRestoringMap& theMap, - const std::string& thePrefix); + //--------------------------------------------------------------- + typedef std::string TFileName; + typedef std::vector TFileNames; - static Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const std::string& thePrefix, - const Storable::TRestoringMap& theMap); + virtual + bool + Save(SALOMEDS::SComponent_ptr theComponent, + const std::string& theURL, + bool theIsMultiFile, + bool theIsASCII, + TFileNames& theFileNames, + TFileNames& theFiles); + + //--------------------------------------------------------------- + virtual + CORBA::Boolean + CanCopy(SALOMEDS::SObject_ptr theObject); + + virtual + bool + CopyFrom(SALOMEDS::SObject_ptr theObject, + CORBA::Long& theObjectID, + const std::string& theTmpDir, + TFileNames& theFileNames); + + //--------------------------------------------------------------- + virtual + const char* + GetComment() const; - virtual void ToStream(std::ostringstream& theStr); - virtual const char* GetComment() const; static const std::string myComment; - TInput* GetInput(); - const std::string& GetName() const { return myName;} - const QFileInfo& GetFileInfo() const { return myFileInfo;} -#ifdef ENABLE_MULTIPR - const QFileInfo& GetFileInfoMultipr() const { return myFileInfoMultipr;} -#endif - const std::string& GetFileName() const { return myInitFileName;} - const ECreationId& GetCreationId() const { return myCreationId;} - -#ifdef ENABLE_MULTIPR - // MULTIPR - void AddPartMultipr(const char* thePartName, const char* theMEDFilename); - void SetResolutionMultipr(const char* theName, char theNewResolution); // 'F'=FULL 'M'=MEDIUM 'L'=LOW 'H'=HIDE - std::string FindPartMultipr(const char* theName); - std::vector GetCurrentRepresentationMultipr(); - void SetIsDistributedMEDMultipr(bool theIsDistributedMED); - bool IsDistributedMEDMultipr() const; -#endif + virtual + PInput + GetInput(const std::string& theMeshName = "", + VISU::Entity theEntity = VISU::NONE, + const std::string& theFieldName = "", + CORBA::Long theTimeStampNumber = -1); + + virtual + std::string + GetInitFileName() const; + + virtual + void + SetInitFileName(const std::string& theFileName); + + virtual + std::string + GetFileName() const; + QFileInfo + GetFileInfo() const; + + ECreationId + GetCreationId() const; + private: SALOMEDS::SObject_var mySObject; SALOMEDS::Study_var myStudyDocument; SALOMEDS::SComponent_var mySComponent; public: - std::string GetRefFatherEntry(); - std::string GetEntry(); - const SALOMEDS::SObject_var& GetSObject() const; - const SALOMEDS::Study_var& GetStudyDocument() const; - const SALOMEDS::SComponent_var& GetSComponent() const; - std::string GetEntry(const Storable::TRestoringMap& theRestoringMap); + std::string + GetEntry(); + + SALOMEDS::SObject_var + GetSObject() const; + + SALOMEDS::Study_var + GetStudyDocument() const; + + _PTR(Study) + GetStudy() const; + + SALOMEDS::SComponent_var + GetSComponent() const; + + std::string + GetEntry(const Storable::TRestoringMap& theRestoringMap); // Info on structured mesh contained in TInput public: @@ -219,7 +394,8 @@ namespace VISU }; //! To find Result object as published on father of the given SObject - VISU_I_EXPORT Result_var + VISU_I_EXPORT + Result_var FindResult(SALOMEDS::SObject_ptr theSObject); //! To get VISU::Result object published on the given SALOMEDS::SObject diff --git a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc index 2dacbee6..53ffb8e7 100644 --- a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc +++ b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc @@ -25,10 +25,12 @@ // Module : VISU #include "VISU_ScalarMapOnDeformedShape_i.hh" +#include "VISU_Prs3dUtils.hh" +#include "VISU_Result_i.hh" + #include "VISU_ScalarMapAct.h" #include "VISU_ScalarMapOnDeformedShapePL.hxx" #include "VISU_Convertor.hxx" -#include "VISU_Result_i.hh" #include "SUIT_ResourceMgr.h" #include "SALOME_Event.hxx" @@ -65,7 +67,10 @@ VISU::ScalarMapOnDeformedShape_i theTimeStampNumber, false); if(theIsMemoryCheck && aResult){ - VISU::Result_i::TInput* anInput = theResult->GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName, + theEntity, + theFieldName, + theTimeStampNumber); const VISU::PField aField = anInput->GetField(theMeshName, (VISU::TEntity)theEntity, theFieldName); @@ -81,7 +86,8 @@ VISU::ScalarMapOnDeformedShape_i if(anIsEstimated) aSize *= INCMEMORY; aResult = VISU_PipeLine::CheckAvailableMemory(aSize); - MESSAGE("ScalarMapOnDeformedShape_i::IsPossible - CheckAvailableMemory = "< (GetSpecificPL(), &VISU_ScalarMapOnDeformedShapePL::SetScale, theScale)); } @@ -310,8 +318,8 @@ VISU::ScalarMapOnDeformedShape_i void VISU::ScalarMapOnDeformedShape_i ::SetScalarField(VISU::Entity theEntity, - const char* theFieldName, - CORBA::Long theTimeStampNumber) + const char* theFieldName, + CORBA::Long theTimeStampNumber) { bool anIsModified = false; @@ -327,8 +335,13 @@ VISU::ScalarMapOnDeformedShape_i if(!anIsModified) return; + VISU::TSetModified aModified(this); + VISU::TEntity aEntity = VISU::TEntity(theEntity); - VISU::Result_i::TInput* anInput = GetCResult()->GetInput(); + VISU::Result_i::PInput anInput = GetCResult()->GetInput(GetCMeshName(), + theEntity, + theFieldName, + theTimeStampNumber); myScalarField = anInput->GetField(GetCMeshName(), aEntity, theFieldName); VISU::PUnstructuredGridIDMapper anIDMapper = diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index 3a82f2be..8a719f63 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -25,6 +25,7 @@ // Module : VISU #include "VISU_ScalarMap_i.hh" +#include "VISU_Prs3dUtils.hh" #include "VISU_Result_i.hh" @@ -67,7 +68,10 @@ VISU::ScalarMap_i try{ if(theResult){ bool anIsEstimated = true; - VISU::Result_i::TInput* anInput = theResult->GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName, + theEntity, + theFieldName, + theTimeStampNumber); size_t aSize = anInput->GetTimeStampOnMeshSize(theMeshName, (VISU::TEntity)theEntity, theFieldName, @@ -185,9 +189,6 @@ VISU::ScalarMap_i if(const ScalarMap_i* aPrs3d = dynamic_cast(theOrigin)){ ScalarMap_i* anOrigin = const_cast(aPrs3d); - SetRange(anOrigin->GetMin(), anOrigin->GetMax()); - UseFixedRange(anOrigin->IsRangeFixed()); - SetScaling(anOrigin->GetScaling()); myGroupNames = anOrigin->GetGroupNames(); @@ -212,18 +213,7 @@ VISU::ScalarMap_i SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - // Scalar Range - int aRangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0); - if(aRangeType == 1){ - float aMin = aResourceMgr->doubleValue("VISU", "scalar_range_min", 0); - float aMax = aResourceMgr->doubleValue("VISU", "scalar_range_max", 0); - SetRange(aMin,aMax); - } - - UseFixedRange((aRangeType == 1) ? true : false); - bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false); - - if( isLog ) + if( aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false) ) SetScaling(VISU::LOGARITHMIC); else SetScaling(VISU::LINEAR); @@ -250,12 +240,6 @@ VISU::ScalarMap_i SetScaling(VISU::Scaling(VISU::Storable::FindValue(theMap,"myScaling").toInt())); - float aMin = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble(); - float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble(); - SetRange(aMin,aMax); - - UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange").toInt()); - bool anIsExists; QString aGeomNames = VISU::Storable::FindValue(theMap, "myGeomNameList", &anIsExists); if(anIsExists){ @@ -291,9 +275,6 @@ VISU::ScalarMap_i { TSuperClass::ToStream(theStr); - Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() ); - Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() ); - Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() ); Storable::DataToStream( theStr, "myScaling", GetScaling() ); std::ostringstream aGeomNameList; @@ -321,26 +302,12 @@ void VISU::ScalarMap_i ::SetScaling(VISU::Scaling theScaling) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_ColoredPL::SetScaling, theScaling)); } -//---------------------------------------------------------------------------- -void -VISU::ScalarMap_i -::SetRange(CORBA::Double theMin, CORBA::Double theMax) -{ - TSuperClass::SetRange(theMin, theMax); -} - -//---------------------------------------------------------------------------- -void -VISU::ScalarMap_i -::SetSourceRange() -{ - TSuperClass::SetSourceRange(); -} - //---------------------------------------------------------------------------- const VISU::ScalarMap_i::TGroupNames& VISU::ScalarMap_i @@ -375,7 +342,7 @@ void VISU::ScalarMap_i ::AddMeshOnGroup(const char* theGroupName) { - VISU::Result_i::TInput* anInput = GetCResult()->GetInput(); + VISU::Result_i::PInput anInput = GetCResult()->GetInput(); VISU::PUnstructuredGridIDMapper anIDMapper = anInput->GetMeshOnGroup(GetCMeshName(), theGroupName); if(anIDMapper){ int aNbGroups = myGroupNames.size(); @@ -407,7 +374,10 @@ void VISU::ScalarMap_i ::DoSetInput(bool theIsInitilizePipe, bool theReInit) { - VISU::Result_i::TInput* anInput = GetCResult()->GetInput(); + VISU::Result_i::PInput anInput = GetCResult()->GetInput(GetCMeshName(), + GetEntity(), + GetCFieldName(), + GetTimeStampNumber()); if(!anInput) throw std::runtime_error("Mesh_i::Build - GetCResult()->GetInput() == NULL !!!"); @@ -422,13 +392,6 @@ VISU::ScalarMap_i throw std::runtime_error("There is no TimeStamp with the parameters !!!"); GetSpecificPL()->SetUnstructuredGridIDMapper(anIDMapper); - if(theIsInitilizePipe){ - GetSpecificPL()->Init(); - } - - // To update scalar range according to the new input - if(!IsTimeStampFixed() && !IsRangeFixed() || theReInit) - SetSourceRange(); } diff --git a/src/VISU_I/VISU_ScalarMap_i.hh b/src/VISU_I/VISU_ScalarMap_i.hh index 6d73120b..d52a2fb5 100644 --- a/src/VISU_I/VISU_ScalarMap_i.hh +++ b/src/VISU_I/VISU_ScalarMap_i.hh @@ -76,14 +76,6 @@ namespace VISU void SetScaling(VISU::Scaling theScaling); - virtual - void - SetRange(CORBA::Double theMin, CORBA::Double theMax); - - virtual - void - SetSourceRange(); - //---------------------------------------------------------------------------- //! Sets initial source geometry virtual diff --git a/src/VISU_I/VISU_StreamLines_i.cc b/src/VISU_I/VISU_StreamLines_i.cc index 62757e1c..f62b758f 100644 --- a/src/VISU_I/VISU_StreamLines_i.cc +++ b/src/VISU_I/VISU_StreamLines_i.cc @@ -25,6 +25,7 @@ // Module : VISU #include "VISU_StreamLines_i.hh" +#include "VISU_Prs3dUtils.hh" #include "VISU_Result_i.hh" #include "VISU_Actor.h" @@ -59,7 +60,10 @@ VISU::StreamLines_i if(!TSuperClass::IsPossible(theResult, theMeshName, theEntity, theFieldName, theTimeStampNumber, false)) return 0; - VISU::Result_i::TInput* anInput = theResult->GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName, + theEntity, + theFieldName, + theTimeStampNumber); VISU::PUnstructuredGridIDMapper anIDMapper = anInput->GetTimeStampOnMesh(theMeshName, VISU::TEntity(theEntity), @@ -306,15 +310,18 @@ VISU::StreamLines_i ::SetSource(VISU::Prs3d_i* thePrs3d) { mySourceEntry = ""; - if(thePrs3d){ - SALOMEDS::SObject_var aSObject = thePrs3d->GetSObject(); - CORBA::String_var aString = aSObject->GetID(); - if(mySourceEntry == aString.in()) - return; - - mySourceEntry = aString.in(); - myParamsTime.Modified(); - } + if(!thePrs3d) + return; + + SALOMEDS::SObject_var aSObject = thePrs3d->GetSObject(); + CORBA::String_var aString = aSObject->GetID(); + if(mySourceEntry == aString.in()) + return; + + VISU::TSetModified aModified(this); + + mySourceEntry = aString.in(); + myParamsTime.Modified(); } //--------------------------------------------------------------- @@ -324,8 +331,10 @@ VISU::StreamLines_i { if(!myStreamLinesPL->GetSource() && mySourceEntry == "") return; + if(myStreamLinesPL->GetSource() == myAppendFilter->GetOutput()) return; + VISU::Prs3d_var aPrs3d = GetSource(); SetParams(GetIntegrationStep(), GetPropagationTime(), diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index 5e037ba1..ec88462d 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -57,7 +57,7 @@ const string VISU::Table_i::myComment = "TABLE"; /*! Generate unique name */ -const char* VISU::Table_i::GenerateName() +QString VISU::Table_i::GenerateName() { return VISU::GenerateName( "Table", ++myNbPresent ); } @@ -74,7 +74,7 @@ const char* VISU::Table_i::GetComment() const VISU::Table_i::Table_i( SALOMEDS::Study_ptr theStudy, const char* theObjectEntry ) : PrsObject_i(theStudy) { - mySObj = SALOMEDS::SObject::_duplicate((theStudy->FindObjectID(theObjectEntry))); + mySObj = theStudy->FindObjectID(theObjectEntry); myOrientation = VISU::Table::HORIZONTAL; } /*! @@ -126,11 +126,12 @@ VISU::Table_i } //---------------------------------------------------------------------------- -char* +std::string VISU::Table_i ::GetObjectEntry() { - return CORBA::string_dup( mySObj->GetID() ); + CORBA::String_var anEntry = mySObj->GetID(); + return anEntry.in(); } //---------------------------------------------------------------------------- @@ -180,7 +181,7 @@ CORBA::Long VISU::Table_i::GetNbColumns() VISU::Storable* VISU::Table_i::Create() { // generate name ... - SetName(GetTableTitle(), false); + SetName(GetTableTitle().latin1(), false); // mpv (PAL 5357): if name attribute already exist at this label, use it as name of table if ( GetName() == "" ) @@ -197,7 +198,7 @@ VISU::Storable* VISU::Table_i::Create() } if ( GetName() == "" ) - SetName(GenerateName(), false); + SetName(GenerateName().latin1(), false); // ... and build the object return Build( false ); } @@ -292,8 +293,10 @@ void VISU::Table_i::ToStream( std::ostringstream& theStr ) /*! Called from engine to restore table from the file */ -VISU::Storable* VISU::Table_i::Restore(SALOMEDS::SObject_ptr theSObject, - const string& thePrefix, const Storable::TRestoringMap& theMap) +VISU::Storable* VISU::Table_i::StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile) { SALOMEDS::Study_var aStudy = theSObject->GetStudy(); VISU::Table_i* pResent = new VISU::Table_i( aStudy, "" ); @@ -302,7 +305,7 @@ VISU::Storable* VISU::Table_i::Restore(SALOMEDS::SObject_ptr theSObject, /*! Gets title for the original table object */ -const char* VISU::Table_i::GetTableTitle() +QString VISU::Table_i::GetTableTitle() { SALOMEDS::SObject_var SO = mySObj; SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); @@ -312,11 +315,13 @@ const char* VISU::Table_i::GetTableTitle() if ( !SO->_is_nil() ) { if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) { anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); - return anInt->GetTitle(); + CORBA::String_var aString = anInt->GetTitle(); + return aString.in(); } else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) { aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); - return aReal->GetTitle(); + CORBA::String_var aString = aReal->GetTitle(); + return aString.in(); } } return ""; @@ -365,7 +370,7 @@ const string VISU::Curve_i::myComment = "CURVE"; /*! Generate unique name */ -const char* VISU::Curve_i::GenerateName() +QString VISU::Curve_i::GenerateName() { return VISU::GenerateName( "Curve", ++myNbPresent ); } @@ -527,7 +532,7 @@ VISU::Storable* VISU::Curve_i::Build(int theRestoring ) CORBA::Boolean VISU::Curve_i::IsValid() { // getting table SObject by it's entry - SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry()); + SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry().c_str()); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeTableOfInteger_var anInt; @@ -555,7 +560,7 @@ string VISU::Curve_i::GetHorTitle() { string title; // getting table SObject by it's entry - SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry()); + SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry().c_str()); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeTableOfInteger_var anInt; @@ -585,7 +590,7 @@ string VISU::Curve_i::GetVerTitle() { string title; // getting table SObject by it's entry - SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry()); + SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry().c_str()); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeTableOfInteger_var anInt; @@ -613,7 +618,7 @@ string VISU::Curve_i::GetHorUnits() { string units; // getting table SObject by it's entry - SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry()); + SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry().c_str()); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeTableOfInteger_var anInt; @@ -641,7 +646,7 @@ string VISU::Curve_i::GetVerUnits() { string units; // getting table SObject by it's entry - SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry()); + SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry().c_str()); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeTableOfInteger_var anInt; @@ -669,7 +674,7 @@ int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList, QStringLis { theHorList = 0; theVerList = 0; // getting table SObject by it's entry - SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry()); + SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry().c_str()); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeTableOfInteger_var anInt; @@ -791,7 +796,7 @@ SPlot2d_Curve* VISU::Curve_i::CreatePresentation() CORBA::String_var aString = mySObj->GetID(); crv->setIO(new SALOME_InteractiveObject(aString.in(), "VISU", GetName().c_str())); if ( myTable ) - crv->setTableIO(new SALOME_InteractiveObject(myTable->GetObjectEntry(), "VISU", myTable->GetName().c_str())); + crv->setTableIO(new SALOME_InteractiveObject(myTable->GetObjectEntry().c_str(), "VISU", myTable->GetName().c_str())); return crv; } /*! @@ -837,14 +842,16 @@ void VISU::Curve_i::ToStream( std::ostringstream& theStr ) /*! Gets reference table's entry */ -const char* VISU::Curve_i::GetTableID() { +std::string VISU::Curve_i::GetTableID() { return myTable->GetObjectEntry(); } /*! Called from engine to restore curve from the file */ -VISU::Storable* VISU::Curve_i::Restore(SALOMEDS::SObject_ptr theSObject, - const string& thePrefix, const Storable::TRestoringMap& theMap) +VISU::Storable* VISU::Curve_i::StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile) { SALOMEDS::Study_var aStudy = theSObject->GetStudy(); VISU::Table_i* pTable = GetTable(aStudy, theSObject->GetFather()); @@ -889,7 +896,7 @@ const string VISU::Container_i::myComment = "CONTAINER"; /*! Generate unique name */ -const char* VISU::Container_i::GenerateName() +QString VISU::Container_i::GenerateName() { return VISU::GenerateName( "Plot2DView", ++myNbPresent ); } @@ -1136,8 +1143,10 @@ void VISU::Container_i::ToStream( std::ostringstream& theStr ) /*! Called from engine to restore container from the file */ -VISU::Storable* VISU::Container_i::Restore(SALOMEDS::SObject_ptr theSObject, - const string& thePrefix, const Storable::TRestoringMap& theMap) +VISU::Storable* VISU::Container_i::StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile) { SALOMEDS::Study_var aStudy = theSObject->GetStudy(); VISU::Container_i* pResent = new VISU::Container_i( aStudy ); diff --git a/src/VISU_I/VISU_Table_i.hh b/src/VISU_I/VISU_Table_i.hh index b241a6b9..dcdecc6b 100644 --- a/src/VISU_I/VISU_Table_i.hh +++ b/src/VISU_I/VISU_Table_i.hh @@ -71,17 +71,18 @@ namespace VISU{ virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO); - static Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const std::string& thePrefix, - const Storable::TRestoringMap& theMap); + static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile); virtual void ToStream( std::ostringstream& theStr ); static const std::string myComment; virtual const char* GetComment() const; - virtual const char* GenerateName(); - virtual const char* GetTableTitle(); + virtual QString GenerateName(); + virtual QString GetTableTitle(); - virtual char* GetObjectEntry(); + virtual std::string GetObjectEntry(); }; SALOMEDS::SObject_var ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy); bool ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName); @@ -140,15 +141,16 @@ namespace VISU{ virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO); - static Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const std::string& thePrefix, - const Storable::TRestoringMap& theMap); + static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile); virtual void ToStream( std::ostringstream& theStr ); static const std::string myComment; virtual const char* GetComment() const; - virtual const char* GenerateName(); - virtual const char* GetTableID(); + virtual QString GenerateName(); + virtual std::string GetTableID(); virtual CORBA::Boolean IsAuto() { return myAuto; } virtual CORBA::Boolean IsValid(); @@ -194,14 +196,15 @@ namespace VISU{ virtual Storable* Create(); virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO ); - static Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const std::string& thePrefix, - const Storable::TRestoringMap& theMap); + static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix, + CORBA::Boolean theIsMultiFile); virtual void ToStream( std::ostringstream& theStr ); static const std::string myComment; virtual const char* GetComment() const; - virtual const char* GenerateName(); + virtual QString GenerateName(); void Update(); VISU::Curve_i* GetCurve( CORBA::Long theIndex ); diff --git a/src/VISU_I/VISU_Vectors_i.cc b/src/VISU_I/VISU_Vectors_i.cc index 8434c013..9aca7084 100644 --- a/src/VISU_I/VISU_Vectors_i.cc +++ b/src/VISU_I/VISU_Vectors_i.cc @@ -25,6 +25,7 @@ // Module : VISU #include "VISU_Vectors_i.hh" +#include "VISU_Prs3dUtils.hh" #include "VISU_Result_i.hh" #include "VISU_VectorsAct.h" @@ -65,7 +66,10 @@ VISU::Vectors_i false); if(theIsMemoryCheck && aResult){ bool anIsEstimated = true; - VISU::Result_i::TInput* anInput = theResult->GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName, + theEntity, + theFieldName, + theTimeStampNumber); size_t aSize = anInput->GetTimeStampOnMeshSize(theMeshName, (VISU::TEntity)theEntity, theFieldName, @@ -203,6 +207,8 @@ VISU::Vectors_i if(VISU::CheckIsSameValue(myLineWidth, theWidth)) return; + VISU::TSetModified aModified(this); + myLineWidth = theWidth; myParamsTime.Modified(); } @@ -221,6 +227,8 @@ void VISU::Vectors_i ::SetGlyphType(VISU::Vectors::GlyphType theType) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_VectorsPL::SetGlyphType, VISU_VectorsPL::GlyphType(theType))); } @@ -239,6 +247,8 @@ void VISU::Vectors_i ::SetGlyphPos(VISU::Vectors::GlyphPos thePos) { + VISU::TSetModified aModified(this); + ProcessVoidEvent(new TVoidMemFun1ArgEvent (GetSpecificPL(), &VISU_VectorsPL::SetGlyphPos, VISU_VectorsPL::GlyphPos(thePos))); }