1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_ClippingDlg.h
25 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
27 #ifndef SMESHGUI_CLIPPINGDLG_H
28 #define SMESHGUI_CLIPPINGDLG_H
31 #include "SMESH_SMESHGUI.hxx"
34 #include <SVTK_ViewWindow.h>
42 #include <vtkSmartPointer.h>
55 class QListWidgetItem;
62 class QtxDoubleSpinBox;
64 class vtkDataSetMapper;
66 class vtkCallbackCommand;
68 class vtkImplicitPlaneWidget;
72 enum Mode { Absolute, Relative };
73 enum Orientation { XY, YZ, ZX };
75 class OrientedPlane: public vtkPlane
77 vtkDataSetMapper* myMapper;
80 static OrientedPlane *New();
81 static OrientedPlane *New(SVTK_ViewWindow* theViewWindow);
82 vtkTypeMacro (OrientedPlane, vtkPlane);
84 QPointer<SVTK_ViewWindow> myViewWindow;
85 SMESH::Orientation myRelativeOrientation;
88 double X, Y, Z, Dx, Dy, Dz;
89 int myAbsoluteOrientation;
91 bool IsOpenGLClipping;
94 vtkPlaneSource* myPlaneSource;
95 SALOME_Actor *myActor;
97 void SetOrientation (SMESH::Orientation theOrientation) { myRelativeOrientation = theOrientation; }
98 SMESH::Orientation GetOrientation() { return myRelativeOrientation; }
100 void SetDistance (float theDistance) { myDistance = theDistance; }
101 float GetDistance() { return myDistance; }
103 void ShallowCopy (OrientedPlane* theOrientedPlane);
104 OrientedPlane* InvertPlane ();
107 OrientedPlane(SVTK_ViewWindow* theViewWindow);
115 OrientedPlane (const OrientedPlane&);
116 void operator= (const OrientedPlane&);
119 typedef vtkSmartPointer<OrientedPlane> TPlane;
120 typedef std::list<vtkActor*> TActorList;
124 TPlaneData( TPlane thePlane,
125 TActorList theActorList )
128 ActorList = theActorList;
131 TActorList ActorList;
134 typedef std::vector<TPlane> TPlaneVector;
135 typedef std::vector<TPlaneData> TPlaneDataVector;
138 //=================================================================================
139 // class : SMESHGUI_ClippingDlg
141 //=================================================================================
142 class SMESHGUI_EXPORT SMESHGUI_ClippingDlg : public QDialog
147 SMESHGUI_ClippingDlg( SMESHGUI*, SVTK_ViewWindow* );
148 ~SMESHGUI_ClippingDlg();
150 static bool AddPlane ( SMESH::TActorList theActorList,
151 SMESH::OrientedPlane* thePlane );
153 void keyPressEvent( QKeyEvent* );
154 static void ProcessEvents( vtkObject* theObject,
155 unsigned long theEvent,
159 double getDistance() const;
160 void setDistance( const double );
161 double getRotation1() const;
162 double getRotation2() const;
163 void setRotation( const double, const double );
165 void setOrigin(double theVal[3]);
166 void setDirection(double theVal[3]);
168 void initializePlaneData();
171 void updateActorList();
172 void updateActorItem( QListWidgetItem* theItem,
173 bool theUpdateSelectAll,
174 bool theUpdateClippingPlaneMap );
175 SMESH::TActorList getCurrentActors();
177 void dumpPlaneData() const;
178 void absolutePlaneToRelative ( double theOrigin[3], double theDir[3] );
179 void setBoundsForPreviewWidget();
180 vtkImplicitPlaneWidget* createPreviewWidget();
184 SMESHGUI* mySMESHGUI;
185 SVTK_ViewWindow* myViewWindow;
186 SMESH::TPlaneDataVector myPlanes;
188 vtkCallbackCommand* myCallback;
189 vtkImplicitPlaneWidget* myPreviewWidget;
192 QComboBox* ComboBoxPlanes;
193 QCheckBox* isOpenGLClipping;
194 QPushButton* buttonNew;
196 QPushButton* buttonDelete;
198 QListWidget* ActorList;
199 QCheckBox* SelectAllCheckBox;
201 QStackedLayout* ModeStackedLayout;
203 QGroupBox* GroupAbsolutePoint;
207 QtxDoubleSpinBox* SpinBox_X;
208 QtxDoubleSpinBox* SpinBox_Y;
209 QtxDoubleSpinBox* SpinBox_Z;
210 QPushButton* resetButton;
212 QGroupBox* GroupAbsoluteDirection;
216 QtxDoubleSpinBox* SpinBox_Dx;
217 QtxDoubleSpinBox* SpinBox_Dy;
218 QtxDoubleSpinBox* SpinBox_Dz;
219 QPushButton* invertButton;
220 QComboBox* CBAbsoluteOrientation;
222 QGroupBox* GroupRelative;
223 QLabel* TextLabelOrientation;
224 QLabel* TextLabelDistance;
225 QLabel* TextLabelRotation1;
226 QLabel* TextLabelRotation2;
227 QLabel* TLValueDistance;
228 QLabel* TLValueRotation1;
229 QLabel* TLValueRotation2;
230 QSlider* SliderDistance;
231 QSlider* SliderRotation1;
232 QSlider* SliderRotation2;
233 QComboBox* CBRelativeOrientation;
235 QCheckBox* PreviewCheckBox;
236 QCheckBox* AutoApplyCheckBox;
238 QPushButton* buttonOk;
239 QPushButton* buttonCancel;
240 QPushButton* buttonApply;
241 QPushButton* buttonHelp;
243 bool myIsSelectPlane;
244 bool myIsPreviewMoved;
245 QString myHelpFileName;
247 SMESH::Mode CurrentMode;
250 virtual void reject();
253 void onModeAbsolute();
254 void onModeRelative();
256 void ClickOnDelete();
257 void onSelectPlane( int );
258 void onSelectAll( int );
259 void onActorItemChanged( QListWidgetItem* );
260 void SetCurrentPlaneParam();
262 void onIsOpenGLClipping(bool);
263 void OnPreviewToggle( bool );
264 void onAutoApply(bool);
269 void SliderDistanceHasMoved(int);
270 void SliderRotation1HasMoved(int);
271 void SliderRotation2HasMoved(int);
272 void onSelectAbsoluteOrientation( int );
273 void onSelectRelativeOrientation( int );
278 #endif // SMESHGUI_CLIPPINGDLG_H