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_SymmetryDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_SymmetryDlg.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_MeshUtils.h"
35 #include "SMESHGUI_IdValidator.h"
36 #include "SMESHGUI_SpinBox.h"
38 #include "SMESH_Actor.h"
39 #include "SMESH_TypeFilter.hxx"
40 #include "SMDS_Mesh.hxx"
42 #include "QAD_Application.h"
43 #include "QAD_Desktop.h"
44 #include "QAD_MessageBox.h"
45 #include "utilities.h"
48 #include <qapplication.h>
49 #include <qbuttongroup.h>
50 #include <qgroupbox.h>
52 #include <qlineedit.h>
53 #include <qpushbutton.h>
54 #include <qradiobutton.h>
55 #include <qcheckbox.h>
60 #include "SALOMEconfig.h"
61 #include CORBA_SERVER_HEADER(SMESH_Group)
65 //=================================================================================
66 // class : SMESHGUI_SymmetryDlg()
68 //=================================================================================
69 SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
70 bool modal, WFlags fl )
71 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
72 Qt::WDestructiveClose)
74 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_POINT")));
75 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_AXIS")));
76 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_PLANE")));
77 QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
80 setName( "SMESHGUI_SymmetryDlg" );
82 setCaption( tr( "SMESH_SYMMETRY" ) );
83 setSizeGripEnabled( TRUE );
84 SMESHGUI_SymmetryDlgLayout = new QGridLayout( this );
85 SMESHGUI_SymmetryDlgLayout->setSpacing( 6 );
86 SMESHGUI_SymmetryDlgLayout->setMargin( 11 );
88 /***************************************************************/
89 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
90 GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
91 GroupConstructors->setTitle( tr( "SMESH_SYMMETRY" ) );
92 GroupConstructors->setExclusive( TRUE );
93 GroupConstructors->setColumnLayout(0, Qt::Vertical );
94 GroupConstructors->layout()->setSpacing( 0 );
95 GroupConstructors->layout()->setMargin( 0 );
96 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
97 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
98 GroupConstructorsLayout->setSpacing( 6 );
99 GroupConstructorsLayout->setMargin( 11 );
100 QHBoxLayout* RBLayout = new QHBoxLayout( 0, 0, 6, "Layout2");
101 RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
102 RadioButton1->setText( tr( "" ) );
103 RadioButton1->setPixmap( image0 );
104 RBLayout->addWidget( RadioButton1);
105 RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" );
106 RadioButton2->setText( tr( "" ) );
107 RadioButton2->setPixmap( image1 );
108 RBLayout->addWidget( RadioButton2);
109 RadioButton3= new QRadioButton( GroupConstructors, "RadioButton3" );
110 RadioButton3->setText( tr( "" ) );
111 RadioButton3->setPixmap( image2 );
112 RBLayout->addWidget( RadioButton3);
113 GroupConstructorsLayout->addLayout( RBLayout, 0, 0 );
114 SMESHGUI_SymmetryDlgLayout->addWidget( GroupConstructors, 0, 0 );
116 /***************************************************************/
117 GroupButtons = new QGroupBox( this, "GroupButtons" );
118 GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
119 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
120 GroupButtons->setTitle( tr( "" ) );
121 GroupButtons->setColumnLayout(0, Qt::Vertical );
122 GroupButtons->layout()->setSpacing( 0 );
123 GroupButtons->layout()->setMargin( 0 );
124 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
125 GroupButtonsLayout->setAlignment( Qt::AlignTop );
126 GroupButtonsLayout->setSpacing( 6 );
127 GroupButtonsLayout->setMargin( 11 );
128 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
129 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
130 buttonCancel->setAutoDefault( TRUE );
131 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
132 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
133 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
134 buttonApply->setAutoDefault( TRUE );
135 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
136 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
137 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
138 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
139 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
140 buttonOk->setAutoDefault( TRUE );
141 buttonOk->setDefault( TRUE );
142 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
143 SMESHGUI_SymmetryDlgLayout->addWidget( GroupButtons, 2, 0 );
145 /***************************************************************/
146 GroupArguments = new QGroupBox( this, "GroupArguments" );
147 GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) );
148 GroupArguments->setColumnLayout(0, Qt::Vertical );
149 GroupArguments->layout()->setSpacing( 0 );
150 GroupArguments->layout()->setMargin( 0 );
151 GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
152 GroupArgumentsLayout->setAlignment( Qt::AlignTop );
153 GroupArgumentsLayout->setSpacing( 6 );
154 GroupArgumentsLayout->setMargin( 11 );
156 // Controls for elements selection
157 TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
158 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
159 TextLabelElements->setFixedWidth(74);
160 GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
162 SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
163 SelectElementsButton->setText( tr( "" ) );
164 SelectElementsButton->setPixmap( image3 );
165 SelectElementsButton->setToggleButton( FALSE );
166 GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
168 LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" );
169 LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
170 GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 );
172 // Control for the whole mesh selection
173 CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" );
174 CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) );
175 GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 2 );
177 // Controls for mirror selection
178 GroupMirror = new QGroupBox( GroupArguments, "GroupMirror" );
179 GroupMirror->setColumnLayout(0, Qt::Vertical );
180 GroupMirror->layout()->setSpacing( 0 );
181 GroupMirror->layout()->setMargin( 0 );
182 QGridLayout* GroupMirrorLayout = new QGridLayout( GroupMirror->layout() );
183 GroupMirrorLayout->setAlignment( Qt::AlignTop );
184 GroupMirrorLayout->setSpacing( 6 );
185 GroupMirrorLayout->setMargin( 11 );
187 TextLabelPoint = new QLabel( GroupMirror, "TextLabelPoint" );
188 TextLabelPoint->setText( tr( "SMESH_POINT" ) );
189 GroupMirrorLayout->addWidget( TextLabelPoint, 0, 0 );
191 SelectPointButton = new QPushButton( GroupMirror, "SelectPointButton" );
192 SelectPointButton->setPixmap( image3 );
193 GroupMirrorLayout->addWidget( SelectPointButton, 0, 1 );
195 TextLabelX = new QLabel( GroupMirror, "TextLabelX" );
196 TextLabelX->setText( tr( "SMESH_X" ) );
197 GroupMirrorLayout->addWidget( TextLabelX, 0, 2 );
199 SpinBox_X = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_X");
200 GroupMirrorLayout->addWidget( SpinBox_X, 0, 3 );
202 TextLabelY = new QLabel( GroupMirror, "TextLabelY" );
203 TextLabelY->setText( tr( "SMESH_Y" ) );
204 GroupMirrorLayout->addWidget( TextLabelY, 0, 4 );
206 SpinBox_Y = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_Y");
207 GroupMirrorLayout->addWidget( SpinBox_Y, 0, 5 );
209 TextLabelZ = new QLabel( GroupMirror, "TextLabelZ" );
210 TextLabelZ->setText( tr( "SMESH_Z" ) );
211 GroupMirrorLayout->addWidget( TextLabelZ, 0, 6 );
213 SpinBox_Z = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_Z");
214 GroupMirrorLayout->addWidget( SpinBox_Z, 0, 7 );
216 TextLabelVector = new QLabel( GroupMirror, "TextLabelVector" );
217 GroupMirrorLayout->addWidget( TextLabelVector, 1, 0 );
219 SelectVectorButton = new QPushButton( GroupMirror, "SelectVectorButton" );
220 SelectVectorButton->setPixmap( image3 );
221 GroupMirrorLayout->addWidget( SelectVectorButton, 1, 1 );
223 TextLabelDX = new QLabel( GroupMirror, "TextLabelDX" );
224 TextLabelDX->setText( tr( "SMESH_DX" ) );
225 GroupMirrorLayout->addWidget( TextLabelDX, 1, 2 );
227 SpinBox_DX = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DX");
228 GroupMirrorLayout->addWidget( SpinBox_DX, 1, 3 );
230 TextLabelDY = new QLabel( GroupMirror, "TextLabelDY" );
231 TextLabelDY->setText( tr( "SMESH_DY" ) );
232 GroupMirrorLayout->addWidget( TextLabelDY, 1, 4 );
234 SpinBox_DY = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DY");
235 GroupMirrorLayout->addWidget( SpinBox_DY, 1, 5 );
237 TextLabelDZ = new QLabel( GroupMirror, "TextLabelDZ" );
238 TextLabelDZ->setText( tr( "SMESH_DZ" ) );
239 GroupMirrorLayout->addWidget( TextLabelDZ, 1, 6 );
241 SpinBox_DZ = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DZ");
242 GroupMirrorLayout->addWidget( SpinBox_DZ, 1, 7 );
244 GroupArgumentsLayout->addMultiCellWidget( GroupMirror, 2, 2, 0, 2 );
246 // Controls for "Create a copy" option
247 CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" );
248 CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) );
249 GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 3, 3, 0, 2 );
252 SMESHGUI_SymmetryDlgLayout->addWidget( GroupArguments, 1, 0 );
254 /* Initialisations */
255 SpinBox_X->RangeStepAndValidator ( COORD_MIN, COORD_MAX, 10.0, 3 );
256 SpinBox_Y->RangeStepAndValidator ( COORD_MIN, COORD_MAX, 10.0, 3 );
257 SpinBox_Z->RangeStepAndValidator ( COORD_MIN, COORD_MAX, 10.0, 3 );
258 SpinBox_DX->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
259 SpinBox_DY->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
260 SpinBox_DZ->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
262 GroupArguments->show();
263 RadioButton1->setChecked( TRUE );
266 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
267 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
269 // Costruction of the logical filter
270 SMESH_ListOfFilter aListOfFilters;
271 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
272 if ( !aMeshOrSubMeshFilter.IsNull() )
273 aListOfFilters.Append( aMeshOrSubMeshFilter );
274 Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
275 if ( !aSmeshGroupFilter.IsNull() )
276 aListOfFilters.Append( aSmeshGroupFilter );
278 myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
281 /* signals and slots connections */
282 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
283 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
284 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
285 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
287 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
288 connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
289 connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
291 connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
292 connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
293 connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
295 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
296 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
297 /* to close dialog if study change */
298 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
299 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
300 SLOT( onTextChange( const QString& )));
301 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
302 SLOT( onSelectMesh( bool )));
304 /* Move widget on the botton right corner of main widget */
306 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
308 this->show() ; /* displays Dialog */
310 ConstructorsClicked(0);
314 //=================================================================================
315 // function : ~SMESHGUI_SymmetryDlg()
316 // purpose : Destroys the object and frees any allocated resources
317 //=================================================================================
318 SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg()
320 // no need to delete child widgets, Qt does it all for us
324 //=================================================================================
327 //=================================================================================
328 void SMESHGUI_SymmetryDlg::Init( bool ResetControls )
332 myEditCurrentArgument = 0;
333 LineEditElements->clear();
337 buttonOk->setEnabled( false );
338 buttonApply->setEnabled( false );
341 myMesh = SMESH::SMESH_Mesh::_nil();
345 SpinBox_X->SetValue(0.0);
346 SpinBox_Y->SetValue(0.0);
347 SpinBox_Z->SetValue(0.0);
348 SpinBox_DX->SetValue(0.0);
349 SpinBox_DY->SetValue(0.0);
350 SpinBox_DZ->SetValue(0.0);
352 CheckBoxCopy->setChecked(false);
353 CheckBoxMesh->setChecked(false);
354 onSelectMesh( false );
359 //=================================================================================
360 // function : ConstructorsClicked()
361 // purpose : Radio button management
362 //=================================================================================
363 void SMESHGUI_SymmetryDlg::ConstructorsClicked(int constructorId)
365 disconnect(mySelection, 0, this, 0);
367 if (constructorId!=0 && !TextLabelVector->isVisible())
369 TextLabelVector->show();
370 SelectVectorButton->show();
379 switch(constructorId)
383 GroupMirror->setTitle( tr( "SMESH_POINT" ) );
385 TextLabelVector->hide();
386 SelectVectorButton->hide();
397 GroupMirror->setTitle( tr( "SMESH_AXIS" ) );
398 TextLabelVector->setText( tr( "SMESH_VECTOR" ) );
403 GroupMirror->setTitle( tr( "SMESH_PLANE" ) );
404 TextLabelVector->setText( tr( "SMESH_NORMAL" ) );
409 if (myEditCurrentArgument != (QWidget*)LineEditElements)
411 SMESH::SetPointRepresentation(false);
412 if (!CheckBoxMesh->isChecked())
413 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
416 myEditCurrentArgument = (QWidget*)LineEditElements;
417 LineEditElements->setFocus();
419 if (CheckBoxMesh->isChecked())
422 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
426 //=================================================================================
427 // function : ClickOnApply()
429 //=================================================================================
430 void SMESHGUI_SymmetryDlg::ClickOnApply()
432 if (mySMESHGUI->ActiveStudyLocked())
435 if ( myNbOkElements && IsMirrorOk() )
437 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
439 SMESH::long_array_var anElementsId = new SMESH::long_array;
441 anElementsId->length( aListElementsId.count() );
442 for ( int i = 0; i < aListElementsId.count(); i++ )
443 anElementsId[i] = aListElementsId[i].toInt();
445 SMESH::AxisStruct aMirror;
447 aMirror.x = SpinBox_X->GetValue();
448 aMirror.y = SpinBox_Y->GetValue();
449 aMirror.z = SpinBox_Z->GetValue();
450 if (GetConstructorId() == 0)
451 aMirror.vx = aMirror.vy = aMirror.vz = 0;
454 aMirror.vx = SpinBox_DX->GetValue();
455 aMirror.vy = SpinBox_DY->GetValue();
456 aMirror.vz = SpinBox_DZ->GetValue();
459 bool toCreateCopy = CheckBoxCopy->isChecked();
461 SMESH::SMESH_MeshEditor::MirrorType aMirrorType;
463 if (GetConstructorId() == 0)
464 aMirrorType = SMESH::SMESH_MeshEditor::POINT;
465 if (GetConstructorId() == 1)
466 aMirrorType = SMESH::SMESH_MeshEditor::AXIS;
467 if (GetConstructorId() == 2)
468 aMirrorType = SMESH::SMESH_MeshEditor::PLANE;
472 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
473 QApplication::setOverrideCursor(Qt::waitCursor);
474 aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, toCreateCopy);
475 QApplication::restoreOverrideCursor();
481 mySelection->ClearIObjects();
484 ConstructorsClicked( GetConstructorId() );
488 //=================================================================================
489 // function : ClickOnOk()
491 //=================================================================================
492 void SMESHGUI_SymmetryDlg::ClickOnOk()
499 //=================================================================================
500 // function : ClickOnCancel()
502 //=================================================================================
503 void SMESHGUI_SymmetryDlg::ClickOnCancel()
505 mySelection->ClearFilters();
506 mySelection->ClearIObjects();
507 SMESH::SetPointRepresentation(false);
508 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
509 disconnect( mySelection, 0, this, 0 );
510 mySMESHGUI->ResetState() ;
514 //=======================================================================
515 //function : onTextChange
517 //=======================================================================
519 void SMESHGUI_SymmetryDlg::onTextChange(const QString& theNewText)
521 QLineEdit* send = (QLineEdit*)sender();
523 if ( myBusy ) return;
526 if (send == LineEditElements)
529 buttonOk->setEnabled( false );
530 buttonApply->setEnabled( false );
532 // hilight entered elements
533 SMDS_Mesh* aMesh = 0;
535 aMesh = myActor->GetObject()->GetMesh();
539 mySelection->ClearIObjects();
540 mySelection->AddIObject( myActor->getIO() );
542 QStringList aListId = QStringList::split( " ", theNewText, false);
544 if (send == LineEditElements) {
545 for ( int i = 0; i < aListId.count(); i++ ) {
546 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
548 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
549 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
553 myElementsId = theNewText;
557 if ( myNbOkElements && IsMirrorOk() ) {
558 buttonOk->setEnabled( true );
559 buttonApply->setEnabled( true );
565 //=================================================================================
566 // function : SelectionIntoArgument()
567 // purpose : Called when selection as changed or other case
568 //=================================================================================
569 void SMESHGUI_SymmetryDlg::SelectionIntoArgument()
571 if ( myBusy ) return;
576 QString aString = "";
579 if (myEditCurrentArgument == (QWidget*)LineEditElements)
581 LineEditElements->setText( aString );
583 buttonOk->setEnabled( false );
584 buttonApply->setEnabled( false );
588 if ( !GroupButtons->isEnabled() ) // inactive
592 int nbSel = mySelection->IObjectCount();
596 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
597 myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() );
598 if(myMesh->_is_nil())
601 myActor = SMESH::FindActorByObject(myMesh);
603 myActor = SMESH::FindActorByEntry(IO->getEntry());
609 if (myEditCurrentArgument == (QWidget*)LineEditElements)
613 if (CheckBoxMesh->isChecked())
615 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
617 if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH
620 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
624 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ )
626 const SMDS_MeshElement * e = aSMDSMesh->FindElement( i );
628 myElementsId += QString(" %1").arg(i);
633 else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
636 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
638 // get IDs from submesh
639 SMESH::long_array_var anElementsIds = new SMESH::long_array;
640 anElementsIds = aSubMesh->GetElementsId();
641 for ( int i = 0; i < anElementsIds->length(); i++ )
642 myElementsId += QString(" %1").arg(anElementsIds[i]);
643 aNbUnits = anElementsIds->length();
648 SMESH::SMESH_GroupBase_var aGroup
649 = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
650 if (aGroup->_is_nil())
653 // get IDs from smesh group
654 SMESH::long_array_var anElementsIds = new SMESH::long_array;
655 anElementsIds = aGroup->GetListOfID();
656 for ( int i = 0; i < anElementsIds->length(); i++ )
657 myElementsId += QString(" %1").arg(anElementsIds[i]);
658 aNbUnits = anElementsIds->length();
663 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
664 myElementsId = aString;
670 myNbOkElements = true;
674 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
678 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
682 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
690 if (myEditCurrentArgument == (QWidget*)SpinBox_X)
692 SpinBox_X->SetValue(x);
693 SpinBox_Y->SetValue(y);
694 SpinBox_Z->SetValue(z);
696 else if (myEditCurrentArgument == (QWidget*)SpinBox_DX)
698 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
699 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
700 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
705 if (myEditCurrentArgument == (QWidget*)LineEditElements)
706 LineEditElements->setText( aString );
710 if(myNbOkElements && IsMirrorOk())
712 buttonOk->setEnabled( true );
713 buttonApply->setEnabled( true );
718 //=================================================================================
719 // function : SetEditCurrentArgument()
721 //=================================================================================
722 void SMESHGUI_SymmetryDlg::SetEditCurrentArgument()
724 QPushButton* send = (QPushButton*)sender();
726 disconnect( mySelection, 0, this, 0 );
727 mySelection->ClearIObjects();
728 mySelection->ClearFilters();
730 if(send == SelectElementsButton) {
731 myEditCurrentArgument = (QWidget*)LineEditElements;
732 SMESH::SetPointRepresentation(false);
733 if (CheckBoxMesh->isChecked())
735 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
736 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
739 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
741 else if (send == SelectPointButton)
743 myEditCurrentArgument = (QWidget*)SpinBox_X;
744 SMESH::SetPointRepresentation(true);
745 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
747 else if (send == SelectVectorButton)
749 myEditCurrentArgument = (QWidget*)SpinBox_DX;
750 SMESH::SetPointRepresentation(true);
751 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
754 myEditCurrentArgument->setFocus();
755 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
756 SelectionIntoArgument() ;
759 //=================================================================================
760 // function : DeactivateActiveDialog()
762 //=================================================================================
763 void SMESHGUI_SymmetryDlg::DeactivateActiveDialog()
765 if ( GroupConstructors->isEnabled() ) {
766 GroupConstructors->setEnabled(false) ;
767 GroupArguments->setEnabled(false) ;
768 GroupButtons->setEnabled(false) ;
769 mySMESHGUI->ResetState() ;
770 mySMESHGUI->SetActiveDialogBox(0) ;
775 //=================================================================================
776 // function : ActivateThisDialog()
778 //=================================================================================
779 void SMESHGUI_SymmetryDlg::ActivateThisDialog()
781 /* Emit a signal to deactivate the active dialog */
782 mySMESHGUI->EmitSignalDeactivateDialog() ;
783 GroupConstructors->setEnabled(true) ;
784 GroupArguments->setEnabled(true) ;
785 GroupButtons->setEnabled(true) ;
787 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
789 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
790 SelectionIntoArgument();
794 //=================================================================================
795 // function : enterEvent()
797 //=================================================================================
798 void SMESHGUI_SymmetryDlg::enterEvent(QEvent* e)
800 if ( GroupConstructors->isEnabled() )
802 ActivateThisDialog() ;
806 //=================================================================================
807 // function : closeEvent()
809 //=================================================================================
810 void SMESHGUI_SymmetryDlg::closeEvent( QCloseEvent* e )
812 /* same than click on cancel button */
813 this->ClickOnCancel() ;
817 //=======================================================================
818 //function : hideEvent
819 //purpose : caused by ESC key
820 //=======================================================================
822 void SMESHGUI_SymmetryDlg::hideEvent ( QHideEvent * e )
824 if ( !isMinimized() )
829 //=======================================================================
830 //function : onSelectMesh
832 //=======================================================================
833 void SMESHGUI_SymmetryDlg::onSelectMesh ( bool toSelectMesh )
836 TextLabelElements->setText( tr( "SMESH_NAME" ) );
838 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
840 if (myEditCurrentArgument != LineEditElements)
842 LineEditElements->clear();
846 mySelection->ClearFilters() ;
847 SMESH::SetPointRepresentation(false);
851 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
852 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
853 LineEditElements->setReadOnly(true);
857 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
858 LineEditElements->setReadOnly(false);
859 onTextChange(LineEditElements->text());
862 SelectionIntoArgument();
866 //=================================================================================
867 // function : GetConstructorId()
869 //=================================================================================
870 int SMESHGUI_SymmetryDlg::GetConstructorId()
872 if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
873 return GroupConstructors->id( GroupConstructors->selected() );
878 //=================================================================================
879 // function : IsAxisOk()
881 //=================================================================================
882 bool SMESHGUI_SymmetryDlg::IsMirrorOk()
886 if (GetConstructorId() != 0)
887 isOk = SpinBox_DX->GetValue() != 0 || SpinBox_DY->GetValue() != 0 || SpinBox_DZ->GetValue() != 0;
893 //=================================================================================
894 // function : onVectorChanged()
896 //=================================================================================
897 void SMESHGUI_SymmetryDlg::onVectorChanged()
901 buttonOk->setEnabled( true );
902 buttonApply->setEnabled( true );
906 buttonOk->setEnabled( false );
907 buttonApply->setEnabled( false );