Salome HOME
712fd37459c19c9db642a9189478c8afe732e6db
[modules/visu.git] / src / VISUGUI / VisuGUI_ClippingPanel.h
1 // Copyright (C) 2007-2011  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 #ifndef DIALOGBOX_CLIPPINGPANEL_H
21 #define DIALOGBOX_CLIPPINGPANEL_H
22
23
24 class VisuGUI;
25 class QListWidget;
26 class QTableWidget;
27 class VisuGUI_ClippingPlaneDlg;
28 class QCheckBox;
29 class SVTK_ViewWindow;
30 class SUIT_ViewWindow;
31 class vtkPolyDataMapper;
32 class vtkImageData;
33 class vtkEDFCutter;
34
35 #include "VISU_Prs3d_i.hh"
36 #include "VisuGUI_Panel.h"
37 //#include <VisuGUI_SegmentationMgr.h>
38 #include <VISU_ClippingPlaneMgr.hxx>
39
40 #include <QList>
41 #include <vtkActor.h>
42 #include <vtkPlane.h>
43
44 #include <SALOMEDSClient_SObject.hxx>
45
46
47 /*class CutPlaneFunction: public vtkPlane
48 {
49 public:
50   static CutPlaneFunction* New();
51
52   vtkTypeMacro(CutPlaneFunction, vtkPlane);
53
54   virtual double EvaluateFunction(double x[3]);
55   virtual double EvaluateFunction(double x, double y, double z);
56
57   void setActive(bool theActive);
58   bool isActive() const { return myIsActive; }
59
60   void setPlaneObject(_PTR(SObject) aSOPlane) { mySObject = aSOPlane; }
61   _PTR(SObject) getPlaneObject() const { return mySObject; }
62
63 protected:
64   CutPlaneFunction();
65   ~CutPlaneFunction();
66
67 private:
68   bool myIsActive;
69   _PTR(SObject) mySObject;
70 };
71
72
73
74 struct PlaneDef
75 {
76   vtkSmartPointer<CutPlaneFunction> plane;
77   bool isAuto;
78   QString name;
79 };
80 */
81
82 class PreviewPlane
83 {
84 public:
85   //PreviewPlane(SVTK_ViewWindow* theWindow, const PlaneDef& thePlane, const double* theBounds);
86   PreviewPlane(SVTK_ViewWindow* theWindow, VISU_CutPlaneFunction* thePlane, const double* theBounds);
87   ~PreviewPlane();
88
89   void setVisible(bool theVisible)
90   { myActor->SetVisibility(theVisible); }
91
92 private:
93   SVTK_ViewWindow* myWindow;
94
95   vtkActor* myActor;
96   vtkPolyDataMapper* myMapper;
97   const double* myBounds;
98   vtkPlane* myPlane;
99   vtkImageData* myBox;
100   vtkEDFCutter* myCutter;
101 };
102
103
104 //typedef QList<PlaneDef> QListOfPlanes;
105 typedef QList<vtkPlane*> ListOfvtkPlanes;
106 typedef QList<PreviewPlane*> ListOfPreview;
107
108
109
110
111
112 class VisuGUI_ClippingPanel: public VisuGUI_Panel
113 {
114   Q_OBJECT
115 public:
116   VisuGUI_ClippingPanel(VisuGUI* theModule, QWidget* theParent = 0);
117   ~VisuGUI_ClippingPanel();
118
119   void init();
120
121   //protected:
122   //virtual void showEvent(QShowEvent* event);
123   //virtual void hideEvent(QHideEvent* event);
124
125 public slots:
126   void onPresentationCreate(VISU::Prs3d_i* thePrs);
127
128 protected slots:
129   virtual void onApply();
130   virtual void onHelp();
131
132 private slots:
133   void onNew();
134   void onNewPlane();
135   void onEdit();
136   void onPlaneEdited();
137   void onPlaneDelete();
138   void onCancelDialog();
139   void setPlanesNonActive(bool theState);
140   void setPlanesVisible(bool theVisible);
141   void onWindowActivated(SUIT_ViewWindow* theWindow);
142   void onCellChanged(int row, int col);
143   void onObjectDelete(QString theEntry);
144   void onPrsSelected(int thePrs);
145   void onWindowDestroyed(QObject* theWnd);
146
147  private:
148   void fillPrsList();
149   void fillPlanesList();
150
151   bool isAutoApply() const;
152
153   VISU_ClippingPlaneMgr& getPlanesMgr() const;
154
155
156   //void updatePlane(_PTR(SObject) theObject, PlaneDef& thePlane);
157   //PlaneDef createEmptyPlane();
158   //static bool containsPlane(VISU::Prs3d_i* thePrs, const PlaneDef& thePlane);
159
160   QString getPrsName(VISU::Prs3d_i* thePrs);
161
162   bool isVISUDataReady();
163
164   void applyPlaneToPrs(int thePlaneNum, int thePrsNum, bool isChecked);
165
166   //QList<VISU::Prs3d_i*> getPrsList(_PTR(Study) theStudy, _PTR(SObject) theObject);
167   QStringList getPrsList(_PTR(Study) theStudy, _PTR(SObject) theObject);
168   VISU::Prs3d_i* getPrs(QString theEntry);
169
170   QListWidget* myPrsList;
171   QTableWidget* myPlanesList;
172
173   QCheckBox* myShowPlanes;
174   QCheckBox* myNonActivePlanes;
175   QCheckBox* myAutoApply;
176   
177   //QListOfPlanes myPlanes;
178   //  QList<VISU::Prs3d_i*> myPresentations;
179   QStringList myPresentations; // Stores entries of presentation objects
180   ListOfPreview myPreview;
181
182   VisuGUI_ClippingPlaneDlg* myPlaneDlg;
183   //int myEditingPlanePos;
184   SVTK_ViewWindow* myViewWindow;
185   bool myIsApplied;
186   //QList<int> myCheckedPlanes;
187 };
188
189 #endif