Salome HOME
d41b0731d3652750ae60971cca6996a815556cbb
[modules/visu.git] / src / VISUGUI / VisuGUI_ClippingDlg.h
1 // Copyright (C) 2007-2011  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
23 #ifndef DIALOGBOX_CLIPPING_H
24 #define DIALOGBOX_CLIPPING_H
25
26 #include "SALOME_InteractiveObject.hxx"
27
28 #include "SalomeApp_DoubleSpinBox.h"
29
30 // QT Includes
31 #include <QDialog>
32 #include <QPointer>
33
34 // VTK Includes
35 #include <vtkSmartPointer.h>
36 #include <vtkPlane.h>
37
38 // STL Includes
39 #include <vector>
40
41 class QLabel;
42 class QPushButton;
43 class QCheckBox;
44 class QGroupBox;
45 class QComboBox;
46 class QButtonGroup;
47 class QTabWidget;
48 class QListWidget;
49
50 class SALOME_Actor;
51
52 class SVTK_ViewWindow;
53
54 class LightApp_SelectionMgr;
55
56 class SalomeApp_IntSpinBox;
57
58 class VisuGUI;
59 class vtkPlaneSource;
60 class vtkDataSetMapper;
61 class OrientedPlane;
62 class VISU_Actor;
63 class PreviewPlane;
64
65 namespace VISU {
66   class Prs3d_i;
67
68   typedef vtkSmartPointer<OrientedPlane> TVTKPlane;
69   typedef std::vector<TVTKPlane> TPlanes;
70   enum Orientation {XY, YZ, ZX};
71 };
72
73 //=================================================================================
74 //class    : OrientedPlane
75 //purpose  :
76 //=================================================================================
77 class OrientedPlane: public vtkPlane
78 {
79   QPointer<SVTK_ViewWindow> myViewWindow;
80   vtkDataSetMapper* myMapper;
81
82 public:
83   static OrientedPlane* New();
84   static OrientedPlane* New (SVTK_ViewWindow* vw);
85
86   vtkTypeMacro(OrientedPlane, vtkPlane);
87
88   VISU::Orientation myOrientation;
89   float myDistance;
90   double myAngle[2];
91
92   vtkPlaneSource* myPlaneSource;
93   SALOME_Actor* myActor;
94
95   void SetOrientation(VISU::Orientation theOrientation);
96   VISU::Orientation GetOrientation();
97
98   void SetDistance(float theDistance);
99   float GetDistance();
100
101   void ShallowCopy(OrientedPlane* theOrientedPlane);
102
103 protected:
104   OrientedPlane();
105   OrientedPlane(SVTK_ViewWindow* vw);
106   ~OrientedPlane();
107
108   void Init();
109
110 private:
111   OrientedPlane(const OrientedPlane&);
112   void operator=(const OrientedPlane&);
113 };
114
115 //=================================================================================
116 // class    : VisuGUI_ClippingDlg
117 // purpose  :
118 //=================================================================================
119 class VisuGUI_ClippingDlg : public QDialog
120 {
121     Q_OBJECT
122
123 public:
124     VisuGUI_ClippingDlg( VisuGUI* theModule,
125                          bool modal = false );
126
127     float  getDistance()  { return (float)SpinBoxDistance->value(); }
128     void   setDistance(const float theDistance) { SpinBoxDistance->setValue(theDistance); }
129     double getRotation1() { return SpinBoxRot1->value(); }
130     double getRotation2() { return SpinBoxRot2->value(); }
131     void   setRotation(const double theRot1, const double theRot2);
132     void Sinchronize();
133
134     ~VisuGUI_ClippingDlg();
135
136 private:
137     void keyPressEvent( QKeyEvent* e );
138   
139     void SetPrs3d(VISU::Prs3d_i* thePrs);
140   
141     VISU_Actor* getSelectedActor();
142
143     void applyLocalPlanes();
144
145     void removeAllClippingPlanes(VISU::Prs3d_i* thePrs);
146
147 private:
148
149     LightApp_SelectionMgr* mySelectionMgr;
150     Handle(SALOME_InteractiveObject) myIO;
151
152     VisuGUI       * myVisuGUI;
153     VISU::Prs3d_i * myPrs3d;
154     VISU::TPlanes   myPlanes;
155
156     QComboBox*        ComboBoxPlanes;
157     QPushButton*      buttonNew;
158     QPushButton*      buttonDelete;
159
160     QLabel*           TextLabelOrientation;
161     QLabel*           TextLabelDistance;
162     QLabel*           TextLabelRot1;
163     QLabel*           TextLabelRot2;
164
165     QTabWidget*       TabPane;
166
167     QComboBox*        ComboBoxOrientation;
168     SalomeApp_DoubleSpinBox*  SpinBoxDistance;
169     SalomeApp_DoubleSpinBox*  SpinBoxRot1;
170     SalomeApp_DoubleSpinBox*  SpinBoxRot2;
171
172     QWidget*          WidgetIJKTab;
173     QButtonGroup*     ButtonGroupIJKAxis;
174     QGroupBox*        GroupBoxIJKAxis;
175     QLabel*           TextLabelIJKIndex;
176     SalomeApp_IntSpinBox* SpinBoxIJKIndex;
177     QCheckBox*        CheckBoxIJKPlaneReverse;
178
179     QCheckBox*        PreviewCheckBox;
180     QCheckBox*        AutoApplyCheckBox;
181
182     QPushButton*      buttonOk;
183     QPushButton*      buttonCancel;
184     QPushButton*      buttonApply;
185     QPushButton*      buttonHelp;
186
187     bool myIsSelectPlane;
188
189     VISU_Actor* myDSActor;
190     QList<PreviewPlane*> myPreviewList;
191
192 protected:
193     QWidget* createParamsTab();
194     QWidget* createIJKParamsTab();
195     void setIJKByNonStructured();
196     bool isStructured() const;
197
198 public slots:
199
200     void onSelectPlane(int theIndex);
201     void ClickOnNew();
202     void ClickOnDelete();
203     void onSelectOrientation(int theItem);
204     void SetCurrentPlaneParam();
205     void SetCurrentPlaneIJKParam();
206     void onIJKAxisChanged(int axis);
207     void onTabChanged(QWidget* newTab);
208     void onSelectionChanged();
209     void OnPreviewToggle(bool theIsToggled);
210     void ClickOnOk();
211     void ClickOnCancel();
212     void ClickOnApply();
213     void ClickOnHelp();
214 };
215
216 #endif // DIALOGBOX_CLIPPING_H
217
218