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