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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : SMESHGUI_AddMeshElementDlg.cxx
25 // Author : Nicolas REJNERI
29 #include "SMESHGUI_AddMeshElementDlg.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_MeshUtils.h"
35 #include "SMESHGUI_IdValidator.h"
36 #include "SMESH_ActorUtils.h"
38 #include "SMDS_Mesh.hxx"
39 #include "SMESH_Actor.h"
41 #include "SUIT_Session.h"
42 #include "SUIT_MessageBox.h"
43 #include "LightApp_Application.h"
45 #include "SVTK_Selection.h"
46 #include "SVTK_Selector.h"
47 #include "SALOME_ListIO.hxx"
48 #include "SALOME_ListIteratorOfListIO.hxx"
50 #include "SalomeApp_Study.h"
51 #include "SalomeApp_Application.h"
53 #include "SVTK_ViewModel.h"
54 #include "SVTK_ViewWindow.h"
56 #include "utilities.h"
58 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
61 #include <TColStd_MapOfInteger.hxx>
62 #include <TColStd_IndexedMapOfInteger.hxx>
66 #include <vtkIdList.h>
67 #include <vtkIntArray.h>
68 #include <vtkCellArray.h>
69 #include <vtkUnsignedCharArray.h>
70 #include <vtkUnstructuredGrid.h>
71 #include <vtkDataSetMapper.h>
72 #include <vtkProperty.h>
75 #include <qbuttongroup.h>
76 #include <qgroupbox.h>
78 #include <qlineedit.h>
79 #include <qpushbutton.h>
80 #include <qradiobutton.h>
84 #include <qwhatsthis.h>
87 #include <qcheckbox.h>
97 class TElementSimulation {
98 SalomeApp_Application* myApplication;
99 SUIT_ViewWindow* myViewWindow;
100 SVTK_ViewWindow* myVTKViewWindow;
102 SALOME_Actor* myPreviewActor;
103 vtkDataSetMapper* myMapper;
104 vtkUnstructuredGrid* myGrid;
107 TElementSimulation (SalomeApp_Application* theApplication)
109 myApplication = theApplication;
110 SUIT_ViewManager* mgr = theApplication->activeViewManager();
112 myViewWindow = mgr->getActiveView();
113 myVTKViewWindow = GetVtkViewWindow(myViewWindow);
115 myGrid = vtkUnstructuredGrid::New();
117 // Create and display actor
118 myMapper = vtkDataSetMapper::New();
119 myMapper->SetInput(myGrid);
121 myPreviewActor = SALOME_Actor::New();
122 myPreviewActor->PickableOff();
123 myPreviewActor->VisibilityOff();
124 myPreviewActor->SetMapper(myMapper);
126 vtkFloatingPointType anRGB[3];
127 vtkProperty* aProp = vtkProperty::New();
128 GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
129 aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
130 myPreviewActor->SetProperty( aProp );
133 vtkProperty* aBackProp = vtkProperty::New();
134 GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
135 aBackProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
136 myPreviewActor->SetBackfaceProperty( aBackProp );
139 myVTKViewWindow->AddActor(myPreviewActor);
142 typedef std::vector<vtkIdType> TVTKIds;
143 void SetPosition (SMESH_Actor* theActor,
145 const TVTKIds& theIds)
147 vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
148 myGrid->SetPoints(aGrid->GetPoints());
150 const int* aConn = NULL;
154 static int anIds[] = {0,2,1,3};
160 static int anIds[] = {0,3,2,1,4};
166 static int anIds[] = {0,3,2,1,4,7,6,5};
173 vtkIdList *anIds = vtkIdList::New();
176 for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
177 anIds->InsertId(i,theIds[aConn[i]]);
179 for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
180 anIds->InsertId(i,theIds[i]);
182 myGrid->InsertNextCell(theType,anIds);
191 void SetVisibility (bool theVisibility)
193 myPreviewActor->SetVisibility(theVisibility);
194 RepaintCurrentView();
198 ~TElementSimulation()
200 if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) {
201 myVTKViewWindow->RemoveActor(myPreviewActor);
203 myPreviewActor->Delete();
205 myMapper->RemoveAllInputs();
213 //=================================================================================
214 // function : SMESHGUI_AddMeshElementDlg()
215 // purpose : constructor
216 //=================================================================================
217 SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule,
219 SMDSAbs_ElementType ElementType, int nbNodes,
220 bool modal, WFlags fl)
221 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
222 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
223 mySMESHGUI( theModule ),
224 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
226 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
227 (SUIT_Session::session()->activeApplication());
229 mySimulation = new SMESH::TElementSimulation (anApp);
230 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
232 // verify nb nodes and type
234 myElementType = ElementType;
235 switch (ElementType) {
237 // if (myNbNodes != 3 && myNbNodes != 4)
241 // if (myNbNodes != 4 && myNbNodes != 8) //(nbNodes < 4 || nbNodes > 8 || nbNodes == 7)
245 myElementType = SMDSAbs_Edge;
250 if (myNbNodes == 2) {
252 myHelpFileName = "adding_nodes_and_elements_page.html#adding_edges_anchor";
254 else if (myNbNodes == 3) {
255 elemName = "TRIANGLE";
256 myHelpFileName = "adding_nodes_and_elements_page.html#adding_triangles_anchor";
258 else if (myNbNodes == 4)
259 if (myElementType == SMDSAbs_Face) {
260 elemName = "QUADRANGLE";
261 myHelpFileName = "adding_nodes_and_elements_page.html#adding_quadrangles_anchor";
265 myHelpFileName = "adding_nodes_and_elements_page.html#adding_tetrahedrons_anchor";
267 else if (myNbNodes == 8) {
269 myHelpFileName = "adding_nodes_and_elements_page.html#adding_hexahedrons_anchor";
271 else if (myElementType == SMDSAbs_Face) {
272 elemName = "POLYGON";
274 myHelpFileName = "adding_nodes_and_elements_page.html#adding_polygons_anchor";
276 else if (myElementType == SMDSAbs_Volume) {
277 myHelpFileName = "adding_nodes_and_elements_page.html#adding_polyhedrons_anchor";
280 QString iconName = tr(QString("ICON_DLG_%1").arg(elemName));
281 QString buttonGrTitle = tr(QString("SMESH_%1").arg(elemName));
282 QString caption = tr(QString("SMESH_ADD_%1_TITLE").arg(elemName));
283 QString grBoxTitle = tr(QString("SMESH_ADD_%1").arg(elemName));
285 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", iconName));
286 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
289 setName("SMESHGUI_AddMeshElementDlg");
293 setSizeGripEnabled(TRUE);
294 SMESHGUI_AddMeshElementDlgLayout = new QGridLayout(this);
295 SMESHGUI_AddMeshElementDlgLayout->setSpacing(6);
296 SMESHGUI_AddMeshElementDlgLayout->setMargin(11);
298 /***************************************************************/
299 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
300 GroupConstructors->setTitle(buttonGrTitle);
302 GroupConstructors->setExclusive(TRUE);
303 GroupConstructors->setColumnLayout(0, Qt::Vertical);
304 GroupConstructors->layout()->setSpacing(0);
305 GroupConstructors->layout()->setMargin(0);
306 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
307 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
308 GroupConstructorsLayout->setSpacing(6);
309 GroupConstructorsLayout->setMargin(11);
310 Constructor1 = new QRadioButton(GroupConstructors, "Constructor1");
311 Constructor1->setText(tr("" ));
312 Constructor1->setPixmap(image0);
313 Constructor1->setChecked(TRUE);
314 Constructor1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth()));
315 Constructor1->setMinimumSize(QSize(50, 0));
316 GroupConstructorsLayout->addWidget(Constructor1, 0, 0);
317 QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
318 GroupConstructorsLayout->addItem(spacer, 0, 1);
319 SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupConstructors, 0, 0);
321 /***************************************************************/
322 GroupButtons = new QGroupBox(this, "GroupButtons");
323 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
324 GroupButtons->setTitle(tr("" ));
325 GroupButtons->setColumnLayout(0, Qt::Vertical);
326 GroupButtons->layout()->setSpacing(0);
327 GroupButtons->layout()->setMargin(0);
328 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
329 GroupButtonsLayout->setAlignment(Qt::AlignTop);
330 GroupButtonsLayout->setSpacing(6);
331 GroupButtonsLayout->setMargin(11);
332 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
333 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
334 buttonCancel->setAutoDefault(TRUE);
335 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
336 buttonApply = new QPushButton(GroupButtons, "buttonApply");
337 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
338 buttonApply->setAutoDefault(TRUE);
339 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
340 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
341 GroupButtonsLayout->addItem(spacer_9, 0, 2);
342 buttonOk = new QPushButton(GroupButtons, "buttonOk");
343 buttonOk->setText(tr("SMESH_BUT_OK" ));
344 buttonOk->setAutoDefault(TRUE);
345 buttonOk->setDefault(TRUE);
346 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
347 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
348 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
349 buttonHelp->setAutoDefault(TRUE);
350 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
352 SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupButtons, 2, 0);
354 /***************************************************************/
355 GroupC1 = new QGroupBox(this, "GroupC1");
356 GroupC1->setTitle(grBoxTitle);
358 GroupC1->setMinimumSize(QSize(0, 0));
359 GroupC1->setFrameShape(QGroupBox::Box);
360 GroupC1->setFrameShadow(QGroupBox::Sunken);
361 GroupC1->setColumnLayout(0, Qt::Vertical);
362 GroupC1->layout()->setSpacing(0);
363 GroupC1->layout()->setMargin(0);
364 GroupC1Layout = new QGridLayout(GroupC1->layout());
365 GroupC1Layout->setAlignment(Qt::AlignTop);
366 GroupC1Layout->setSpacing(6);
367 GroupC1Layout->setMargin(11);
368 TextLabelC1A1 = new QLabel(GroupC1, "TextLabelC1A1");
369 TextLabelC1A1->setText(tr("SMESH_ID_NODES" ));
370 TextLabelC1A1->setMinimumSize(QSize(50, 0));
371 TextLabelC1A1->setFrameShape(QLabel::NoFrame);
372 TextLabelC1A1->setFrameShadow(QLabel::Plain);
373 GroupC1Layout->addWidget(TextLabelC1A1, 0, 0);
374 SelectButtonC1A1 = new QPushButton(GroupC1, "SelectButtonC1A1");
375 SelectButtonC1A1->setText(tr("" ));
376 SelectButtonC1A1->setPixmap(image1);
377 SelectButtonC1A1->setToggleButton(FALSE);
378 GroupC1Layout->addWidget(SelectButtonC1A1, 0, 1);
379 LineEditC1A1 = new QLineEdit(GroupC1, "LineEditC1A1");
380 // LineEditC1A1->setReadOnly(TRUE);
382 LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this, "validator", myNbNodes));
383 GroupC1Layout->addWidget(LineEditC1A1, 0, 2);
385 if (myElementType == SMDSAbs_Face) {
386 Reverse = new QCheckBox(GroupC1, "Reverse");
387 Reverse->setText(tr("SMESH_REVERSE" ));
388 GroupC1Layout->addWidget(Reverse, 1, 0);
393 SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupC1, 1, 0);
395 Init(); /* Initialisations */
398 //=================================================================================
399 // function : ~SMESHGUI_AddMeshElementDlg()
400 // purpose : Destroys the object and frees any allocated resources
401 //=================================================================================
402 SMESHGUI_AddMeshElementDlg::~SMESHGUI_AddMeshElementDlg()
404 // no need to delete child widgets, Qt does it all for us
408 //=================================================================================
411 //=================================================================================
412 void SMESHGUI_AddMeshElementDlg::Init()
415 Constructor1->setChecked(TRUE);
416 myEditCurrentArgument = LineEditC1A1;
417 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
422 /* signals and slots connections */
423 connect(buttonOk, SIGNAL(clicked()), SLOT(ClickOnOk()));
424 connect(buttonCancel, SIGNAL(clicked()), SLOT(ClickOnCancel()));
425 connect(buttonApply, SIGNAL(clicked()), SLOT(ClickOnApply()));
426 connect(buttonHelp, SIGNAL(clicked()), SLOT(ClickOnHelp()));
428 connect(SelectButtonC1A1, SIGNAL(clicked()), SLOT(SetEditCurrentArgument()));
429 connect(LineEditC1A1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
430 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
431 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument()));
432 /* to close dialog if study frame change */
433 connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel()));
436 connect(Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)));
438 this->show(); // displays Dialog
440 // set selection mode
441 SMESH::SetPointRepresentation(true);
443 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
444 aViewWindow->SetSelectionMode( NodeSelection );
448 SelectionIntoArgument();
451 //=================================================================================
452 // function : ClickOnApply()
454 //=================================================================================
455 void SMESHGUI_AddMeshElementDlg::ClickOnApply()
457 if (myNbOkNodes && !mySMESHGUI->isActiveStudyLocked()) {
459 SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
460 anArrayOfIdeces->length(myNbNodes);
461 bool reverse = (Reverse && Reverse->isChecked());
462 QStringList aListId = QStringList::split(" ", myEditCurrentArgument->text(), false);
463 for (int i = 0; i < aListId.count(); i++)
465 anArrayOfIdeces[i] = aListId[ myNbNodes - i - 1 ].toInt();
467 anArrayOfIdeces[i] = aListId[ i ].toInt();
469 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
470 switch (myElementType) {
472 aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break;
475 aMeshEditor->AddPolygonalFace(anArrayOfIdeces.inout());
477 aMeshEditor->AddFace(anArrayOfIdeces.inout());
482 aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break;
486 SALOME_ListIO aList; aList.Append( myActor->getIO() );
487 mySelector->ClearIndex();
488 mySelectionMgr->setSelectedObjects( aList, false );
491 mySimulation->SetVisibility(false);
493 buttonOk->setEnabled(false);
494 buttonApply->setEnabled(false);
496 myEditCurrentArgument->setText("");
502 //=================================================================================
503 // function : ClickOnOk()
505 //=================================================================================
506 void SMESHGUI_AddMeshElementDlg::ClickOnOk()
508 this->ClickOnApply();
509 this->ClickOnCancel();
513 //=================================================================================
514 // function : ClickOnCancel()
516 //=================================================================================
517 void SMESHGUI_AddMeshElementDlg::ClickOnCancel()
519 //mySelectionMgr->clearSelected();
520 mySimulation->SetVisibility(false);
521 SMESH::SetPointRepresentation(false);
522 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
523 aViewWindow->SetSelectionMode( ActorSelection );
524 disconnect(mySelectionMgr, 0, this, 0);
525 mySMESHGUI->ResetState();
530 //=================================================================================
531 // function : ClickOnHelp()
533 //=================================================================================
534 void SMESHGUI_AddMeshElementDlg::ClickOnHelp()
536 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
538 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
542 platform = "winapplication";
544 platform = "application";
546 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
547 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
548 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
549 QObject::tr("BUT_OK"));
553 //=================================================================================
554 // function : onTextChange()
556 //=================================================================================
557 void SMESHGUI_AddMeshElementDlg::onTextChange (const QString& theNewText)
564 buttonOk->setEnabled(false);
565 buttonApply->setEnabled(false);
567 mySimulation->SetVisibility(false);
569 // hilight entered nodes
570 SMDS_Mesh* aMesh = 0;
572 aMesh = myActor->GetObject()->GetMesh();
575 TColStd_MapOfInteger newIndices;
577 QStringList aListId = QStringList::split(" ", theNewText, false);
579 for (int i = 0; i < aListId.count(); i++) {
580 if( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) )
582 newIndices.Add( n->GetID() );
589 mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false );
590 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
591 aViewWindow->highlight( myActor->getIO(), true, true );
593 myNbOkNodes = ( allOk && myNbNodes == aListId.count() );
597 if ( !allOk || myElementType != SMDSAbs_Face || aListId.count() < 3 )
600 myNbOkNodes = aListId.count();
605 buttonOk->setEnabled(true);
606 buttonApply->setEnabled(true);
613 //=================================================================================
614 // function : SelectionIntoArgument()
615 // purpose : Called when selection has changed
616 //=================================================================================
617 void SMESHGUI_AddMeshElementDlg::SelectionIntoArgument()
626 myEditCurrentArgument->setText("");
629 if (!GroupButtons->isEnabled()) // inactive
632 buttonOk->setEnabled(false);
633 buttonApply->setEnabled(false);
635 mySimulation->SetVisibility(false);
636 // SMESH::SetPointRepresentation(true);
640 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
642 if (aList.Extent() != 1)
645 Handle(SALOME_InteractiveObject) anIO = aList.First();
646 myMesh = SMESH::GetMeshByIO(anIO);
647 if (myMesh->_is_nil())
650 myActor = SMESH::FindActorByEntry(anIO->getEntry());
654 // get selected nodes
655 QString aString = "";
656 int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,myActor->getIO(),aString);
658 myEditCurrentArgument->setText(aString);
660 if (myIsPoly && myElementType == SMDSAbs_Face && nbNodes >= 3 ) {
662 } else if (myNbNodes != nbNodes) {
667 myNbOkNodes = nbNodes;
669 buttonOk->setEnabled(true);
670 buttonApply->setEnabled(true);
675 //=================================================================================
676 // function : displaySimulation()
678 //=================================================================================
679 void SMESHGUI_AddMeshElementDlg::displaySimulation()
681 if (myNbOkNodes && GroupButtons->isEnabled()) {
682 SMESH::TElementSimulation::TVTKIds anIds;
683 QStringList aListId = QStringList::split(" ", myEditCurrentArgument->text(), false);
684 for (int i = 0; i < aListId.count(); i++)
685 anIds.push_back(myActor->GetObject()->GetNodeVTKId(aListId[ i ].toInt()));
687 if (Reverse && Reverse->isChecked())
688 reverse(anIds.begin(),anIds.end());
692 switch ( myElementType ) {
693 case SMDSAbs_Face : aType = VTK_POLYGON; break;
698 case 2: aType = VTK_LINE; break;
699 case 3: aType = VTK_TRIANGLE; break;
700 case 4: aType = myElementType == SMDSAbs_Face ? VTK_QUAD : VTK_TETRA; break;
701 case 8: aType = VTK_HEXAHEDRON; break;
706 mySimulation->SetPosition(myActor,aType,anIds);
711 //=================================================================================
712 // function : SetEditCurrentArgument()
714 //=================================================================================
715 void SMESHGUI_AddMeshElementDlg::SetEditCurrentArgument()
717 QPushButton* send = (QPushButton*)sender();
718 if (send == SelectButtonC1A1) {
719 LineEditC1A1->setFocus();
720 myEditCurrentArgument = LineEditC1A1;
722 SelectionIntoArgument();
725 //=================================================================================
726 // function : DeactivateActiveDialog()
728 //=================================================================================
729 void SMESHGUI_AddMeshElementDlg::DeactivateActiveDialog()
731 if (GroupConstructors->isEnabled()) {
732 GroupConstructors->setEnabled(false);
733 GroupC1->setEnabled(false);
734 GroupButtons->setEnabled(false);
735 mySimulation->SetVisibility(false);
736 mySMESHGUI->ResetState();
737 mySMESHGUI->SetActiveDialogBox(0);
741 //=================================================================================
742 // function : ActivateThisDialog()
744 //=================================================================================
745 void SMESHGUI_AddMeshElementDlg::ActivateThisDialog()
747 /* Emit a signal to deactivate the active dialog */
748 mySMESHGUI->EmitSignalDeactivateDialog();
750 GroupConstructors->setEnabled(true);
751 GroupC1->setEnabled(true);
752 GroupButtons->setEnabled(true);
754 SMESH::SetPointRepresentation(true);
756 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
757 aViewWindow->SetSelectionMode( NodeSelection );
758 SelectionIntoArgument();
761 //=================================================================================
762 // function : enterEvent()
764 //=================================================================================
765 void SMESHGUI_AddMeshElementDlg::enterEvent (QEvent*)
767 if (GroupConstructors->isEnabled())
769 ActivateThisDialog();
773 //=================================================================================
774 // function : closeEvent()
776 //=================================================================================
777 void SMESHGUI_AddMeshElementDlg::closeEvent (QCloseEvent*)
779 /* same than click on cancel button */
780 this->ClickOnCancel();
784 //=================================================================================
785 // function : hideEvent()
786 // purpose : caused by ESC key
787 //=================================================================================
788 void SMESHGUI_AddMeshElementDlg::hideEvent (QHideEvent*)
794 //=================================================================================
795 // function : CheckBox()
797 //=================================================================================
798 void SMESHGUI_AddMeshElementDlg::CheckBox (int state)
804 mySimulation->SetVisibility(false);
809 //=================================================================================
810 // function : keyPressEvent()
812 //=================================================================================
813 void SMESHGUI_AddMeshElementDlg::keyPressEvent( QKeyEvent* e )
815 QDialog::keyPressEvent( e );
816 if ( e->isAccepted() )
819 if ( e->key() == Key_F1 )