Salome HOME
6e23c9131490734f7396570bd9f7a4a117bad0ba
[modules/visu.git] / src / VISUGUI / VisuGUI_ScalarBarDlg.h
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : VisuGUI_ScalarBarDlg.h
25 //  Author : Laurent CORNABE & Hubert ROLLAND 
26 //  Module : VISU
27 //  $Header$
28
29 #ifndef VISUGUI_SCALARBARDLG_H
30 #define VISUGUI_SCALARBARDLG_H
31
32 #include <qbuttongroup.h>
33 #include <qgroupbox.h>
34 #include <qlabel.h>
35 #include <qradiobutton.h>
36 #include <qcheckbox.h>
37 #include <qpushbutton.h>
38 #include <qspinbox.h>
39 #include <qlineedit.h>
40 #include <qcombobox.h>
41 #include <qvbox.h>
42 #include <qtoolbutton.h>
43
44 #include "QtxDblSpinBox.h"
45
46 class QButtonGroup;
47 class QGroupBox;
48 class QLabel;
49 class QRadioButton;
50 class QCheckBox;
51 class QPushButton;
52 class QSpinBox;
53 class QLineEdit;
54 class QComboBox;
55 class QVBox;
56 class QToolButton;
57
58 class QtxDblSpinBox;
59
60 #include <qdialog.h>
61
62 #include "VISU_ScalarMap_i.hh"
63
64 class VisuGUI_TextPrefDlg: public QDialog 
65 {
66   Q_OBJECT;
67
68 public:
69     VisuGUI_TextPrefDlg(QWidget* parent);
70     ~VisuGUI_TextPrefDlg() {};
71
72     bool isBoldTitle() { return myTitBoldChk->isChecked();}
73     void setBoldTitle(bool isBold) { myTitBoldChk->setChecked(isBold);}
74
75     bool isItalicTitle() { return myTitItalicChk->isChecked();}
76     void setItalicTitle(bool isItalic) { myTitItalicChk->setChecked(isItalic);}
77
78     bool isShadowTitle() { return myTitShadowChk->isChecked();}
79     void setShadowTitle(bool isShadow) { myTitShadowChk->setChecked(isShadow);}
80
81     QString getTitleText() { return myTitleEdt->text();}
82     void setTitleText(QString theText) { myTitleEdt->setText(theText);}
83
84     QColor getTitleColor() { return myTitColor->paletteBackgroundColor();}
85     void setTitleColor(QColor theColor) { myTitColor->setPaletteBackgroundColor(theColor);}
86
87     int getTitleFont();
88     void setTitleFont(int theFont);
89
90
91     bool isBoldLabel()   { return myLblBoldChk->isChecked();}
92     void setBoldLabel(bool isBold)   { myLblBoldChk->setChecked(isBold);}
93
94     bool isItalicLabel() { return myLblItalicChk->isChecked();}
95     void setItalicLabel(bool isItalic) { myLblItalicChk->setChecked(isItalic);}
96
97     bool isShadowLabel() { return myLblShadowChk->isChecked();}
98     void setShadowLabel(bool isShadow) { myLblShadowChk->setChecked(isShadow);}
99
100     QColor getLabelColor() { return myLblColor->paletteBackgroundColor();}
101     void setLabelColor(QColor theColor) { myLblColor->setPaletteBackgroundColor(theColor);}
102
103     int getLabelFont();
104     void setLabelFont(int theFont);
105
106     void setTitleVisible(bool isVisible) 
107       { (isVisible)? myTitleEdt->show() : myTitleEdt->hide();}
108
109 private slots:
110   void setTitleColor();
111   void setLabelColor(); 
112
113  private:
114     QLineEdit* myTitleEdt;
115     QComboBox* myTitFontCombo;
116     QCheckBox* myTitBoldChk;
117     QCheckBox* myTitItalicChk;
118     QCheckBox* myTitShadowChk;
119     QToolButton* myTitColor;
120
121     QComboBox* myLblFontCombo;
122     QCheckBox* myLblBoldChk;
123     QCheckBox* myLblItalicChk;
124     QCheckBox* myLblShadowChk;
125     QToolButton* myLblColor;
126 };
127
128
129 class VisuGUI_ScalarBarPane : public QVBox
130 {
131   Q_OBJECT;
132
133 public:
134     VisuGUI_ScalarBarPane(QWidget* parent, bool SetPref);
135     ~VisuGUI_ScalarBarPane() {};
136
137     void    setRange( double imin, double imax, /*double fmin, double fmax,*/ bool sbRange );
138     bool    isIRange() {return RBIrange->isChecked();}
139     double  getMin() {return MinEdit->text().toDouble();}
140     double  getMax() {return MaxEdit->text().toDouble();}
141     int     getOrientation();
142     void    setPosAndSize( double x, double y, double w, double h, bool vert );
143     double  getX() {return XSpin->value();}
144     double  getY() {return YSpin->value();}
145     double  getWidth() {return WidthSpin->value();}
146     double  getHeight() {return HeightSpin->value();}
147     void    setScalarBarData( int colors, int labels );
148     int     getNbColors() {return ColorSpin->value();}
149     int     getNbLabels() {return LabelSpin->value();}
150     bool    isLogarithmic() {return CBLog->isChecked();}
151     void    setLogarithmic( bool on ) {CBLog->setChecked( on );}
152     bool    isToSave() {return CBSave ? CBSave->isChecked() : false;}
153
154     void initFromResources();
155     void storeToResources();
156
157     void initFromPrsObject(VISU::ScalarMap_i* thePrs);
158     int storeToPrsObject(VISU::ScalarMap_i* thePrs);
159
160     bool check();
161
162 protected:
163     QButtonGroup*   RangeGroup;
164     QRadioButton*   RBFrange;
165     QRadioButton*   RBIrange;
166     QLineEdit*      MinEdit;
167     QLineEdit*      MaxEdit;
168
169     QRadioButton*   RBhori;
170     QRadioButton*   RBvert;
171
172     QtxDblSpinBox* XSpin;
173     QtxDblSpinBox* YSpin;
174
175     QtxDblSpinBox* WidthSpin;
176     QtxDblSpinBox* HeightSpin;
177
178     QSpinBox*       ColorSpin;
179     QSpinBox*       LabelSpin;
180
181     QCheckBox*      CBSave;
182     QCheckBox*      CBLog;
183     QLabel*         myModeLbl;
184     QComboBox*      myModeCombo;
185     QPushButton*    myTextBtn;
186     VisuGUI_TextPrefDlg* myTextDlg;
187     
188     double          Imin,   Imax,  /* Fmin,   Fmax,*/   Rmin,   Rmax;
189     double          myHorX, myHorY, myHorW, myHorH;
190     double          myVerX, myVerY, myVerW, myVerH;
191     int             myRangeMode;
192     bool myIsStoreTextProp;
193
194 private slots:
195     void changeDefaults( int );
196     void changeRange( int );
197     void XYChanged( double );
198     void onTextPref();
199 };
200
201
202
203 class VisuGUI_ScalarBarDlg : public QDialog
204
205   Q_OBJECT;
206
207 public:
208     VisuGUI_ScalarBarDlg( QWidget* parent = 0, bool SetPref = FALSE );
209     ~VisuGUI_ScalarBarDlg() {};
210
211     bool isToSave() {return myScalarPane->isToSave();}
212
213     void initFromResources() {myScalarPane->initFromResources();}
214     void storeToResources() {myScalarPane->storeToResources();}
215
216     void initFromPrsObject(VISU::ScalarMap_i* thePrs) {myScalarPane->initFromPrsObject(thePrs);}
217     int storeToPrsObject(VISU::ScalarMap_i* thePrs) {return myScalarPane->storeToPrsObject(thePrs);}
218
219
220 protected slots:
221     void accept();
222
223  protected:
224     VisuGUI_ScalarBarPane* myScalarPane;
225
226 };
227
228 #endif // VISUGUI_SCALARBARDLG_H