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"
37 #include "SMESH_Actor.h"
38 #include "SMESH_TypeFilter.hxx"
39 #include "SMDS_Mesh.hxx"
41 #include "QAD_Application.h"
42 #include "QAD_Desktop.h"
43 #include "QAD_MessageBox.h"
44 #include "utilities.h"
47 #include <qapplication.h>
48 #include <qbuttongroup.h>
49 #include <qgroupbox.h>
51 #include <qlineedit.h>
52 #include <qpushbutton.h>
53 #include <qradiobutton.h>
54 #include <qcheckbox.h>
60 //=================================================================================
61 // class : SMESHGUI_SymmetryDlg()
63 //=================================================================================
64 SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
65 bool modal, WFlags fl )
66 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
67 Qt::WDestructiveClose)
69 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_POINT")));
70 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_AXIS")));
71 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_PLANE")));
72 QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
75 setName( "SMESHGUI_SymmetryDlg" );
77 setCaption( tr( "SMESH_SYMMETRY" ) );
78 setSizeGripEnabled( TRUE );
79 SMESHGUI_SymmetryDlgLayout = new QGridLayout( this );
80 SMESHGUI_SymmetryDlgLayout->setSpacing( 6 );
81 SMESHGUI_SymmetryDlgLayout->setMargin( 11 );
83 /***************************************************************/
84 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
85 GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
86 GroupConstructors->setTitle( tr( "SMESH_SYMMETRY" ) );
87 GroupConstructors->setExclusive( TRUE );
88 GroupConstructors->setColumnLayout(0, Qt::Vertical );
89 GroupConstructors->layout()->setSpacing( 0 );
90 GroupConstructors->layout()->setMargin( 0 );
91 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
92 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
93 GroupConstructorsLayout->setSpacing( 6 );
94 GroupConstructorsLayout->setMargin( 11 );
95 QHBoxLayout* RBLayout = new QHBoxLayout( 0, 0, 6, "Layout2");
96 RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
97 RadioButton1->setText( tr( "" ) );
98 RadioButton1->setPixmap( image0 );
99 RBLayout->addWidget( RadioButton1);
100 RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" );
101 RadioButton2->setText( tr( "" ) );
102 RadioButton2->setPixmap( image1 );
103 RBLayout->addWidget( RadioButton2);
104 RadioButton3= new QRadioButton( GroupConstructors, "RadioButton3" );
105 RadioButton3->setText( tr( "" ) );
106 RadioButton3->setPixmap( image2 );
107 RBLayout->addWidget( RadioButton3);
108 GroupConstructorsLayout->addLayout( RBLayout, 0, 0 );
109 SMESHGUI_SymmetryDlgLayout->addWidget( GroupConstructors, 0, 0 );
111 /***************************************************************/
112 GroupButtons = new QGroupBox( this, "GroupButtons" );
113 GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
114 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
115 GroupButtons->setTitle( tr( "" ) );
116 GroupButtons->setColumnLayout(0, Qt::Vertical );
117 GroupButtons->layout()->setSpacing( 0 );
118 GroupButtons->layout()->setMargin( 0 );
119 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
120 GroupButtonsLayout->setAlignment( Qt::AlignTop );
121 GroupButtonsLayout->setSpacing( 6 );
122 GroupButtonsLayout->setMargin( 11 );
123 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
124 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
125 buttonCancel->setAutoDefault( TRUE );
126 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
127 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
128 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
129 buttonApply->setAutoDefault( TRUE );
130 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
131 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
132 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
133 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
134 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
135 buttonOk->setAutoDefault( TRUE );
136 buttonOk->setDefault( TRUE );
137 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
138 SMESHGUI_SymmetryDlgLayout->addWidget( GroupButtons, 2, 0 );
140 /***************************************************************/
141 GroupArguments = new QGroupBox( this, "GroupArguments" );
142 GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) );
143 GroupArguments->setColumnLayout(0, Qt::Vertical );
144 GroupArguments->layout()->setSpacing( 0 );
145 GroupArguments->layout()->setMargin( 0 );
146 GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
147 GroupArgumentsLayout->setAlignment( Qt::AlignTop );
148 GroupArgumentsLayout->setSpacing( 6 );
149 GroupArgumentsLayout->setMargin( 11 );
151 // Controls for elements selection
152 TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
153 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
154 TextLabelElements->setFixedWidth(74);
155 GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
157 SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
158 SelectElementsButton->setText( tr( "" ) );
159 SelectElementsButton->setPixmap( image3 );
160 SelectElementsButton->setToggleButton( FALSE );
161 GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
163 LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" );
164 LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
165 GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 );
167 // Control for the whole mesh selection
168 CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" );
169 CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) );
170 GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 2 );
172 // Controls for mirror selection
173 GroupMirror = new QGroupBox( GroupArguments, "GroupMirror" );
174 GroupMirror->setColumnLayout(0, Qt::Vertical );
175 GroupMirror->layout()->setSpacing( 0 );
176 GroupMirror->layout()->setMargin( 0 );
177 QGridLayout* GroupMirrorLayout = new QGridLayout( GroupMirror->layout() );
178 GroupMirrorLayout->setAlignment( Qt::AlignTop );
179 GroupMirrorLayout->setSpacing( 6 );
180 GroupMirrorLayout->setMargin( 11 );
182 TextLabelPoint = new QLabel( GroupMirror, "TextLabelPoint" );
183 TextLabelPoint->setText( tr( "SMESH_POINT" ) );
184 GroupMirrorLayout->addWidget( TextLabelPoint, 0, 0 );
186 SelectPointButton = new QPushButton( GroupMirror, "SelectPointButton" );
187 SelectPointButton->setPixmap( image3 );
188 GroupMirrorLayout->addWidget( SelectPointButton, 0, 1 );
190 TextLabelX = new QLabel( GroupMirror, "TextLabelX" );
191 TextLabelX->setText( tr( "SMESH_X" ) );
192 GroupMirrorLayout->addWidget( TextLabelX, 0, 2 );
194 SpinBox_X = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_X");
195 GroupMirrorLayout->addWidget( SpinBox_X, 0, 3 );
197 TextLabelY = new QLabel( GroupMirror, "TextLabelY" );
198 TextLabelY->setText( tr( "SMESH_Y" ) );
199 GroupMirrorLayout->addWidget( TextLabelY, 0, 4 );
201 SpinBox_Y = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_Y");
202 GroupMirrorLayout->addWidget( SpinBox_Y, 0, 5 );
204 TextLabelZ = new QLabel( GroupMirror, "TextLabelZ" );
205 TextLabelZ->setText( tr( "SMESH_Z" ) );
206 GroupMirrorLayout->addWidget( TextLabelZ, 0, 6 );
208 SpinBox_Z = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_Z");
209 GroupMirrorLayout->addWidget( SpinBox_Z, 0, 7 );
211 TextLabelVector = new QLabel( GroupMirror, "TextLabelVector" );
212 GroupMirrorLayout->addWidget( TextLabelVector, 1, 0 );
214 SelectVectorButton = new QPushButton( GroupMirror, "SelectVectorButton" );
215 SelectVectorButton->setPixmap( image3 );
216 GroupMirrorLayout->addWidget( SelectVectorButton, 1, 1 );
218 TextLabelDX = new QLabel( GroupMirror, "TextLabelDX" );
219 TextLabelDX->setText( tr( "SMESH_DX" ) );
220 GroupMirrorLayout->addWidget( TextLabelDX, 1, 2 );
222 SpinBox_DX = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DX");
223 GroupMirrorLayout->addWidget( SpinBox_DX, 1, 3 );
225 TextLabelDY = new QLabel( GroupMirror, "TextLabelDY" );
226 TextLabelDY->setText( tr( "SMESH_DY" ) );
227 GroupMirrorLayout->addWidget( TextLabelDY, 1, 4 );
229 SpinBox_DY = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DY");
230 GroupMirrorLayout->addWidget( SpinBox_DY, 1, 5 );
232 TextLabelDZ = new QLabel( GroupMirror, "TextLabelDZ" );
233 TextLabelDZ->setText( tr( "SMESH_DZ" ) );
234 GroupMirrorLayout->addWidget( TextLabelDZ, 1, 6 );
236 SpinBox_DZ = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DZ");
237 GroupMirrorLayout->addWidget( SpinBox_DZ, 1, 7 );
239 GroupArgumentsLayout->addMultiCellWidget( GroupMirror, 2, 2, 0, 2 );
241 // Controls for "Create a copy" option
242 CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" );
243 CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) );
244 GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 3, 3, 0, 2 );
247 SMESHGUI_SymmetryDlgLayout->addWidget( GroupArguments, 1, 0 );
249 /* Initialisations */
250 SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
251 SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
252 SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
253 SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
254 SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
255 SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
257 GroupArguments->show();
258 RadioButton1->setChecked( TRUE );
261 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
262 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
264 // Costruction of the logical filter
265 SMESH_ListOfFilter aListOfFilters;
266 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
267 if ( !aMeshOrSubMeshFilter.IsNull() )
268 aListOfFilters.Append( aMeshOrSubMeshFilter );
269 Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
270 if ( !aSmeshGroupFilter.IsNull() )
271 aListOfFilters.Append( aSmeshGroupFilter );
273 myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
276 /* signals and slots connections */
277 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
278 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
279 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
280 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
282 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
283 connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
284 connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
286 connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
287 connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
288 connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
290 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
291 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
292 /* to close dialog if study change */
293 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
294 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
295 SLOT( onTextChange( const QString& )));
296 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
297 SLOT( onSelectMesh( bool )));
299 /* Move widget on the botton right corner of main widget */
301 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
303 this->show() ; /* displays Dialog */
305 ConstructorsClicked(0);
309 //=================================================================================
310 // function : ~SMESHGUI_SymmetryDlg()
311 // purpose : Destroys the object and frees any allocated resources
312 //=================================================================================
313 SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg()
315 // no need to delete child widgets, Qt does it all for us
319 //=================================================================================
322 //=================================================================================
323 void SMESHGUI_SymmetryDlg::Init( bool ResetControls )
327 myEditCurrentArgument = 0;
328 LineEditElements->clear();
332 buttonOk->setEnabled( false );
333 buttonApply->setEnabled( false );
336 myMesh = SMESH::SMESH_Mesh::_nil();
340 SpinBox_X->SetValue(0.0);
341 SpinBox_Y->SetValue(0.0);
342 SpinBox_Z->SetValue(0.0);
343 SpinBox_DX->SetValue(0.0);
344 SpinBox_DY->SetValue(0.0);
345 SpinBox_DZ->SetValue(0.0);
347 CheckBoxCopy->setChecked(false);
348 CheckBoxMesh->setChecked(false);
349 onSelectMesh( false );
354 //=================================================================================
355 // function : ConstructorsClicked()
356 // purpose : Radio button management
357 //=================================================================================
358 void SMESHGUI_SymmetryDlg::ConstructorsClicked(int constructorId)
360 disconnect(mySelection, 0, this, 0);
362 if (constructorId!=0 && !TextLabelVector->isVisible())
364 TextLabelVector->show();
365 SelectVectorButton->show();
374 switch(constructorId)
378 GroupMirror->setTitle( tr( "SMESH_POINT" ) );
380 TextLabelVector->hide();
381 SelectVectorButton->hide();
392 GroupMirror->setTitle( tr( "SMESH_AXIS" ) );
393 TextLabelVector->setText( tr( "SMESH_VECTOR" ) );
398 GroupMirror->setTitle( tr( "SMESH_PLANE" ) );
399 TextLabelVector->setText( tr( "SMESH_NORMAL" ) );
404 if (myEditCurrentArgument != (QWidget*)LineEditElements)
406 SMESH::SetPointRepresentation(false);
407 if (!CheckBoxMesh->isChecked())
408 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
411 myEditCurrentArgument = (QWidget*)LineEditElements;
412 LineEditElements->setFocus();
414 if (CheckBoxMesh->isChecked())
417 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
421 //=================================================================================
422 // function : ClickOnApply()
424 //=================================================================================
425 void SMESHGUI_SymmetryDlg::ClickOnApply()
427 if (mySMESHGUI->ActiveStudyLocked())
430 if ( myNbOkElements && IsMirrorOk() )
432 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
434 SMESH::long_array_var anElementsId = new SMESH::long_array;
436 anElementsId->length( aListElementsId.count() );
437 for ( int i = 0; i < aListElementsId.count(); i++ )
438 anElementsId[i] = aListElementsId[i].toInt();
440 SMESH::AxisStruct aMirror;
442 aMirror.x = SpinBox_X->GetValue();
443 aMirror.y = SpinBox_Y->GetValue();
444 aMirror.z = SpinBox_Z->GetValue();
445 if (GetConstructorId() == 0)
446 aMirror.vx = aMirror.vy = aMirror.vz = 0;
449 aMirror.vx = SpinBox_DX->GetValue();
450 aMirror.vy = SpinBox_DY->GetValue();
451 aMirror.vz = SpinBox_DZ->GetValue();
454 bool toCreateCopy = CheckBoxCopy->isChecked();
456 SMESH::SMESH_MeshEditor::MirrorType aMirrorType;
458 if (GetConstructorId() == 0)
459 aMirrorType = SMESH::SMESH_MeshEditor::POINT;
460 if (GetConstructorId() == 1)
461 aMirrorType = SMESH::SMESH_MeshEditor::AXIS;
462 if (GetConstructorId() == 2)
463 aMirrorType = SMESH::SMESH_MeshEditor::PLANE;
467 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
468 QApplication::setOverrideCursor(Qt::waitCursor);
469 aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, toCreateCopy);
470 QApplication::restoreOverrideCursor();
476 mySelection->ClearIObjects();
479 ConstructorsClicked( GetConstructorId() );
483 //=================================================================================
484 // function : ClickOnOk()
486 //=================================================================================
487 void SMESHGUI_SymmetryDlg::ClickOnOk()
494 //=================================================================================
495 // function : ClickOnCancel()
497 //=================================================================================
498 void SMESHGUI_SymmetryDlg::ClickOnCancel()
500 mySelection->ClearFilters();
501 mySelection->ClearIObjects();
502 SMESH::SetPointRepresentation(false);
503 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
504 disconnect( mySelection, 0, this, 0 );
505 mySMESHGUI->ResetState() ;
509 //=======================================================================
510 //function : onTextChange
512 //=======================================================================
514 void SMESHGUI_SymmetryDlg::onTextChange(const QString& theNewText)
516 QLineEdit* send = (QLineEdit*)sender();
518 if ( myBusy ) return;
521 if (send == LineEditElements)
524 buttonOk->setEnabled( false );
525 buttonApply->setEnabled( false );
527 // hilight entered elements
528 SMDS_Mesh* aMesh = 0;
530 aMesh = myActor->GetObject()->GetMesh();
534 mySelection->ClearIObjects();
535 mySelection->AddIObject( myActor->getIO() );
537 QStringList aListId = QStringList::split( " ", theNewText, false);
539 if (send == LineEditElements) {
540 for ( int i = 0; i < aListId.count(); i++ ) {
541 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
543 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
544 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
548 myElementsId = theNewText;
552 if ( myNbOkElements && IsMirrorOk() ) {
553 buttonOk->setEnabled( true );
554 buttonApply->setEnabled( true );
560 //=================================================================================
561 // function : SelectionIntoArgument()
562 // purpose : Called when selection as changed or other case
563 //=================================================================================
564 void SMESHGUI_SymmetryDlg::SelectionIntoArgument()
566 if ( myBusy ) return;
571 QString aString = "";
574 if (myEditCurrentArgument == (QWidget*)LineEditElements)
576 LineEditElements->setText( aString );
578 buttonOk->setEnabled( false );
579 buttonApply->setEnabled( false );
583 if ( !GroupButtons->isEnabled() ) // inactive
587 int nbSel = mySelection->IObjectCount();
591 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
592 myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() );
593 if(myMesh->_is_nil())
595 myActor = SMESH::FindActorByObject(myMesh);
601 if (myEditCurrentArgument == (QWidget*)LineEditElements)
605 if (CheckBoxMesh->isChecked())
607 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
609 if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH
612 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
616 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ )
618 const SMDS_MeshElement * e = aSMDSMesh->FindElement( i );
620 myElementsId += QString(" %1").arg(i);
625 else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
628 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
630 // get IDs from submesh
631 SMESH::long_array_var anElementsIds = new SMESH::long_array;
632 anElementsIds = aSubMesh->GetElementsId();
633 for ( int i = 0; i < anElementsIds->length(); i++ )
634 myElementsId += QString(" %1").arg(anElementsIds[i]);
635 aNbUnits = anElementsIds->length();
640 SMESH::SMESH_GroupBase_var aGroup
641 = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
642 if (aGroup->_is_nil())
645 // get IDs from smesh group
646 SMESH::long_array_var anElementsIds = new SMESH::long_array;
647 anElementsIds = aGroup->GetListOfID();
648 for ( int i = 0; i < anElementsIds->length(); i++ )
649 myElementsId += QString(" %1").arg(anElementsIds[i]);
650 aNbUnits = anElementsIds->length();
655 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
656 myElementsId = aString;
662 myNbOkElements = true;
666 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
670 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
674 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
682 if (myEditCurrentArgument == (QWidget*)SpinBox_X)
684 SpinBox_X->SetValue(x);
685 SpinBox_Y->SetValue(y);
686 SpinBox_Z->SetValue(z);
688 else if (myEditCurrentArgument == (QWidget*)SpinBox_DX)
690 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
691 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
692 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
697 if (myEditCurrentArgument == (QWidget*)LineEditElements)
698 LineEditElements->setText( aString );
702 if(myNbOkElements && IsMirrorOk())
704 buttonOk->setEnabled( true );
705 buttonApply->setEnabled( true );
710 //=================================================================================
711 // function : SetEditCurrentArgument()
713 //=================================================================================
714 void SMESHGUI_SymmetryDlg::SetEditCurrentArgument()
716 QPushButton* send = (QPushButton*)sender();
718 disconnect( mySelection, 0, this, 0 );
719 mySelection->ClearIObjects();
720 mySelection->ClearFilters();
722 if(send == SelectElementsButton) {
723 myEditCurrentArgument = (QWidget*)LineEditElements;
724 SMESH::SetPointRepresentation(false);
725 if (CheckBoxMesh->isChecked())
727 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
728 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
731 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
733 else if (send == SelectPointButton)
735 myEditCurrentArgument = (QWidget*)SpinBox_X;
736 SMESH::SetPointRepresentation(true);
737 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
739 else if (send == SelectVectorButton)
741 myEditCurrentArgument = (QWidget*)SpinBox_DX;
742 SMESH::SetPointRepresentation(true);
743 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
746 myEditCurrentArgument->setFocus();
747 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
748 SelectionIntoArgument() ;
751 //=================================================================================
752 // function : DeactivateActiveDialog()
754 //=================================================================================
755 void SMESHGUI_SymmetryDlg::DeactivateActiveDialog()
757 if ( GroupConstructors->isEnabled() ) {
758 GroupConstructors->setEnabled(false) ;
759 GroupArguments->setEnabled(false) ;
760 GroupButtons->setEnabled(false) ;
761 mySMESHGUI->ResetState() ;
762 mySMESHGUI->SetActiveDialogBox(0) ;
767 //=================================================================================
768 // function : ActivateThisDialog()
770 //=================================================================================
771 void SMESHGUI_SymmetryDlg::ActivateThisDialog()
773 /* Emit a signal to deactivate the active dialog */
774 mySMESHGUI->EmitSignalDeactivateDialog() ;
775 GroupConstructors->setEnabled(true) ;
776 GroupArguments->setEnabled(true) ;
777 GroupButtons->setEnabled(true) ;
779 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
781 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
782 SelectionIntoArgument();
786 //=================================================================================
787 // function : enterEvent()
789 //=================================================================================
790 void SMESHGUI_SymmetryDlg::enterEvent(QEvent* e)
792 if ( GroupConstructors->isEnabled() )
794 ActivateThisDialog() ;
798 //=================================================================================
799 // function : closeEvent()
801 //=================================================================================
802 void SMESHGUI_SymmetryDlg::closeEvent( QCloseEvent* e )
804 /* same than click on cancel button */
805 this->ClickOnCancel() ;
809 //=======================================================================
810 //function : hideEvent
811 //purpose : caused by ESC key
812 //=======================================================================
814 void SMESHGUI_SymmetryDlg::hideEvent ( QHideEvent * e )
816 if ( !isMinimized() )
821 //=======================================================================
822 //function : onSelectMesh
824 //=======================================================================
825 void SMESHGUI_SymmetryDlg::onSelectMesh ( bool toSelectMesh )
828 TextLabelElements->setText( tr( "SMESH_NAME" ) );
830 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
832 if (myEditCurrentArgument != LineEditElements)
834 LineEditElements->clear();
838 mySelection->ClearFilters() ;
839 SMESH::SetPointRepresentation(false);
843 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
844 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
845 LineEditElements->setReadOnly(true);
849 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
850 LineEditElements->setReadOnly(false);
851 onTextChange(LineEditElements->text());
854 SelectionIntoArgument();
858 //=================================================================================
859 // function : GetConstructorId()
861 //=================================================================================
862 int SMESHGUI_SymmetryDlg::GetConstructorId()
864 if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
865 return GroupConstructors->id( GroupConstructors->selected() );
870 //=================================================================================
871 // function : IsAxisOk()
873 //=================================================================================
874 bool SMESHGUI_SymmetryDlg::IsMirrorOk()
878 if (GetConstructorId() != 0)
879 isOk = SpinBox_DX->GetValue() != 0 || SpinBox_DY->GetValue() != 0 || SpinBox_DZ->GetValue() != 0;
885 //=================================================================================
886 // function : onVectorChanged()
888 //=================================================================================
889 void SMESHGUI_SymmetryDlg::onVectorChanged()
893 buttonOk->setEnabled( true );
894 buttonApply->setEnabled( true );
898 buttonOk->setEnabled( false );
899 buttonApply->setEnabled( false );