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
30 #include "VisuGUI_IsoSurfacesDlg.h"
32 #include "QAD_Application.h"
33 #include "QAD_Desktop.h"
34 #include <qvalidator.h>
35 #include "QAD_MessageBox.h"
41 VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg()
42 : QDialog( QAD_Application::getDesktop(), "VisuGUI_IsoSurfacesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
44 setCaption( tr( "Iso Surfaces Definition" ) );
45 setSizeGripEnabled( TRUE );
47 QGridLayout* TopLayout = new QGridLayout( this );
48 TopLayout->setSpacing( 6 );
49 TopLayout->setMargin( 11 );
51 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
52 TopGroup->setColumnLayout(0, Qt::Vertical );
53 TopGroup->layout()->setSpacing( 0 );
54 TopGroup->layout()->setMargin( 0 );
55 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
56 TopGroupLayout->setAlignment( Qt::AlignTop );
57 TopGroupLayout->setSpacing( 6 );
58 TopGroupLayout->setMargin( 11 );
60 QLabel* LabelMin = new QLabel( tr( "Minimum value:" ), TopGroup, "LabelMin" );
61 TopGroupLayout->addWidget( LabelMin, 0, 0 );
62 //MinIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1 );
63 MinIso = new QLineEdit( TopGroup );
64 MinIso->setValidator( new QDoubleValidator(this) );
65 MinIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
66 MinIso->setMinimumSize( 70, 0 );
67 LabelMin->setBuddy(MinIso);
68 TopGroupLayout->addWidget( MinIso, 0, 1 );
70 QLabel* LabelMax = new QLabel( tr( "Maximum value:" ), TopGroup, "LabelMax" );
71 TopGroupLayout->addWidget( LabelMax, 1, 0 );
72 //MaxIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1);
73 MaxIso = new QLineEdit( TopGroup );
74 MaxIso->setValidator( new QDoubleValidator(this) );
75 MaxIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
76 MaxIso->setMinimumSize( 70, 0 );
77 LabelMax->setBuddy(MaxIso);
78 TopGroupLayout->addWidget( MaxIso, 1, 1 );
80 QLabel* LabelNbr = new QLabel( tr( "Number of surfaces:" ), TopGroup, "LabelNbr" );
81 TopGroupLayout->addWidget( LabelNbr, 2, 0 );
82 NbrIso = new QSpinBox( 1, 100, 1, TopGroup, "NbrIso" );
83 NbrIso->setValue( 1 );
84 TopGroupLayout->addWidget( NbrIso, 2, 1 );
86 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
87 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
88 GroupButtons->setColumnLayout(0, Qt::Vertical );
89 GroupButtons->layout()->setSpacing( 0 );
90 GroupButtons->layout()->setMargin( 0 );
91 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
92 GroupButtonsLayout->setAlignment( Qt::AlignTop );
93 GroupButtonsLayout->setSpacing( 6 );
94 GroupButtonsLayout->setMargin( 11 );
96 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
97 buttonOk->setAutoDefault( TRUE );
98 buttonOk->setDefault( TRUE );
99 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
100 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
101 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
102 buttonCancel->setAutoDefault( TRUE );
103 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
105 TopLayout->addWidget( TopGroup, 0, 0 );
106 TopLayout->addWidget( GroupButtons, 1, 0 );
108 // signals and slots connections
109 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
110 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
116 VisuGUI_IsoSurfacesDlg::~VisuGUI_IsoSurfacesDlg()
121 void VisuGUI_IsoSurfacesDlg::initFromPrsObject(VISU::IsoSurfaces_i* thePrs) {
122 NbrIso->setValue(thePrs->GetNbSurfaces());
123 MinIso->setText(QString::number(thePrs->GetRangeMin()));
124 MaxIso->setText(QString::number(thePrs->GetRangeMax()));
128 void VisuGUI_IsoSurfacesDlg::storeToPrsObject(VISU::IsoSurfaces_i* thePrs) {
129 thePrs->SetNbSurfaces(NbrIso->value());
130 thePrs->SetRange(MinIso->text().toDouble(), MaxIso->text().toDouble());
134 void VisuGUI_IsoSurfacesDlg::accept() {
135 if (MinIso->text().toDouble() >= MaxIso->text().toDouble())
136 QAD_MessageBox::warn1( this,tr("VISU_WARNING"),
137 tr("MSG_MINMAX_VALUES"),