Salome HOME
PR: synchro V7_main tag mergefrom_V6_main_28Feb13
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ClippingDlg.h
1 // Copyright (C) 2007-2012  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 // SMESH SMESHGUI : GUI for SMESH component
24 // File   : SMESHGUI_ClippingDlg.h
25 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
26 //
27 #ifndef SMESHGUI_CLIPPINGDLG_H
28 #define SMESHGUI_CLIPPINGDLG_H
29
30 // SMESH includes
31 #include "SMESH_SMESHGUI.hxx"
32
33 // SALOME includes
34 #include <SVTK_ViewWindow.h>
35
36 // Qt includes
37 #include <QDialog>
38 #include <QPointer>
39
40 // VTK includes
41 #include <vtkPlane.h>
42 #include <vtkSmartPointer.h>
43
44 // STL includes
45 #include <list>
46 #include <map>
47 #include <vector>
48
49 class QLabel;
50 class QPushButton;
51 class QCheckBox;
52 class QComboBox;
53 class QListWidget;
54 class QListWidgetItem;
55 class SALOME_Actor;
56 class SMESHGUI;
57 class SMESH_Actor;
58 class SMESHGUI_SpinBox;
59 class vtkActor;
60 class vtkDataSetMapper;
61 class vtkPlaneSource;
62
63 namespace SMESH
64 {
65   enum Orientation { XY, YZ, ZX };
66
67   class OrientedPlane: public vtkPlane
68   {
69     QPointer<SVTK_ViewWindow> myViewWindow;
70     vtkDataSetMapper* myMapper;
71
72   public:
73     static OrientedPlane *New();
74     static OrientedPlane *New(SVTK_ViewWindow* theViewWindow);
75     vtkTypeMacro (OrientedPlane, vtkPlane);
76
77     SMESH::Orientation myOrientation;
78     float myDistance;
79     double myAngle[2];
80
81     vtkPlaneSource* myPlaneSource;
82     SALOME_Actor *myActor;
83
84     void SetOrientation (SMESH::Orientation theOrientation) { myOrientation = theOrientation; }
85     SMESH::Orientation GetOrientation() { return myOrientation; }
86
87     void SetDistance (float theDistance) { myDistance = theDistance; }
88     float GetDistance() { return myDistance; }
89
90     void ShallowCopy (OrientedPlane* theOrientedPlane);
91
92   protected:
93     OrientedPlane(SVTK_ViewWindow* theViewWindow);
94     OrientedPlane();
95
96     void Init();
97
98     ~OrientedPlane();
99   private:
100     // Not implemented.
101     OrientedPlane (const OrientedPlane&);
102     void operator= (const OrientedPlane&);
103   };
104
105   typedef vtkSmartPointer<OrientedPlane>    TPlane;
106   typedef std::list<vtkActor*>              TActorList;
107
108   struct TPlaneData
109   {
110     TPlaneData( TPlane thePlane,
111                 TActorList theActorList )
112     {
113       Plane = thePlane;
114       ActorList = theActorList;
115     }
116     TPlane     Plane;
117     TActorList ActorList;
118   };
119
120   typedef std::vector<TPlane>               TPlaneVector;
121   typedef std::vector<TPlaneData>           TPlaneDataVector;
122 };
123
124 //=================================================================================
125 // class    : SMESHGUI_ClippingDlg
126 // purpose  :
127 //=================================================================================
128 class SMESHGUI_EXPORT SMESHGUI_ClippingDlg : public QDialog
129 {
130   Q_OBJECT
131
132 public:
133   SMESHGUI_ClippingDlg( SMESHGUI*, SVTK_ViewWindow* );
134   ~SMESHGUI_ClippingDlg();
135   
136   double                  getDistance() const;
137   void                    setDistance( const double );
138   double                  getRotation1() const;
139   double                  getRotation2() const;
140   void                    setRotation( const double, const double );
141
142   // used in SMESHGUI::restoreVisualParameters() to avoid
143   // declaration of OrientedPlane outside of SMESHGUI_ClippingDlg.cxx
144   static SMESH::OrientedPlane* AddPlane (SMESH::TActorList          theActorList,
145                                          SVTK_ViewWindow*           theViewWindow,
146                                          SMESH::Orientation         theOrientation,
147                                          double                     theDistance,
148                                          const vtkFloatingPointType theAngle[2]);
149
150 protected:  
151   void                    keyPressEvent( QKeyEvent* );
152
153 private:
154   void                    initializePlaneData();
155
156   void                    synchronize();
157
158   void                    updateActorList();
159   SMESH::TActorList       getCurrentActors();
160
161   void                    updateActorItem( QListWidgetItem* theItem,
162                                            bool theUpdateSelectAll,
163                                            bool theUpdateClippingPlaneMap );
164
165   void                    dumpPlaneData() const;
166
167 private:
168   SMESHGUI*               mySMESHGUI;
169   SVTK_ViewWindow*        myViewWindow;
170   SMESH::TPlaneDataVector myPlanes;
171   
172   QComboBox*              ComboBoxPlanes;
173   QPushButton*            buttonNew;
174   QPushButton*            buttonDelete;
175   QListWidget*            ActorList;
176   QCheckBox*              SelectAllCheckBox;
177   QLabel*                 TextLabelOrientation;
178   QComboBox*              ComboBoxOrientation;
179   QLabel*                 TextLabelDistance;
180   SMESHGUI_SpinBox*       SpinBoxDistance;
181   QLabel*                 TextLabelRot1;
182   SMESHGUI_SpinBox*       SpinBoxRot1;
183   QLabel*                 TextLabelRot2;
184   SMESHGUI_SpinBox*       SpinBoxRot2;
185   QCheckBox*              PreviewCheckBox;
186   QCheckBox*              AutoApplyCheckBox;
187   QPushButton*            buttonOk;
188   QPushButton*            buttonCancel;
189   QPushButton*            buttonApply;
190   QPushButton*            buttonHelp;
191   
192   bool                    myIsSelectPlane;
193   QString                 myHelpFileName;
194
195 protected slots:
196   virtual void            reject();
197
198 public slots:
199   void                    onSelectPlane( int );
200   void                    ClickOnNew();
201   void                    ClickOnDelete();
202   void                    onActorItemChanged( QListWidgetItem* );
203   void                    onSelectAll( int );
204   void                    onSelectOrientation( int );
205   void                    SetCurrentPlaneParam();
206   void                    OnPreviewToggle( bool );
207   void                    onAutoApply(bool);
208   void                    ClickOnOk();
209   void                    ClickOnApply();
210   void                    ClickOnHelp();
211 };
212
213 #endif // SMESHGUI_CLIPPINGDLG_H