1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESHGUI_ExtrusionDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_ExtrusionDlg.h"
30 #include <SMESHGUI_SpinBox.h>
32 #include <SUIT_ResourceMgr.h>
34 #include <SMDSAbs_ElementType.hxx>
35 #include <SMESH_Type.h>
37 #include <qcheckbox.h>
38 #include <qvalidator.h>
41 #include <qgroupbox.h>
42 #include <qbuttongroup.h>
43 #include <qradiobutton.h>
45 //=================================================================================
46 // function : SMESHGUI_ExtrusionDlg()
47 // purpose : constructor
48 //=================================================================================
49 SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg()
50 : SMESHGUI_Dialog( 0, false, true, OK | Apply | Close )
52 QPixmap image0( resMgr()->loadPixmap( "SMESH", tr( "ICON_DLG_EDGE") ) ),
53 image1( resMgr()->loadPixmap( "SMESH", tr( "ICON_DLG_TRIANGLE") ) );
56 setCaption(tr("EXTRUSION_ALONG_LINE"));
58 QVBoxLayout* main = new QVBoxLayout( mainFrame() );
60 /***************************************************************/
61 myGroupConstructors = new QButtonGroup("GroupConstructors", mainFrame() );
62 myGroupConstructors->setTitle(tr("SMESH_EXTRUSION"));
63 myGroupConstructors->setExclusive(TRUE);
64 myGroupConstructors->setColumnLayout(0, Qt::Vertical);
65 myGroupConstructors->layout()->setSpacing(0);
66 myGroupConstructors->layout()->setMargin(0);
67 QGridLayout* GroupConstructorsLayout = new QGridLayout(myGroupConstructors->layout());
68 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
69 GroupConstructorsLayout->setSpacing(6);
70 GroupConstructorsLayout->setMargin(11);
71 QRadioButton* RadioButton1 = new QRadioButton(myGroupConstructors, "RadioButton1");
72 RadioButton1->setText(tr(""));
73 RadioButton1->setPixmap(image0);
74 GroupConstructorsLayout->addWidget(RadioButton1, 0, 0);
75 QRadioButton* RadioButton2 = new QRadioButton(myGroupConstructors, "RadioButton2");
76 RadioButton2->setText(tr(""));
77 RadioButton2->setPixmap(image1);
78 GroupConstructorsLayout->addWidget(RadioButton2, 0, 2);
79 main->addWidget(myGroupConstructors);
81 /***************************************************************/
82 myGroupArguments = new QGroupBox( mainFrame(), "GroupArguments");
83 myGroupArguments->setTitle(tr("EXTRUSION_1D"));
84 myGroupArguments->setColumnLayout( 1, Qt::Horizontal );
85 myGroupArguments->layout()->setSpacing(0);
86 myGroupArguments->layout()->setMargin(11);
88 QGroupBox* sel = new QGroupBox( myGroupArguments );
89 sel->setColumnLayout( 3, Qt::Horizontal );
90 sel->setFrameShape( QFrame::NoFrame );
91 sel->layout()->setSpacing(0);
92 sel->layout()->setMargin(0);
94 // Controls for elements selection
95 createObject( tr( "SMESH_ID_ELEMENTS" ), sel, 0 );
96 createObject( tr( "SMESH_NAME" ), sel, 1 );
98 int epr = prefix( "SMESH element" );
99 setObjectType( 0, epr + SMDSAbs_Edge, epr + SMDSAbs_Face, -1 );
100 setNameIndication( 0, ListOfNames );
101 setReadOnly( 0, false );
102 int mpr = prefix( "SMESH" );
103 setObjectType( 1, mpr + MESH, mpr + SUBMESH, mpr + SUBMESH_EDGE, mpr + GROUP, -1 );
104 setNameIndication( 1, OneName );
106 QGroupBox* box1 = new QGroupBox( myGroupArguments );
107 box1->setColumnLayout( 1, Qt::Vertical );
108 box1->setFrameShape( QFrame::NoFrame );
109 box1->layout()->setSpacing(0);
110 box1->layout()->setMargin(0);
112 // Control for the whole mesh selection
113 myCheckBoxMesh = new QCheckBox( box1, "CheckBoxMesh" );
114 myCheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
116 QGroupBox* box2 = new QGroupBox( myGroupArguments );
117 box2->setColumnLayout( 1, Qt::Vertical );
118 box2->setFrameShape( QFrame::NoFrame );
119 box2->layout()->setSpacing(0);
120 box2->layout()->setMargin(0);
122 // Controls for vector selection
123 QLabel* TextLabelVector = new QLabel( box2, "TextLabelVector" );
124 TextLabelVector->setText( tr( "SMESH_VECTOR" ) );
126 QLabel* TextLabelDx = new QLabel( box2, "TextLabelDx" );
127 TextLabelDx->setText(tr("SMESH_DX"));
129 myDx = new SMESHGUI_SpinBox( box2, "SpinBox_Dx" );
131 QLabel* TextLabelDy = new QLabel( box2, "TextLabelDy" );
132 TextLabelDy->setText(tr("SMESH_DY"));
134 myDy = new SMESHGUI_SpinBox( box2, "SpinBox_Dy" );
136 QLabel* TextLabelDz = new QLabel( box2, "TextLabelDz" );
137 TextLabelDz->setText(tr("SMESH_DZ"));
139 myDz = new SMESHGUI_SpinBox( box2, "SpinBox_Dz" );
141 QGroupBox* box3 = new QGroupBox( myGroupArguments );
142 box3->setColumnLayout( 1, Qt::Vertical );
143 box3->setFrameShape( QFrame::NoFrame );
144 box3->layout()->setSpacing(0);
145 box3->layout()->setMargin(0);
147 // Controls for nb. steps defining
148 QLabel* TextLabelNbSteps = new QLabel( box3, "TextLabelNbSteps" );
149 TextLabelNbSteps->setText(tr("SMESH_NUMBEROFSTEPS" ));
151 myNbSteps = new QSpinBox( box3, "SpinBox_NbSteps" );
153 main->addWidget( myGroupArguments );
155 /* Initialisations */
156 myDx->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
157 myDy->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
158 myDz->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
160 QIntValidator* anIntValidator = new QIntValidator( myNbSteps );
161 myNbSteps->setValidator( anIntValidator );
162 myNbSteps->setRange( 1, 999999 );
164 connect( myGroupConstructors, SIGNAL( clicked( int ) ), this, SLOT ( onConstructorsClicked( int ) ) );
165 connect( myGroupConstructors, SIGNAL( clicked( int ) ), this, SIGNAL( constructorClicked( int ) ) );
166 connect( myCheckBoxMesh, SIGNAL( toggled( bool ) ), this, SLOT ( onSelectMesh( bool ) ) );
169 //=================================================================================
170 // function : ~SMESHGUI_ExtrusionDlg()
171 // purpose : destructor
172 //=================================================================================
173 SMESHGUI_ExtrusionDlg::~SMESHGUI_ExtrusionDlg()
177 //=================================================================================
178 // function : onConstructorsClicked()
179 // purpose : Radio button management
180 //=================================================================================
181 void SMESHGUI_ExtrusionDlg::onConstructorsClicked( int id )
183 myGroupArguments->setTitle( tr( QString( "EXTRUSION_%1D" ).arg( id+1 ) ) );
184 int mpr = prefix( "SMESH" );
185 setObjectType( 1, mpr + MESH, mpr + SUBMESH, mpr + ( id==0 ? SUBMESH_EDGE : SUBMESH_FACE ), mpr + GROUP, -1 );
189 //=================================================================================
190 // function : onSelectMesh()
192 //=================================================================================
193 void SMESHGUI_ExtrusionDlg::onSelectMesh( bool toSelectMesh )
195 setObjectShown( 0, !toSelectMesh );
196 setObjectShown( 1, toSelectMesh );
200 //=================================================================================
201 // function : constructorId()
203 //=================================================================================
204 int SMESHGUI_ExtrusionDlg::constructorId() const
206 if( myGroupConstructors && myGroupConstructors->selected() )
207 return myGroupConstructors->id( myGroupConstructors->selected() );
212 //=================================================================================
215 //=================================================================================
216 void SMESHGUI_ExtrusionDlg::init()
218 myGroupConstructors->setButton( 0 );
219 myCheckBoxMesh->setChecked( false );
220 onSelectMesh( false );
221 myDx->setValue( 0.0 );
222 myDy->setValue( 0.0 );
223 myDz->setValue( 0.0 );
226 //=================================================================================
227 // function : coords()
229 //=================================================================================
230 void SMESHGUI_ExtrusionDlg::coords( double& x, double& y, double& z ) const
237 //=================================================================================
238 // function : nbStep()
240 //=================================================================================
241 int SMESHGUI_ExtrusionDlg::nbStep() const
243 return myNbSteps->value();
246 //=================================================================================
247 // function : isSelectMesh()
249 //=================================================================================
250 bool SMESHGUI_ExtrusionDlg::isSelectMesh() const
252 return myCheckBoxMesh->isChecked();