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