Salome HOME
a3d6f004083144aae1fe941eab7eb9b7dae5e330
[modules/visu.git] / src / VISUGUI / VisuGUI_ClippingPanel.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #ifndef DIALOGBOX_CLIPPINGPANEL_H
23 #define DIALOGBOX_CLIPPINGPANEL_H
24
25
26 class VisuGUI;
27 class QListWidget;
28 class QTableWidget;
29 class VisuGUI_ClippingPlaneDlg;
30 class QCheckBox;
31 class SVTK_ViewWindow;
32 class SUIT_ViewWindow;
33 class vtkPolyDataMapper;
34 class vtkImageData;
35 class vtkCutter;
36
37 #include "VISU_Prs3d_i.hh"
38 #include "VisuGUI_Panel.h"
39 //#include <VisuGUI_SegmentationMgr.h>
40 #include <VISU_ClippingPlaneMgr.hxx>
41
42 #include <QList>
43 #include <vtkActor.h>
44 #include <vtkPlane.h>
45
46 #include <SALOMEDSClient_SObject.hxx>
47
48
49 /*class CutPlaneFunction: public vtkPlane
50 {
51 public:
52   static CutPlaneFunction* New();
53
54   vtkTypeMacro(CutPlaneFunction, vtkPlane);
55
56   virtual double EvaluateFunction(double x[3]);
57   virtual double EvaluateFunction(double x, double y, double z);
58
59   void setActive(bool theActive);
60   bool isActive() const { return myIsActive; }
61
62   void setPlaneObject(_PTR(SObject) aSOPlane) { mySObject = aSOPlane; }
63   _PTR(SObject) getPlaneObject() const { return mySObject; }
64
65 protected:
66   CutPlaneFunction();
67   ~CutPlaneFunction();
68
69 private:
70   bool myIsActive;
71   _PTR(SObject) mySObject;
72 };
73
74
75
76 struct PlaneDef
77 {
78   vtkSmartPointer<CutPlaneFunction> plane;
79   bool isAuto;
80   QString name;
81 };
82 */
83
84 class PreviewPlane
85 {
86 public:
87   //PreviewPlane(SVTK_ViewWindow* theWindow, const PlaneDef& thePlane, const double* theBounds);
88   PreviewPlane(SVTK_ViewWindow* theWindow, VISU_CutPlaneFunction* thePlane, const double* theBounds);
89   ~PreviewPlane();
90
91   void setVisible(bool theVisible)
92   { myActor->SetVisibility(theVisible); }
93
94 private:
95   SVTK_ViewWindow* myWindow;
96
97   vtkActor* myActor;
98   vtkPolyDataMapper* myMapper;
99   const double* myBounds;
100   vtkPlane* myPlane;
101   vtkImageData* myBox;
102   vtkCutter* myCutter;
103 };
104
105
106 //typedef QList<PlaneDef> QListOfPlanes;
107 typedef QList<vtkPlane*> ListOfvtkPlanes;
108 typedef QList<PreviewPlane*> ListOfPreview;
109
110
111
112
113
114 class VisuGUI_ClippingPanel: public VisuGUI_Panel
115 {
116   Q_OBJECT
117 public:
118   VisuGUI_ClippingPanel(VisuGUI* theModule, QWidget* theParent = 0);
119   ~VisuGUI_ClippingPanel();
120
121   void init();
122
123   //protected:
124   //virtual void showEvent(QShowEvent* event);
125   //virtual void hideEvent(QHideEvent* event);
126
127 public slots:
128   void onPresentationCreate(VISU::Prs3d_i* thePrs);
129
130 protected slots:
131   virtual void onApply();
132   virtual void onHelp();
133
134 private slots:
135   void onNew();
136   void onNewPlane();
137   void onEdit();
138   void onPlaneEdited();
139   void onPlaneDelete();
140   void onCancelDialog();
141   void setPlanesNonActive(bool theState);
142   void setPlanesVisible(bool theVisible);
143   void onWindowActivated(SUIT_ViewWindow* theWindow);
144   void onCellChanged(int row, int col);
145   void onObjectDelete(QString theEntry);
146   void onPrsSelected(int thePrs);
147   void onWindowDestroyed(QObject* theWnd);
148
149  private:
150   void fillPrsList();
151   void fillPlanesList();
152
153   bool isAutoApply() const;
154
155   VISU_ClippingPlaneMgr& getPlanesMgr() const;
156
157
158   //void updatePlane(_PTR(SObject) theObject, PlaneDef& thePlane);
159   //PlaneDef createEmptyPlane();
160   //static bool containsPlane(VISU::Prs3d_i* thePrs, const PlaneDef& thePlane);
161
162   QString getPrsName(VISU::Prs3d_i* thePrs);
163
164   bool isVISUDataReady();
165
166   void applyPlaneToPrs(int thePlaneNum, int thePrsNum, bool isChecked);
167
168   //QList<VISU::Prs3d_i*> getPrsList(_PTR(Study) theStudy, _PTR(SObject) theObject);
169   QStringList getPrsList(_PTR(Study) theStudy, _PTR(SObject) theObject);
170   VISU::Prs3d_i* getPrs(QString theEntry);
171
172   QListWidget* myPrsList;
173   QTableWidget* myPlanesList;
174
175   QCheckBox* myShowPlanes;
176   QCheckBox* myNonActivePlanes;
177   QCheckBox* myAutoApply;
178   
179   //QListOfPlanes myPlanes;
180   //  QList<VISU::Prs3d_i*> myPresentations;
181   QStringList myPresentations; // Stores entries of presentation objects
182   ListOfPreview myPreview;
183
184   VisuGUI_ClippingPlaneDlg* myPlaneDlg;
185   //int myEditingPlanePos;
186   SVTK_ViewWindow* myViewWindow;
187   bool myIsApplied;
188   //QList<int> myCheckedPlanes;
189 };
190
191 #endif