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 : VisuGUI_IsoSurfacesDlg.cxx
25 // Author : Laurent CORNABE & Hubert ROLLAND
29 #include "VisuGUI_IsoSurfacesDlg.h"
30 #include "VISU_IsoSurfaces_i.hh"
32 #include "QAD_Application.h"
33 #include "QAD_Desktop.h"
34 #include "QAD_MessageBox.h"
39 #include <qvalidator.h>
46 VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg()
47 : QDialog( QAD_Application::getDesktop(), "VisuGUI_IsoSurfacesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
49 setCaption( tr( "Iso Surfaces Definition" ) );
50 setSizeGripEnabled( TRUE );
52 QGridLayout* TopLayout = new QGridLayout( this );
53 TopLayout->setSpacing( 6 );
54 TopLayout->setMargin( 11 );
56 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
57 TopGroup->setColumnLayout(0, Qt::Vertical );
58 TopGroup->layout()->setSpacing( 0 );
59 TopGroup->layout()->setMargin( 0 );
60 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
61 TopGroupLayout->setAlignment( Qt::AlignTop );
62 TopGroupLayout->setSpacing( 6 );
63 TopGroupLayout->setMargin( 11 );
65 QLabel* LabelMin = new QLabel( tr( "Minimum value:" ), TopGroup, "LabelMin" );
66 TopGroupLayout->addWidget( LabelMin, 0, 0 );
67 //MinIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1 );
68 MinIso = new QLineEdit( TopGroup );
69 MinIso->setValidator( new QDoubleValidator(this) );
70 MinIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
71 MinIso->setMinimumSize( 70, 0 );
72 LabelMin->setBuddy(MinIso);
73 TopGroupLayout->addWidget( MinIso, 0, 1 );
75 QLabel* LabelMax = new QLabel( tr( "Maximum value:" ), TopGroup, "LabelMax" );
76 TopGroupLayout->addWidget( LabelMax, 1, 0 );
77 //MaxIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1);
78 MaxIso = new QLineEdit( TopGroup );
79 MaxIso->setValidator( new QDoubleValidator(this) );
80 MaxIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
81 MaxIso->setMinimumSize( 70, 0 );
82 LabelMax->setBuddy(MaxIso);
83 TopGroupLayout->addWidget( MaxIso, 1, 1 );
85 CBUpdate = new QCheckBox ( tr( "Update scalar bar with these values" ), TopGroup);
86 CBUpdate->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
87 TopGroupLayout->addMultiCellWidget( CBUpdate, 4, 4, 0, 1);
88 CBUpdate->setChecked(true);
90 CBLog = new QCheckBox ( tr( "Logarithmic scaling" ), TopGroup);
91 CBLog->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
92 TopGroupLayout->addMultiCellWidget( CBLog, 3, 3, 0, 1);
94 QLabel* LabelNbr = new QLabel( tr( "Number of surfaces:" ), TopGroup, "LabelNbr" );
95 TopGroupLayout->addWidget( LabelNbr, 2, 0 );
96 NbrIso = new QSpinBox( 1, 100, 1, TopGroup, "NbrIso" );
97 NbrIso->setValue( 1 );
98 TopGroupLayout->addWidget( NbrIso, 2, 1 );
100 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
101 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
102 GroupButtons->setColumnLayout(0, Qt::Vertical );
103 GroupButtons->layout()->setSpacing( 0 );
104 GroupButtons->layout()->setMargin( 0 );
105 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
106 GroupButtonsLayout->setAlignment( Qt::AlignTop );
107 GroupButtonsLayout->setSpacing( 6 );
108 GroupButtonsLayout->setMargin( 11 );
110 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
111 buttonOk->setAutoDefault( TRUE );
112 buttonOk->setDefault( TRUE );
113 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
114 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
115 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
116 buttonCancel->setAutoDefault( TRUE );
117 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
119 TopLayout->addWidget( TopGroup, 0, 0 );
120 TopLayout->addWidget( GroupButtons, 1, 0 );
122 // signals and slots connections
123 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
124 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
125 connect( CBUpdate, SIGNAL( clicked() ), this, SLOT(onCBUpdate() ) );
131 VisuGUI_IsoSurfacesDlg::~VisuGUI_IsoSurfacesDlg()
135 void VisuGUI_IsoSurfacesDlg::initFromPrsObject(VISU::IsoSurfaces_i* thePrs) {
136 NbrIso->setValue(thePrs->GetNbSurfaces());
137 MinIso->setText(QString::number(thePrs->GetSubMin()));
138 MaxIso->setText(QString::number(thePrs->GetSubMax()));
139 switch(thePrs->GetScaling()){
140 case VISU::LOGARITHMIC :
141 CBLog->setChecked(true);
144 CBLog->setChecked(false);
148 void VisuGUI_IsoSurfacesDlg::storeToPrsObject(VISU::IsoSurfaces_i* thePrs) {
149 thePrs->SetNbSurfaces(NbrIso->value());
150 thePrs->SetSubRange(MinIso->text().toDouble(), MaxIso->text().toDouble());
151 if (CBUpdate->isChecked())
153 thePrs->SetRange(MinIso->text().toDouble(), MaxIso->text().toDouble());
154 if (CBLog->isChecked())
155 thePrs->SetScaling(VISU::LOGARITHMIC);
157 thePrs->SetScaling(VISU::LINEAR);
161 void VisuGUI_IsoSurfacesDlg::accept() {
163 if (MinIso->text().toDouble() >= MaxIso->text().toDouble())
164 QAD_MessageBox::warn1( this,tr("VISU_WARNING"),
165 tr("MSG_MINMAX_VALUES"),
167 else if ( CBUpdate->isChecked() && CBLog->isChecked() && (MinIso->text().toDouble() <=0 || MaxIso->text().toDouble() <=0) )
170 QAD_MessageBox::warn1( this,
172 tr("WRN_LOGARITHMIC_RANGE_ISOSURF"),
175 else QDialog::accept();
178 void VisuGUI_IsoSurfacesDlg::onCBUpdate()
180 if (CBUpdate->isChecked())
181 CBLog->setDisabled(false);
182 else CBLog->setDisabled(true);