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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : VisuGUI_IsoSurfacesDlg.cxx
25 // Author : Laurent CORNABE & Hubert ROLLAND
29 #include "VisuGUI_IsoSurfacesDlg.h"
32 #include "VisuGUI_Tools.h"
33 #include "VisuGUI_InputPane.h"
35 #include "VISU_ColoredPrs3dFactory.hh"
37 #include "LightApp_Application.h"
39 #include "SUIT_Desktop.h"
40 #include "SUIT_Session.h"
41 #include "SUIT_MessageBox.h"
42 #include "SUIT_ResourceMgr.h"
47 #include <qvalidator.h>
48 #include <qtabwidget.h>
53 VisuGUI_IsoSurfPane::VisuGUI_IsoSurfPane (QWidget* parent,
54 VisuGUI_ScalarBarPane* theScalarPane)
56 myScalarPane(theScalarPane)
58 QFrame* TopGroup = new QFrame( this, "TopGroup" );
59 TopGroup->setFrameStyle(QFrame::Box | QFrame::Sunken);
60 TopGroup->setLineWidth(1);
62 QGridLayout* TopGroupLayout = new QGridLayout(TopGroup);
63 TopGroupLayout->setAlignment( Qt::AlignTop );
64 TopGroupLayout->setSpacing( 6 );
65 TopGroupLayout->setMargin( 11 );
67 QLabel* LabelNbr = new QLabel (tr("NB_SURFACES"), TopGroup, "LabelNbr");
68 TopGroupLayout->addWidget( LabelNbr, 0, 0 );
69 NbrIso = new QSpinBox( 1, 100, 1, TopGroup, "NbrIso" );
70 NbrIso->setValue( 1 );
71 TopGroupLayout->addWidget( NbrIso, 0, 1 );
73 QLabel* LabelMin = new QLabel (tr("MIN_VALUE"), TopGroup, "LabelMin");
74 TopGroupLayout->addWidget(LabelMin, 1, 0);
75 //MinIso = new QtxDblSpinBox( -DBL_MAX, DBL_MAX, 0.1, TopGroup );
76 MinIso = new QLineEdit( TopGroup );
77 MinIso->setValidator( new QDoubleValidator(TopGroup) );
78 MinIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
79 MinIso->setMinimumSize( 70, 0 );
80 LabelMin->setBuddy(MinIso);
81 TopGroupLayout->addWidget( MinIso, 1, 1 );
83 QLabel* LabelMax = new QLabel (tr("MAX_VALUE"), TopGroup, "LabelMax");
84 TopGroupLayout->addWidget( LabelMax, 2, 0 );
85 //MaxIso = new QtxSpinBoxDbl( -DBL_MAX, DBL_MAX, 0.1, TopGroup );
86 MaxIso = new QLineEdit( TopGroup );
87 MaxIso->setValidator( new QDoubleValidator(TopGroup) );
88 MaxIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
89 MaxIso->setMinimumSize( 70, 0 );
90 LabelMax->setBuddy(MaxIso);
91 TopGroupLayout->addWidget( MaxIso, 2, 1 );
93 QPushButton* aUpdateBtn = new QPushButton( "Update scalar bar range with these values", TopGroup);
94 TopGroupLayout->addMultiCellWidget( aUpdateBtn, 3, 3, 0, 1);
95 connect( aUpdateBtn, SIGNAL( clicked() ), this, SLOT(onCBUpdate() ) );
98 void VisuGUI_IsoSurfPane::initFromPrsObject (VISU::IsoSurfaces_i* thePrs)
100 NbrIso->setValue(thePrs->GetNbSurfaces());
101 MinIso->setText(QString::number(thePrs->GetSubMin()));
102 MaxIso->setText(QString::number(thePrs->GetSubMax()));
105 int VisuGUI_IsoSurfPane::storeToPrsObject (VISU::IsoSurfaces_i* thePrs)
107 thePrs->SetNbSurfaces(NbrIso->value());
108 thePrs->SetSubRange(MinIso->text().toDouble(), MaxIso->text().toDouble());
112 void VisuGUI_IsoSurfPane::onCBUpdate()
114 myScalarPane->setRange(MinIso->text().toDouble(), MaxIso->text().toDouble(), true);
117 bool VisuGUI_IsoSurfPane::check()
119 if (MinIso->text().toDouble() >= MaxIso->text().toDouble()) {
120 MESSAGE(tr("MSG_MINMAX_VALUES"));
121 SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
122 tr("MSG_MINMAX_VALUES"),
136 VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg (SalomeApp_Module* theModule)
137 : VisuGUI_ScalarBarBaseDlg(theModule)
139 setCaption(tr("DEFINE_ISOSURFACES"));
140 setSizeGripEnabled( TRUE );
142 QVBoxLayout* TopLayout = new QVBoxLayout(this);
143 TopLayout->setSpacing( 6 );
144 TopLayout->setMargin(11);
146 myTabBox = new QTabWidget(this);
147 myIsoPane = new VisuGUI_IsoSurfPane(this, GetScalarPane());
148 myIsoPane->setMargin( 5 );
149 myTabBox->addTab(myIsoPane, "Iso Surface");
150 myInputPane = new VisuGUI_InputPane(VISU::TISOSURFACES, theModule, this);
151 myTabBox->addTab(GetScalarPane(), "Scalar Bar");
152 myTabBox->addTab(myInputPane, "Input");
154 TopLayout->addWidget(myTabBox);
156 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
157 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
158 GroupButtons->setColumnLayout(0, Qt::Vertical );
159 GroupButtons->layout()->setSpacing( 0 );
160 GroupButtons->layout()->setMargin( 0 );
161 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
162 GroupButtonsLayout->setAlignment( Qt::AlignTop );
163 GroupButtonsLayout->setSpacing( 6 );
164 GroupButtonsLayout->setMargin( 11 );
166 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
167 buttonOk->setAutoDefault( TRUE );
168 buttonOk->setDefault( TRUE );
169 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
170 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
171 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
172 buttonCancel->setAutoDefault( TRUE );
173 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
174 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
175 buttonHelp->setAutoDefault( TRUE );
176 GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
178 TopLayout->addWidget(GroupButtons);
180 // signals and slots connections
181 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
182 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
183 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
186 VisuGUI_IsoSurfacesDlg::~VisuGUI_IsoSurfacesDlg()
189 void VisuGUI_IsoSurfacesDlg::accept()
191 if ( myIsoPane->check() )
192 VisuGUI_ScalarBarBaseDlg::accept();
195 void VisuGUI_IsoSurfacesDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
199 myPrsCopy = VISU::TSameAsFactory<VISU::TISOSURFACES>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
201 VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
203 myIsoPane->initFromPrsObject(myPrsCopy);
208 myInputPane->initFromPrsObject( myPrsCopy );
209 myTabBox->setCurrentPage( 0 );
212 int VisuGUI_IsoSurfacesDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
214 if(!myInputPane->check() || !GetScalarPane()->check())
217 int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
218 anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy );
219 anIsOk &= myIsoPane->storeToPrsObject( myPrsCopy );
221 VISU::TSameAsFactory<VISU::TISOSURFACES>().Copy(myPrsCopy, thePrs);
226 QString VisuGUI_IsoSurfacesDlg::GetContextHelpFilePath()
228 return "iso_surfaces_page.html";