Salome HOME
Update copyright information
[modules/visu.git] / src / VISU_I / VISU_ClippingPlaneMgr.hxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //  VISU OBJECT : interactive object for VISU entities implementation
21 //  File   : VISU_ClippingPlaneMgr.hxx
22 //  Author : VSV
23 //  Module : VISU
24 //
25 #ifndef _VISU_ClippingPlane_H_
26 #define _VISU_ClippingPlane_H_
27
28 #include "VISU_I.hxx"
29 #include "VISUConfig.hh"
30 #include "SALOME_Component_i.hxx"
31 #include "VISU_ColoredPrs3d_i.hh"
32
33 #include <vtkPlane.h>
34 #include <string>
35
36 class vtkImplicitFunctionCollection;
37
38
39 class VISU_I_EXPORT VISU_CutPlaneFunction: public vtkPlane
40 {
41 public:
42   static VISU_CutPlaneFunction* New();
43
44   vtkTypeMacro(VISU_CutPlaneFunction, vtkPlane);
45
46   virtual double EvaluateFunction(double x[3]);
47   virtual double EvaluateFunction(double x, double y, double z);
48
49   void setActive(bool theActive);
50   bool isActive() const { return myIsActive; }
51
52   void setPlaneObject(_PTR(SObject) aSOPlane) { mySObject = aSOPlane; }
53   _PTR(SObject) getPlaneObject() const { return mySObject; }
54
55   void setName(std::string theName) { myName = theName; }
56   std::string getName() const { return myName; }
57   
58   void setAuto(bool isAuto) { myIsAuto = isAuto; }
59   bool isAuto() const { return myIsAuto; }
60
61 protected:
62   VISU_CutPlaneFunction();
63   ~VISU_CutPlaneFunction();
64
65 private:
66   bool myIsActive;
67   _PTR(SObject) mySObject;
68   std::string myName;
69   bool myIsAuto;
70 };
71
72
73
74 class VISU_I_EXPORT VISU_ClippingPlaneMgr {
75 public:
76   VISU_ClippingPlaneMgr();
77   ~VISU_ClippingPlaneMgr();
78
79   void SetStudy(_PTR(Study) theStudy, bool reinitStudy = false);
80
81
82   long CreateClippingPlane(double X,double  Y, double Z, 
83                            double dX, double dY, double dZ, 
84                            bool isAuto, const char* name);
85
86   void EditClippingPlane(long id, double X,double  Y, double Z, 
87                            double dX, double dY, double dZ, 
88                            bool isAuto, const char* name);
89
90   _PTR(SObject) CreateClippingPlaneObject(double X,double  Y, double Z, 
91                                           double dX, double dY, double dZ, 
92                                           bool isAuto, const char* name);
93   
94   /* Returns clipping plane by its Id */
95   VISU_CutPlaneFunction* GetClippingPlane(long id);
96
97   /* Returns -1 if Plane is not exists */
98   int GetPlaneId(VISU_CutPlaneFunction* thePlane);
99   
100   /* Deletes clipping plane by its Id */
101   bool DeleteClippingPlane(long id);
102   
103   /* Applyes a clipping plane with Id to presentation thePrs */
104   bool ApplyClippingPlane(VISU::Prs3d_i* thePrs, long id);
105
106   bool DetachClippingPlane(VISU::Prs3d_i* thePrs, long id);
107   
108   /* Get number of clipping planes */
109   long GetClippingPlanesNb();
110
111   _PTR(SObject) GetClippingPlanesFolder(bool toCreate);
112
113   static bool ContainsPlane(VISU::Prs3d_ptr thePrs, VISU_CutPlaneFunction* thePlane);
114   static bool ContainsPlane(VISU::Prs3d_i* thePrs, VISU_CutPlaneFunction* thePlane);
115
116   vtkImplicitFunctionCollection* GetPlanesList() const { return myPlanes; }
117
118
119 private:
120   void applyPlaneToAll(VISU_CutPlaneFunction* thePlane);
121
122
123   _PTR(Study) myStudy;
124
125   vtkImplicitFunctionCollection* myPlanes;
126 };
127
128 #endif