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