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