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>
40 #include <qtabwidget.h>
46 VisuGUI_IsoSurfPane::VisuGUI_IsoSurfPane(QWidget* parent)
49 QFrame* TopGroup = new QFrame( this, "TopGroup" );
50 TopGroup->setFrameStyle(QFrame::Box | QFrame::Sunken);
51 TopGroup->setLineWidth(1);
53 QGridLayout* TopGroupLayout = new QGridLayout(TopGroup);
54 TopGroupLayout->setAlignment( Qt::AlignTop );
55 TopGroupLayout->setSpacing( 6 );
56 TopGroupLayout->setMargin( 11 );
58 QLabel* LabelNbr = new QLabel( tr( "Number of surfaces:" ), TopGroup, "LabelNbr" );
59 TopGroupLayout->addWidget( LabelNbr, 0, 0 );
60 NbrIso = new QSpinBox( 1, 100, 1, TopGroup, "NbrIso" );
61 NbrIso->setValue( 1 );
62 TopGroupLayout->addWidget( NbrIso, 0, 1 );
64 QLabel* LabelMin = new QLabel( tr( "Minimum value:" ), TopGroup, "LabelMin" );
65 TopGroupLayout->addWidget( LabelMin, 1, 0 );
66 //MinIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1 );
67 MinIso = new QLineEdit( TopGroup );
68 MinIso->setValidator( new QDoubleValidator(TopGroup) );
69 MinIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
70 MinIso->setMinimumSize( 70, 0 );
71 LabelMin->setBuddy(MinIso);
72 TopGroupLayout->addWidget( MinIso, 1, 1 );
74 QLabel* LabelMax = new QLabel( tr( "Maximum value:" ), TopGroup, "LabelMax" );
75 TopGroupLayout->addWidget( LabelMax, 2, 0 );
76 //MaxIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1);
77 MaxIso = new QLineEdit( TopGroup );
78 MaxIso->setValidator( new QDoubleValidator(TopGroup) );
79 MaxIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
80 MaxIso->setMinimumSize( 70, 0 );
81 LabelMax->setBuddy(MaxIso);
82 TopGroupLayout->addWidget( MaxIso, 2, 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(false);
89 QPushButton* aUpdateBtn = new QPushButton( "Update scalar bar range with these values", TopGroup);
90 TopGroupLayout->addMultiCellWidget( aUpdateBtn, 3, 3, 0, 1);
91 connect( aUpdateBtn, SIGNAL( clicked() ), this, SLOT(onCBUpdate() ) );
93 // CBLog = new QCheckBox ( tr( "Logarithmic scaling" ), TopGroup);
94 // CBLog->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
95 // TopGroupLayout->addMultiCellWidget( CBLog, 3, 3, 0, 1);
101 void VisuGUI_IsoSurfPane::initFromPrsObject(VISU::IsoSurfaces_i* thePrs) {
102 NbrIso->setValue(thePrs->GetNbSurfaces());
103 MinIso->setText(QString::number(thePrs->GetSubMin()));
104 MaxIso->setText(QString::number(thePrs->GetSubMax()));
105 // switch(thePrs->GetScaling()){
106 // case VISU::LOGARITHMIC :
107 // CBLog->setChecked(true);
110 // CBLog->setChecked(false);
114 int VisuGUI_IsoSurfPane::storeToPrsObject(VISU::IsoSurfaces_i* thePrs) {
115 thePrs->SetNbSurfaces(NbrIso->value());
116 thePrs->SetSubRange(MinIso->text().toDouble(), MaxIso->text().toDouble());
118 // if (CBUpdate->isChecked())
120 // thePrs->SetRange(MinIso->text().toDouble(), MaxIso->text().toDouble());
121 // if (CBLog->isChecked())
122 // thePrs->SetScaling(VISU::LOGARITHMIC);
124 // thePrs->SetScaling(VISU::LINEAR);
128 void VisuGUI_IsoSurfPane::onCBUpdate()
130 // if (CBUpdate->isChecked()) {
131 myScalarPane->setRange(MinIso->text().toDouble(), MaxIso->text().toDouble(), true);
133 // CBLog->setDisabled(false);
134 // else CBLog->setDisabled(true);
138 bool VisuGUI_IsoSurfPane::check() {
139 if (MinIso->text().toDouble() >= MaxIso->text().toDouble()) {
140 MESSAGE(tr("MSG_MINMAX_VALUES"));
141 QAD_MessageBox::warn1( this,tr("VISU_WARNING"),
142 tr("MSG_MINMAX_VALUES"),
145 } // else if (/* CBUpdate->isChecked() && CBLog->isChecked() && */
146 // (MinIso->text().toDouble() <=0 || MaxIso->text().toDouble() <=0) ) {
147 // QAD_MessageBox::warn1( this,
148 // tr("VISU_WARNING"),
149 // tr("WRN_LOGARITHMIC_RANGE_ISOSURF"),
150 // tr("VISU_BUT_OK"));
163 VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg()
164 : QDialog( QAD_Application::getDesktop(), "VisuGUI_IsoSurfacesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
166 setCaption( tr( "Iso Surfaces Definition" ) );
167 setSizeGripEnabled( TRUE );
169 QVBoxLayout* TopLayout = new QVBoxLayout(this);
170 TopLayout->setSpacing( 6 );
171 TopLayout->setMargin(11);
173 QTabWidget* aTabBox = new QTabWidget(this);
174 myIsoPane = new VisuGUI_IsoSurfPane(this);
175 myIsoPane->setMargin( 5 );
176 aTabBox->addTab(myIsoPane, "Iso Surface");
177 myScalarPane = new VisuGUI_ScalarBarPane(this, false);
178 myIsoPane->setScalarBarPane(myScalarPane);
179 myScalarPane->setMargin( 5 );
180 aTabBox->addTab(myScalarPane, "Scalar Bar");
182 TopLayout->addWidget(aTabBox);
184 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
185 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
186 GroupButtons->setColumnLayout(0, Qt::Vertical );
187 GroupButtons->layout()->setSpacing( 0 );
188 GroupButtons->layout()->setMargin( 0 );
189 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
190 GroupButtonsLayout->setAlignment( Qt::AlignTop );
191 GroupButtonsLayout->setSpacing( 6 );
192 GroupButtonsLayout->setMargin( 11 );
194 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
195 buttonOk->setAutoDefault( TRUE );
196 buttonOk->setDefault( TRUE );
197 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
198 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
199 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
200 buttonCancel->setAutoDefault( TRUE );
201 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
203 TopLayout->addWidget(GroupButtons);
205 // signals and slots connections
206 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
207 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
210 void VisuGUI_IsoSurfacesDlg::accept() {
211 if (myIsoPane->check() && myScalarPane->check()) QDialog::accept();