Salome HOME
Porting SMESH module to Qt 4
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ConvToQuadDlg.cxx
1 // SMESH SMESHGUI : GUI for SMESH component
2 //
3 // Copyright (C) 2005  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : SMESHGUI_ConvToQuadDlg.cxx
23 // Author : Open CASCADE S.A.S.
24 //
25
26 // SMESH includes
27 #include "SMESHGUI_ConvToQuadDlg.h"
28
29 // Qt includes
30 #include <QGroupBox>
31 #include <QCheckBox>
32 #include <QRadioButton>
33 #include <QButtonGroup>
34 #include <QGroupBox>
35 #include <QFrame>
36 #include <QHBoxLayout>
37 #include <QGridLayout>
38
39 #define SPACING 6
40 #define MARGIN  11
41
42 SMESHGUI_ConvToQuadDlg::SMESHGUI_ConvToQuadDlg()
43   : SMESHGUI_Dialog( 0, false, true )
44 {
45   setWindowTitle( tr( "CAPTION" ) );
46
47   // Create top controls  
48
49   // mesh
50   createObject( tr( "MESH" ), mainFrame(), 0 );
51
52   //Create check box
53   myMedNdsOnGeom = new QCheckBox( tr( "MEDIUMNDS" ), mainFrame() );
54
55   //Create RadioButtons
56   myBGBox = new QGroupBox( mainFrame() );
57   myBG = new QButtonGroup( mainFrame() );
58   QHBoxLayout* aBGLayout = new QHBoxLayout( myBGBox );
59   aBGLayout->setMargin(MARGIN);
60   aBGLayout->setSpacing(SPACING);
61   
62   myRB1 = new QRadioButton( tr( "RADIOBTN_1" ), myBGBox );
63   myRB2 = new QRadioButton( tr( "RADIOBTN_2" ), myBGBox );
64
65   aBGLayout->addWidget(myRB1);
66   aBGLayout->addWidget(myRB2);
67   myBG->addButton(myRB1, 0);
68   myBG->addButton(myRB2, 1);
69   myRB1->setChecked( true );
70
71   // Fill layout
72   QGridLayout* aLay = new QGridLayout( mainFrame() );
73   aLay->setMargin( 0 );
74   aLay->setSpacing( SPACING );
75
76   aLay->addWidget( objectWg( 0,  Label ),   0, 0 );
77   aLay->addWidget( objectWg( 0,  Btn ),     0, 1 );
78   aLay->addWidget( objectWg( 0,  Control ), 0, 2 );
79   aLay->addWidget( myMedNdsOnGeom,          1, 0, 1, 3 );
80   aLay->addWidget( myBGBox,                 2, 0, 1, 3 );
81   
82   connect(myBG, SIGNAL( buttonClicked( int ) ), this, SIGNAL( onClicked( int ) ) );
83 }
84
85 SMESHGUI_ConvToQuadDlg::~SMESHGUI_ConvToQuadDlg()
86 {
87 }
88
89 bool SMESHGUI_ConvToQuadDlg::IsMediumNdsOnGeom() const
90 {
91   return !myMedNdsOnGeom->isChecked();
92 }
93
94 void SMESHGUI_ConvToQuadDlg::SetMediumNdsOnGeom(const bool theCheck)
95 {
96   myMedNdsOnGeom->setChecked(theCheck);
97 }
98
99 bool SMESHGUI_ConvToQuadDlg::IsEnabledCheck() const
100 {
101   return myMedNdsOnGeom->isEnabled();
102 }
103
104 void SMESHGUI_ConvToQuadDlg::SetEnabledCheck( const bool theCheck )
105 {
106   myMedNdsOnGeom->setEnabled( theCheck );
107 }
108
109 int SMESHGUI_ConvToQuadDlg::CurrentRB( )
110 {
111   return myBG->checkedId();
112 }
113
114 void SMESHGUI_ConvToQuadDlg::SetEnabledControls( const bool theCheck )
115 {
116   myBGBox->setEnabled( theCheck );
117   myMedNdsOnGeom->setEnabled( theCheck );
118   setButtonEnabled( theCheck, QtxDialog::OK | QtxDialog::Apply );
119 }
120
121 void SMESHGUI_ConvToQuadDlg::SetEnabledRB( const int idx, const bool theCheck ) 
122 {
123   if(idx)
124   {
125     myRB2->setEnabled( theCheck );
126     myRB1->setEnabled( !theCheck );
127     myRB1->setChecked( true );
128   }
129   else
130   {
131     myRB1->setEnabled( theCheck );
132     myRB2->setEnabled( !theCheck );
133     myRB2->setChecked( true );
134   }
135   emit onClicked( myBG->checkedId() );
136 }
137
138