1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VVTK_SizeBox.cxx
25 // Author : Oleg UVAROV
28 #include "VVTK_SizeBox.h"
30 #include "SUIT_ResourceMgr.h"
31 #include "SUIT_Session.h"
33 #include "QtxDblSpinBox.h"
34 #include "QtxIntSpinBox.h"
38 #include <qlineedit.h>
39 #include <qcheckbox.h>
40 #include <qgroupbox.h>
41 #include <qbuttongroup.h>
42 #include <qradiobutton.h>
43 #include <qpushbutton.h>
44 #include <qcolordialog.h>
48 VVTK_SizeBox::VVTK_SizeBox( QWidget* parent ) :
51 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
53 layout()->setSpacing( 0 );
54 layout()->setMargin( 0 );
57 QGroupBox* SizeGroup = new QGroupBox ( tr( "SIZE_TITLE" ), this, "SizeGroup" );
58 SizeGroup->setColumnLayout(0, Qt::Vertical );
59 SizeGroup->layout()->setSpacing( 0 );
60 SizeGroup->layout()->setMargin( 0 );
62 QGridLayout* SizeGroupLayout = new QGridLayout (SizeGroup->layout());
63 SizeGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
64 SizeGroupLayout->setSpacing(6);
65 SizeGroupLayout->setMargin(11);
68 myOutsideSizeLabel = new QLabel( tr( "OUTSIDE_SIZE" ), SizeGroup );
69 myOutsideSizeSpinBox = new QtxIntSpinBox( 0, 100, 1, SizeGroup );
70 myOutsideSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
72 SizeGroupLayout->addWidget( myOutsideSizeLabel, 0, 0 );
73 SizeGroupLayout->addWidget( myOutsideSizeSpinBox, 0, 1 );
76 myGeomSizeLabel = new QLabel( tr( "GEOM_SIZE" ), SizeGroup );
77 myGeomSizeSpinBox = new QtxIntSpinBox( 0, 100, 1, SizeGroup );
78 myGeomSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
80 SizeGroupLayout->addWidget( myGeomSizeLabel, 0, 0 );
81 SizeGroupLayout->addWidget( myGeomSizeSpinBox, 0, 1 );
84 myMinSizeLabel = new QLabel( tr( "MIN_SIZE" ), SizeGroup );
85 myMinSizeSpinBox = new QtxIntSpinBox( 0, 100, 1, SizeGroup );
86 myMinSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
88 SizeGroupLayout->addWidget( myMinSizeLabel, 1, 0 );
89 SizeGroupLayout->addWidget( myMinSizeSpinBox, 1, 1 );
92 myMaxSizeLabel = new QLabel( tr( "MAX_SIZE" ), SizeGroup );
93 myMaxSizeSpinBox = new QtxIntSpinBox( 0, 100, 1, SizeGroup );
94 myMaxSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
96 SizeGroupLayout->addWidget( myMaxSizeLabel, 1, 2 );
97 SizeGroupLayout->addWidget( myMaxSizeSpinBox, 1, 3 );
100 myMagnificationLabel = new QLabel( tr( "MAGNIFICATION" ), SizeGroup );
101 myMagnificationSpinBox = new QtxIntSpinBox( 1, 10000, 10, SizeGroup );
102 myMagnificationSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
104 SizeGroupLayout->addWidget( myMagnificationLabel, 2, 0 );
105 SizeGroupLayout->addWidget( myMagnificationSpinBox, 2, 1 );
108 myIncrementLabel = new QLabel( tr( "INCREMENT" ), SizeGroup );
109 myIncrementSpinBox = new QtxDblSpinBox( 0.01, 10, 0.1, SizeGroup );
110 myIncrementSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
112 SizeGroupLayout->addWidget( myIncrementLabel, 2, 2 );
113 SizeGroupLayout->addWidget( myIncrementSpinBox, 2, 3 );
117 myColorGroup = new QGroupBox ( tr( "COLOR_TITLE" ), this, "ColorGroup" );
118 myColorGroup->setColumnLayout(0, Qt::Vertical );
119 myColorGroup->layout()->setSpacing( 0 );
120 myColorGroup->layout()->setMargin( 0 );
122 QGridLayout* ColorGroupLayout = new QGridLayout (myColorGroup->layout());
123 ColorGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
124 ColorGroupLayout->setSpacing(6);
125 ColorGroupLayout->setMargin(11);
127 myUniformCheckBox = new QCheckBox( tr( "UNIFORM_COLOR" ), myColorGroup );
129 myColorLabel = new QLabel( tr( "COLOR" ), myColorGroup );
130 myColorButton = new QPushButton( myColorGroup );
132 ColorGroupLayout->addWidget( myUniformCheckBox, 0, 0 );
133 ColorGroupLayout->addWidget( myColorLabel, 0, 1 );
134 ColorGroupLayout->addWidget( myColorButton, 0, 2 );
136 connect( myUniformCheckBox, SIGNAL( toggled( bool ) ), myColorButton, SLOT( setEnabled( bool ) ) );
137 connect( myColorButton, SIGNAL( clicked() ), this, SLOT( onColorButtonPressed() ) );
139 setType( VVTK_SizeBox::Results );
142 void VVTK_SizeBox::onToggleResults()
144 myType = VVTK_SizeBox::Results;
146 myOutsideSizeLabel->hide();
147 myOutsideSizeSpinBox->hide();
149 myGeomSizeLabel->hide();
150 myGeomSizeSpinBox->hide();
152 myMinSizeLabel->show();
153 myMinSizeSpinBox->show();
155 myMaxSizeLabel->show();
156 myMaxSizeSpinBox->show();
158 myMagnificationLabel->show();
159 myMagnificationSpinBox->show();
161 myIncrementLabel->show();
162 myIncrementSpinBox->show();
164 myColorGroup->hide();
166 myUniformCheckBox->hide();
169 void VVTK_SizeBox::onToggleGeometry()
171 myType = VVTK_SizeBox::Geometry;
173 myOutsideSizeLabel->hide();
174 myOutsideSizeSpinBox->hide();
176 myGeomSizeLabel->show();
177 myGeomSizeSpinBox->show();
179 myMinSizeLabel->hide();
180 myMinSizeSpinBox->hide();
182 myMaxSizeLabel->hide();
183 myMaxSizeSpinBox->hide();
185 myMagnificationLabel->show();
186 myMagnificationSpinBox->show();
188 myIncrementLabel->show();
189 myIncrementSpinBox->show();
191 myColorGroup->show();
193 myUniformCheckBox->hide();
196 void VVTK_SizeBox::onToggleInside()
198 myType = VVTK_SizeBox::Inside;
200 myOutsideSizeLabel->hide();
201 myOutsideSizeSpinBox->hide();
203 myGeomSizeLabel->hide();
204 myGeomSizeSpinBox->hide();
206 myMinSizeLabel->show();
207 myMinSizeSpinBox->show();
209 myMaxSizeLabel->show();
210 myMaxSizeSpinBox->show();
212 myMagnificationLabel->hide();
213 myMagnificationSpinBox->hide();
215 myIncrementLabel->hide();
216 myIncrementSpinBox->hide();
218 myColorGroup->hide();
220 myUniformCheckBox->hide();
223 void VVTK_SizeBox::onToggleOutside()
225 myType = VVTK_SizeBox::Outside;
227 myOutsideSizeLabel->show();
228 myOutsideSizeSpinBox->show();
230 myGeomSizeLabel->hide();
231 myGeomSizeSpinBox->hide();
233 myMinSizeLabel->hide();
234 myMinSizeSpinBox->hide();
236 myMaxSizeLabel->hide();
237 myMaxSizeSpinBox->hide();
239 myMagnificationLabel->hide();
240 myMagnificationSpinBox->hide();
242 myIncrementLabel->hide();
243 myIncrementSpinBox->hide();
245 myColorGroup->show();
247 myUniformCheckBox->show();
250 void VVTK_SizeBox::setType( int theType )
256 case VVTK_SizeBox::Results : onToggleResults(); break;
257 case VVTK_SizeBox::Geometry : onToggleGeometry(); break;
258 case VVTK_SizeBox::Inside : onToggleInside(); break;
259 case VVTK_SizeBox::Outside : onToggleOutside(); break;
264 float VVTK_SizeBox::getOutsideSize() const
266 return myOutsideSizeSpinBox->value() / 100.0;
269 void VVTK_SizeBox::setOutsideSize( float theOutsideSize )
271 myOutsideSizeSpinBox->setValue( ( int )( theOutsideSize * 100 ) );
274 float VVTK_SizeBox::getGeomSize() const
276 return myGeomSizeSpinBox->value() / 100.0;
279 void VVTK_SizeBox::setGeomSize( float theGeomSize )
281 myGeomSizeSpinBox->setValue( ( int )( theGeomSize * 100 ) );
284 float VVTK_SizeBox::getMinSize() const
286 return myMinSizeSpinBox->value() / 100.0;
289 void VVTK_SizeBox::setMinSize( float theMinSize )
291 myMinSizeSpinBox->setValue( ( int )( theMinSize * 100 ) );
294 float VVTK_SizeBox::getMaxSize() const
296 return myMaxSizeSpinBox->value() / 100.0;
299 void VVTK_SizeBox::setMaxSize( float theMaxSize )
301 myMaxSizeSpinBox->setValue( ( int )( theMaxSize * 100 ) );
304 float VVTK_SizeBox::getMagnification() const
306 return myMagnificationSpinBox->value() / 100.0;
309 void VVTK_SizeBox::setMagnification( float theMagnification )
311 myMagnificationSpinBox->setValue( ( int )( theMagnification * 100 ) );
314 float VVTK_SizeBox::getIncrement() const
316 return myIncrementSpinBox->value();
319 void VVTK_SizeBox::setIncrement( float theIncrement )
321 myIncrementSpinBox->setValue( theIncrement );
324 bool VVTK_SizeBox::getUniform() const
326 return myUniformCheckBox->isChecked();
329 void VVTK_SizeBox::setUniform( bool theUniform )
331 myUniformCheckBox->setChecked( theUniform );
332 myColorButton->setEnabled( theUniform );
335 QColor VVTK_SizeBox::getColor() const
337 return myColorButton->paletteBackgroundColor();
340 void VVTK_SizeBox::setColor( const QColor& theColor )
342 myColorButton->setPaletteBackgroundColor( theColor );
345 void VVTK_SizeBox::onColorButtonPressed()
347 QColor aColor = QColorDialog::getColor( myColorButton->paletteBackgroundColor(), this );
348 if( aColor.isValid() )
349 myColorButton->setPaletteBackgroundColor( aColor );