Salome HOME
Update copyright information
[modules/visu.git] / src / VISUGUI / VisuGUI_Prs3dDlg.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 //  VISU VISUGUI : GUI of VISU component
24 //  File   : VisuGUI_Prs3dDlg.h
25 //  Author : Laurent CORNABE & Hubert ROLLAND
26 //  Module : VISU
27 //
28 #ifndef VISUGUI_PRS3DDLG_H
29 #define VISUGUI_PRS3DDLG_H
30
31 #include <QDialog>
32
33 #include "SALOME_GenericObjPointer.hh"
34 #include "VISU_ColoredPrs3d_i.hh"
35
36 class QButtonGroup;
37 class QGroupBox;
38 class QLabel;
39 class QCheckBox;
40 class QPushButton;
41 class QRadioButton;
42 class QLineEdit;
43 class QComboBox;
44 class QToolButton;
45 class QTabWidget;
46
47 class SalomeApp_DoubleSpinBox;
48
49 class SalomeApp_Module;
50 class SalomeApp_IntSpinBox;
51 class SVTK_FontWidget;
52 class VISU_ScalarMapAct;
53 class VISU_ScalarMapPL;
54
55 namespace VISU
56 {
57   class ColoredPrs3d_i;
58   class ScalarMap_i;
59 }
60
61
62 //----------------------------------------------------------------------------
63 class VisuGUI_TextPrefDlg: public QDialog
64 {
65   Q_OBJECT;
66
67  public:
68   VisuGUI_TextPrefDlg (QWidget* parent);
69   ~VisuGUI_TextPrefDlg() {};
70
71   QString getTitleText();
72   void setTitleText( const QString& theText);
73
74   void setTitleVisible( bool isVisible );
75
76   void storeBeginValues();
77
78  private:
79   void keyPressEvent( QKeyEvent* e );
80
81  public:
82   SVTK_FontWidget* myTitleFont;
83   SVTK_FontWidget* myLabelFont;
84
85  protected slots:
86   void accept();
87   void reject();
88   void onHelp();
89
90  private:
91   QLineEdit* myTitleEdt;
92   QString    myTitle;
93   QColor     myColors[2];
94   int        myComboVals[2];
95   bool       myCheckVals[6];
96 };
97
98
99 //----------------------------------------------------------------------------
100 class VisuGUI_BarPrefDlg: public QDialog
101 {
102   Q_OBJECT;
103
104  public:
105   VisuGUI_BarPrefDlg (QWidget* parent);
106   ~VisuGUI_BarPrefDlg() {};
107
108   void setRatios(int titleRatioSize, int labelRatioWidth,
109                  int barRatioWidth, int barRatioHeight);
110   void getRatios(int& titleRatioSize, int& labelRatioWidth,
111                  int& barRatioWidth, int& barRatioHeight);
112
113   void setUnitsVisible(bool isVisible);
114   bool isUnitsVisible();
115
116   void setLabelsPrecision( const int p );
117   int getLabelsPrecision() const;
118
119   void setOrientation( const int ori );
120   int getOrientation() const;
121
122
123  private:
124   void keyPressEvent( QKeyEvent* e );
125
126  signals:
127   void updatePreview();
128
129  protected slots:
130   void accept();
131   void reject();
132   void onHelp();
133
134  protected:
135   SalomeApp_IntSpinBox*  myTitleSizeSpin;
136   SalomeApp_IntSpinBox*  myLabelSizeSpin;
137   SalomeApp_IntSpinBox*  myBarWidthSpin;
138   SalomeApp_IntSpinBox*  myBarHeightSpin;
139   QCheckBox* myUnitsChk;  
140   SalomeApp_IntSpinBox*  myPrecisionSpin;
141
142   int        myTitleSize;
143   int        myLabelSize;
144   int        myBarWidth;
145   int        myBarHeight;
146   bool       myUnits;
147   int        myPrecision;
148   int        myOrientation;
149 };
150
151
152 //----------------------------------------------------------------------------
153 class VisuGUI_ScalarBarPane : public QWidget//QVBox
154 {
155   Q_OBJECT;
156
157  public:
158   VisuGUI_ScalarBarPane(QWidget* parent, bool theIsDisplayGaussMetric = false, bool thePreview = FALSE);
159   ~VisuGUI_ScalarBarPane();
160
161   void    setRange( double imin, double imax, bool sbRange );
162   void    setDefaultRange(double imin, double imax);
163   int     getOrientation();
164   void    setPosAndSize( double x, double y, double w, double h, bool vert );
165   void    setScalarBarData( int colors, int labels );
166   bool    isIRange();
167   double  getMin();
168   double  getMax();
169   double  getX();
170   double  getY();
171   double  getWidth();
172   double  getHeight();
173   int     getNbColors();
174   int     getNbLabels();
175   bool    isLogarithmic();
176   void    setLogarithmic( bool on );
177   bool    isShowDistribution();
178   void    setShowDistribution( bool on );
179   bool    isToSave();
180
181   void storeToResources();
182   void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs);
183
184   int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
185
186   bool check();
187
188  protected:
189   QButtonGroup*   RangeGroup;
190   QRadioButton*   RBFrange;
191   QRadioButton*   RBIrange;
192   QLineEdit*      MinEdit;
193   QLineEdit*      MaxEdit;
194
195   QRadioButton*   RBhori;
196   QRadioButton*   RBvert;
197
198   SalomeApp_DoubleSpinBox*  XSpin;
199   SalomeApp_DoubleSpinBox*  YSpin;
200
201   SalomeApp_DoubleSpinBox*  WidthSpin;
202   SalomeApp_DoubleSpinBox*  HeightSpin;
203
204   SalomeApp_IntSpinBox* ColorSpin;
205   SalomeApp_IntSpinBox* LabelSpin;
206
207   QCheckBox*      CBSave;
208   QCheckBox*      CBLog;
209   QCheckBox*      CBDistr;
210   QCheckBox*      myHideBar;
211
212   QLabel*         myModeLbl;
213   QComboBox*      myModeCombo;
214   QLabel*         myGaussMetricLabel;
215   QComboBox*      myGaussMetric;
216   QPushButton*    myTextBtn;
217   QPushButton*    myBarBtn;
218   VisuGUI_TextPrefDlg* myTextDlg;
219   VisuGUI_BarPrefDlg* myBarDlg;
220
221   double          myHorX, myHorY, myHorW, myHorH;
222   double          myVerX, myVerY, myVerW, myVerH;
223   int             myHorTS, myHorLS, myHorBW, myHorBH;
224   int             myVerTS, myVerTH, myVerLS, myVerBW, myVerBH;
225   bool            myIsStoreTextProp;
226
227  private slots:
228   void changeDefaults( int );
229  void changeRange( int );
230  void onFieldRange( bool );
231  void onImposedRange( bool );
232   void XYChanged( double );
233   void changeScalarMode( int );
234   void changeGaussMetric( int );
235   void onTextPref();
236   void onBarPref();
237   void onPreviewCheck(bool thePreview);
238   void updatePreview();  
239   void onShowDistribution(bool);
240
241  private:
242   void createScalarBar();
243   void deleteScalarBar();
244
245   QCheckBox*         myPreviewCheck;
246   VISU_ScalarMapAct* myPreviewActor;
247   VISU::ScalarMap_i* myScalarMap;
248   VISU_ScalarMapPL*  myScalarMapPL;
249   std::string        myTitle;
250
251   bool myBusy;
252   bool myIsDisplayGaussMetric;
253 };
254
255
256 //----------------------------------------------------------------------------
257 class VisuGUI_Prs3dDlg : public QDialog
258 {
259   Q_OBJECT;
260
261  public:
262   VisuGUI_Prs3dDlg( SalomeApp_Module* theModule );
263   ~VisuGUI_Prs3dDlg() {}
264
265   virtual void     initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
266                                       bool theInit ) = 0;
267
268   virtual int      storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) = 0;
269
270  protected:
271   virtual QString  GetContextHelpFilePath() = 0;
272
273  protected slots:
274   void onHelp();
275
276  private:
277   void keyPressEvent( QKeyEvent* e );
278 };
279
280
281 //----------------------------------------------------------------------------
282 class VisuGUI_ScalarBarBaseDlg : public VisuGUI_Prs3dDlg
283 {
284   Q_OBJECT;
285
286  public:
287   VisuGUI_ScalarBarBaseDlg( SalomeApp_Module* theModule, bool theIsDisplayGaussMetric = false, bool thePreview = FALSE );
288   ~VisuGUI_ScalarBarBaseDlg();
289
290   virtual void     initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
291                                       bool theInit );
292  protected slots:
293   void accept();
294   void reject();
295
296  protected:
297   VisuGUI_ScalarBarPane* GetScalarPane();
298
299  private:
300   VisuGUI_ScalarBarPane* myScalarPane;
301 };
302
303
304 //----------------------------------------------------------------------------
305
306 #endif