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_IdValidator.h"
35 #include "SMESHGUI_SpinBox.h"
36 #include "SMESH_Actor.h"
37 #include "SMDS_Mesh.hxx"
39 #include "QAD_Application.h"
40 #include "QAD_Desktop.h"
41 #include "QAD_MessageBox.h"
42 #include "utilities.h"
45 #include <qapplication.h>
46 #include <qbuttongroup.h>
47 #include <qgroupbox.h>
49 #include <qlineedit.h>
50 #include <qpushbutton.h>
51 #include <qradiobutton.h>
52 #include <qcheckbox.h>
58 //=================================================================================
59 // class : SMESHGUI_SymmetryDlg()
61 //=================================================================================
62 SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
63 bool modal, WFlags fl )
64 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
65 Qt::WDestructiveClose)
67 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_POINT")));
68 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_AXIS")));
69 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_PLANE")));
70 QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
73 setName( "SMESHGUI_SymmetryDlg" );
75 setCaption( tr( "SMESH_SYMMETRY" ) );
76 setSizeGripEnabled( TRUE );
77 SMESHGUI_SymmetryDlgLayout = new QGridLayout( this );
78 SMESHGUI_SymmetryDlgLayout->setSpacing( 6 );
79 SMESHGUI_SymmetryDlgLayout->setMargin( 11 );
81 /***************************************************************/
82 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
83 GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
84 GroupConstructors->setTitle( tr( "SMESH_SYMMETRY" ) );
85 GroupConstructors->setExclusive( TRUE );
86 GroupConstructors->setColumnLayout(0, Qt::Vertical );
87 GroupConstructors->layout()->setSpacing( 0 );
88 GroupConstructors->layout()->setMargin( 0 );
89 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
90 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
91 GroupConstructorsLayout->setSpacing( 6 );
92 GroupConstructorsLayout->setMargin( 11 );
93 QHBoxLayout* RBLayout = new QHBoxLayout( 0, 0, 6, "Layout2");
94 RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
95 RadioButton1->setText( tr( "" ) );
96 RadioButton1->setPixmap( image0 );
97 RBLayout->addWidget( RadioButton1);
98 RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" );
99 RadioButton2->setText( tr( "" ) );
100 RadioButton2->setPixmap( image1 );
101 RBLayout->addWidget( RadioButton2);
102 RadioButton3= new QRadioButton( GroupConstructors, "RadioButton3" );
103 RadioButton3->setText( tr( "" ) );
104 RadioButton3->setPixmap( image2 );
105 RBLayout->addWidget( RadioButton3);
106 GroupConstructorsLayout->addLayout( RBLayout, 0, 0 );
107 SMESHGUI_SymmetryDlgLayout->addWidget( GroupConstructors, 0, 0 );
109 /***************************************************************/
110 GroupButtons = new QGroupBox( this, "GroupButtons" );
111 GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
112 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
113 GroupButtons->setTitle( tr( "" ) );
114 GroupButtons->setColumnLayout(0, Qt::Vertical );
115 GroupButtons->layout()->setSpacing( 0 );
116 GroupButtons->layout()->setMargin( 0 );
117 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
118 GroupButtonsLayout->setAlignment( Qt::AlignTop );
119 GroupButtonsLayout->setSpacing( 6 );
120 GroupButtonsLayout->setMargin( 11 );
121 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
122 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
123 buttonCancel->setAutoDefault( TRUE );
124 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
125 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
126 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
127 buttonApply->setAutoDefault( TRUE );
128 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
129 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
130 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
131 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
132 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
133 buttonOk->setAutoDefault( TRUE );
134 buttonOk->setDefault( TRUE );
135 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
136 SMESHGUI_SymmetryDlgLayout->addWidget( GroupButtons, 2, 0 );
138 /***************************************************************/
139 GroupArguments = new QGroupBox( this, "GroupArguments" );
140 GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) );
141 GroupArguments->setColumnLayout(0, Qt::Vertical );
142 GroupArguments->layout()->setSpacing( 0 );
143 GroupArguments->layout()->setMargin( 0 );
144 GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
145 GroupArgumentsLayout->setAlignment( Qt::AlignTop );
146 GroupArgumentsLayout->setSpacing( 6 );
147 GroupArgumentsLayout->setMargin( 11 );
149 // Controls for elements selection
150 TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
151 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
152 TextLabelElements->setFixedWidth(74);
153 GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
155 SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
156 SelectElementsButton->setText( tr( "" ) );
157 SelectElementsButton->setPixmap( image3 );
158 SelectElementsButton->setToggleButton( FALSE );
159 GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
161 LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" );
162 LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
163 GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 );
165 // Control for the whole mesh selection
166 CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" );
167 CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) );
168 GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 2 );
170 // Controls for mirror selection
171 GroupMirror = new QGroupBox( GroupArguments, "GroupMirror" );
172 GroupMirror->setColumnLayout(0, Qt::Vertical );
173 GroupMirror->layout()->setSpacing( 0 );
174 GroupMirror->layout()->setMargin( 0 );
175 QGridLayout* GroupMirrorLayout = new QGridLayout( GroupMirror->layout() );
176 GroupMirrorLayout->setAlignment( Qt::AlignTop );
177 GroupMirrorLayout->setSpacing( 6 );
178 GroupMirrorLayout->setMargin( 11 );
180 TextLabelPoint = new QLabel( GroupMirror, "TextLabelPoint" );
181 TextLabelPoint->setText( tr( "SMESH_POINT" ) );
182 GroupMirrorLayout->addWidget( TextLabelPoint, 0, 0 );
184 SelectPointButton = new QPushButton( GroupMirror, "SelectPointButton" );
185 SelectPointButton->setPixmap( image3 );
186 GroupMirrorLayout->addWidget( SelectPointButton, 0, 1 );
188 TextLabelX = new QLabel( GroupMirror, "TextLabelX" );
189 TextLabelX->setText( tr( "SMESH_X" ) );
190 GroupMirrorLayout->addWidget( TextLabelX, 0, 2 );
192 SpinBox_X = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_X");
193 GroupMirrorLayout->addWidget( SpinBox_X, 0, 3 );
195 TextLabelY = new QLabel( GroupMirror, "TextLabelY" );
196 TextLabelY->setText( tr( "SMESH_Y" ) );
197 GroupMirrorLayout->addWidget( TextLabelY, 0, 4 );
199 SpinBox_Y = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_Y");
200 GroupMirrorLayout->addWidget( SpinBox_Y, 0, 5 );
202 TextLabelZ = new QLabel( GroupMirror, "TextLabelZ" );
203 TextLabelZ->setText( tr( "SMESH_Z" ) );
204 GroupMirrorLayout->addWidget( TextLabelZ, 0, 6 );
206 SpinBox_Z = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_Z");
207 GroupMirrorLayout->addWidget( SpinBox_Z, 0, 7 );
209 TextLabelVector = new QLabel( GroupMirror, "TextLabelVector" );
210 GroupMirrorLayout->addWidget( TextLabelVector, 1, 0 );
212 SelectVectorButton = new QPushButton( GroupMirror, "SelectVectorButton" );
213 SelectVectorButton->setPixmap( image3 );
214 GroupMirrorLayout->addWidget( SelectVectorButton, 1, 1 );
216 TextLabelDX = new QLabel( GroupMirror, "TextLabelDX" );
217 TextLabelDX->setText( tr( "SMESH_DX" ) );
218 GroupMirrorLayout->addWidget( TextLabelDX, 1, 2 );
220 SpinBox_DX = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DX");
221 GroupMirrorLayout->addWidget( SpinBox_DX, 1, 3 );
223 TextLabelDY = new QLabel( GroupMirror, "TextLabelDY" );
224 TextLabelDY->setText( tr( "SMESH_DY" ) );
225 GroupMirrorLayout->addWidget( TextLabelDY, 1, 4 );
227 SpinBox_DY = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DY");
228 GroupMirrorLayout->addWidget( SpinBox_DY, 1, 5 );
230 TextLabelDZ = new QLabel( GroupMirror, "TextLabelDZ" );
231 TextLabelDZ->setText( tr( "SMESH_DZ" ) );
232 GroupMirrorLayout->addWidget( TextLabelDZ, 1, 6 );
234 SpinBox_DZ = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DZ");
235 GroupMirrorLayout->addWidget( SpinBox_DZ, 1, 7 );
237 GroupArgumentsLayout->addMultiCellWidget( GroupMirror, 2, 2, 0, 2 );
239 // Controls for "Create a copy" option
240 CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" );
241 CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) );
242 GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 3, 3, 0, 2 );
245 SMESHGUI_SymmetryDlgLayout->addWidget( GroupArguments, 1, 0 );
247 /* Initialisations */
248 SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
249 SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
250 SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
251 SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
252 SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
253 SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
255 GroupArguments->show();
256 RadioButton1->setChecked( TRUE );
259 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
260 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
262 myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
265 /* signals and slots connections */
266 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
267 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
268 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
269 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
271 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
272 connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
273 connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
275 connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
276 connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
277 connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
279 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
280 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
281 /* to close dialog if study change */
282 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
283 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
284 SLOT( onTextChange( const QString& )));
285 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
286 SLOT( onSelectMesh( bool )));
288 /* Move widget on the botton right corner of main widget */
290 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
292 this->show() ; /* displays Dialog */
294 ConstructorsClicked(0);
298 //=================================================================================
299 // function : ~SMESHGUI_SymmetryDlg()
300 // purpose : Destroys the object and frees any allocated resources
301 //=================================================================================
302 SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg()
304 // no need to delete child widgets, Qt does it all for us
308 //=================================================================================
311 //=================================================================================
312 void SMESHGUI_SymmetryDlg::Init( bool ResetControls )
316 myEditCurrentArgument = 0;
317 LineEditElements->clear();
321 buttonOk->setEnabled( false );
322 buttonApply->setEnabled( false );
325 myMesh = SMESH::SMESH_Mesh::_nil();
329 SpinBox_X->SetValue(0.0);
330 SpinBox_Y->SetValue(0.0);
331 SpinBox_Z->SetValue(0.0);
332 SpinBox_DX->SetValue(0.0);
333 SpinBox_DY->SetValue(0.0);
334 SpinBox_DZ->SetValue(0.0);
336 CheckBoxCopy->setChecked(false);
337 CheckBoxMesh->setChecked(false);
338 onSelectMesh( false );
343 //=================================================================================
344 // function : ConstructorsClicked()
345 // purpose : Radio button management
346 //=================================================================================
347 void SMESHGUI_SymmetryDlg::ConstructorsClicked(int constructorId)
349 disconnect(mySelection, 0, this, 0);
351 if (constructorId!=0 && !TextLabelVector->isVisible())
353 TextLabelVector->show();
354 SelectVectorButton->show();
363 switch(constructorId)
367 GroupMirror->setTitle( tr( "SMESH_POINT" ) );
369 TextLabelVector->hide();
370 SelectVectorButton->hide();
381 GroupMirror->setTitle( tr( "SMESH_AXIS" ) );
382 TextLabelVector->setText( tr( "SMESH_VECTOR" ) );
387 GroupMirror->setTitle( tr( "SMESH_PLANE" ) );
388 TextLabelVector->setText( tr( "SMESH_NORMAL" ) );
393 if (myEditCurrentArgument != (QWidget*)LineEditElements)
395 SMESH::SetPointRepresentation(false);
396 if (!CheckBoxMesh->isChecked())
397 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
400 myEditCurrentArgument = (QWidget*)LineEditElements;
401 LineEditElements->setFocus();
403 if (CheckBoxMesh->isChecked())
406 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
410 //=================================================================================
411 // function : ClickOnApply()
413 //=================================================================================
414 void SMESHGUI_SymmetryDlg::ClickOnApply()
416 if (mySMESHGUI->ActiveStudyLocked())
419 if ( myNbOkElements && IsMirrorOk() )
421 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
423 SMESH::long_array_var anElementsId = new SMESH::long_array;
425 anElementsId->length( aListElementsId.count() );
426 for ( int i = 0; i < aListElementsId.count(); i++ )
427 anElementsId[i] = aListElementsId[i].toInt();
429 SMESH::AxisStruct aMirror;
431 aMirror.x = SpinBox_X->GetValue();
432 aMirror.y = SpinBox_Y->GetValue();
433 aMirror.z = SpinBox_Z->GetValue();
434 if (GetConstructorId() == 0)
435 aMirror.vx = aMirror.vy = aMirror.vz = 0;
438 aMirror.vx = SpinBox_DX->GetValue();
439 aMirror.vy = SpinBox_DY->GetValue();
440 aMirror.vz = SpinBox_DZ->GetValue();
443 bool toCreateCopy = CheckBoxCopy->isChecked();
445 SMESH::SMESH_MeshEditor::MirrorType aMirrorType;
447 if (GetConstructorId() == 0)
448 aMirrorType = SMESH::SMESH_MeshEditor::POINT;
449 if (GetConstructorId() == 1)
450 aMirrorType = SMESH::SMESH_MeshEditor::AXIS;
451 if (GetConstructorId() == 2)
452 aMirrorType = SMESH::SMESH_MeshEditor::PLANE;
456 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
457 QApplication::setOverrideCursor(Qt::waitCursor);
458 aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, toCreateCopy);
459 QApplication::restoreOverrideCursor();
465 mySelection->ClearIObjects();
468 ConstructorsClicked( GetConstructorId() );
472 //=================================================================================
473 // function : ClickOnOk()
475 //=================================================================================
476 void SMESHGUI_SymmetryDlg::ClickOnOk()
483 //=================================================================================
484 // function : ClickOnCancel()
486 //=================================================================================
487 void SMESHGUI_SymmetryDlg::ClickOnCancel()
489 mySelection->ClearFilters();
490 mySelection->ClearIObjects();
491 SMESH::SetPointRepresentation(false);
492 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
493 disconnect( mySelection, 0, this, 0 );
494 mySMESHGUI->ResetState() ;
498 //=======================================================================
499 //function : onTextChange
501 //=======================================================================
503 void SMESHGUI_SymmetryDlg::onTextChange(const QString& theNewText)
505 QLineEdit* send = (QLineEdit*)sender();
507 if ( myBusy ) return;
510 if (send == LineEditElements)
513 buttonOk->setEnabled( false );
514 buttonApply->setEnabled( false );
516 // hilight entered elements
517 SMDS_Mesh* aMesh = 0;
519 aMesh = myActor->GetObject()->GetMesh();
523 mySelection->ClearIObjects();
524 mySelection->AddIObject( myActor->getIO() );
526 QStringList aListId = QStringList::split( " ", theNewText, false);
528 if (send == LineEditElements) {
529 for ( int i = 0; i < aListId.count(); i++ ) {
530 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
532 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
533 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
537 myElementsId = theNewText;
541 if ( myNbOkElements && IsMirrorOk() ) {
542 buttonOk->setEnabled( true );
543 buttonApply->setEnabled( true );
549 //=================================================================================
550 // function : SelectionIntoArgument()
551 // purpose : Called when selection as changed or other case
552 //=================================================================================
553 void SMESHGUI_SymmetryDlg::SelectionIntoArgument()
555 if ( myBusy ) return;
560 QString aString = "";
563 if (myEditCurrentArgument == (QWidget*)LineEditElements)
565 LineEditElements->setText( aString );
567 buttonOk->setEnabled( false );
568 buttonApply->setEnabled( false );
572 if ( !GroupButtons->isEnabled() ) // inactive
576 int nbSel = mySelection->IObjectCount();
580 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
581 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO) ;
582 myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() );
586 if (myEditCurrentArgument == (QWidget*)LineEditElements)
590 // get selected elements
591 if (CheckBoxMesh->isChecked())
593 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
594 if(!myMesh->_is_nil())
600 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
603 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ )
605 const SMDS_MeshElement * e = aSMDSMesh->FindElement( i );
607 myElementsId += QString(" %1").arg(i);
614 // get IDs from submesh
615 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
616 if(aSubMesh->_is_nil())
619 myMesh = aSubMesh->GetFather();
620 if(myMesh->_is_nil())
623 myActor = SMESH::FindActorByObject(myMesh);
627 SMESH::long_array_var anElementsIds = new SMESH::long_array;
628 anElementsIds = aSubMesh->GetElementsId();
629 for ( int i = 0; i < anElementsIds->length(); i++ )
630 myElementsId += QString(" %1").arg(anElementsIds[i]);
631 aNbUnits = anElementsIds->length();
636 if(myMesh->_is_nil())
639 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
640 if(!aSubMesh->_is_nil())
641 myMesh = aSubMesh->GetFather(); // get mesh from submesh
645 SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(IO);
646 if ( !aGroup->_is_nil() )
647 myMesh = aGroup->GetMesh(); // get mesh from group
650 if(myMesh->_is_nil())
654 myActor = SMESH::FindActorByObject(myMesh);
660 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
661 myElementsId = aString;
667 myNbOkElements = true;
671 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
675 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
679 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
687 if (myEditCurrentArgument == (QWidget*)SpinBox_X)
689 SpinBox_X->SetValue(x);
690 SpinBox_Y->SetValue(y);
691 SpinBox_Z->SetValue(z);
693 else if (myEditCurrentArgument == (QWidget*)SpinBox_DX)
695 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
696 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
697 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
702 if (myEditCurrentArgument == (QWidget*)LineEditElements)
703 LineEditElements->setText( aString );
707 if(myNbOkElements && IsMirrorOk())
709 buttonOk->setEnabled( true );
710 buttonApply->setEnabled( true );
715 //=================================================================================
716 // function : SetEditCurrentArgument()
718 //=================================================================================
719 void SMESHGUI_SymmetryDlg::SetEditCurrentArgument()
721 QPushButton* send = (QPushButton*)sender();
723 disconnect( mySelection, 0, this, 0 );
724 mySelection->ClearIObjects();
725 mySelection->ClearFilters();
727 if(send == SelectElementsButton) {
728 myEditCurrentArgument = (QWidget*)LineEditElements;
729 SMESH::SetPointRepresentation(false);
730 if (CheckBoxMesh->isChecked())
732 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
733 mySelection->AddFilter(myMeshOrSubMeshFilter) ;
736 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
738 else if (send == SelectPointButton)
740 myEditCurrentArgument = (QWidget*)SpinBox_X;
741 SMESH::SetPointRepresentation(true);
742 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
744 else if (send == SelectVectorButton)
746 myEditCurrentArgument = (QWidget*)SpinBox_DX;
747 SMESH::SetPointRepresentation(true);
748 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
751 myEditCurrentArgument->setFocus();
752 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
753 SelectionIntoArgument() ;
756 //=================================================================================
757 // function : DeactivateActiveDialog()
759 //=================================================================================
760 void SMESHGUI_SymmetryDlg::DeactivateActiveDialog()
762 if ( GroupConstructors->isEnabled() ) {
763 GroupConstructors->setEnabled(false) ;
764 GroupArguments->setEnabled(false) ;
765 GroupButtons->setEnabled(false) ;
766 mySMESHGUI->ResetState() ;
767 mySMESHGUI->SetActiveDialogBox(0) ;
772 //=================================================================================
773 // function : ActivateThisDialog()
775 //=================================================================================
776 void SMESHGUI_SymmetryDlg::ActivateThisDialog()
778 /* Emit a signal to deactivate the active dialog */
779 mySMESHGUI->EmitSignalDeactivateDialog() ;
780 GroupConstructors->setEnabled(true) ;
781 GroupArguments->setEnabled(true) ;
782 GroupButtons->setEnabled(true) ;
784 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
786 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
787 SelectionIntoArgument();
791 //=================================================================================
792 // function : enterEvent()
794 //=================================================================================
795 void SMESHGUI_SymmetryDlg::enterEvent(QEvent* e)
797 if ( GroupConstructors->isEnabled() )
799 ActivateThisDialog() ;
803 //=================================================================================
804 // function : closeEvent()
806 //=================================================================================
807 void SMESHGUI_SymmetryDlg::closeEvent( QCloseEvent* e )
809 /* same than click on cancel button */
810 this->ClickOnCancel() ;
814 //=======================================================================
815 //function : hideEvent
816 //purpose : caused by ESC key
817 //=======================================================================
819 void SMESHGUI_SymmetryDlg::hideEvent ( QHideEvent * e )
821 if ( !isMinimized() )
826 //=======================================================================
827 //function : onSelectMesh
829 //=======================================================================
830 void SMESHGUI_SymmetryDlg::onSelectMesh ( bool toSelectMesh )
833 TextLabelElements->setText( tr( "SMESH_NAME" ) );
835 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
837 if (myEditCurrentArgument != LineEditElements)
839 LineEditElements->clear();
843 mySelection->ClearFilters() ;
844 SMESH::SetPointRepresentation(false);
848 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
849 mySelection->AddFilter(myMeshOrSubMeshFilter);
850 LineEditElements->setReadOnly(true);
854 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
855 LineEditElements->setReadOnly(false);
856 onTextChange(LineEditElements->text());
859 SelectionIntoArgument();
863 //=================================================================================
864 // function : GetConstructorId()
866 //=================================================================================
867 int SMESHGUI_SymmetryDlg::GetConstructorId()
869 if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
870 return GroupConstructors->id( GroupConstructors->selected() );
875 //=================================================================================
876 // function : IsAxisOk()
878 //=================================================================================
879 bool SMESHGUI_SymmetryDlg::IsMirrorOk()
883 if (GetConstructorId() != 0)
884 isOk = SpinBox_DX->GetValue() != 0 || SpinBox_DY->GetValue() != 0 || SpinBox_DZ->GetValue() != 0;
890 //=================================================================================
891 // function : onVectorChanged()
893 //=================================================================================
894 void SMESHGUI_SymmetryDlg::onVectorChanged()
898 buttonOk->setEnabled( true );
899 buttonApply->setEnabled( true );
903 buttonOk->setEnabled( false );
904 buttonApply->setEnabled( false );