Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ConvToQuadDlg.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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 // SMESH SMESHGUI : GUI for SMESH component
23 // File   : SMESHGUI_ConvToQuadDlg.cxx
24 // Author : Open CASCADE S.A.S.
25 // SMESH includes
26 //
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   setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) );
51   createObject( tr( "MESH" ), mainFrame(), 0 );
52
53   //Create check box
54   myMedNdsOnGeom = new QCheckBox( tr( "MEDIUMNDS" ), mainFrame() );
55
56   //Create RadioButtons
57   myBGBox = new QGroupBox( mainFrame() );
58   myBG = new QButtonGroup( mainFrame() );
59   QVBoxLayout* aBGLayout = new QVBoxLayout( myBGBox );
60   aBGLayout->setMargin(MARGIN);
61   aBGLayout->setSpacing(SPACING);
62   
63   myRB1 = new QRadioButton( tr( "RADIOBTN_1" ), myBGBox );
64   myRB2 = new QRadioButton( tr( "RADIOBTN_2" ), myBGBox );
65
66   aBGLayout->addWidget(myRB1);
67   aBGLayout->addWidget(myRB2);
68   myBG->addButton(myRB1, 0);
69   myBG->addButton(myRB2, 1);
70   myRB1->setChecked( true );
71
72   // Fill layout
73   QGridLayout* aLay = new QGridLayout( mainFrame() );
74   aLay->setMargin( 5 );
75   aLay->setSpacing( 5 );
76
77   aLay->addWidget( objectWg( 0,  Label ),   0, 0 );
78   aLay->addWidget( objectWg( 0,  Btn ),     0, 1 );
79   aLay->addWidget( objectWg( 0,  Control ), 0, 2 );
80   aLay->addWidget( myMedNdsOnGeom,          1, 0, 1, 3 );
81   aLay->addWidget( myBGBox,                 2, 0, 1, 3 );
82   
83   connect(myBG, SIGNAL( buttonClicked( int ) ), this, SIGNAL( onClicked( int ) ) );
84 }
85
86 SMESHGUI_ConvToQuadDlg::~SMESHGUI_ConvToQuadDlg()
87 {
88 }
89
90 bool SMESHGUI_ConvToQuadDlg::IsMediumNdsOnGeom() const
91 {
92   return !myMedNdsOnGeom->isChecked();
93 }
94
95 void SMESHGUI_ConvToQuadDlg::SetMediumNdsOnGeom(const bool theCheck)
96 {
97   myMedNdsOnGeom->setChecked(theCheck);
98 }
99
100 bool SMESHGUI_ConvToQuadDlg::IsEnabledCheck() const
101 {
102   return myMedNdsOnGeom->isEnabled();
103 }
104
105 void SMESHGUI_ConvToQuadDlg::SetEnabledCheck( const bool theCheck )
106 {
107   myMedNdsOnGeom->setEnabled( theCheck );
108 }
109
110 int SMESHGUI_ConvToQuadDlg::CurrentRB( )
111 {
112   return myBG->checkedId();
113 }
114
115 void SMESHGUI_ConvToQuadDlg::SetEnabledControls( const bool theCheck )
116 {
117   myBGBox->setEnabled( theCheck );
118   myMedNdsOnGeom->setEnabled( theCheck );
119   setButtonEnabled( theCheck, QtxDialog::OK | QtxDialog::Apply );
120 }
121
122 void SMESHGUI_ConvToQuadDlg::SetEnabledRB( const int idx, const bool theCheck ) 
123 {
124   if(idx)
125   {
126     myRB2->setEnabled( theCheck );
127     myRB1->setEnabled( !theCheck );
128     myRB1->setChecked( true );
129   }
130   else
131   {
132     myRB1->setEnabled( theCheck );
133     myRB2->setEnabled( !theCheck );
134     myRB2->setChecked( true );
135   }
136   emit onClicked( myBG->checkedId() );
137 }
138
139