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
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
28 #include "SMESHGUI_InitMeshDlg.h"
29 #include "SMESHGUI_AddSubMeshDlg.h"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_HypothesesUtils.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_EditHypothesesDlg.h"
46 #include "SMESHGUI_CreateHypothesesDlg.h"
47 #include "SMESHGUI_FilterDlg.h"
48 #include "SMESHGUI_FilterLibraryDlg.h"
49 #include "SMESHGUI_SingleEditDlg.h"
50 #include "SMESHGUI_MultiEditDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_DeleteGroupDlg.h"
53 #include "SMESHGUI_SmoothingDlg.h"
54 #include "SMESHGUI_RenumberingDlg.h"
55 #include "SMESHGUI_ExtrusionDlg.h"
56 #include "SMESHGUI_RevolutionDlg.h"
57 #include "SMESHGUI_TranslationDlg.h"
58 #include "SMESHGUI_RotationDlg.h"
59 #include "SMESHGUI_SymmetryDlg.h"
60 #include "SMESHGUI_SewingDlg.h"
61 #include "SMESHGUI_MergeNodesDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_PrecisionDlg.h"
65 #include "VTKViewer_ViewFrame.h"
66 #include "VTKViewer_InteractorStyleSALOME.h"
67 #include "VTKViewer_RenderWindowInteractor.h"
69 #include "SMESH_Actor.h"
70 #include "SMESH_Object.h"
73 #include "QAD_Tools.h"
74 #include "QAD_Config.h"
75 #include "QAD_Settings.h"
76 #include "QAD_RightFrame.h"
77 #include "QAD_MessageBox.h"
78 #include "QAD_Resource.h"
79 #include "QAD_FileDlg.h"
80 #include "QAD_Desktop.h"
81 #include "QAD_ResourceMgr.h"
82 #include "QAD_WaitCursor.h"
84 #include "SALOME_NamingService.hxx"
85 #include "SALOME_ListIteratorOfListIO.hxx"
86 #include "SALOME_InteractiveObject.hxx"
88 #include "SALOMEGUI_Desktop.h"
89 #include "SALOMEGUI_NameDlg.h"
90 #include "SALOMEGUI_ImportOperation.h"
91 #include "SALOMEGUI_QtCatchCorbaException.hxx"
93 #include "SMESHGUI_Utils.h"
94 #include "SMESHGUI_SMESHGenUtils.h"
95 #include "SMESHGUI_GEOMGenUtils.h"
96 #include "SMESHGUI_MeshUtils.h"
97 #include "SMESHGUI_GroupUtils.h"
98 #include "SMESHGUI_FilterUtils.h"
99 #include "SMESHGUI_PatternUtils.h"
100 #include "SMESHGUI_VTKUtils.h"
102 #include "SALOMEconfig.h"
103 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
106 #define INCLUDE_MENUITEM_DEF
107 #include <qapplication.h>
108 #include <qlineedit.h>
109 #include <qmenudata.h>
110 #include <qmenubar.h>
111 #include <qpopupmenu.h>
114 #include <qpainter.h>
115 #include <qcheckbox.h>
116 #include <qcolordialog.h>
117 #include <qspinbox.h>
121 #include <qradiobutton.h>
123 #include <boost/shared_ptr.hpp>
125 #include <vtkRenderer.h>
126 #include <vtkRenderWindow.h>
127 #include <vtkActorCollection.h>
128 #include <vtkScalarBarActor.h>
130 #include "utilities.h"
136 //=============================================================
137 void ImportMeshesFromFile(QAD_Desktop * parent,
138 SMESH::SMESH_Gen_ptr theComponentMesh,
141 void ExportMeshToFile(QAD_Desktop * parent, int theCommandID);
143 void SetDisplayMode(int theCommandID);
145 void SetDisplayEntity(int theCommandID);
147 void Control( int theCommandID );
149 void SetDisplaySettings();
153 //=============================================================
154 void ImportMeshesFromFile(QAD_Desktop * parent,
155 SMESH::SMESH_Gen_ptr theComponentMesh,
161 if(theCommandID == 113){
162 filter = QObject::tr("MED files (*.med)");
163 }else if (theCommandID == 112){
164 filter = QObject::tr("IDEAS files (*.unv)");
165 }else if (theCommandID == 111){
166 filter = QObject::tr("DAT files (*.dat)");
168 QString filename = QAD_FileDlg::getFileName(parent,
171 QObject::tr("Import mesh"),
173 if(!filename.isEmpty()) {
175 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
178 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
179 switch ( theCommandID ) {
182 aMeshes->length( 1 );
183 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
188 SMESH::DriverMED_ReadStatus res;
189 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
190 if ( res != SMESH::DRS_OK ) {
192 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
193 QObject::tr("SMESH_WRN_WARNING"),
194 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
195 QObject::tr("SMESH_BUT_OK"));
196 aMeshes->length( 0 );
203 bool isEmpty = false;
204 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
205 SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( aMeshes[i] );
206 if ( !aMeshSO->_is_nil() ) {
207 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
208 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ) );
209 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
210 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
211 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
218 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
219 QObject::tr("SMESH_WRN_WARNING"),
220 QObject::tr("SMESH_DRS_EMPTY"),
221 QObject::tr("SMESH_BUT_OK"));
225 catch (const SALOME::SALOME_Exception& S_ex){
227 QtCatchCorbaException(S_ex);
234 void ExportMeshToFile(QAD_Desktop * parent, int theCommandID)
236 SALOME_Selection *aSel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
237 if(aSel->IObjectCount()){
238 Handle(SALOME_InteractiveObject) anIObject = aSel->firstIObject();
239 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
240 if ( !aMesh->_is_nil() ) {
241 QString aFilter, aTitle = QObject::tr("Export mesh");
242 switch ( theCommandID ) {
244 aFilter = QObject::tr("MED files (*.med)");
247 aFilter = QObject::tr("DAT files (*.dat)");
250 if(aMesh->NbPyramids()){
251 int aRet = QAD_MessageBox::warn2(QAD_Application::getDesktop(),
252 QObject::tr("SMESH_WRN_WARNING"),
253 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
254 QObject::tr("SMESH_BUT_YES"),
255 QObject::tr("SMESH_BUT_NO"),
260 aFilter = QObject::tr("IDEAS files (*.unv)");
266 QString aFilename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false);
267 if ( !aFilename.isEmpty() ) {
268 // Check whether the file already exists and delete it if yes
269 QFile aFile( aFilename );
270 if ( aFile.exists() )
273 switch ( theCommandID ) {
275 aMesh->ExportMED( aFilename.latin1(), true ); // currently, automatic groups are always created
278 aMesh->ExportDAT( aFilename.latin1() );
281 aMesh->ExportUNV( aFilename.latin1() );
291 inline void InverseEntityMode(unsigned int& theOutputMode,
292 unsigned int theMode)
294 bool anIsNotPresent = ~theOutputMode & theMode;
296 theOutputMode |= theMode;
298 theOutputMode &= ~theMode;
301 void SetDisplayEntity(int theCommandID){
302 SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
303 if(Sel->IObjectCount() >= 1){
304 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
305 for(; It.More(); It.Next()){
306 Handle(SALOME_InteractiveObject) IObject = It.Value();
307 if(IObject->hasEntry()){
308 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
309 unsigned int aMode = anActor->GetEntityMode();
310 switch(theCommandID){
312 InverseEntityMode(aMode,SMESH_Actor::eEdges);
315 InverseEntityMode(aMode,SMESH_Actor::eFaces);
318 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
321 aMode = SMESH_Actor::eAllEntity;
325 anActor->SetEntityMode(aMode);
332 void SetDisplayMode(int theCommandID){
333 SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
334 if(Sel->IObjectCount() >= 1){
335 switch(theCommandID){
337 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
338 new SMESHGUI_ClippingDlg(QAD_Application::getDesktop(),"",false);
342 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
343 new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false);
346 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
347 for(; It.More(); It.Next()){
348 Handle(SALOME_InteractiveObject) IObject = It.Value();
349 if(IObject->hasEntry()){
350 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
351 switch(theCommandID){
353 anActor->SetRepresentation(SMESH_Actor::eEdge);
356 anActor->SetRepresentation(SMESH_Actor::eSurface);
359 if(anActor->IsShrunk())
362 anActor->SetShrink();
365 anActor->SetRepresentation(SMESH_Actor::ePoint);
369 anActor->GetSufaceColor(color[0], color[1], color[2]);
370 int c0 = int (color[0] * 255);
371 int c1 = int (color[1] * 255);
372 int c2 = int (color[2] * 255);
373 QColor c(c0, c1, c2);
376 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
377 c0 = int (edgecolor[0] * 255);
378 c1 = int (edgecolor[1] * 255);
379 c2 = int (edgecolor[2] * 255);
380 QColor e(c0, c1, c2);
382 float backfacecolor[3];
383 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
384 c0 = int (backfacecolor[0] * 255);
385 c1 = int (backfacecolor[1] * 255);
386 c2 = int (backfacecolor[2] * 255);
387 QColor b(c0, c1, c2);
390 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
391 c0 = int (nodecolor[0] * 255);
392 c1 = int (nodecolor[1] * 255);
393 c2 = int (nodecolor[2] * 255);
394 QColor n(c0, c1, c2);
396 int Edgewidth = (int)anActor->GetLineWidth();
399 int intValue = int(anActor->GetNodeSize());
400 float Shrink = anActor->GetShrinkFactor();
402 SMESHGUI_Preferences_ColorDlg *aDlg =
403 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),"");
404 aDlg->SetColor(1, c);
405 aDlg->SetColor(2, e);
406 aDlg->SetColor(3, n);
407 aDlg->SetColor(4, b);
408 aDlg->SetIntValue(1, Edgewidth);
409 aDlg->SetIntValue(2, intValue);
410 aDlg->SetIntValue(3, int(Shrink*100.));
412 QColor color = aDlg->GetColor(1);
413 QColor edgecolor = aDlg->GetColor(2);
414 QColor nodecolor = aDlg->GetColor(3);
415 QColor backfacecolor = aDlg->GetColor(4);
416 /* actor color and backface color */
417 anActor->SetSufaceColor(float (color.red()) / 255.,
418 float (color.green()) / 255.,
419 float (color.blue()) / 255.);
420 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
421 float (backfacecolor.green()) / 255.,
422 float (backfacecolor.blue()) / 255.);
425 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
426 float (edgecolor.green()) / 255.,
427 float (edgecolor.blue()) / 255.);
429 /* Shrink factor and size edges */
430 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
431 anActor->SetLineWidth(aDlg->GetIntValue(1));
433 /* Nodes color and size */
434 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
435 float (nodecolor.green()) / 255.,
436 float (nodecolor.blue()) / 255.);
437 anActor->SetNodeSize(aDlg->GetIntValue(2));
446 SMESH::RepaintCurrentView();
451 void SetDisplaySettings()
453 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
454 SMESHGUI_Preferences_ColorDlg *aDlg =
455 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), "");
458 QString SCr, SCg, SCb;
459 SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed");
460 SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen");
461 SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue");
462 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
463 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
464 else color = QColor(0, 170, 255);
465 aDlg->SetColor(1, color);
467 SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed");
468 SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen");
469 SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue");
470 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
471 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
472 else color = QColor(0, 170, 255);
473 aDlg->SetColor(2, color);
475 SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed");
476 SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen");
477 SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue");
478 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
479 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
480 else color = Qt::red;
481 aDlg->SetColor(3, color);
483 QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed");
484 QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen");
485 QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue");
486 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
487 color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt());
488 else color = Qt::blue;
489 aDlg->SetColor(4, color);
491 QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth");
492 if (intValue.isEmpty()) intValue = "1";
493 aDlg->SetIntValue(1, intValue.toInt());
494 intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize");
495 if (intValue.isEmpty()) intValue = "3";
496 aDlg->SetIntValue(2, intValue.toInt());
497 intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff");
498 if (intValue.isEmpty()) intValue = "75";
499 aDlg->SetIntValue(3, intValue.toInt());
502 QColor colorFill = aDlg->GetColor(1);
503 QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red());
504 QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen", colorFill.green());
505 QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue());
507 QColor colorOutline = aDlg->GetColor(2);
508 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed", colorOutline.red());
509 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen", colorOutline.green());
510 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue", colorOutline.blue());
512 QColor colorNode = aDlg->GetColor(3);
513 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red());
514 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen", colorNode.green());
515 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue());
517 QColor colorBackFace = aDlg->GetColor(4);
518 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed", colorBackFace.red());
519 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen", colorBackFace.green());
520 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue", colorBackFace.blue());
522 int width = aDlg->GetIntValue(1);
523 QAD_CONFIG->addSetting("SMESH:SettingsWidth", width);
525 int nodes_size = aDlg->GetIntValue(2);
526 QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size);
528 int shrink_coeff = aDlg->GetIntValue(3);
529 QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff);
536 void Control( int theCommandID )
538 SALOME_Selection *Sel = SALOME_Selection::Selection( SMESH::GetActiveStudy()->getSelection() );
540 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
543 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
544 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
545 switch ( theCommandID ){
547 aTitle = QObject::tr( "LENGTH_EDGES" );
548 aControl = SMESH_Actor::eLength;
551 aTitle = QObject::tr( "LENGTH2D_EDGES" );
552 aControl = SMESH_Actor::eLength2D;
555 aTitle = QObject::tr( "FREE_EDGES" );
556 aControl = SMESH_Actor::eFreeEdges;
559 aTitle = QObject::tr( "FREE_BORDERS" );
560 aControl = SMESH_Actor::eFreeBorders;
563 aTitle = QObject::tr( "MULTI_BORDERS" );
564 aControl = SMESH_Actor::eMultiConnection;
567 aTitle = QObject::tr( "MULTI2D_BORDERS" );
568 aControl = SMESH_Actor::eMultiConnection2D;
571 aTitle = QObject::tr( "AREA_ELEMENTS" );
572 aControl = SMESH_Actor::eArea;
575 aTitle = QObject::tr( "TAPER_ELEMENTS" );
576 aControl = SMESH_Actor::eTaper;
579 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
580 aControl = SMESH_Actor::eAspectRatio;
583 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
584 aControl = SMESH_Actor::eAspectRatio3D;
587 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
588 aControl = SMESH_Actor::eMinimumAngle;
591 aTitle = QObject::tr( "WARP_ELEMENTS" );
592 aControl = SMESH_Actor::eWarping;
595 aTitle = QObject::tr( "SKEW_ELEMENTS" );
596 aControl = SMESH_Actor::eSkew;
599 anActor->SetControlMode(aControl);
600 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
607 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
608 MeshObjectType theType,
609 const QString theInTypeName,
610 QString & theOutTypeName)
612 SMESH_TypeFilter aTypeFilter( theType );
613 if ( aTypeFilter.IsOk( theIO )) {
614 theOutTypeName = theInTypeName;
621 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
623 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
624 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theIO->getEntry());
625 if (!aSObj->_is_nil()) {
626 SALOMEDS::SComponent_var aSComp = aSObj->GetFatherComponent();
627 CORBA::String_var anID = aSComp->GetID();
628 if (!strcmp(anID.in(),theIO->getEntry()))
634 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
635 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
636 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
637 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
638 CheckOIType ( theIO, GROUP, "Group", aTypeName )
646 QString CheckHomogeneousSelection()
648 QAD_Study* aStudy = SMESH::GetActiveStudy();
649 SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection());
652 SALOME_ListIteratorOfListIO Itinit(aSel->StoredIObjects());
653 for (; Itinit.More(); Itinit.Next())
655 List.Append(Itinit.Value());
658 QString RefType = CheckTypeObject(aSel->firstIObject());
659 SALOME_ListIteratorOfListIO It(List);
660 for (; It.More(); It.Next())
662 Handle(SALOME_InteractiveObject) IObject = It.Value();
663 QString Type = CheckTypeObject(IObject);
664 if (Type.compare(RefType) != 0)
665 return "Heterogeneous Selection";
668 aSel->ClearIObjects();
669 SALOME_ListIteratorOfListIO It1(List);
670 for (; It1.More(); It1.Next())
672 int res = aSel->AddIObject(It1.Value());
674 aStudy->highlight(It1.Value(), false);
676 aStudy->highlight(It1.Value(), true);
683 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
684 QString aParentComponent = ((SALOMEGUI_Desktop*)QAD_Application::getDesktop())->getComponentFromSelection();
685 if ( aParentComponent != QAD_Application::getDesktop()->getActiveComponent() ) {
686 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
687 QObject::tr("ERR_ERROR"),
688 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg(QAD_Application::getDesktop()->getComponentUserName( "SMESH" )),
689 QObject::tr("BUT_OK") );
692 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
693 if (QAD_MessageBox::warn2
694 (QAD_Application::getDesktop(),
695 QObject::tr("SMESH_WRN_WARNING"),
696 QObject::tr("SMESH_REALLY_DELETE"),
697 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
700 QAD_Study* anActiveStudy = SMESH::GetActiveStudy();
701 int nbSf = anActiveStudy->getStudyFramesCount();
703 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
704 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
705 SALOMEDS::GenericAttribute_var anAttr;
706 SALOMEDS::AttributeIOR_var anIOR;
708 SALOME_Selection *Sel = SALOME_Selection::Selection(anActiveStudy->getSelection());
709 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
710 for(; It.More(); It.Next()){
711 Handle(SALOME_InteractiveObject) IObject = It.Value();
712 if(IObject->hasEntry()){
713 SALOMEDS::SObject_var SO = aStudy->FindObjectID(IObject->getEntry());
715 /* Erase child graphical objects */
716 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
717 for(; it->More(); it->Next()){
718 SALOMEDS::SObject_var CSO = it->Value();
719 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
720 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
722 for(int i = 0; i < nbSf; i++){
723 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
724 CORBA::String_var anEntry = CSO->GetID();
725 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
726 SMESH::RemoveActor(sf,anActor);
732 /* Erase main graphical object */
733 for(int i = 0; i < nbSf; i++){
734 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
735 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
736 SMESH::RemoveActor(sf,anActor);
740 // Remove object(s) from data structures
741 SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
743 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(obj->GetObject());
744 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(obj->GetObject());
746 if ( !aGroup->_is_nil() ) { // DELETE GROUP
747 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
748 aMesh->RemoveGroup( aGroup );
750 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
751 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
752 aMesh->RemoveSubMesh( aSubMesh );
754 else {// default action: remove SObject from the study
755 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
756 //QAD_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
758 aStudyBuilder->RemoveObjectWithChildren( obj );
763 } /* IObject->hasEntry() */
766 /* Clear any previous selection */
767 Sel->ClearIObjects();
768 anActiveStudy->updateObjBrowser();
774 //=============================================================================
778 //=============================================================================
779 class CustomItem : public QCustomMenuItem
782 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
785 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
788 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
789 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
790 p->setFont( myFont );
791 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
797 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
800 bool fullSpan() const
810 //=============================================================================
814 //=============================================================================
815 SMESHGUI::SMESHGUI( const QString& theName, QObject* theParent ) :
816 SALOMEGUI( theName, theParent )
818 myActiveDialogBox = 0 ;
821 SMESH::GetSMESHGen();
822 SMESH::GetFilterManager();
825 /* load resources for all available meshers */
826 SMESH::InitAvailableHypotheses();
829 //=============================================================================
833 //=============================================================================
834 SMESHGUI::~SMESHGUI()
836 SMESH::GetFilterManager()->Destroy();
839 //=============================================================================
843 //=============================================================================
844 SMESHGUI* SMESHGUI::GetSMESHGUI()
846 static SMESHGUI aSMESHGUI;
847 aSMESHGUI.myActiveStudy = SMESH::GetActiveStudy();
848 SMESH::GetSMESHGen()->SetCurrentStudy( SMESH::GetActiveStudyDocument() );
850 /* Automatic Update flag */
851 aSMESHGUI.myAutomaticUpdate = ( QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) == 0 );
858 Standard_EXPORT SALOMEGUI* GetComponentGUI() {
859 return SMESHGUI::GetSMESHGUI();
863 //=============================================================================
867 //=============================================================================
868 void SMESHGUI::SetState(int aState)
870 this->myState = aState;
874 //=============================================================================
878 //=============================================================================
879 void SMESHGUI::ResetState()
885 //=============================================================================
889 //=============================================================================
890 void SMESHGUI::EmitSignalDeactivateDialog()
892 emit this->SignalDeactivateActiveDialog();
896 //=============================================================================
900 //=============================================================================
901 void SMESHGUI::EmitSignalStudyFrameChanged()
903 emit this->SignalStudyFrameChanged();
907 //=============================================================================
911 //=============================================================================
912 void SMESHGUI::EmitSignalCloseAllDialogs()
914 emit SignalCloseAllDialogs();
918 //=============================================================================
922 //=============================================================================
923 QDialog *SMESHGUI::GetActiveDialogBox()
925 return this->myActiveDialogBox;
928 //=============================================================================
932 //=============================================================================
933 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
935 this->myActiveDialogBox = (QDialog *) aDlg;
939 //=============================================================================
943 //=============================================================================
944 QAD_Study *SMESHGUI::GetActiveStudy()
946 return this->myActiveStudy;
949 //=============================================================================
953 //=============================================================================
954 QAD_Desktop *SMESHGUI::GetDesktop()
956 return QAD_Application::getDesktop();
959 //=============================================================================
963 //=============================================================================
964 bool SMESHGUI::ActiveStudyChanged(QAD_Desktop* parent)
966 MESSAGE("SMESHGUI::activeStudyChanged init.");
967 QAD_Study* prevStudy = myActiveStudy;
968 /* Create or retrieve an object SMESHGUI */
969 MESSAGE("Active study changed : prev study =" << prevStudy);
970 SMESHGUI::GetSMESHGUI();
971 EmitSignalStudyFrameChanged();
972 MESSAGE("Active study changed : active study =" << myActiveStudy);
973 if ( prevStudy != myActiveStudy ) {
974 EmitSignalCloseAllDialogs();
975 MESSAGE("Active study changed : SMESHGUI nullified" << endl);
977 SMESH::UpdateSelectionProp();
979 MESSAGE("SMESHGUI::activeStudyChanged done.");
983 //=============================================================================
987 //=============================================================================
988 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
990 /* Here the position is on the bottom right corner - 10 */
991 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
993 QAD_Desktop *PP = QAD_Application::getDesktop();
994 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
995 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
999 //=============================================================================
1003 //=============================================================================
1004 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
1005 return theStudy->GetProperties()->IsLocked();
1008 static bool checkLock(const SALOMEDS::Study_var& theStudy) {
1009 if (isStudyLocked(theStudy)) {
1010 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
1011 QObject::tr("WRN_WARNING"),
1012 QObject::tr("WRN_STUDY_LOCKED"),
1013 QObject::tr("BUT_OK") );
1019 //=======================================================================
1020 //function : CheckActiveStudyLocked
1022 //=======================================================================
1024 bool SMESHGUI::ActiveStudyLocked()
1026 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1027 return checkLock( aStudy );
1030 //=============================================================================
1034 //=============================================================================
1035 bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
1037 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1039 switch (theCommandID) {
1041 if(checkLock(aStudy)) break;
1049 if(checkLock(aStudy)) break;
1050 ::ImportMeshesFromFile(parent,SMESH::GetSMESHGen(),theCommandID);
1054 case 122: // EXPORT MED
1058 ::ExportMeshToFile(parent, theCommandID);
1062 case 200: // SCALAR BAR
1064 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1065 if( Sel && Sel->IObjectCount() ) {
1066 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
1067 if( anIO->hasEntry() ) {
1068 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1069 anActor->SetControlMode( SMESH_Actor::eNone );
1077 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1078 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( parent, Sel );
1082 case 1134: // Clipping
1083 case 1133: // Tranparency
1084 case 1132: // Colors / Size
1091 ::SetDisplayMode(theCommandID);
1097 case 219: // Volumes
1098 case 220: // All Entity
1099 ::SetDisplayEntity(theCommandID);
1104 if(checkLock(aStudy)) break;
1105 SMESH::UpdateView();
1110 case 301: // DISPLAY
1111 case 302: // DISPLAY ONLY
1113 SMESH::EDisplaing anAction;
1114 switch(theCommandID){
1115 case 300: anAction = SMESH::eErase; break;
1116 case 301: anAction = SMESH::eDisplay; break;
1117 case 302: anAction = SMESH::eDisplayOnly; break;
1120 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1121 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1122 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1123 for (; It.More(); It.Next()) {
1124 Handle(SALOME_InteractiveObject) IOS = It.Value();
1125 if (IOS->hasEntry()) {
1126 SMESH::UpdateView(anAction,IOS->getEntry());
1130 Sel->ClearIObjects();
1136 if(checkLock(aStudy)) break;
1137 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1138 EmitSignalDeactivateDialog();
1139 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1140 new SMESHGUI_NodesDlg(parent, "", Sel);
1143 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1144 tr("SMESH_WRN_WARNING"),
1145 tr("SMESH_WRN_VIEWER_VTK"),
1146 tr("SMESH_BUT_OK"));
1151 case 2151: // FILTER
1153 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1155 EmitSignalDeactivateDialog();
1156 new SMESHGUI_FilterDlg( parent, SMESH::EDGE );
1161 case 406: // MOVE NODE
1163 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1165 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1166 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1170 if(checkLock(aStudy)) break;
1171 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1172 new SMESHGUI_MoveNodesDlg( parent, Sel );
1176 case 701: // COMPUTE MESH
1178 if(checkLock(aStudy)) break;
1179 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1180 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1181 int nbSel = Sel->IObjectCount();
1186 SMESH::SMESH_Mesh_var aMesh;
1187 SMESH::SMESH_subMesh_var aSubMesh;
1188 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1189 if (IObject->hasEntry()){
1190 SALOMEDS::SObject_var aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1191 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1192 if ( aShapeObject->_is_nil() ) {
1196 if(!aMeshSObj->_is_nil()) {
1197 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1198 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1200 if (!aMesh->_is_nil()){
1201 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1202 if (!refShapeObject->_is_nil()) {
1203 if(!SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1204 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1205 tr("SMESH_WRN_WARNING"),
1206 tr("SMESH_WRN_MISSING_PARAMETERS"),
1207 tr("SMESH_BUT_OK"));
1211 if (SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject))
1212 SMESH::ModifiedMesh(aMeshSObj,true);
1213 // TO Do : change icon of all submeshes
1215 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1216 tr("SMESH_WRN_WARNING"),
1217 tr("SMESH_WRN_COMPUTE_FAILED"),
1218 tr("SMESH_BUT_OK"));
1220 catch(const SALOME::SALOME_Exception & S_ex){
1221 QtCatchCorbaException(S_ex);
1224 }else if(!aSubMesh->_is_nil()){
1225 aMesh = aSubMesh->GetFather();
1226 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1227 if(!refShapeObject->_is_nil()){
1228 bool compute = SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1230 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1231 tr("SMESH_WRN_WARNING"),
1232 tr("SMESH_WRN_MISSING_PARAMETERS"),
1233 tr("SMESH_BUT_OK"));
1237 if ( SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject) )
1238 SMESH::ModifiedMesh(aMeshSObj,true);
1239 // TO Do : change icon of all submeshes
1241 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1242 tr("SMESH_WRN_WARNING"),
1243 tr("SMESH_WRN_COMPUTE_FAILED"),
1244 tr("SMESH_BUT_OK"));
1245 }catch(const SALOME::SALOME_Exception & S_ex){
1246 QtCatchCorbaException(S_ex);
1252 CORBA::Long anId = aStudy->StudyId();
1253 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1254 if(myAutomaticUpdate && aVisualObj){
1255 aVisualObj->Update();
1256 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1258 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1260 SMESH::DisplayActor(myActiveStudy->getActiveStudyFrame(),anActor); //apo
1266 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1267 tr("SMESH_WRN_WARNING"),
1268 tr("SMESH_WRN_VIEWER_VTK"),
1269 tr("SMESH_BUT_OK"));
1274 case 702: // ADD SUB MESH
1276 if(checkLock(aStudy)) break;
1277 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1278 EmitSignalDeactivateDialog();
1279 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1280 new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
1283 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1284 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1285 tr("SMESH_BUT_OK"));
1290 case 703: // INIT MESH
1292 if(checkLock(aStudy)) break;
1293 EmitSignalDeactivateDialog();
1294 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1295 new SMESHGUI_InitMeshDlg(parent, "", Sel);
1299 case 704: // EDIT Hypothesis
1301 if(checkLock(aStudy)) break;
1302 EmitSignalDeactivateDialog();
1303 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1304 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1308 case 705: // EDIT Global Hypothesis
1310 if(checkLock(aStudy)) break;
1311 EmitSignalDeactivateDialog();
1312 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1313 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1317 case 706: // EDIT Local Hypothesis
1319 if(checkLock(aStudy)) break;
1320 EmitSignalDeactivateDialog();
1321 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1322 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1326 case 407: // DIAGONAL INVERSION
1327 case 408: // Delete diagonal
1329 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1331 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1332 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1336 if ( checkLock( aStudy ) )
1339 SALOME_Selection *aSel =
1340 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1341 /*Standard_Boolean aRes;
1342 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1343 if ( aMesh->_is_nil() )
1345 QAD_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1346 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1350 EmitSignalDeactivateDialog();
1351 if ( theCommandID == 407 )
1352 new SMESHGUI_TrianglesInversionDlg( parent, aSel );
1354 new SMESHGUI_UnionOfTwoTrianglesDlg( parent, aSel );
1357 case 409: // Change orientation
1358 case 410: // Union of triangles
1359 case 411: // Cutting of quadrangles
1361 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1363 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1364 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1368 if ( checkLock( aStudy ) )
1371 SALOME_Selection *aSel =
1372 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1374 EmitSignalDeactivateDialog();
1375 SMESHGUI_MultiEditDlg* aDlg;
1376 if ( theCommandID == 409 )
1377 aDlg = new SMESHGUI_ChangeOrientationDlg( parent, aSel );
1378 else if ( theCommandID == 410 )
1379 aDlg = new SMESHGUI_UnionOfTrianglesDlg( parent, aSel );
1381 aDlg = new SMESHGUI_CuttingOfQuadsDlg( parent, aSel );
1384 DefineDlgPosition( aDlg, x, y );
1389 case 412: // Smoothing
1391 if(checkLock(aStudy)) break;
1392 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1393 EmitSignalDeactivateDialog();
1394 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1395 new SMESHGUI_SmoothingDlg(parent, "", Sel);
1398 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1399 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1400 tr("SMESH_BUT_OK"));
1404 case 413: // Extrusion
1406 if(checkLock(aStudy)) break;
1407 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1408 EmitSignalDeactivateDialog();
1409 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1410 new SMESHGUI_ExtrusionDlg(parent, "", Sel);
1413 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1414 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1415 tr("SMESH_BUT_OK"));
1419 case 414: // Revolution
1421 if(checkLock(aStudy)) break;
1422 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1423 EmitSignalDeactivateDialog();
1424 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1425 new SMESHGUI_RevolutionDlg(parent, "", Sel);
1428 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1429 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1430 tr("SMESH_BUT_OK"));
1434 case 415: // Pattern mapping
1436 if ( checkLock( aStudy ) )
1438 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1440 EmitSignalDeactivateDialog();
1441 SALOME_Selection *Sel = SALOME_Selection::Selection(
1442 myActiveStudy->getSelection() );
1443 new SMESHGUI_MeshPatternDlg( parent, Sel );
1446 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1447 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1448 tr("SMESH_BUT_OK"));
1452 case 801: // CREATE GROUP
1454 if(checkLock(aStudy)) break;
1455 EmitSignalDeactivateDialog();
1456 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1457 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1458 int nbSel = Sel->IObjectCount();
1460 // check if mesh is selected
1461 aMesh = SMESH::GetMeshByIO(Sel->firstIObject());
1463 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aMesh);
1468 case 802: // CONSTRUCT GROUP
1470 if(checkLock(aStudy)) break;
1471 EmitSignalDeactivateDialog();
1472 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1473 int nbSel = Sel->IObjectCount();
1475 // check if submesh is selected
1476 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1477 if (IObject->hasEntry()) {
1478 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(IObject->getEntry());
1479 if(!aSObj->_is_nil()) {
1480 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(aSObj->GetObject());
1481 if (!aSubMesh->_is_nil()) {
1483 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1484 // get submesh elements list by types
1485 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1486 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1487 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1488 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1489 // create group for each type o elements
1490 QString aName = IObject->getName();
1491 if (aNodes->length() > 0) {
1492 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName);
1493 aGroup->Add(aNodes.inout());
1495 if (aEdges->length() > 0) {
1496 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName);
1497 aGroup->Add(aEdges.inout());
1499 if (aFaces->length() > 0) {
1500 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName);
1501 aGroup->Add(aFaces.inout());
1503 if (aVolumes->length() > 0) {
1504 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName);
1505 aGroup->Add(aVolumes.inout());
1507 myActiveStudy->updateObjBrowser(true);
1508 }catch(const SALOME::SALOME_Exception & S_ex){
1509 QtCatchCorbaException(S_ex);
1518 case 803: // EDIT GROUP
1520 if(checkLock(aStudy)) break;
1521 EmitSignalDeactivateDialog();
1522 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1523 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1524 SALOME_ListIteratorOfListIO It (IOs);
1525 int nbSelectedGroups = 0;
1526 for ( ; It.More(); It.Next() )
1528 SMESH::SMESH_Group_var aGroup =
1529 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1530 if (!aGroup->_is_nil()) {
1532 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aGroup);
1536 if (nbSelectedGroups == 0)
1538 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, SMESH::SMESH_Group::_nil());
1544 case 804: // Add elements to group
1546 if(checkLock(aStudy)) break;
1547 if (myState == 800) {
1548 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1549 if (aDlg) aDlg->onAdd();
1554 case 805: // Remove elements from group
1556 if(checkLock(aStudy)) break;
1557 if (myState == 800) {
1558 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1559 if (aDlg) aDlg->onRemove();
1564 case 810: // Union Groups
1565 case 811: // Intersect groups
1566 case 812: // Cut groups
1568 if ( checkLock( aStudy ) )
1571 EmitSignalDeactivateDialog();
1572 SALOME_Selection *Sel = SALOME_Selection::Selection(
1573 myActiveStudy->getSelection() );
1576 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1577 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1578 else aMode = SMESHGUI_GroupOpDlg::CUT;
1580 ( new SMESHGUI_GroupOpDlg( parent, Sel, aMode ) )->show();
1584 case 813: // Delete groups with their contents
1586 if ( checkLock( aStudy ) )
1589 EmitSignalDeactivateDialog();
1590 SALOME_Selection *Sel = SALOME_Selection::Selection(
1591 myActiveStudy->getSelection() );
1593 ( new SMESHGUI_DeleteGroupDlg( parent, Sel ) )->show();
1597 case 900: // MESH INFOS
1599 EmitSignalDeactivateDialog();
1600 SALOME_Selection *Sel =
1601 SALOME_Selection::Selection(myActiveStudy->getSelection());
1602 if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
1603 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1604 SALOME_ListIteratorOfListIO It (IOs);
1605 for ( ; It.More(); It.Next() ) {
1606 Sel->ClearIObjects();
1607 Sel->AddIObject( It.Value() );
1608 new SMESHGUI_MeshInfosDlg(parent, "", false);
1610 // restore selection
1611 Sel->ClearIObjects();
1612 for (It.Initialize( IOs ) ; It.More(); It.Next() )
1613 Sel->AddIObject( It.Value() );
1616 new SMESHGUI_MeshInfosDlg(parent, "", false);
1620 case 902: // STANDARD MESH INFOS
1622 EmitSignalDeactivateDialog();
1623 SALOME_Selection *Sel =
1624 SALOME_Selection::Selection(myActiveStudy->getSelection());
1625 if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
1626 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1627 SALOME_ListIteratorOfListIO It (IOs);
1628 for ( ; It.More(); It.Next() ) {
1629 Sel->ClearIObjects();
1630 Sel->AddIObject( It.Value() );
1631 new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
1633 // restore selection
1634 Sel->ClearIObjects();
1635 for (It.Initialize( IOs ) ; It.More(); It.Next() )
1636 Sel->AddIObject( It.Value() );
1639 new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
1643 case 1001: // AUTOMATIC UPDATE PREFERENCES
1645 parent->menuBar()->setItemChecked(1001, !parent->menuBar()->isItemChecked(1001));
1646 if (parent->menuBar()->isItemChecked(1001)) {
1647 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true");
1648 myAutomaticUpdate = true;
1651 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false");
1652 myAutomaticUpdate = false;
1657 case 1003: // MESH PREFERENCES
1659 ::SetDisplaySettings();
1665 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( parent );
1671 ( new SMESHGUI_PrecisionDlg( parent ) )->exec();
1677 parent->menuBar()->setItemChecked(10071, !parent->menuBar()->isItemChecked(10071));
1678 if (parent->menuBar()->isItemChecked(10071)) {
1679 QAD_CONFIG->addSetting("SMESH:DispayEntity","true");
1682 QAD_CONFIG->addSetting("SMESH:DispayEntity","false");
1688 SMESHGUI_Preferences_SelectionDlg* aDlg =
1689 new SMESHGUI_Preferences_SelectionDlg(parent);
1692 QString SCr, SCg, SCb;
1693 SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed");
1694 SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen");
1695 SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue");
1696 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1697 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1698 else aColor = Qt::cyan;
1699 aDlg->SetColor(1, aColor);
1701 SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed");
1702 SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen");
1703 SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue");
1704 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1705 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1706 else aColor = Qt::yellow;
1707 aDlg->SetColor(2, aColor);
1709 SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed");
1710 SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen");
1711 SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue");
1712 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1713 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1714 else aColor = Qt::white;
1715 aDlg->SetColor(3, aColor);
1717 QString SW1 = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth");
1718 if (SW1.isEmpty()) SW1 = "5";
1719 aDlg->SetWidth(1, SW1.toInt());
1721 QString SW2 = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth");
1722 if (SW2.isEmpty()) SW2 = "5";
1723 aDlg->SetWidth(2, SW2.toInt());
1725 QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol");
1726 if (SP1.isEmpty()) SP1 = "0.025";
1727 aDlg->SetPrecision(1, SP1.toDouble());
1729 QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol");
1730 if (SP2.isEmpty()) SP2 = "0.001";
1731 aDlg->SetPrecision(2, SP2.toDouble());
1734 QColor aPreColor = aDlg->GetColor(1);
1735 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorRed", aPreColor.red());
1736 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorGreen", aPreColor.green());
1737 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorBlue", aPreColor.blue());
1739 QColor aSelColor = aDlg->GetColor(2);
1740 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorRed", aSelColor.red());
1741 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorGreen", aSelColor.green());
1742 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorBlue", aSelColor.blue());
1744 QColor aHiColor = aDlg->GetColor(3);
1745 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorRed", aHiColor.red());
1746 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorGreen", aHiColor.green());
1747 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorBlue", aHiColor.blue());
1749 int aPreWidth = aDlg->GetWidth(1);
1750 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectWidth", aPreWidth);
1751 int aSelWidth = aDlg->GetWidth(2);
1752 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectWidth", aSelWidth);
1754 double aTolNodes = aDlg->GetPrecision(1);
1755 QAD_CONFIG->addSetting("SMESH:SettingsNodeSelectTol", aTolNodes);
1756 double aTolItems = aDlg->GetPrecision(2);
1757 QAD_CONFIG->addSetting("SMESH:SettingsElementsSelectTol", aTolItems);
1759 // update current study settings
1760 SMESH::UpdateSelectionProp();
1762 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
1763 if (studyFrame->getTypeView() == VIEW_VTK) {
1764 VTKViewer_ViewFrame* aViewFrame = SMESH::GetVtkViewFrame(studyFrame);
1765 // update VTK viewer properties
1766 VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor();
1768 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1769 aSelColor.blue()/255., aSelWidth);
1770 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1771 VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
1773 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1774 aPreColor.blue()/255., aPreWidth);
1777 vtkRenderer* aRenderer = aViewFrame->getRenderer();
1778 vtkActorCollection *aCollection = aRenderer->GetActors();
1779 aCollection->InitTraversal();
1780 while(vtkActor *anAct = aCollection->GetNextActor()){
1781 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1782 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1783 aHiColor.blue()/255.);
1784 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1785 aPreColor.blue()/255.);
1794 case 1100: // EDIT HYPOTHESIS
1796 if(checkLock(aStudy)) break;
1797 SALOME_Selection *Sel =
1798 SALOME_Selection::Selection(myActiveStudy->getSelection());
1799 int nbSel = Sel->IObjectCount();
1802 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(Sel->firstIObject());
1804 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1805 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1806 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1807 if ( !Hyp->_is_nil() )
1809 char* sName = Hyp->GetName();
1810 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1813 aCreator->EditHypothesis(Hyp);
1824 case 1101: // RENAME
1826 if ( checkLock( aStudy ) )
1829 SALOME_Selection *Sel =
1830 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1832 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1833 for ( ; It.More(); It.Next() )
1835 Handle(SALOME_InteractiveObject) IObject = It.Value();
1836 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
1837 SALOMEDS::GenericAttribute_var anAttr;
1838 SALOMEDS::AttributeName_var aName;
1839 if ( !obj->_is_nil() )
1841 if ( obj->FindAttribute(anAttr, "AttributeName") )
1843 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1844 QString newName = QString(aName->Value());
1845 newName = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), newName );
1846 if ( !newName.isEmpty() )
1848 myActiveStudy->renameIObject( IObject, newName );
1850 // if current object is group update group's name
1851 SMESH::SMESH_GroupBase_var aGroup =
1852 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1853 if (!aGroup->_is_nil() )
1854 aGroup->SetName( newName.latin1() );
1862 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1864 if(checkLock(aStudy)) break;
1866 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1867 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1868 for (int i = 0; It.More(); It.Next(), i++) {
1869 Handle(SALOME_InteractiveObject) IObject = It.Value();
1870 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1872 Sel->ClearIObjects();
1873 myActiveStudy->updateObjBrowser(true);
1877 case 401: // GEOM::EDGE
1878 case 4021: // TRIANGLE
1883 if(checkLock(aStudy)) break;
1884 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1885 EmitSignalDeactivateDialog();
1886 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1887 SMDSAbs_ElementType type = SMDSAbs_Edge;
1889 switch (theCommandID) {
1890 case 4021: // TRIANGLE
1891 type = SMDSAbs_Face; nbNodes = 3; break;
1893 type = SMDSAbs_Face; nbNodes = 4; break;
1895 type = SMDSAbs_Volume; nbNodes = 4; break;
1897 type = SMDSAbs_Volume; nbNodes = 8; break;
1900 new SMESHGUI_AddMeshElementDlg(parent, "", Sel, type, nbNodes);
1903 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1904 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1905 tr("SMESH_BUT_OK"));
1910 case 4041: // REMOVES NODES
1912 if(checkLock(aStudy)) break;
1913 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1914 EmitSignalDeactivateDialog();
1915 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1916 new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
1919 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1920 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1921 tr("SMESH_BUT_OK"));
1925 case 4042: // REMOVES ELEMENTS
1927 if(checkLock(aStudy)) break;
1928 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1929 EmitSignalDeactivateDialog();
1930 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1931 new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
1935 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1936 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1937 tr("SMESH_BUT_OK"));
1941 case 4051: // RENUMBERING NODES
1943 if(checkLock(aStudy)) break;
1944 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1945 EmitSignalDeactivateDialog();
1946 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1947 new SMESHGUI_RenumberingDlg(parent, "", Sel, 0);
1951 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1952 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1953 tr("SMESH_BUT_OK"));
1957 case 4052: // RENUMBERING ELEMENTS
1959 if(checkLock(aStudy)) break;
1960 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1961 EmitSignalDeactivateDialog();
1962 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1963 new SMESHGUI_RenumberingDlg(parent, "", Sel, 1);
1967 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1968 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1969 tr("SMESH_BUT_OK"));
1973 case 4061: // TRANSLATION
1975 if(checkLock(aStudy)) break;
1976 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1977 EmitSignalDeactivateDialog();
1978 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1979 new SMESHGUI_TranslationDlg(parent, "", Sel);
1982 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1983 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1984 tr("SMESH_BUT_OK"));
1988 case 4062: // ROTATION
1990 if(checkLock(aStudy)) break;
1991 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1992 EmitSignalDeactivateDialog();
1993 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1994 new SMESHGUI_RotationDlg(parent, "", Sel);
1997 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1998 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1999 tr("SMESH_BUT_OK"));
2003 case 4063: // SYMMETRY
2005 if(checkLock(aStudy)) break;
2006 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2007 EmitSignalDeactivateDialog();
2008 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2009 new SMESHGUI_SymmetryDlg(parent, "", Sel);
2012 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2013 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2014 tr("SMESH_BUT_OK"));
2018 case 4064: // SEWING
2020 if(checkLock(aStudy)) break;
2021 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2022 EmitSignalDeactivateDialog();
2023 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2024 new SMESHGUI_SewingDlg(parent, "", Sel);
2027 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2028 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2029 tr("SMESH_BUT_OK"));
2033 case 4065: // MERGE NODES
2035 if(checkLock(aStudy)) break;
2036 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2037 EmitSignalDeactivateDialog();
2038 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2039 new SMESHGUI_MergeNodesDlg(parent, "", Sel);
2042 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2043 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2044 tr("SMESH_BUT_OK"));
2050 case 5000: // HYPOTHESIS
2052 if(checkLock(aStudy)) break;
2053 EmitSignalDeactivateDialog();
2054 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false);
2059 if(checkLock(aStudy)) break;
2060 EmitSignalDeactivateDialog();
2061 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true);
2065 case 5105: // Library of selection filters
2067 static QValueList<int> aTypes;
2068 if ( aTypes.isEmpty() )
2070 aTypes.append( SMESH::NODE );
2071 aTypes.append( SMESH::EDGE );
2072 aTypes.append( SMESH::FACE );
2073 aTypes.append( SMESH::VOLUME );
2075 new SMESHGUI_FilterLibraryDlg( parent, aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2079 case 6017: // CONTROLS
2092 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2093 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2094 if ( Sel->IObjectCount() == 1 && Sel->firstIObject()->hasEntry() ) {
2095 SALOMEDS::SObject_var SO = aStudy->FindObjectID( Sel->firstIObject()->getEntry() );
2096 if ( !SO->_is_nil() ) {
2097 CORBA::Object_var aObject = SO->GetObject();
2098 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2099 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2100 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2101 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2102 ::Control( theCommandID );
2107 QAD_MessageBox::warn1(GetDesktop(),
2108 tr( "SMESH_WRN_WARNING" ),
2109 tr( "SMESH_BAD_SELECTION" ),
2110 tr( "SMESH_BUT_OK" ) );
2114 QAD_MessageBox::warn1(GetDesktop(),
2115 tr( "SMESH_WRN_WARNING" ),
2116 tr( "NOT_A_VTK_VIEWER" ),
2117 tr( "SMESH_BUT_OK" ) );
2122 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2123 if (Sel->IObjectCount() == 1) {
2124 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2125 if(anIObject->hasEntry())
2126 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2127 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2134 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2135 if (Sel->IObjectCount() == 1) {
2136 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2137 if(anIObject->hasEntry())
2138 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2139 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2144 case 10001: // DISPLAY MODE PREFERENCE
2147 parent->menuBar()->setItemChecked(10001, true);
2148 parent->menuBar()->setItemChecked(10002, false);
2149 parent->menuBar()->setItemChecked(10004, false);
2150 parent->menuBar()->setItemEnabled(10003, true);
2151 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe");
2156 parent->menuBar()->setItemChecked(10002, true);
2157 parent->menuBar()->setItemChecked(10001, false);
2158 parent->menuBar()->setItemChecked(10004, false);
2159 parent->menuBar()->setItemEnabled(10003, true);
2160 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2165 parent->menuBar()->setItemChecked(10003,!parent->menuBar()->isItemChecked(10003));
2166 QAD_CONFIG->addSetting("SMESH:Shrink", parent->menuBar()->isItemChecked(10003) ? "yes" : "no");
2171 parent->menuBar()->setItemChecked(10001, false);
2172 parent->menuBar()->setItemChecked(10004, true);
2173 parent->menuBar()->setItemChecked(10002, false);
2174 parent->menuBar()->setItemEnabled(10003, false);
2175 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Nodes");
2181 myActiveStudy->updateObjBrowser(true);
2185 //=============================================================================
2189 //=============================================================================
2190 bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
2191 QAD_StudyFrame * studyFrame)
2196 //=============================================================================
2200 //=============================================================================
2201 bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent,
2202 QAD_StudyFrame * studyFrame)
2207 //=============================================================================
2211 //=============================================================================
2212 bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent,
2213 QAD_StudyFrame * studyFrame)
2218 //=============================================================================
2222 //=============================================================================
2223 bool SMESHGUI::SetSettings(QAD_Desktop * parent)
2225 MESSAGE("SMESHGUI::SetSettings.");
2226 SMESHGUI::GetSMESHGUI();
2229 QString DisplayMode = "Shading";
2230 if ( QAD_CONFIG->hasSetting("SMESH:DisplayMode") )
2231 DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
2233 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2235 bool Shrink = false;
2236 if ( QAD_CONFIG->hasSetting("SMESH:Shrink") )
2237 Shrink = QAD_CONFIG->getSetting("SMESH:Shrink") == "yes";
2239 if (DisplayMode == "Wireframe") {
2241 parent->menuBar()->setItemChecked(10004, false);
2242 parent->menuBar()->setItemChecked(10002, false);
2243 parent->menuBar()->setItemChecked(10001, true);
2244 parent->menuBar()->setItemEnabled(10003, true);
2246 else if (DisplayMode == "Nodes") {
2248 parent->menuBar()->setItemChecked(10004, true);
2249 parent->menuBar()->setItemChecked(10002, false);
2250 parent->menuBar()->setItemChecked(10001, false);
2251 parent->menuBar()->setItemEnabled(10003, false);
2254 // default is shading
2255 parent->menuBar()->setItemChecked(10004, false);
2256 parent->menuBar()->setItemChecked(10002, true);
2257 parent->menuBar()->setItemChecked(10001, false);
2258 parent->menuBar()->setItemEnabled(10003, true);
2260 parent->menuBar()->setItemChecked(10003, Shrink);
2262 /* Automatic Update */
2263 QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate");
2264 if (AutoUpdate.compare("true") == 0) {
2265 parent->menuBar()->setItemChecked(1001, true);
2266 myAutomaticUpdate = true;
2269 parent->menuBar()->setItemChecked(1001, false);
2270 myAutomaticUpdate = false;
2273 QString anIsDisplayEntity = QAD_CONFIG->getSetting("SMESH:DispayEntity");
2274 if(anIsDisplayEntity.compare("true") == 0)
2275 parent->menuBar()->setItemChecked(10071,true);
2277 parent->menuBar()->setItemChecked(10071,false);
2280 SMESH::UpdateSelectionProp();
2283 parent->menuBar()->setItemEnabled(111, false); // IMPORT DAT
2284 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2289 //=============================================================================
2293 //=============================================================================
2294 void SMESHGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject)
2296 // NRI : Temporary added
2297 // if ( myStudy->GetProperties()->IsLocked() ) {
2298 // theObject = "NothingSelected";
2299 // theContext = "NothingSelected";
2303 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2304 int nbSel = Sel->IObjectCount();
2307 theObject = "NothingSelected";
2308 theContext = "NothingSelected";
2311 if ( myState == 800 && Sel->HasIndex( Sel->firstIObject() ) )
2312 theObject = "Elements";
2314 theObject = ::CheckTypeObject( Sel->firstIObject() );
2318 theObject = ::CheckHomogeneousSelection();
2323 //=============================================================================
2327 //=============================================================================
2328 bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
2329 const QString& theParent, const QString& theObject)
2331 // get active study frame
2332 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
2334 // get parent component which selected object(s) belongs to
2335 QString parentComp = ( (SALOMEGUI_Desktop*)parent )->getComponentFromSelection();
2338 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2339 int nbSel = Sel->IObjectCount();
2344 else if ( nbSel == 1 ) {
2345 if ( parentComp != parent->getActiveComponent() ) {
2346 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2348 int id = popup->idAt( 0 );
2349 if ( id <= QAD_TopLabel_Popup_ID )
2350 popup->removeItemAt( 0 );
2356 // get selected interactive object
2357 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
2358 SALOMEDS::SObject_var SO = SMESH::GetActiveStudyDocument()->FindObjectID( IObject->getEntry() );
2359 // find popup menu's TopLabel item
2360 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2361 if ( topItem >= 0 ) {
2362 if ( theParent == "Viewer" ) {
2363 // set bold font for popup menu's TopLabel item (Viewer popup)
2364 QFont fnt = popup->font(); fnt.setBold( TRUE );
2365 popup->removeItem( QAD_TopLabel_Popup_ID );
2366 popup->insertItem( new CustomItem( QString( IObject->getName() ), fnt ), QAD_TopLabel_Popup_ID, topItem );
2368 else if ( theParent == "ObjectBrowser" ) {
2369 // remove popup menu's TopLabel item (Object Browser popup)
2370 popup->removeItem( QAD_TopLabel_Popup_ID );
2374 if ( theObject == "Hypothesis" || theObject == "Algorithm" ) {
2375 // remove Display/Erase commands
2376 popup->removeItem( QAD_Display_Popup_ID );
2377 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2378 popup->removeItem( QAD_Erase_Popup_ID );
2379 // remove "Unassign ..." command if hyp/algo is not assigned
2380 if ( SO->_is_nil() || !IObject->hasReference()/* !IsReferencedObject( SO ) */)
2381 popup->removeItem( 1102 );
2383 else if ( theObject == "Mesh" || theObject == "SubMesh" || theObject == "Group" ) {
2385 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SO );
2386 if ( aShapeObject->_is_nil() ) {
2388 popup->removeItem( 701 ); // Compute
2389 popup->removeItem( 705 ); // Edit hypothesis
2390 popup->removeItem( 706 ); // ...
2392 SMESH::SMESH_GroupOnGeom_var aGeomGroup =
2393 SMESH::SMESH_GroupOnGeom::_narrow( SO->GetObject() );
2394 if ( !aGeomGroup->_is_nil() ) // group linked on geometry
2395 popup->removeItem( 803 ); // EDIT GROUP
2397 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
2398 // if object has actor
2399 if ( anActor && studyFrame->getTypeView() == VIEW_VTK ) {
2400 VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
2401 if ( myRenderInter->isVisible( IObject ) ) {
2402 popup->removeItem( QAD_Display_Popup_ID );
2403 popup->setItemChecked( 9010, anActor->GetPointsLabeled() ); // Numbering / Display Nodes #
2404 popup->setItemChecked( 9011, anActor->GetCellsLabeled() ); // Numbering / Display Elements #
2405 TVisualObjPtr aVisualObj = anActor->GetObject();
2406 int aNbEdges = aVisualObj->GetNbEntities(SMDSAbs_Edge);
2407 int aNbFaces = aVisualObj->GetNbEntities(SMDSAbs_Face);
2408 int aNbVolumes = aVisualObj->GetNbEntities(SMDSAbs_Volume);
2410 QMenuItem* mi = popup->findItem( 1131 );
2411 if ( mi && mi->popup() ) {
2412 int prType = anActor->GetRepresentation();
2413 // Display Mode / Wireframe
2414 if(aNbVolumes == 0 && aNbFaces == 0 && aNbEdges == 0){
2415 mi->popup()->removeItem( 211 );
2417 mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge );
2419 // Display Mode / Shading
2420 if(aNbFaces == 0 && aNbVolumes == 0){
2421 mi->popup()->removeItem( 212 );
2423 mi->popup()->setItemChecked( 212, prType == SMESH_Actor::eSurface );
2425 // Display Mode / Points
2426 mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint );
2427 // Display Mode / Shrink
2428 bool isShrunk = anActor->IsShrunk();
2429 bool isShrunkable = anActor->IsShrunkable();
2430 mi->popup()->setItemChecked( 213, isShrunk );
2431 mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable);
2435 mi = popup->findItem( 1135 );
2437 if (aNbVolumes>0) aIsSomething++;
2438 if (aNbFaces>0) aIsSomething++;
2439 if (aNbEdges>0) aIsSomething++;
2440 if ( mi && (aIsSomething <= 1)){
2441 popup->removeItem(1135);
2442 }else if ( mi && mi->popup() ) {
2443 QPopupMenu* aPopup = mi->popup();
2444 unsigned int aMode = anActor->GetEntityMode();
2446 bool aIsVolumesMode = aMode & SMESH_Actor::eVolumes;
2447 bool aIsFacesMode = aMode & SMESH_Actor::eFaces;
2448 bool aIsEdgesMode = aMode & SMESH_Actor::eEdges;
2451 aPopup->removeItem( 219 );
2453 aPopup->setItemChecked( 219, aIsVolumesMode );
2456 aPopup->removeItem( 218 );
2458 aPopup->setItemChecked( 218, aIsFacesMode );
2462 aPopup->removeItem( 217 );
2464 aPopup->setItemChecked( 217, aIsEdgesMode );
2467 bool aIsRemove = (aNbVolumes == 0 || aIsVolumesMode);
2468 aIsRemove &= (aNbFaces == 0 || aIsFacesMode);
2469 aIsRemove &= (aNbEdges == 0 || aIsEdgesMode);
2472 aPopup->removeItem( 220 );
2476 mi = popup->findItem( 2000 );
2477 if ( mi && mi->popup() ) {
2478 SMESH_Actor::eControl cMode = anActor->GetControlMode();
2480 case SMESH_Actor::eLength:
2481 mi->popup()->setItemChecked( 6001, true ); break;
2482 case SMESH_Actor::eLength2D:
2483 mi->popup()->setItemChecked( 6018, true ); break;
2484 case SMESH_Actor::eFreeEdges:
2485 mi->popup()->setItemChecked( 6002, true );
2486 mi->popup()->removeItem( 201 );
2488 case SMESH_Actor::eFreeBorders:
2489 mi->popup()->setItemChecked( 6003, true );
2490 mi->popup()->removeItem( 201 );
2492 case SMESH_Actor::eMultiConnection:
2493 mi->popup()->setItemChecked( 6004, true ); break;
2494 case SMESH_Actor::eMultiConnection2D:
2495 mi->popup()->setItemChecked( 6019, true ); break;
2496 case SMESH_Actor::eArea:
2497 mi->popup()->setItemChecked( 6011, true ); break;
2498 case SMESH_Actor::eTaper:
2499 mi->popup()->setItemChecked( 6012, true ); break;
2500 case SMESH_Actor::eAspectRatio:
2501 mi->popup()->setItemChecked( 6013, true ); break;
2502 case SMESH_Actor::eAspectRatio3D:
2503 mi->popup()->setItemChecked( 6017, true ); break;
2504 case SMESH_Actor::eMinimumAngle:
2505 mi->popup()->setItemChecked( 6014, true ); break;
2506 case SMESH_Actor::eWarping:
2507 mi->popup()->setItemChecked( 6015, true ); break;
2508 case SMESH_Actor::eSkew:
2509 mi->popup()->setItemChecked( 6016, true ); break;
2510 case SMESH_Actor::eNone:
2512 mi->popup()->removeItem( 200 );
2513 mi->popup()->removeItem( 201 );
2516 TVisualObjPtr aVisualObj = anActor->GetObject();
2518 mi->popup()->removeItem( 6001 );
2519 mi->popup()->removeItem( 6003 );
2520 mi->popup()->removeItem( 6004 );
2523 mi->popup()->removeItem( 6018 );
2524 mi->popup()->removeItem( 6002 );
2525 mi->popup()->removeItem( 6011 );
2526 mi->popup()->removeItem( 6012 );
2527 mi->popup()->removeItem( 6013 );
2528 mi->popup()->removeItem( 6014 );
2529 mi->popup()->removeItem( 6015 );
2530 mi->popup()->removeItem( 6016 );
2531 mi->popup()->removeItem( 6019 );
2533 if(aNbVolumes == 0){
2534 mi->popup()->removeItem( 6017 );
2536 if(aNbFaces == 0 && aNbEdges == 0 && aNbVolumes == 0)
2537 popup->removeItem( 2000 ); // Scalar Bar
2541 popup->removeItem( QAD_Erase_Popup_ID );
2542 popup->removeItem( 114 ); // Numbering popup menu
2543 popup->removeItem( 1131 ); // Display mode
2544 popup->removeItem( 1132 ); // Color / size
2545 popup->removeItem( 1133 ); // Transparency
2546 popup->removeItem( 1134 ); // Clipping
2547 popup->removeItem( 2000 ); // Scalar Bar
2551 // object doesn't have actor
2552 CORBA::Object_var anObject = SO->GetObject();
2553 bool bDisplay = false;
2554 if ( !CORBA::is_nil( anObject ) ) {
2555 SMESH::SMESH_Mesh_var aMeshObj = SMESH::SMESH_Mesh::_narrow( anObject );
2556 if ( !aMeshObj->_is_nil() && ( aMeshObj->NbNodes() > 0 || aMeshObj->NbFaces() > 0 || aMeshObj->NbVolumes() > 0 ) )
2558 SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObject );
2559 if ( !aSubMeshObj->_is_nil() && ( aSubMeshObj->GetNumberOfNodes(false) > 0 || aSubMeshObj->GetNumberOfElements() > 0 ) )
2561 SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( anObject );
2562 if ( !aGroupObj->_is_nil() && aGroupObj->Size() > 0 )
2566 popup->removeItem( QAD_Display_Popup_ID );
2567 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2569 popup->removeItem( QAD_Erase_Popup_ID );
2570 popup->removeItem( 114 ); // Numbering popup menu
2571 popup->removeItem( 1131 ); // Display mode
2572 popup->removeItem( 1132 ); // Color / size
2573 popup->removeItem( 1133 ); // Transparency
2574 popup->removeItem( 1134 ); // Clipping
2575 popup->removeItem( 2000 ); // Scalar Bar
2578 else if( theObject!="Component" ) {
2579 // another SMESH object
2580 popup->removeItem( QAD_Display_Popup_ID );
2581 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2582 popup->removeItem( QAD_Erase_Popup_ID );
2587 // multiple selection
2588 if ( parentComp != parent->getActiveComponent() ) {
2589 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2591 int id = popup->idAt( 0 );
2592 if ( id <= QAD_TopLabel_Popup_ID )
2593 popup->removeItemAt( 0 );
2597 if ( parentComp.isNull() ) {
2598 // objects from different components are selected
2599 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2600 popup->removeItem( QAD_Display_Popup_ID );
2601 popup->removeItem( QAD_Erase_Popup_ID );
2605 QString type = ::CheckHomogeneousSelection();
2606 if ( type != "Heterogeneous Selection" ) {
2607 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2608 if ( topItem >= 0 ) {
2609 // set bold font for popup menu's TopLabel item
2610 QFont fnt = popup->font(); fnt.setBold( TRUE );
2611 popup->removeItem( QAD_TopLabel_Popup_ID );
2612 popup->insertItem( new CustomItem( QString("%1 ").arg( nbSel ) + type + "(s) ", fnt ), QAD_TopLabel_Popup_ID, topItem );
2620 //=============================================================================
2621 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2622 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2624 //=============================================================================
2625 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2628 if(theIO->hasEntry()){
2629 QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
2630 QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
2631 SMESH::UpdateView(aStudyFrame,SMESH::eDisplay,theIO->getEntry());
2635 void SMESHGUI::SupportedViewType(int *buffer, int bufferSize)
2637 if (!buffer || !bufferSize)
2639 buffer[0] = (int)VIEW_VTK;
2642 void SMESHGUI::Deactivate()
2644 if ( SMESHGUI::GetSMESHGUI() ) {
2645 SMESHGUI::GetSMESHGUI()->EmitSignalCloseAllDialogs();