Salome HOME
Add support for tetra, pyramid and prism
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_EditScalarBarDlg.cxx
1 //  SMESH SMESHGUI : GUI for SMESH 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   : SMESHGUI_EditScalarBarDlg.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //  $Header$
28
29 using namespace std;
30 #include "SMESHGUI_EditScalarBarDlg.h"
31 #include "SMESHGUI.h"
32
33 // QT Includes
34 #include <qframe.h>
35 #include <qlabel.h>
36 #include <qlineedit.h>
37 #include <qpushbutton.h>
38 #include <qlayout.h>
39 #include <qvariant.h>
40 #include <qtooltip.h>
41 #include <qwhatsthis.h>
42
43 /* 
44  *  Constructs a SMESHGUI_EditScalarBarDlg which is a child of 'parent', with the 
45  *  name 'name' and widget flags set to 'f' 
46  *
47  *  The dialog will by default be modeless, unless you set 'modal' to
48  *  TRUE to construct a modal dialog.
49  */
50 SMESHGUI_EditScalarBarDlg::SMESHGUI_EditScalarBarDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
51     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
52 {
53     if ( !name )
54         setName( "SMESHGUI_EditScalarBarDlg" );
55     resize( 124, 122 ); 
56     setCaption( tr( "SMESH_SCALARBAR"  ) );
57     setSizeGripEnabled( TRUE );
58     grid = new QGridLayout( this ); 
59     grid->setSpacing( 6 );
60     grid->setMargin( 11 );
61
62     grid_2 = new QGridLayout; 
63     grid_2->setSpacing( 6 );
64     grid_2->setMargin( 0 );
65
66     PushButtonUpdateView = new QPushButton( this, "PushButtonUpdateView" );
67     PushButtonUpdateView->setText( tr( "SMESH_UPDATEVIEW"  ) );
68
69     grid_2->addWidget( PushButtonUpdateView, 1, 0 );
70
71     grid_3 = new QGridLayout; 
72     grid_3->setSpacing( 6 );
73     grid_3->setMargin( 0 );
74
75     grid_4 = new QGridLayout; 
76     grid_4->setSpacing( 6 );
77     grid_4->setMargin( 0 );
78
79     grid_5 = new QGridLayout; 
80     grid_5->setSpacing( 6 );
81     grid_5->setMargin( 0 );
82
83     LineEditMax = new QLineEdit( this, "LineEditMax" );
84
85     grid_5->addWidget( LineEditMax, 0, 0 );
86
87     LineEditMin = new QLineEdit( this, "LineEditMin" );
88
89     grid_5->addWidget( LineEditMin, 1, 0 );
90
91     grid_4->addLayout( grid_5, 0, 1 );
92
93     grid_6 = new QGridLayout; 
94     grid_6->setSpacing( 6 );
95     grid_6->setMargin( 0 );
96
97     TextLabelMax = new QLabel( this, "TextLabelMax" );
98     TextLabelMax->setText( tr( "SMESH_MAX"  ) );
99
100     grid_6->addWidget( TextLabelMax, 0, 0 );
101
102     TextLabelMin = new QLabel( this, "TextLabelMin" );
103     TextLabelMin->setText( tr( "SMESH_MIN"  ) );
104
105     grid_6->addWidget( TextLabelMin, 1, 0 );
106
107     grid_4->addLayout( grid_6, 0, 0 );
108
109     grid_3->addLayout( grid_4, 0, 0 );
110
111     Line1 = new QFrame( this, "Line1" );
112     Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken );
113
114     grid_3->addWidget( Line1, 1, 0 );
115
116     grid_2->addLayout( grid_3, 0, 0 );
117
118     grid->addLayout( grid_2, 0, 0 );
119
120     mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
121     if ( mySMESHGUI && mySMESHGUI->GetScalarBar() && mySMESHGUI->GetScalarBar()->GetLookupTable() ) {
122       float *range = mySMESHGUI->GetScalarBar()->GetLookupTable()->GetRange();
123       LineEditMin->setText( QString("%1").arg(range[0]) );
124       LineEditMax->setText( QString("%1").arg(range[1]) );
125     }
126     
127     // signals and slots connections
128     connect( PushButtonUpdateView, SIGNAL( clicked() ), this, SLOT( updateView() ) );
129     /* to close dialog if study change */
130     connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( reject() ) ) ;
131 }
132
133 /*  
134  *  Destroys the object and frees any allocated resources
135  */
136 SMESHGUI_EditScalarBarDlg::~SMESHGUI_EditScalarBarDlg()
137 {
138     // no need to delete child widgets, Qt does it all for us
139 }
140
141 void SMESHGUI_EditScalarBarDlg::updateView()
142 {
143   float MinRange = LineEditMin->text().toFloat();
144   float MaxRange = LineEditMax->text().toFloat(); 
145   mySMESHGUI->UpdateScalarBar(MinRange,MaxRange);
146 }