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"
31 //#include "VisuGUI_Selection.h"
33 #include "SalomeApp_Application.h"
35 #include "SUIT_Desktop.h"
36 #include "SUIT_MessageBox.h"
41 #include <qvalidator.h>
42 #include <qtabwidget.h>
47 VisuGUI_IsoSurfPane::VisuGUI_IsoSurfPane (QWidget* parent)
50 QFrame* TopGroup = new QFrame( this, "TopGroup" );
51 TopGroup->setFrameStyle(QFrame::Box | QFrame::Sunken);
52 TopGroup->setLineWidth(1);
54 QGridLayout* TopGroupLayout = new QGridLayout(TopGroup);
55 TopGroupLayout->setAlignment( Qt::AlignTop );
56 TopGroupLayout->setSpacing( 6 );
57 TopGroupLayout->setMargin( 11 );
59 QLabel* LabelNbr = new QLabel( tr( "Number of surfaces:" ), TopGroup, "LabelNbr" );
60 TopGroupLayout->addWidget( LabelNbr, 0, 0 );
61 NbrIso = new QSpinBox( 1, 100, 1, TopGroup, "NbrIso" );
62 NbrIso->setValue( 1 );
63 TopGroupLayout->addWidget( NbrIso, 0, 1 );
65 QLabel* LabelMin = new QLabel( tr( "Minimum value:" ), TopGroup, "LabelMin" );
66 TopGroupLayout->addWidget( LabelMin, 1, 0 );
67 //MinIso = new QtxDblSpinBox( -DBL_MAX, DBL_MAX, 0.1, TopGroup );
68 MinIso = new QLineEdit( TopGroup );
69 MinIso->setValidator( new QDoubleValidator(TopGroup) );
70 MinIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
71 MinIso->setMinimumSize( 70, 0 );
72 LabelMin->setBuddy(MinIso);
73 TopGroupLayout->addWidget( MinIso, 1, 1 );
75 QLabel* LabelMax = new QLabel( tr( "Maximum value:" ), TopGroup, "LabelMax" );
76 TopGroupLayout->addWidget( LabelMax, 2, 0 );
77 //MaxIso = new QtxSpinBoxDbl( -DBL_MAX, DBL_MAX, 0.1, TopGroup );
78 MaxIso = new QLineEdit( TopGroup );
79 MaxIso->setValidator( new QDoubleValidator(TopGroup) );
80 MaxIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
81 MaxIso->setMinimumSize( 70, 0 );
82 LabelMax->setBuddy(MaxIso);
83 TopGroupLayout->addWidget( MaxIso, 2, 1 );
86 // CBUpdate = new QCheckBox ( tr( "Update scalar bar with these values" ), TopGroup);
87 // CBUpdate->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
88 // TopGroupLayout->addMultiCellWidget( CBUpdate, 4, 4, 0, 1);
89 // CBUpdate->setChecked(false);
90 QPushButton* aUpdateBtn = new QPushButton( "Update scalar bar range with these values", TopGroup);
91 TopGroupLayout->addMultiCellWidget( aUpdateBtn, 3, 3, 0, 1);
92 connect( aUpdateBtn, SIGNAL( clicked() ), this, SLOT(onCBUpdate() ) );
94 // CBLog = new QCheckBox ( tr( "Logarithmic scaling" ), TopGroup);
95 // CBLog->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
96 // TopGroupLayout->addMultiCellWidget( CBLog, 3, 3, 0, 1);
99 void VisuGUI_IsoSurfPane::initFromPrsObject (VISU::IsoSurfaces_i* thePrs)
101 NbrIso->setValue(thePrs->GetNbSurfaces());
102 MinIso->setText(QString::number(thePrs->GetSubMin()));
103 MaxIso->setText(QString::number(thePrs->GetSubMax()));
104 // switch(thePrs->GetScaling()){
105 // case VISU::LOGARITHMIC :
106 // CBLog->setChecked(true);
109 // CBLog->setChecked(false);
113 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);
137 bool VisuGUI_IsoSurfPane::check()
139 if (MinIso->text().toDouble() >= MaxIso->text().toDouble()) {
140 MESSAGE(tr("MSG_MINMAX_VALUES"));
141 SUIT_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 // SUIT_MessageBox::warn1( this,
148 // tr("VISU_WARNING"),
149 // tr("WRN_LOGARITHMIC_RANGE_ISOSURF"),
150 // tr("VISU_BUT_OK"));
163 VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg (QWidget* parent)
164 : QDialog(parent, "VisuGUI_IsoSurfacesDlg", true,
165 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
167 setCaption( tr( "Iso Surfaces Definition" ) );
168 setSizeGripEnabled( TRUE );
170 QVBoxLayout* TopLayout = new QVBoxLayout(this);
171 TopLayout->setSpacing( 6 );
172 TopLayout->setMargin(11);
174 QTabWidget* aTabBox = new QTabWidget(this);
175 myIsoPane = new VisuGUI_IsoSurfPane(this);
176 myIsoPane->setMargin( 5 );
177 aTabBox->addTab(myIsoPane, "Iso Surface");
178 myScalarPane = new VisuGUI_ScalarBarPane(this, false);
179 myIsoPane->setScalarBarPane(myScalarPane);
180 myScalarPane->setMargin( 5 );
181 aTabBox->addTab(myScalarPane, "Scalar Bar");
183 TopLayout->addWidget(aTabBox);
185 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
186 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
187 GroupButtons->setColumnLayout(0, Qt::Vertical );
188 GroupButtons->layout()->setSpacing( 0 );
189 GroupButtons->layout()->setMargin( 0 );
190 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
191 GroupButtonsLayout->setAlignment( Qt::AlignTop );
192 GroupButtonsLayout->setSpacing( 6 );
193 GroupButtonsLayout->setMargin( 11 );
195 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
196 buttonOk->setAutoDefault( TRUE );
197 buttonOk->setDefault( TRUE );
198 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
199 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
200 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
201 buttonCancel->setAutoDefault( TRUE );
202 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
204 TopLayout->addWidget(GroupButtons);
206 // signals and slots connections
207 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
208 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
211 void VisuGUI_IsoSurfacesDlg::accept()
213 if (myIsoPane->check() && myScalarPane->check())