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>
59 #include "SALOMEconfig.h"
60 #include CORBA_SERVER_HEADER(SMESH_Group)
64 //=================================================================================
65 // class : SMESHGUI_SymmetryDlg()
67 //=================================================================================
68 SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
69 bool modal, WFlags fl )
70 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
71 Qt::WDestructiveClose)
73 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_POINT")));
74 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_AXIS")));
75 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_PLANE")));
76 QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
79 setName( "SMESHGUI_SymmetryDlg" );
81 setCaption( tr( "SMESH_SYMMETRY" ) );
82 setSizeGripEnabled( TRUE );
83 SMESHGUI_SymmetryDlgLayout = new QGridLayout( this );
84 SMESHGUI_SymmetryDlgLayout->setSpacing( 6 );
85 SMESHGUI_SymmetryDlgLayout->setMargin( 11 );
87 /***************************************************************/
88 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
89 GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
90 GroupConstructors->setTitle( tr( "SMESH_SYMMETRY" ) );
91 GroupConstructors->setExclusive( TRUE );
92 GroupConstructors->setColumnLayout(0, Qt::Vertical );
93 GroupConstructors->layout()->setSpacing( 0 );
94 GroupConstructors->layout()->setMargin( 0 );
95 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
96 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
97 GroupConstructorsLayout->setSpacing( 6 );
98 GroupConstructorsLayout->setMargin( 11 );
99 QHBoxLayout* RBLayout = new QHBoxLayout( 0, 0, 6, "Layout2");
100 RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
101 RadioButton1->setText( tr( "" ) );
102 RadioButton1->setPixmap( image0 );
103 RBLayout->addWidget( RadioButton1);
104 RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" );
105 RadioButton2->setText( tr( "" ) );
106 RadioButton2->setPixmap( image1 );
107 RBLayout->addWidget( RadioButton2);
108 RadioButton3= new QRadioButton( GroupConstructors, "RadioButton3" );
109 RadioButton3->setText( tr( "" ) );
110 RadioButton3->setPixmap( image2 );
111 RBLayout->addWidget( RadioButton3);
112 GroupConstructorsLayout->addLayout( RBLayout, 0, 0 );
113 SMESHGUI_SymmetryDlgLayout->addWidget( GroupConstructors, 0, 0 );
115 /***************************************************************/
116 GroupButtons = new QGroupBox( this, "GroupButtons" );
117 GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
118 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
119 GroupButtons->setTitle( tr( "" ) );
120 GroupButtons->setColumnLayout(0, Qt::Vertical );
121 GroupButtons->layout()->setSpacing( 0 );
122 GroupButtons->layout()->setMargin( 0 );
123 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
124 GroupButtonsLayout->setAlignment( Qt::AlignTop );
125 GroupButtonsLayout->setSpacing( 6 );
126 GroupButtonsLayout->setMargin( 11 );
127 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
128 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
129 buttonCancel->setAutoDefault( TRUE );
130 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
131 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
132 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
133 buttonApply->setAutoDefault( TRUE );
134 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
135 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
136 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
137 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
138 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
139 buttonOk->setAutoDefault( TRUE );
140 buttonOk->setDefault( TRUE );
141 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
142 SMESHGUI_SymmetryDlgLayout->addWidget( GroupButtons, 2, 0 );
144 /***************************************************************/
145 GroupArguments = new QGroupBox( this, "GroupArguments" );
146 GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) );
147 GroupArguments->setColumnLayout(0, Qt::Vertical );
148 GroupArguments->layout()->setSpacing( 0 );
149 GroupArguments->layout()->setMargin( 0 );
150 GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
151 GroupArgumentsLayout->setAlignment( Qt::AlignTop );
152 GroupArgumentsLayout->setSpacing( 6 );
153 GroupArgumentsLayout->setMargin( 11 );
155 // Controls for elements selection
156 TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
157 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
158 TextLabelElements->setFixedWidth(74);
159 GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
161 SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
162 SelectElementsButton->setText( tr( "" ) );
163 SelectElementsButton->setPixmap( image3 );
164 SelectElementsButton->setToggleButton( FALSE );
165 GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
167 LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" );
168 LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
169 GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 );
171 // Control for the whole mesh selection
172 CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" );
173 CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) );
174 GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 2 );
176 // Controls for mirror selection
177 GroupMirror = new QGroupBox( GroupArguments, "GroupMirror" );
178 GroupMirror->setColumnLayout(0, Qt::Vertical );
179 GroupMirror->layout()->setSpacing( 0 );
180 GroupMirror->layout()->setMargin( 0 );
181 QGridLayout* GroupMirrorLayout = new QGridLayout( GroupMirror->layout() );
182 GroupMirrorLayout->setAlignment( Qt::AlignTop );
183 GroupMirrorLayout->setSpacing( 6 );
184 GroupMirrorLayout->setMargin( 11 );
186 TextLabelPoint = new QLabel( GroupMirror, "TextLabelPoint" );
187 TextLabelPoint->setText( tr( "SMESH_POINT" ) );
188 GroupMirrorLayout->addWidget( TextLabelPoint, 0, 0 );
190 SelectPointButton = new QPushButton( GroupMirror, "SelectPointButton" );
191 SelectPointButton->setPixmap( image3 );
192 GroupMirrorLayout->addWidget( SelectPointButton, 0, 1 );
194 TextLabelX = new QLabel( GroupMirror, "TextLabelX" );
195 TextLabelX->setText( tr( "SMESH_X" ) );
196 GroupMirrorLayout->addWidget( TextLabelX, 0, 2 );
198 SpinBox_X = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_X");
199 GroupMirrorLayout->addWidget( SpinBox_X, 0, 3 );
201 TextLabelY = new QLabel( GroupMirror, "TextLabelY" );
202 TextLabelY->setText( tr( "SMESH_Y" ) );
203 GroupMirrorLayout->addWidget( TextLabelY, 0, 4 );
205 SpinBox_Y = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_Y");
206 GroupMirrorLayout->addWidget( SpinBox_Y, 0, 5 );
208 TextLabelZ = new QLabel( GroupMirror, "TextLabelZ" );
209 TextLabelZ->setText( tr( "SMESH_Z" ) );
210 GroupMirrorLayout->addWidget( TextLabelZ, 0, 6 );
212 SpinBox_Z = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_Z");
213 GroupMirrorLayout->addWidget( SpinBox_Z, 0, 7 );
215 TextLabelVector = new QLabel( GroupMirror, "TextLabelVector" );
216 GroupMirrorLayout->addWidget( TextLabelVector, 1, 0 );
218 SelectVectorButton = new QPushButton( GroupMirror, "SelectVectorButton" );
219 SelectVectorButton->setPixmap( image3 );
220 GroupMirrorLayout->addWidget( SelectVectorButton, 1, 1 );
222 TextLabelDX = new QLabel( GroupMirror, "TextLabelDX" );
223 TextLabelDX->setText( tr( "SMESH_DX" ) );
224 GroupMirrorLayout->addWidget( TextLabelDX, 1, 2 );
226 SpinBox_DX = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DX");
227 GroupMirrorLayout->addWidget( SpinBox_DX, 1, 3 );
229 TextLabelDY = new QLabel( GroupMirror, "TextLabelDY" );
230 TextLabelDY->setText( tr( "SMESH_DY" ) );
231 GroupMirrorLayout->addWidget( TextLabelDY, 1, 4 );
233 SpinBox_DY = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DY");
234 GroupMirrorLayout->addWidget( SpinBox_DY, 1, 5 );
236 TextLabelDZ = new QLabel( GroupMirror, "TextLabelDZ" );
237 TextLabelDZ->setText( tr( "SMESH_DZ" ) );
238 GroupMirrorLayout->addWidget( TextLabelDZ, 1, 6 );
240 SpinBox_DZ = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DZ");
241 GroupMirrorLayout->addWidget( SpinBox_DZ, 1, 7 );
243 GroupArgumentsLayout->addMultiCellWidget( GroupMirror, 2, 2, 0, 2 );
245 // Controls for "Create a copy" option
246 CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" );
247 CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) );
248 GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 3, 3, 0, 2 );
251 SMESHGUI_SymmetryDlgLayout->addWidget( GroupArguments, 1, 0 );
253 /* Initialisations */
254 SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
255 SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
256 SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
257 SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
258 SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
259 SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
261 GroupArguments->show();
262 RadioButton1->setChecked( TRUE );
265 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
266 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
268 // Costruction of the logical filter
269 SMESH_ListOfFilter aListOfFilters;
270 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
271 if ( !aMeshOrSubMeshFilter.IsNull() )
272 aListOfFilters.Append( aMeshOrSubMeshFilter );
273 Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
274 if ( !aSmeshGroupFilter.IsNull() )
275 aListOfFilters.Append( aSmeshGroupFilter );
277 myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
280 /* signals and slots connections */
281 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
282 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
283 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
284 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
286 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
287 connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
288 connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
290 connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
291 connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
292 connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
294 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
295 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
296 /* to close dialog if study change */
297 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
298 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
299 SLOT( onTextChange( const QString& )));
300 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
301 SLOT( onSelectMesh( bool )));
303 /* Move widget on the botton right corner of main widget */
305 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
307 this->show() ; /* displays Dialog */
309 ConstructorsClicked(0);
313 //=================================================================================
314 // function : ~SMESHGUI_SymmetryDlg()
315 // purpose : Destroys the object and frees any allocated resources
316 //=================================================================================
317 SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg()
319 // no need to delete child widgets, Qt does it all for us
323 //=================================================================================
326 //=================================================================================
327 void SMESHGUI_SymmetryDlg::Init( bool ResetControls )
331 myEditCurrentArgument = 0;
332 LineEditElements->clear();
336 buttonOk->setEnabled( false );
337 buttonApply->setEnabled( false );
340 myMesh = SMESH::SMESH_Mesh::_nil();
344 SpinBox_X->SetValue(0.0);
345 SpinBox_Y->SetValue(0.0);
346 SpinBox_Z->SetValue(0.0);
347 SpinBox_DX->SetValue(0.0);
348 SpinBox_DY->SetValue(0.0);
349 SpinBox_DZ->SetValue(0.0);
351 CheckBoxCopy->setChecked(false);
352 CheckBoxMesh->setChecked(false);
353 onSelectMesh( false );
358 //=================================================================================
359 // function : ConstructorsClicked()
360 // purpose : Radio button management
361 //=================================================================================
362 void SMESHGUI_SymmetryDlg::ConstructorsClicked(int constructorId)
364 disconnect(mySelection, 0, this, 0);
366 if (constructorId!=0 && !TextLabelVector->isVisible())
368 TextLabelVector->show();
369 SelectVectorButton->show();
378 switch(constructorId)
382 GroupMirror->setTitle( tr( "SMESH_POINT" ) );
384 TextLabelVector->hide();
385 SelectVectorButton->hide();
396 GroupMirror->setTitle( tr( "SMESH_AXIS" ) );
397 TextLabelVector->setText( tr( "SMESH_VECTOR" ) );
402 GroupMirror->setTitle( tr( "SMESH_PLANE" ) );
403 TextLabelVector->setText( tr( "SMESH_NORMAL" ) );
408 if (myEditCurrentArgument != (QWidget*)LineEditElements)
410 SMESH::SetPointRepresentation(false);
411 if (!CheckBoxMesh->isChecked())
412 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
415 myEditCurrentArgument = (QWidget*)LineEditElements;
416 LineEditElements->setFocus();
418 if (CheckBoxMesh->isChecked())
421 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
425 //=================================================================================
426 // function : ClickOnApply()
428 //=================================================================================
429 void SMESHGUI_SymmetryDlg::ClickOnApply()
431 if (mySMESHGUI->ActiveStudyLocked())
434 if ( myNbOkElements && IsMirrorOk() )
436 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
438 SMESH::long_array_var anElementsId = new SMESH::long_array;
440 anElementsId->length( aListElementsId.count() );
441 for ( int i = 0; i < aListElementsId.count(); i++ )
442 anElementsId[i] = aListElementsId[i].toInt();
444 SMESH::AxisStruct aMirror;
446 aMirror.x = SpinBox_X->GetValue();
447 aMirror.y = SpinBox_Y->GetValue();
448 aMirror.z = SpinBox_Z->GetValue();
449 if (GetConstructorId() == 0)
450 aMirror.vx = aMirror.vy = aMirror.vz = 0;
453 aMirror.vx = SpinBox_DX->GetValue();
454 aMirror.vy = SpinBox_DY->GetValue();
455 aMirror.vz = SpinBox_DZ->GetValue();
458 bool toCreateCopy = CheckBoxCopy->isChecked();
460 SMESH::SMESH_MeshEditor::MirrorType aMirrorType;
462 if (GetConstructorId() == 0)
463 aMirrorType = SMESH::SMESH_MeshEditor::POINT;
464 if (GetConstructorId() == 1)
465 aMirrorType = SMESH::SMESH_MeshEditor::AXIS;
466 if (GetConstructorId() == 2)
467 aMirrorType = SMESH::SMESH_MeshEditor::PLANE;
471 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
472 QApplication::setOverrideCursor(Qt::waitCursor);
473 aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, toCreateCopy);
474 QApplication::restoreOverrideCursor();
480 mySelection->ClearIObjects();
483 ConstructorsClicked( GetConstructorId() );
487 //=================================================================================
488 // function : ClickOnOk()
490 //=================================================================================
491 void SMESHGUI_SymmetryDlg::ClickOnOk()
498 //=================================================================================
499 // function : ClickOnCancel()
501 //=================================================================================
502 void SMESHGUI_SymmetryDlg::ClickOnCancel()
504 mySelection->ClearFilters();
505 mySelection->ClearIObjects();
506 SMESH::SetPointRepresentation(false);
507 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
508 disconnect( mySelection, 0, this, 0 );
509 mySMESHGUI->ResetState() ;
513 //=======================================================================
514 //function : onTextChange
516 //=======================================================================
518 void SMESHGUI_SymmetryDlg::onTextChange(const QString& theNewText)
520 QLineEdit* send = (QLineEdit*)sender();
522 if ( myBusy ) return;
525 if (send == LineEditElements)
528 buttonOk->setEnabled( false );
529 buttonApply->setEnabled( false );
531 // hilight entered elements
532 SMDS_Mesh* aMesh = 0;
534 aMesh = myActor->GetObject()->GetMesh();
538 mySelection->ClearIObjects();
539 mySelection->AddIObject( myActor->getIO() );
541 QStringList aListId = QStringList::split( " ", theNewText, false);
543 if (send == LineEditElements) {
544 for ( int i = 0; i < aListId.count(); i++ ) {
545 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
547 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
548 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
552 myElementsId = theNewText;
556 if ( myNbOkElements && IsMirrorOk() ) {
557 buttonOk->setEnabled( true );
558 buttonApply->setEnabled( true );
564 //=================================================================================
565 // function : SelectionIntoArgument()
566 // purpose : Called when selection as changed or other case
567 //=================================================================================
568 void SMESHGUI_SymmetryDlg::SelectionIntoArgument()
570 if ( myBusy ) return;
575 QString aString = "";
578 if (myEditCurrentArgument == (QWidget*)LineEditElements)
580 LineEditElements->setText( aString );
582 buttonOk->setEnabled( false );
583 buttonApply->setEnabled( false );
587 if ( !GroupButtons->isEnabled() ) // inactive
591 int nbSel = mySelection->IObjectCount();
595 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
596 myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() );
597 if(myMesh->_is_nil())
600 myActor = SMESH::FindActorByObject(myMesh);
602 myActor = SMESH::FindActorByEntry(IO->getEntry());
608 if (myEditCurrentArgument == (QWidget*)LineEditElements)
612 if (CheckBoxMesh->isChecked())
614 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
616 if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH
619 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
623 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ )
625 const SMDS_MeshElement * e = aSMDSMesh->FindElement( i );
627 myElementsId += QString(" %1").arg(i);
632 else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
635 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
637 // get IDs from submesh
638 SMESH::long_array_var anElementsIds = new SMESH::long_array;
639 anElementsIds = aSubMesh->GetElementsId();
640 for ( int i = 0; i < anElementsIds->length(); i++ )
641 myElementsId += QString(" %1").arg(anElementsIds[i]);
642 aNbUnits = anElementsIds->length();
647 SMESH::SMESH_GroupBase_var aGroup
648 = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
649 if (aGroup->_is_nil())
652 // get IDs from smesh group
653 SMESH::long_array_var anElementsIds = new SMESH::long_array;
654 anElementsIds = aGroup->GetListOfID();
655 for ( int i = 0; i < anElementsIds->length(); i++ )
656 myElementsId += QString(" %1").arg(anElementsIds[i]);
657 aNbUnits = anElementsIds->length();
662 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
663 myElementsId = aString;
669 myNbOkElements = true;
673 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
677 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
681 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
689 if (myEditCurrentArgument == (QWidget*)SpinBox_X)
691 SpinBox_X->SetValue(x);
692 SpinBox_Y->SetValue(y);
693 SpinBox_Z->SetValue(z);
695 else if (myEditCurrentArgument == (QWidget*)SpinBox_DX)
697 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
698 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
699 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
704 if (myEditCurrentArgument == (QWidget*)LineEditElements)
705 LineEditElements->setText( aString );
709 if(myNbOkElements && IsMirrorOk())
711 buttonOk->setEnabled( true );
712 buttonApply->setEnabled( true );
717 //=================================================================================
718 // function : SetEditCurrentArgument()
720 //=================================================================================
721 void SMESHGUI_SymmetryDlg::SetEditCurrentArgument()
723 QPushButton* send = (QPushButton*)sender();
725 disconnect( mySelection, 0, this, 0 );
726 mySelection->ClearIObjects();
727 mySelection->ClearFilters();
729 if(send == SelectElementsButton) {
730 myEditCurrentArgument = (QWidget*)LineEditElements;
731 SMESH::SetPointRepresentation(false);
732 if (CheckBoxMesh->isChecked())
734 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
735 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
738 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
740 else if (send == SelectPointButton)
742 myEditCurrentArgument = (QWidget*)SpinBox_X;
743 SMESH::SetPointRepresentation(true);
744 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
746 else if (send == SelectVectorButton)
748 myEditCurrentArgument = (QWidget*)SpinBox_DX;
749 SMESH::SetPointRepresentation(true);
750 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
753 myEditCurrentArgument->setFocus();
754 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
755 SelectionIntoArgument() ;
758 //=================================================================================
759 // function : DeactivateActiveDialog()
761 //=================================================================================
762 void SMESHGUI_SymmetryDlg::DeactivateActiveDialog()
764 if ( GroupConstructors->isEnabled() ) {
765 GroupConstructors->setEnabled(false) ;
766 GroupArguments->setEnabled(false) ;
767 GroupButtons->setEnabled(false) ;
768 mySMESHGUI->ResetState() ;
769 mySMESHGUI->SetActiveDialogBox(0) ;
774 //=================================================================================
775 // function : ActivateThisDialog()
777 //=================================================================================
778 void SMESHGUI_SymmetryDlg::ActivateThisDialog()
780 /* Emit a signal to deactivate the active dialog */
781 mySMESHGUI->EmitSignalDeactivateDialog() ;
782 GroupConstructors->setEnabled(true) ;
783 GroupArguments->setEnabled(true) ;
784 GroupButtons->setEnabled(true) ;
786 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
788 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
789 SelectionIntoArgument();
793 //=================================================================================
794 // function : enterEvent()
796 //=================================================================================
797 void SMESHGUI_SymmetryDlg::enterEvent(QEvent* e)
799 if ( GroupConstructors->isEnabled() )
801 ActivateThisDialog() ;
805 //=================================================================================
806 // function : closeEvent()
808 //=================================================================================
809 void SMESHGUI_SymmetryDlg::closeEvent( QCloseEvent* e )
811 /* same than click on cancel button */
812 this->ClickOnCancel() ;
816 //=======================================================================
817 //function : hideEvent
818 //purpose : caused by ESC key
819 //=======================================================================
821 void SMESHGUI_SymmetryDlg::hideEvent ( QHideEvent * e )
823 if ( !isMinimized() )
828 //=======================================================================
829 //function : onSelectMesh
831 //=======================================================================
832 void SMESHGUI_SymmetryDlg::onSelectMesh ( bool toSelectMesh )
835 TextLabelElements->setText( tr( "SMESH_NAME" ) );
837 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
839 if (myEditCurrentArgument != LineEditElements)
841 LineEditElements->clear();
845 mySelection->ClearFilters() ;
846 SMESH::SetPointRepresentation(false);
850 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
851 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
852 LineEditElements->setReadOnly(true);
856 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
857 LineEditElements->setReadOnly(false);
858 onTextChange(LineEditElements->text());
861 SelectionIntoArgument();
865 //=================================================================================
866 // function : GetConstructorId()
868 //=================================================================================
869 int SMESHGUI_SymmetryDlg::GetConstructorId()
871 if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
872 return GroupConstructors->id( GroupConstructors->selected() );
877 //=================================================================================
878 // function : IsAxisOk()
880 //=================================================================================
881 bool SMESHGUI_SymmetryDlg::IsMirrorOk()
885 if (GetConstructorId() != 0)
886 isOk = SpinBox_DX->GetValue() != 0 || SpinBox_DY->GetValue() != 0 || SpinBox_DZ->GetValue() != 0;
892 //=================================================================================
893 // function : onVectorChanged()
895 //=================================================================================
896 void SMESHGUI_SymmetryDlg::onVectorChanged()
900 buttonOk->setEnabled( true );
901 buttonApply->setEnabled( true );
905 buttonOk->setEnabled( false );
906 buttonApply->setEnabled( false );