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"
32 #include "VisuGUI_Tools.h"
34 #include "SalomeApp_Application.h"
36 #include "SUIT_Desktop.h"
37 #include "SUIT_MessageBox.h"
42 #include <qvalidator.h>
43 #include <qtabwidget.h>
48 VisuGUI_IsoSurfPane::VisuGUI_IsoSurfPane (QWidget* parent)
51 QFrame* TopGroup = new QFrame( this, "TopGroup" );
52 TopGroup->setFrameStyle(QFrame::Box | QFrame::Sunken);
53 TopGroup->setLineWidth(1);
55 QGridLayout* TopGroupLayout = new QGridLayout(TopGroup);
56 TopGroupLayout->setAlignment( Qt::AlignTop );
57 TopGroupLayout->setSpacing( 6 );
58 TopGroupLayout->setMargin( 11 );
60 QLabel* LabelNbr = new QLabel (tr("NB_SURFACES"), TopGroup, "LabelNbr");
61 TopGroupLayout->addWidget( LabelNbr, 0, 0 );
62 NbrIso = new QSpinBox( 1, 100, 1, TopGroup, "NbrIso" );
63 NbrIso->setValue( 1 );
64 TopGroupLayout->addWidget( NbrIso, 0, 1 );
66 QLabel* LabelMin = new QLabel (tr("MIN_VALUE"), TopGroup, "LabelMin");
67 TopGroupLayout->addWidget(LabelMin, 1, 0);
68 //MinIso = new QtxDblSpinBox( -DBL_MAX, DBL_MAX, 0.1, TopGroup );
69 MinIso = new QLineEdit( TopGroup );
70 MinIso->setValidator( new QDoubleValidator(TopGroup) );
71 MinIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
72 MinIso->setMinimumSize( 70, 0 );
73 LabelMin->setBuddy(MinIso);
74 TopGroupLayout->addWidget( MinIso, 1, 1 );
76 QLabel* LabelMax = new QLabel (tr("MAX_VALUE"), TopGroup, "LabelMax");
77 TopGroupLayout->addWidget( LabelMax, 2, 0 );
78 //MaxIso = new QtxSpinBoxDbl( -DBL_MAX, DBL_MAX, 0.1, TopGroup );
79 MaxIso = new QLineEdit( TopGroup );
80 MaxIso->setValidator( new QDoubleValidator(TopGroup) );
81 MaxIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
82 MaxIso->setMinimumSize( 70, 0 );
83 LabelMax->setBuddy(MaxIso);
84 TopGroupLayout->addWidget( MaxIso, 2, 1 );
87 // CBUpdate = new QCheckBox ( tr( "Update scalar bar with these values" ), TopGroup);
88 // CBUpdate->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
89 // TopGroupLayout->addMultiCellWidget( CBUpdate, 4, 4, 0, 1);
90 // CBUpdate->setChecked(false);
91 QPushButton* aUpdateBtn = new QPushButton( "Update scalar bar range with these values", TopGroup);
92 TopGroupLayout->addMultiCellWidget( aUpdateBtn, 3, 3, 0, 1);
93 connect( aUpdateBtn, SIGNAL( clicked() ), this, SLOT(onCBUpdate() ) );
95 // CBLog = new QCheckBox ( tr( "Logarithmic scaling" ), TopGroup);
96 // CBLog->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
97 // TopGroupLayout->addMultiCellWidget( CBLog, 3, 3, 0, 1);
100 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)
116 thePrs->SetNbSurfaces(NbrIso->value());
117 thePrs->SetSubRange(MinIso->text().toDouble(), MaxIso->text().toDouble());
119 // if (CBUpdate->isChecked())
121 // thePrs->SetRange(MinIso->text().toDouble(), MaxIso->text().toDouble());
122 // if (CBLog->isChecked())
123 // thePrs->SetScaling(VISU::LOGARITHMIC);
125 // thePrs->SetScaling(VISU::LINEAR);
129 void VisuGUI_IsoSurfPane::onCBUpdate()
131 // if (CBUpdate->isChecked()) {
132 myScalarPane->setRange(MinIso->text().toDouble(), MaxIso->text().toDouble(), true);
134 // CBLog->setDisabled(false);
135 // else CBLog->setDisabled(true);
138 bool VisuGUI_IsoSurfPane::check()
140 if (MinIso->text().toDouble() >= MaxIso->text().toDouble()) {
141 MESSAGE(tr("MSG_MINMAX_VALUES"));
142 SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
143 tr("MSG_MINMAX_VALUES"),
146 } // else if (/* CBUpdate->isChecked() && CBLog->isChecked() && */
147 // (MinIso->text().toDouble() <=0 || MaxIso->text().toDouble() <=0) ) {
148 // SUIT_MessageBox::warn1( this,
150 // tr("WRN_LOGARITHMIC_RANGE_ISOSURF"),
164 VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg (SalomeApp_Module* theModule)
165 : QDialog(VISU::GetDesktop(theModule), "VisuGUI_IsoSurfacesDlg", true,
166 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
168 setCaption(tr("DEFINE_ISOSURFACES"));
169 setSizeGripEnabled( TRUE );
171 QVBoxLayout* TopLayout = new QVBoxLayout(this);
172 TopLayout->setSpacing( 6 );
173 TopLayout->setMargin(11);
175 QTabWidget* aTabBox = new QTabWidget(this);
176 myIsoPane = new VisuGUI_IsoSurfPane(this);
177 myIsoPane->setMargin( 5 );
178 aTabBox->addTab(myIsoPane, "Iso Surface");
179 myScalarPane = new VisuGUI_ScalarBarPane(this, false);
180 myIsoPane->setScalarBarPane(myScalarPane);
181 myScalarPane->setMargin( 5 );
182 aTabBox->addTab(myScalarPane, "Scalar Bar");
184 TopLayout->addWidget(aTabBox);
186 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
187 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
188 GroupButtons->setColumnLayout(0, Qt::Vertical );
189 GroupButtons->layout()->setSpacing( 0 );
190 GroupButtons->layout()->setMargin( 0 );
191 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
192 GroupButtonsLayout->setAlignment( Qt::AlignTop );
193 GroupButtonsLayout->setSpacing( 6 );
194 GroupButtonsLayout->setMargin( 11 );
196 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
197 buttonOk->setAutoDefault( TRUE );
198 buttonOk->setDefault( TRUE );
199 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
200 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
201 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
202 buttonCancel->setAutoDefault( TRUE );
203 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
205 TopLayout->addWidget(GroupButtons);
207 // signals and slots connections
208 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
209 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
212 void VisuGUI_IsoSurfacesDlg::accept()
214 if (myIsoPane->check() && myScalarPane->check())