Salome HOME
23514: EDF 16031 - SMESH freezes
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ConvToQuadDlg.cxx
1 // Copyright (C) 2007-2016  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, or (at your option) any later version.
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 #include "SMESHGUI_ConvToQuadOp.h"
31
32 // Qt includes
33 #include <QGroupBox>
34 #include <QCheckBox>
35 #include <QRadioButton>
36 #include <QButtonGroup>
37 #include <QGroupBox>
38 #include <QFrame>
39 #include <QHBoxLayout>
40 #include <QGridLayout>
41 #include <QLabel>
42
43 #define SPACING 6
44 #define MARGIN  11
45
46 SMESHGUI_ConvToQuadDlg::SMESHGUI_ConvToQuadDlg()
47   : SMESHGUI_Dialog( 0, false, true )
48 {
49   setWindowTitle( tr( "CAPTION" ) );
50
51   // Create top controls  
52
53   // mesh
54   setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) );
55   createObject( tr( "MESH" ), mainFrame(), 0 );
56
57   //Create check box
58   myMedNdsOnGeom = new QCheckBox( tr( "MEDIUMNDS" ), mainFrame() );
59
60   //Create RadioButtons
61   myBGBox = new QGroupBox( mainFrame() );
62   myBG = new QButtonGroup( mainFrame() );
63   QVBoxLayout* aBGLayout = new QVBoxLayout( myBGBox );
64   aBGLayout->setMargin(MARGIN);
65   aBGLayout->setSpacing(SPACING);
66   
67   myRB2Lin = new QRadioButton( tr( "RADIOBTN_1" ), myBGBox );
68   myRB2Quad = new QRadioButton( tr( "RADIOBTN_2" ), myBGBox );
69   myRB2BiQua = new QRadioButton( tr( "RADIOBTN_3" ), myBGBox );
70
71   aBGLayout->addWidget(myRB2Lin);
72   aBGLayout->addWidget(myRB2Quad);
73   aBGLayout->addWidget(myRB2BiQua);
74   myBG->addButton(myRB2Lin, 0);
75   myBG->addButton(myRB2Quad, 1);
76   myBG->addButton(myRB2BiQua, 2);
77   myRB2Lin->setChecked( true );
78
79   myWarning = new QLabel(QString("<b>%1</b>").arg(tr("NON_CONFORM_WARNING")), mainFrame());
80
81   // Fill layout
82   QGridLayout* aLay = new QGridLayout( mainFrame() );
83   aLay->setMargin( 5 );
84   aLay->setSpacing( 5 );
85
86   aLay->addWidget( objectWg( 0,  Label ),   0, 0 );
87   aLay->addWidget( objectWg( 0,  Btn ),     0, 1 );
88   aLay->addWidget( objectWg( 0,  Control ), 0, 2 );
89   aLay->addWidget( myMedNdsOnGeom,          1, 0, 1, 3 );
90   aLay->addWidget( myBGBox,                 2, 0, 1, 3 );
91   aLay->addWidget( myWarning,               3, 0, 1, 3 );
92   
93   connect(myBG, SIGNAL( buttonClicked( int ) ), this, SIGNAL( onClicked( int ) ) );
94 }
95
96 SMESHGUI_ConvToQuadDlg::~SMESHGUI_ConvToQuadDlg()
97 {
98 }
99
100 bool SMESHGUI_ConvToQuadDlg::IsBiQuadratic() const
101 {
102   return myRB2BiQua->isChecked();
103 }
104
105 bool SMESHGUI_ConvToQuadDlg::IsMediumNdsOnGeom() const
106 {
107   return !myMedNdsOnGeom->isChecked();
108 }
109
110 void SMESHGUI_ConvToQuadDlg::SetMediumNdsOnGeom(const bool theCheck)
111 {
112   myMedNdsOnGeom->setChecked(theCheck);
113 }
114
115 bool SMESHGUI_ConvToQuadDlg::IsEnabledCheck() const
116 {
117   return myMedNdsOnGeom->isEnabled();
118 }
119
120 void SMESHGUI_ConvToQuadDlg::SetEnabledCheck( const bool theCheck )
121 {
122   myMedNdsOnGeom->setEnabled( theCheck );
123 }
124
125 int SMESHGUI_ConvToQuadDlg::CurrentRB( )
126 {
127   return myBG->checkedId();
128 }
129
130 void SMESHGUI_ConvToQuadDlg::ShowWarning(bool toShow)
131 {
132   if ( toShow )
133     myWarning->show();
134   else
135     myWarning->hide();
136 }
137
138 bool SMESHGUI_ConvToQuadDlg::isWarningShown()
139 {
140   return myWarning->isVisible();
141 }
142
143 void SMESHGUI_ConvToQuadDlg::SetEnabledControls( const bool theCheck )
144 {
145   //myBGBox->setEnabled( theCheck );
146   myRB2Lin->setEnabled( theCheck );
147   myRB2Quad->setEnabled( theCheck );
148   myRB2BiQua->setEnabled( theCheck );
149   myMedNdsOnGeom->setEnabled( theCheck );
150   //setButtonEnabled( theCheck, QtxDialog::OK | QtxDialog::Apply );
151 }
152
153 void SMESHGUI_ConvToQuadDlg::SetEnabledRB( const int idx, const bool theCheck ) 
154 {
155   myRB2Lin  ->setEnabled( idx & SMESHGUI_ConvToQuadOp::Linear );
156   myRB2Quad ->setEnabled( idx & SMESHGUI_ConvToQuadOp::Quadratic );
157   myRB2BiQua->setEnabled( idx & SMESHGUI_ConvToQuadOp::BiQuadratic );
158
159   if ( idx & SMESHGUI_ConvToQuadOp::Linear )
160   {
161     myRB2Lin->setChecked( true );
162     myRB2Quad->setChecked( false );
163   }
164   else
165   {
166     myRB2Lin->setChecked( false );
167     myRB2Quad->setChecked( true );
168   }
169   myRB2BiQua->setChecked( false );
170
171   myMedNdsOnGeom->setEnabled( theCheck );
172
173   emit onClicked( myBG->checkedId() );
174 }