From: jfa Date: Mon, 25 Apr 2005 08:08:43 +0000 (+0000) Subject: PostPro 2005, T1.5: 2D fields displayed in 3D - implement interface X-Git-Tag: V2_2_0_VISU_improvement_2005-05-27~47 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bff15f1b116da6ce85d3cbe5004b790bd25bf568;p=modules%2Fvisu.git PostPro 2005, T1.5: 2D fields displayed in 3D - implement interface --- diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 8c574a57..322c4e33 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -54,6 +54,7 @@ can be applied on different presentations. TSCALARMAP, /*!< Scalarmap 3D presentation object */ TISOSURFACE, /*!< Iso surface 3D presentation object */ TDEFORMEDSHAPE, /*!< Deformed shape 3D presentation object */ + TPLOT3D, /*!< Plot3D 3D presentation object */ TCUTPLANES, /*!< Cut planes 3D presentation object */ TCUTLINES, /*!< Cut lines 3D presentation object */ TVECTORS, /*!< Vectors 3D presentation object */ @@ -478,6 +479,93 @@ Gets the scale of the presentatable object. */ void SetColor(in SALOMEDS::Color theColor); }; + + //------------------------------------------------------- + /*! + * \brief Plot3D interface + * + * Presentation parameters of Plot3D presentation. This type of presentation + * consists of cutting your initial mesh by a definite number of planes. As the + * result you will see these planes which will be cutted by the borders of the mesh. + */ + interface Plot3D : ScalarMap { + /*! + * This enumeration contains a set of elements defining + * the type of orientation in 3D space of the cut planes. + */ + enum Orientation { XY, /*!< The object is located in the plane formed by X and Y axis. */ + YZ, /*!< The object is located in the plane formed by Y and Z axis. */ + ZX }; /*!< The object is located in the plane formed by Z and X axis. */ + + /*! + * Sets the type of orientation in 3D space of cut planes presentation. + * \param theOrientation This parameter defines the type of orientation of cut planes + * in 3D space. It is taken from the Orientation enumeration. + * \param theXAngle The angle of rotation of the cut planes + * around the first axis of the chosen orientation. + * \param theXAngle The angle of rotation of the cut planes + * around the second axis of the chosen orientation. + */ + void SetOrientation (in Orientation theOrientation, in double theXAngle, in double theYAngle); + + /*! + * Gets the type of orientation in 3D space of cut planes presentation. + */ + Orientation GetOrientationType(); + + /*! + * Gets rotation angle of the cut plane presentation + * around the first axis of the chosen orientation. + */ + //double GetRotateX(); + + /*! + * Gets rotation angle of the cut plane presentation + * around the second axis of the chosen orientation. + */ + //double GetRotateY(); + + /*! + * Sets the position of a cut plane. + * \param thePlanePosition The position of the cut plane. + * \param theIsRelative Define, whether the input position is relative. + */ + void SetPlanePosition (in double thePlanePosition, + in boolean theIsRelative); + + /*! + * Gets the position of the cut plane + */ + double GetPlanePosition(); + + /*! + * Returns true if a position of cut plane is relative + */ + boolean IsPositionRelative(); + + /*! + * Sets the scale factor for scalar values. + * \param theScaleFactor The scaling factor. + */ + void SetScaleFactor (in double theScaleFactor); + + /*! + * Gets the scale factor for scalar values. + */ + double GetScaleFactor(); + + /*! + * Sets the number of contours. + * \param theNb The number of contours. + */ + void SetNbOfContours (in long theNb); + + /*! + * Gets the number of contours. + */ + long GetNbOfContours(); + }; + //------------------------------------------------------- /*! \brief Cut planes interface diff --git a/src/VISU_I/Makefile.in b/src/VISU_I/Makefile.in index 1489eb26..7cd35c67 100644 --- a/src/VISU_I/Makefile.in +++ b/src/VISU_I/Makefile.in @@ -21,7 +21,7 @@ LIB_SRC = VISUConfig.cc VISU_Gen_i.cc VISU_Result_i.cc \ VISU_ViewManager_i.cc VISU_PrsObject_i.cc VISU_Table_i.cc \ VISU_Prs3d_i.cc VISU_Mesh_i.cc VISU_ScalarMap_i.cc \ VISU_IsoSurfaces_i.cc VISU_DeformedShape_i.cc \ - VISU_CutPlanes_i.cc VISU_CutLines_i.cc \ + VISU_Plot3D_i.cc VISU_CutPlanes_i.cc VISU_CutLines_i.cc \ VISU_Vectors_i.cc VISU_StreamLines_i.cc \ VISU_TimeAnimation.cxx VISU_CorbaMedConvertor.cxx @@ -43,7 +43,7 @@ EXPORT_HEADERS = VISUConfig.hh VISU_Gen_i.hh VISU_Result_i.hh \ VISU_PrsObject_i.hh VISU_ViewManager_i.hh VISU_Table_i.hh \ VISU_Prs3d_i.hh VISU_Mesh_i.hh VISU_ScalarMap_i.hh \ VISU_IsoSurfaces_i.hh VISU_DeformedShape_i.hh \ - VISU_CutPlanes_i.hh VISU_CutLines_i.hh \ + VISU_Plot3D_i.hh VISU_CutPlanes_i.hh VISU_CutLines_i.hh \ VISU_Vectors_i.hh VISU_StreamLines_i.hh \ VISU_TimeAnimation.h diff --git a/src/VISU_I/VISU_Plot3D_i.cc b/src/VISU_I/VISU_Plot3D_i.cc new file mode 100644 index 00000000..998fc10c --- /dev/null +++ b/src/VISU_I/VISU_Plot3D_i.cc @@ -0,0 +1,170 @@ + +#include "VISU_Plot3D_i.hh" + +#include "VISU_Result_i.hh" + +#include "VISU_Plot3DPL.hxx" + +#include "VISU_Actor.h" + +using namespace VISU; +using namespace std; + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +int VISU::Plot3D_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, int theIteration, int isMemoryCheck) +{ + return VISU::ScalarMap_i::IsPossible + (theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck); +} + +int VISU::Plot3D_i::myNbPresent = 0; +QString VISU::Plot3D_i::GenerateName() { return VISU::GenerateName("Plot3D",myNbPresent++); } + +const string VISU::Plot3D_i::myComment = "PLOT3D"; +const char* VISU::Plot3D_i::GetComment() const { return myComment.c_str(); } + +VISU::Plot3D_i::Plot3D_i (Result_i* theResult, bool theAddToStudy, SALOMEDS::SObject_ptr theSObject) + : PrsObject_i(theResult->GetStudyDocument()), + Prs3d_i(theResult,theSObject), + ScalarMap_i(theResult,theAddToStudy,theSObject) +{ + myPlot3DPL = NULL; +} + +void VISU::Plot3D_i::SameAs (const Plot3D_i* theOrigin) +{ + VISU::ScalarMap_i::SameAs(theOrigin); +} + +VISU::Storable* VISU::Plot3D_i::Create (const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, int theIteration) +{ + return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration); +} + +VISU::Storable* VISU::Plot3D_i::Restore (const Storable::TRestoringMap& theMap) +{ + DoHook(); + SetNbOfContours(VISU::Storable::FindValue(theMap,"myNbOfContours").toInt()); + SetScaleFactor(VISU::Storable::FindValue(theMap,"myScaleFactor").toDouble()); + SetOrientation(VISU::Plot3D::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane").toInt()), + Storable::FindValue(theMap,"aRot[0]").toDouble(), + Storable::FindValue(theMap,"aRot[1]").toDouble()); + SetPlanePosition(VISU::Storable::FindValue(theMap,"myPlanePosition").toDouble(), + VISU::Storable::FindValue(theMap,"myPlaneCondition").toInt()); + + return ScalarMap_i::Restore(theMap); +} + +void VISU::Plot3D_i::ToStream (std::ostringstream& theStr) +{ + ScalarMap_i::ToStream(theStr); + + Storable::DataToStream(theStr, "myNbOfContours", int(GetNbOfContours())); + Storable::DataToStream(theStr, "myScaleFactor", GetScaleFactor()); + Storable::DataToStream(theStr, "myBasePlane", int(GetOrientationType())); + Storable::DataToStream(theStr, "aRot[0]", 0); + Storable::DataToStream(theStr, "aRot[1]", 0); + Storable::DataToStream(theStr, "myPlanePosition", GetPlanePosition()); + Storable::DataToStream(theStr, "myPlaneCondition", int(IsPositionRelative())); +} + +VISU::Plot3D_i::~Plot3D_i(){ + if(MYDEBUG) MESSAGE("Plot3D_i::~Plot3D_i()"); +} + +void VISU::Plot3D_i::SetOrientation (VISU::Plot3D::Orientation theOrient, + CORBA::Double theXAngle, CORBA::Double theYAngle) +{ + myPlot3DPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(theOrient), + theXAngle,theYAngle); +} + +VISU::Plot3D::Orientation VISU::Plot3D_i::GetOrientationType() +{ + return VISU::Plot3D::Orientation(myPlot3DPL->GetPlaneOrientation()); +} + +//CORBA::Double VISU::Plot3D_i::GetRotateX() +//{ +// //return myPlot3DPL->GetRotateX(); +// return 0.0; +//} +// +//CORBA::Double VISU::Plot3D_i::GetRotateY() +//{ +// //return myPlot3DPL->GetRotateY(); +// return 0.0; +//} +// +//void VISU::Plot3D_i::SetDisplacement (CORBA::Double theDisp) +//{ +// //myPlot3DPL->SetDisplacement(theDisp); +//} +// +//CORBA::Double VISU::Plot3D_i::GetDisplacement() +//{ +// //return myPlot3DPL->GetDisplacement(); +// return 0.0; +//} + +void VISU::Plot3D_i::SetPlanePosition (CORBA::Double thePlanePosition, + CORBA::Boolean theIsRelative) +{ + myPlot3DPL->SetPlanePosition(thePlanePosition, theIsRelative); +} + +CORBA::Double VISU::Plot3D_i::GetPlanePosition() +{ + return myPlot3DPL->GetPlanePosition(); +} + +CORBA::Boolean VISU::Plot3D_i::IsPositionRelative() +{ + return myPlot3DPL->IsPositionRelative(); +} + +void VISU::Plot3D_i::SetScaleFactor (CORBA::Double theScaleFactor) +{ + myPlot3DPL->SetScaleFactor(theScaleFactor); +} + +CORBA::Double VISU::Plot3D_i::GetScaleFactor() +{ + return myPlot3DPL->GetScaleFactor(); +} + +//void VISU::Plot3D_i::SetDefault (CORBA::Long thePlaneNumber) +//{ +// //myPlot3DPL->SetPartDefault(thePlaneNumber); +//} +// +//CORBA::Boolean VISU::Plot3D_i::IsDefault (CORBA::Long thePlaneNumber) +//{ +// //return myPlot3DPL->IsPartDefault(thePlaneNumber); +// return false; +//} + +void VISU::Plot3D_i::SetNbOfContours (CORBA::Long theNb) +{ + myPlot3DPL->SetNumberOfContours(theNb); +} + +CORBA::Long VISU::Plot3D_i::GetNbOfContours() +{ + return myPlot3DPL->GetNumberOfContours(); +} + +void VISU::Plot3D_i::DoHook() +{ + if (!myPipeLine) myPipeLine = VISU_Plot3DPL::New(); + myPlot3DPL = dynamic_cast(myPipeLine); + + ScalarMap_i::DoHook(); +} diff --git a/src/VISU_I/VISU_Plot3D_i.hh b/src/VISU_I/VISU_Plot3D_i.hh new file mode 100644 index 00000000..e0548c79 --- /dev/null +++ b/src/VISU_I/VISU_Plot3D_i.hh @@ -0,0 +1,69 @@ + +#ifndef VISU_Plot3D_i_HeaderFile +#define VISU_Plot3D_i_HeaderFile + +#include "VISU_ScalarMap_i.hh" + +class VISU_Plot3DPL; + +namespace VISU { + class Plot3D_i : public virtual POA_VISU::Plot3D, + public virtual ScalarMap_i + { + static int myNbPresent; + Plot3D_i(); + Plot3D_i(const Plot3D_i&); + + public: + Plot3D_i (Result_i* theResult, bool theAddToStudy = true, + SALOMEDS::SObject_ptr theSObject = SALOMEDS::SObject::_nil()); + virtual void SameAs (const Plot3D_i* theOrigin); + virtual ~Plot3D_i(); + + virtual VISU::VISUType GetType() { return VISU::TPLOT3D; }; + + virtual void SetOrientation (VISU::Plot3D::Orientation theOrient, + CORBA::Double theXAngle, CORBA::Double theYAngle); + + virtual VISU::Plot3D::Orientation GetOrientationType(); + + //virtual CORBA::Double GetRotateX(); + //virtual CORBA::Double GetRotateY(); + + virtual void SetPlanePosition (CORBA::Double thePlanePosition, + CORBA::Boolean theIsRelative); + virtual CORBA::Double GetPlanePosition(); + virtual CORBA::Boolean IsPositionRelative(); + + virtual void SetScaleFactor (CORBA::Double theScaleFactor); + virtual CORBA::Double GetScaleFactor(); + + virtual void SetNbOfContours (CORBA::Long theNb); + virtual CORBA::Long GetNbOfContours(); + + //typedef VISU::Plot3D TInterface; + VISU_Plot3DPL* GetPlot3DPL() { return myPlot3DPL; } + + protected: + virtual void DoHook(); + + VISU_Plot3DPL *myPlot3DPL; + + public: + static int IsPossible (Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, int theIteration, int isMemoryCheck = true); + + virtual Storable* Create (const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, int theIteration); + + virtual void ToStream (std::ostringstream& theStr); + + virtual Storable* Restore (const Storable::TRestoringMap& theMap); + + static const std::string myComment; + virtual const char* GetComment() const; + virtual QString GenerateName(); + }; +} + +#endif