]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx
Salome HOME
NRI : Merge from V1_2.
[modules/visu.git] / src / VISUGUI / VisuGUI_IsoSurfacesDlg.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : VisuGUI_IsoSurfacesDlg.cxx
25 //  Author : Laurent CORNABE & Hubert ROLLAND 
26 //  Module : VISU
27 //  $Header$
28
29 using namespace std;
30 #include "VisuGUI_IsoSurfacesDlg.h"
31 #include <qlayout.h>
32 #include "QAD_Application.h"
33 #include "QAD_Desktop.h"
34 #include <qvalidator.h>
35 #include "QAD_MessageBox.h"
36
37
38 /*!
39   Constructor
40 */
41 VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg()
42     : QDialog( QAD_Application::getDesktop(), "VisuGUI_IsoSurfacesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
43 {
44   setCaption( tr( "Iso Surfaces Definition" ) );
45   setSizeGripEnabled( TRUE );
46
47   QGridLayout* TopLayout = new QGridLayout( this ); 
48   TopLayout->setSpacing( 6 );
49   TopLayout->setMargin( 11 );
50   
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 );
59
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 );
69
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 );
79   
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 );
85
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 );
95
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 );
104   
105   TopLayout->addWidget( TopGroup,     0, 0 );
106   TopLayout->addWidget( GroupButtons, 1, 0 );
107
108   // signals and slots connections
109   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
110   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
111 }
112
113 /*!
114    Destructor
115 */
116 VisuGUI_IsoSurfacesDlg::~VisuGUI_IsoSurfacesDlg()
117 {
118 }
119
120
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()));
125 }
126
127
128 void VisuGUI_IsoSurfacesDlg::storeToPrsObject(VISU::IsoSurfaces_i* thePrs) {
129   thePrs->SetNbSurfaces(NbrIso->value());
130   thePrs->SetRange(MinIso->text().toDouble(), MaxIso->text().toDouble());
131   thePrs->Update();
132 }
133
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"),
138                                 tr("VISU_BUT_OK"));
139   else
140     QDialog::accept();
141 }