1 // Copyright (C) 2007-2022 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, or (at your option) any later version.
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;
63 class QtxDoubleSpinSlider;
64 class QtxIntSpinSlider;
66 class vtkDataSetMapper;
68 class vtkCallbackCommand;
70 class vtkImplicitPlaneWidget;
74 enum Mode { Absolute, Relative };
75 enum Orientation { XY, YZ, ZX };
77 class OrientedPlane: public vtkPlane
79 vtkDataSetMapper* myMapper;
82 static OrientedPlane *New();
83 static OrientedPlane *New(SVTK_ViewWindow* theViewWindow);
84 vtkTypeMacro (OrientedPlane, vtkPlane)
86 QPointer<SVTK_ViewWindow> myViewWindow;
87 SMESH::Orientation myRelativeOrientation;
90 double X, Y, Z, Dx, Dy, Dz;
91 int myAbsoluteOrientation;
93 bool IsOpenGLClipping;
96 vtkPlaneSource* myPlaneSource;
97 SALOME_Actor *myActor;
99 void SetOrientation (SMESH::Orientation theOrientation) { myRelativeOrientation = theOrientation; }
100 SMESH::Orientation GetOrientation() { return myRelativeOrientation; }
102 void SetDistance (float theDistance) { myDistance = theDistance; }
103 float GetDistance() { return myDistance; }
105 void ShallowCopy (OrientedPlane* theOrientedPlane);
106 OrientedPlane* InvertPlane ();
109 OrientedPlane(SVTK_ViewWindow* theViewWindow);
117 OrientedPlane (const OrientedPlane&);
118 void operator= (const OrientedPlane&);
121 typedef vtkSmartPointer<OrientedPlane> TPlane;
122 typedef std::list<vtkActor*> TActorList;
126 TPlaneData( TPlane thePlane,
127 TActorList theActorList )
130 ActorList = theActorList;
133 TActorList ActorList;
136 typedef std::vector<TPlane> TPlaneVector;
137 typedef std::vector<TPlaneData> TPlaneDataVector;
140 //=================================================================================
141 // class : SMESHGUI_ClippingDlg
143 //=================================================================================
144 class SMESHGUI_EXPORT SMESHGUI_ClippingDlg : public QDialog
149 SMESHGUI_ClippingDlg( SMESHGUI*, SVTK_ViewWindow* );
150 ~SMESHGUI_ClippingDlg();
152 static bool AddPlane ( SMESH::TActorList theActorList,
153 SMESH::OrientedPlane* thePlane );
155 void keyPressEvent( QKeyEvent* );
156 static void ProcessEvents( vtkObject* theObject,
157 unsigned long theEvent,
161 double getDistance() const;
162 void setDistance( const double );
163 double getRotation1() const;
164 double getRotation2() const;
165 void setRotation( const double, const double );
167 void setOrigin(double theVal[3]);
168 void setDirection(double theVal[3]);
170 void initializePlaneData();
173 void updateActorList();
174 void updateActorItem( QListWidgetItem* theItem,
175 bool theUpdateSelectAll,
176 bool theUpdateClippingPlaneMap );
177 SMESH::TActorList getCurrentActors();
179 void dumpPlaneData() const;
180 void absolutePlaneToRelative ( double theOrigin[3], double theDir[3] );
181 void setBoundsForPreviewWidget();
182 vtkImplicitPlaneWidget* createPreviewWidget();
186 SMESHGUI* mySMESHGUI;
187 SVTK_ViewWindow* myViewWindow;
188 SMESH::TPlaneDataVector myPlanes;
190 vtkCallbackCommand* myCallback;
191 vtkImplicitPlaneWidget* myPreviewWidget;
194 QComboBox* ComboBoxPlanes;
195 QCheckBox* isOpenGLClipping;
196 QPushButton* buttonNew;
198 QPushButton* buttonDelete;
200 QListWidget* ActorList;
201 QCheckBox* SelectAllCheckBox;
203 QStackedLayout* ModeStackedLayout;
205 QGroupBox* GroupAbsolutePoint;
209 QtxDoubleSpinBox* SpinBox_X;
210 QtxDoubleSpinBox* SpinBox_Y;
211 QtxDoubleSpinBox* SpinBox_Z;
212 QPushButton* resetButton;
214 QGroupBox* GroupAbsoluteDirection;
218 QtxDoubleSpinBox* SpinBox_Dx;
219 QtxDoubleSpinBox* SpinBox_Dy;
220 QtxDoubleSpinBox* SpinBox_Dz;
221 QPushButton* invertButton;
222 QComboBox* CBAbsoluteOrientation;
224 QGroupBox* GroupRelative;
225 QLabel* TextLabelOrientation;
226 QLabel* TextLabelDistance;
227 QLabel* TextLabelRotation1;
228 QLabel* TextLabelRotation2;
229 QtxDoubleSpinSlider* SpinSliderDistance;
230 QtxIntSpinSlider* SpinSliderRotation1;
231 QtxIntSpinSlider* SpinSliderRotation2;
232 QComboBox* CBRelativeOrientation;
234 QCheckBox* PreviewCheckBox;
235 QCheckBox* AutoApplyCheckBox;
237 QPushButton* buttonOk;
238 QPushButton* buttonCancel;
239 QPushButton* buttonApply;
240 QPushButton* buttonHelp;
242 bool myIsSelectPlane;
243 bool myIsPreviewMoved;
244 QString myHelpFileName;
246 SMESH::Mode CurrentMode;
249 virtual void reject();
252 void onModeAbsolute();
253 void onModeRelative();
255 void ClickOnDelete();
256 void onSelectPlane( int );
257 void onSelectAll( int );
258 void onActorItemChanged( QListWidgetItem* );
259 void SetCurrentPlaneParam();
261 void onIsOpenGLClipping(bool);
262 void OnPreviewToggle( bool );
263 void onAutoApply(bool);
268 void onSelectAbsoluteOrientation( int );
269 void onSelectRelativeOrientation( int );
274 #endif // SMESHGUI_CLIPPINGDLG_H