Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/visu.git] / src / VVTK / VVTK_SegmentationCursorDlg.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 //  File   : VVTK_SegmentationCursorDlg.h
23 //  Author : Oleg Uvarov
24 //  Module : VISU
25 //
26 #ifndef VVTK_SEGMENTATIONCURSORDLG_H
27 #define VVTK_SEGMENTATIONCURSORDLG_H
28
29 #include "VVTK.h"
30
31 #include "VISU_GaussPtsDeviceActor.h"
32
33 #include <QDialog>
34
35 #include <vtkObject.h>
36 #include <vtkSmartPointer.h>
37
38 class vtkActorCollection;
39 class vtkCallbackCommand;
40 class vtkImageData;
41
42 class QLabel;
43 class QLineEdit;
44 class QPushButton;
45 class QRadioButton;
46 class QTabWidget;
47 class QGroupBox;
48 class QWidget;
49 //class QVBox;
50
51 class QtxAction;
52 class QtxDoubleSpinBox;
53 class QtxIntSpinBox;
54
55 class VISU_GaussPtsAct1;
56 class VISU_InsideCursorSettings;
57 class VISU_OutsideCursorSettings;
58 class VISU_WidgetCtrl;
59
60 class VVTK_PrimitiveBox;
61 class VVTK_SizeBox;
62
63 class SVTK_RenderWindowInteractor;
64
65
66 //! Segmentation Cursor Dialog.
67 /*!
68  * Uses for set up Segmentation and Outside Cursor Gauss Points preferenses
69  * and apply them to all actors in the current renderer.
70  */
71 class VVTK_SegmentationCursorDlg : public QDialog
72 {
73   Q_OBJECT
74
75 public:
76   VVTK_SegmentationCursorDlg( QWidget* parent = 0, const char* name = 0 );
77   ~VVTK_SegmentationCursorDlg();
78
79   void             SetWidgetCtrl( VISU_WidgetCtrl* );
80   void             SetPlaneAction( QtxAction* theAction ) { myPlaneAction = theAction; }
81   void             SetSphereAction( QtxAction* theAction ) { mySphereAction = theAction; }
82
83   bool             GetIsPlaneSegmentation() const { return myIsPlaneSegmentation; }
84   void             SetIsPlaneSegmentation( bool on ) { myIsPlaneSegmentation = on; }
85
86   //! Update contents of the Segmentation tab.
87   void             UpdateSegmentation();
88   void             UpdateInsideGaussPoints();
89   void             UpdateOutsideGaussPoints();
90
91   //! Update contents of the Outside Cursor tab.
92   void             UpdateOutsideCursor();
93
94   VISU_InsideCursorSettings*  GetInsideCursorSettings();
95   VISU_OutsideCursorSettings* GetOutsideCursorSettings();
96
97   vtkSmartPointer<vtkCallbackCommand> GetEventCallbackCommand() { return myEventCallbackCommand; }
98
99   void             SetInteractor( SVTK_RenderWindowInteractor* theInteractor ) { myInteractor = theInteractor; }
100
101 public:
102   float            getMagnification() const;
103   void             setMagnification( float );
104
105   float            getIncrement() const;
106   void             setIncrement( float );
107
108 protected:
109   void             ApplySegmentationCursor();
110   void             ApplyInsideGaussPoints();
111   void             ApplyOutsideGaussPoints();
112
113   bool             CheckNumberOfFaces();
114
115   VISU::TTextureValue
116   MakeImageData( bool theInside,
117                  const QString& theMainTexture, 
118                  const QString& theAlphaTexture );
119
120 private:
121   static void      ProcessEvents(vtkObject* theObject, 
122                                  unsigned long theEvent,
123                                  void* theClientData, 
124                                  void* theCallData);
125   
126   void             keyPressEvent( QKeyEvent* e );
127
128 protected slots:
129   virtual void     done( int );
130   void             onParentShow();
131   void             onParentHide();
132
133   void             onClickApply();
134   void             onClickClose();
135   void             onClickHelp();
136
137 signals:
138   void             scgClose();
139
140 private:
141   SVTK_RenderWindowInteractor* myInteractor;
142
143   QTabWidget*       myTabBox;
144
145   // Segmentation cursor
146   QWidget*          mySegmentationCursorBox;
147
148   QGroupBox*        myOriginGroup;
149   QtxDoubleSpinBox* myXOriginSpinBox;
150   QtxDoubleSpinBox* myYOriginSpinBox;
151   QtxDoubleSpinBox* myZOriginSpinBox;
152
153   QGroupBox*        myDirectionGroup;
154   QtxDoubleSpinBox* myDXDirectionSpinBox;
155   QtxDoubleSpinBox* myDYDirectionSpinBox;
156   QtxDoubleSpinBox* myDZDirectionSpinBox;
157
158   QGroupBox*        myDepthGroup;
159   QtxDoubleSpinBox* myDepthSpinBox;
160
161   QGroupBox*        myRadiusGroup;
162   QtxDoubleSpinBox* myRadiusSpinBox;
163   QtxDoubleSpinBox* myRatioSpinBox;
164
165   bool              myIsPlaneSegmentation;
166
167   float             myPriority;
168   vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
169
170   VISU_WidgetCtrl*  myWidgetCtrl;
171   QtxAction*        myPlaneAction;
172   QtxAction*        mySphereAction;
173
174   // Gauss Points
175   QWidget*          myGaussPointsBox;
176
177   VVTK_PrimitiveBox* myInsidePrimitiveBox;
178   VVTK_SizeBox*     myInsideSizeBox;
179
180   QString           myInsideMainTexture;
181   QString           myInsideAlphaTexture;
182
183   vtkSmartPointer<VISU_InsideCursorSettings> myInsideCursorSettings;
184
185   VVTK_PrimitiveBox* myOutsidePrimitiveBox;
186   VVTK_SizeBox*     myOutsideSizeBox;
187
188   QString           myOutsideMainTexture;
189   QString           myOutsideAlphaTexture;
190
191   vtkSmartPointer<VISU_OutsideCursorSettings> myOutsideCursorSettings;
192
193   QLabel*           myMagnificationLabel;
194   QtxIntSpinBox*    myMagnificationSpinBox;
195   QLabel*           myIncrementLabel;
196   QtxDoubleSpinBox* myIncrementSpinBox;
197 };
198
199 #endif