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_InitMeshOp.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_ExtrusionAlongPathDlg.h"
57 #include "SMESHGUI_RevolutionDlg.h"
58 #include "SMESHGUI_TranslationDlg.h"
59 #include "SMESHGUI_RotationDlg.h"
60 #include "SMESHGUI_SymmetryDlg.h"
61 #include "SMESHGUI_SewingDlg.h"
62 #include "SMESHGUI_MergeNodesDlg.h"
63 #include "SMESHGUI_MeshPatternDlg.h"
64 #include "SMESHGUI_PrecisionDlg.h"
65 #include "SMESHGUI_Selection.h"
66 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
68 #include <SVTK_InteractorStyle.h>
69 #include <SVTK_RenderWindowInteractor.h>
71 #include "SMESH_Actor.h"
72 #include "SMESH_Object.h"
73 #include "SMESH_TypeFilter.hxx"
75 #include "SUIT_Tools.h"
76 #include "SUIT_MessageBox.h"
77 #include "SUIT_ResourceMgr.h"
78 #include "SUIT_FileDlg.h"
79 #include "SUIT_Desktop.h"
80 #include "SUIT_ResourceMgr.h"
81 #include "SUIT_OverrideCursor.h"
82 #include "SUIT_Study.h"
83 #include "SUIT_Session.h"
85 #include "SALOME_NamingService.hxx"
86 #include "SALOME_ListIteratorOfListIO.hxx"
87 #include "SALOME_InteractiveObject.hxx"
88 #include "SALOME_ListIO.hxx"
89 #include <SALOME_LifeCycleCORBA.hxx>
91 #include "OB_Browser.h"
93 #include "QtxPopupMgr.h"
95 #include "SalomeApp_Tools.h"
96 #include "SalomeApp_Study.h"
97 #include "SalomeApp_NameDlg.h"
98 #include "SalomeApp_DataOwner.h"
99 #include "SalomeApp_Application.h"
100 #include "SalomeApp_Preferences.h"
101 #include "SalomeApp_VTKSelector.h"
102 #include "SalomeApp_Operation.h"
103 #include "SalomeApp_UpdateFlags.h"
105 #include "SalomeApp_ImportOperation.h"
107 #include <SVTK_ViewWindow.h>
108 #include <SVTK_ViewModel.h>
110 #include <VTKViewer_ViewManager.h>
112 #include "SMESHGUI_Utils.h"
113 #include "SMESHGUI_GEOMGenUtils.h"
114 #include "SMESHGUI_MeshUtils.h"
115 #include "SMESHGUI_GroupUtils.h"
116 #include "SMESHGUI_FilterUtils.h"
117 #include "SMESHGUI_PatternUtils.h"
118 #include "SMESHGUI_VTKUtils.h"
120 #include "SALOMEconfig.h"
121 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
124 #define INCLUDE_MENUITEM_DEF
125 #include <qapplication.h>
126 #include <qlineedit.h>
127 #include <qmenudata.h>
128 #include <qmenubar.h>
129 #include <qpopupmenu.h>
132 #include <qpainter.h>
133 #include <qcheckbox.h>
134 #include <qcolordialog.h>
135 #include <qspinbox.h>
140 #include <qradiobutton.h>
142 #include <boost/shared_ptr.hpp>
144 #include <vtkRenderer.h>
145 #include <vtkRenderWindow.h>
146 #include <vtkActorCollection.h>
147 #include <vtkScalarBarActor.h>
148 #include <vtkUnstructuredGrid.h>
150 #include "utilities.h"
152 #include "SALOMEDS_Study.hxx"
153 #include "SALOMEDSClient_StudyBuilder.hxx"
154 #include "SALOMEDSClient_SComponent.hxx"
160 //=============================================================
161 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
164 void ExportMeshToFile(int theCommandID);
166 void SetDisplayMode(int theCommandID);
168 void SetDisplayEntity(int theCommandID);
170 void Control( int theCommandID );
172 void SetDisplaySettings();
176 //=============================================================
177 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
183 if(theCommandID == 113){
184 filter.append(QObject::tr("MED files (*.med)"));
185 filter.append(QObject::tr("All files (*)"));
186 }else if (theCommandID == 112){
187 filter.append(QObject::tr("IDEAS files (*.unv)"));
188 }else if (theCommandID == 111){
189 filter.append(QObject::tr("DAT files (*.dat)"));
191 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
194 QObject::tr("Import mesh"),
196 if(!filename.isEmpty()) {
197 SUIT_OverrideCursor wc;
198 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
201 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
202 switch ( theCommandID ) {
205 aMeshes->length( 1 );
206 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
211 SMESH::DriverMED_ReadStatus res;
212 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
213 if ( res != SMESH::DRS_OK ) {
215 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
216 QObject::tr("SMESH_WRN_WARNING"),
217 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
218 QObject::tr("SMESH_BUT_OK"));
219 aMeshes->length( 0 );
226 bool isEmpty = false;
227 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
228 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
230 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
231 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
232 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
233 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
234 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
241 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
242 QObject::tr("SMESH_WRN_WARNING"),
243 QObject::tr("SMESH_DRS_EMPTY"),
244 QObject::tr("SMESH_BUT_OK"));
248 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
250 catch (const SALOME::SALOME_Exception& S_ex){
252 SalomeApp_Tools::QtCatchCorbaException(S_ex);
259 void ExportMeshToFile( int theCommandID )
261 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
262 SALOME_ListIO selected;
264 aSel->selectedObjects( selected );
266 if(selected.Extent()){
267 Handle(SALOME_InteractiveObject) anIObject = selected.First();
268 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
269 if ( !aMesh->_is_nil() ) {
270 QString aFilter, aTitle = QObject::tr("Export mesh");
271 QMap<QString, SMESH::MED_VERSION> aFilterMap;
272 switch ( theCommandID ) {
275 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
276 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
280 aFilter = QObject::tr("DAT files (*.dat)");
284 if(aMesh->NbPyramids()){
285 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
286 QObject::tr("SMESH_WRN_WARNING"),
287 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
288 QObject::tr("SMESH_BUT_YES"),
289 QObject::tr("SMESH_BUT_NO"),
294 aFilter = QObject::tr("IDEAS files (*.unv)");
301 SMESH::MED_VERSION aFormat;
303 if ( theCommandID != 122 && theCommandID != 125 )
304 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
308 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
309 filters.push_back( it.key() );
311 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
312 fd->setCaption( aTitle );
313 fd->setFilters( filters );
317 aFilename = fd->selectedFile();
318 aFormat = aFilterMap[fd->selectedFilter()];
320 if( !aFilename.isEmpty()
321 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
322 && aFormat==SMESH::MED_V2_1){
323 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
324 QObject::tr("SMESH_WRN_WARNING"),
325 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
326 QObject::tr("SMESH_BUT_YES"),
327 QObject::tr("SMESH_BUT_NO"),
336 if ( !aFilename.isEmpty() ) {
337 // Check whether the file already exists and delete it if yes
338 QFile aFile( aFilename );
339 if ( aFile.exists() )
341 SUIT_OverrideCursor wc;
342 switch ( theCommandID ) {
345 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
349 aMesh->ExportDAT( aFilename.latin1() );
353 aMesh->ExportUNV( aFilename.latin1() );
363 inline void InverseEntityMode(unsigned int& theOutputMode,
364 unsigned int theMode)
366 bool anIsNotPresent = ~theOutputMode & theMode;
368 theOutputMode |= theMode;
370 theOutputMode &= ~theMode;
373 void SetDisplayEntity(int theCommandID){
374 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
375 SALOME_ListIO selected;
377 aSel->selectedObjects( selected );
379 if(selected.Extent() >= 1){
380 SALOME_ListIteratorOfListIO It( selected );
381 for(; It.More(); It.Next()){
382 Handle(SALOME_InteractiveObject) IObject = It.Value();
383 if(IObject->hasEntry()){
384 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
385 unsigned int aMode = anActor->GetEntityMode();
386 switch(theCommandID){
388 InverseEntityMode(aMode,SMESH_Actor::eEdges);
391 InverseEntityMode(aMode,SMESH_Actor::eFaces);
394 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
397 aMode = SMESH_Actor::eAllEntity;
401 anActor->SetEntityMode(aMode);
408 void SetDisplayMode(int theCommandID){
409 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
410 SALOME_ListIO selected;
412 aSel->selectedObjects( selected );
414 if(selected.Extent() >= 1){
415 switch(theCommandID){
417 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
418 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
422 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
423 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
426 SALOME_ListIteratorOfListIO It( selected );
427 for(; It.More(); It.Next()){
428 Handle(SALOME_InteractiveObject) IObject = It.Value();
429 if(IObject->hasEntry()){
430 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
431 switch(theCommandID){
433 anActor->SetRepresentation(SMESH_Actor::eEdge);
436 anActor->SetRepresentation(SMESH_Actor::eSurface);
439 if(anActor->IsShrunk())
442 anActor->SetShrink();
445 anActor->SetRepresentation(SMESH_Actor::ePoint);
449 anActor->GetSufaceColor(color[0], color[1], color[2]);
450 int c0 = int (color[0] * 255);
451 int c1 = int (color[1] * 255);
452 int c2 = int (color[2] * 255);
453 QColor c(c0, c1, c2);
456 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
457 c0 = int (edgecolor[0] * 255);
458 c1 = int (edgecolor[1] * 255);
459 c2 = int (edgecolor[2] * 255);
460 QColor e(c0, c1, c2);
462 float backfacecolor[3];
463 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
464 c0 = int (backfacecolor[0] * 255);
465 c1 = int (backfacecolor[1] * 255);
466 c2 = int (backfacecolor[2] * 255);
467 QColor b(c0, c1, c2);
470 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
471 c0 = int (nodecolor[0] * 255);
472 c1 = int (nodecolor[1] * 255);
473 c2 = int (nodecolor[2] * 255);
474 QColor n(c0, c1, c2);
476 int Edgewidth = (int)anActor->GetLineWidth();
479 int intValue = int(anActor->GetNodeSize());
480 float Shrink = anActor->GetShrinkFactor();
482 SMESHGUI_Preferences_ColorDlg *aDlg =
483 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
484 aDlg->SetColor(1, c);
485 aDlg->SetColor(2, e);
486 aDlg->SetColor(3, n);
487 aDlg->SetColor(4, b);
488 aDlg->SetIntValue(1, Edgewidth);
489 aDlg->SetIntValue(2, intValue);
490 aDlg->SetIntValue(3, int(Shrink*100.));
492 QColor color = aDlg->GetColor(1);
493 QColor edgecolor = aDlg->GetColor(2);
494 QColor nodecolor = aDlg->GetColor(3);
495 QColor backfacecolor = aDlg->GetColor(4);
496 /* actor color and backface color */
497 anActor->SetSufaceColor(float (color.red()) / 255.,
498 float (color.green()) / 255.,
499 float (color.blue()) / 255.);
500 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
501 float (backfacecolor.green()) / 255.,
502 float (backfacecolor.blue()) / 255.);
505 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
506 float (edgecolor.green()) / 255.,
507 float (edgecolor.blue()) / 255.);
509 /* Shrink factor and size edges */
510 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
511 anActor->SetLineWidth(aDlg->GetIntValue(1));
513 /* Nodes color and size */
514 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
515 float (nodecolor.green()) / 255.,
516 float (nodecolor.blue()) / 255.);
517 anActor->SetNodeSize(aDlg->GetIntValue(2));
526 SMESH::RepaintCurrentView();
531 void SetDisplaySettings()
533 SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
537 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
538 SMESHGUI_Preferences_ColorDlg *aDlg =
539 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
541 QColor color = mgr->colorValue( "SMESH", "SettingsFillColor", QColor(0, 170, 255) );
542 aDlg->SetColor(1, color);
544 color = mgr->colorValue( "SMESH", "SettingsOutlineColor", QColor(0, 170, 255) );
545 aDlg->SetColor(2, color);
547 color = mgr->colorValue( "SMESH", "SettingsNodeColor", Qt::red );
548 aDlg->SetColor(3, color);
550 color = mgr->colorValue( "SMESH", "SettingsBackFaceColor", Qt::blue );
551 aDlg->SetColor(4, color);
553 int iVal = mgr->integerValue( "SMESH", "SettingsWidth", 1 );
554 aDlg->SetIntValue(1, iVal);
556 iVal = mgr->integerValue( "SMESH", "SettingsNodesSize", 3 );
557 aDlg->SetIntValue(2, iVal);
559 iVal = mgr->integerValue( "SMESH", "SettingsShrinkCoeff", 75 );
560 aDlg->SetIntValue(3, iVal);
563 mgr->setValue( "SMESH", "SettingsFillColor", aDlg->GetColor(1) );
564 mgr->setValue( "SMESH", "SettingsOutlineColor", aDlg->GetColor(2) );
565 mgr->setValue( "SMESH", "SettingsNodeColor", aDlg->GetColor(3) );
566 mgr->setValue( "SMESH", "SettingsBackFaceColor", aDlg->GetColor(4) );
568 mgr->setValue( "SMESH", "SettingsWidth", aDlg->GetIntValue(1) );
569 mgr->setValue( "SMESH", "SettingsNodesSize", aDlg->GetIntValue(2) );
570 mgr->setValue( "SMESH", "SettingsShrinkCoeff", aDlg->GetIntValue(3) );
577 void Control( int theCommandID )
579 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
580 SALOME_ListIO selected;
582 aSel->selectedObjects( selected );
584 if( !selected.IsEmpty() ){
585 Handle(SALOME_InteractiveObject) anIO = selected.First();
588 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
589 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
590 switch ( theCommandID ){
592 aTitle = QObject::tr( "LENGTH_EDGES" );
593 aControl = SMESH_Actor::eLength;
596 aTitle = QObject::tr( "LENGTH2D_EDGES" );
597 aControl = SMESH_Actor::eLength2D;
600 aTitle = QObject::tr( "FREE_EDGES" );
601 aControl = SMESH_Actor::eFreeEdges;
604 aTitle = QObject::tr( "FREE_BORDERS" );
605 aControl = SMESH_Actor::eFreeBorders;
608 aTitle = QObject::tr( "MULTI_BORDERS" );
609 aControl = SMESH_Actor::eMultiConnection;
612 aTitle = QObject::tr( "MULTI2D_BORDERS" );
613 aControl = SMESH_Actor::eMultiConnection2D;
616 aTitle = QObject::tr( "AREA_ELEMENTS" );
617 aControl = SMESH_Actor::eArea;
620 aTitle = QObject::tr( "TAPER_ELEMENTS" );
621 aControl = SMESH_Actor::eTaper;
624 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
625 aControl = SMESH_Actor::eAspectRatio;
628 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
629 aControl = SMESH_Actor::eAspectRatio3D;
632 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
633 aControl = SMESH_Actor::eMinimumAngle;
636 aTitle = QObject::tr( "WARP_ELEMENTS" );
637 aControl = SMESH_Actor::eWarping;
640 aTitle = QObject::tr( "SKEW_ELEMENTS" );
641 aControl = SMESH_Actor::eSkew;
644 anActor->SetControlMode(aControl);
645 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
652 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
653 MeshObjectType theType,
654 const QString theInTypeName,
655 QString & theOutTypeName)
657 SMESH_TypeFilter aTypeFilter( theType );
659 if( !theIO.IsNull() )
661 entry = theIO->getEntry();
662 SalomeApp_DataOwner owner( entry );
663 if ( aTypeFilter.isOk( &owner )) {
664 theOutTypeName = theInTypeName;
672 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
674 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
675 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
677 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
678 CORBA::String_var anID = aSComp->GetID().c_str();
679 if (!strcmp(anID.in(),theIO->getEntry()))
685 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
686 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
687 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
688 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
689 CheckOIType ( theIO, GROUP, "Group", aTypeName )
697 QString CheckHomogeneousSelection()
699 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
700 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
701 SALOME_ListIO selected;
703 aSel->selectedObjects( selected );
705 QString RefType = CheckTypeObject(selected.First());
706 SALOME_ListIteratorOfListIO It(selected);
707 for (; It.More(); It.Next())
709 Handle(SALOME_InteractiveObject) IObject = It.Value();
710 QString Type = CheckTypeObject(IObject);
711 if (Type.compare(RefType) != 0)
712 return "Heterogeneous Selection";
720 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
721 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
722 SALOME_ListIO selected; aSel->selectedObjects( selected );
724 QString aParentComponent = QString::null;
725 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
727 QString cur = anIt.Value()->getComponentDataType();
728 if( aParentComponent.isNull() )
729 aParentComponent = cur;
730 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
731 aParentComponent = "";
734 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
735 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
736 QObject::tr("ERR_ERROR"),
737 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
738 QObject::tr("BUT_OK") );
741 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
742 if (SUIT_MessageBox::warn2
743 (SMESHGUI::desktop(),
744 QObject::tr("SMESH_WRN_WARNING"),
745 QObject::tr("SMESH_REALLY_DELETE"),
746 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
749 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
750 SUIT_ViewManager* vm = anApp->activeViewManager();
751 int nbSf = vm->getViewsCount();
753 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
754 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
755 _PTR(GenericAttribute) anAttr;
756 _PTR(AttributeIOR) anIOR;
758 SALOME_ListIteratorOfListIO It(selected);
760 aStudyBuilder->NewCommand(); // There is a transaction
761 for(; It.More(); It.Next()){
762 Handle(SALOME_InteractiveObject) IObject = It.Value();
763 if(IObject->hasEntry()){
764 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
766 /* Erase child graphical objects */
767 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
768 for(it->InitEx(true); it->More(); it->Next()){
769 _PTR(SObject) CSO = it->Value();
770 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
773 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
774 for(int i = 0; i < nbSf; i++){
775 SUIT_ViewWindow *sf = aViews[i];
776 CORBA::String_var anEntry = CSO->GetID().c_str();
777 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
778 SMESH::RemoveActor(sf,anActor);
784 /* Erase main graphical object */
785 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
786 for(int i = 0; i < nbSf; i++){
787 SUIT_ViewWindow *sf = aViews[i];
788 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
789 SMESH::RemoveActor(sf,anActor);
793 // Remove object(s) from data structures
794 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
796 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
797 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
799 if ( !aGroup->_is_nil() ) { // DELETE GROUP
800 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
801 aMesh->RemoveGroup( aGroup );
803 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
804 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
805 aMesh->RemoveSubMesh( aSubMesh );
807 else {// default action: remove SObject from the study
808 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
809 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
811 aStudyBuilder->RemoveObjectWithChildren( obj );
816 } /* IObject->hasEntry() */
818 aStudyBuilder->CommitCommand();
820 /* Clear any previous selection */
822 aSel->setSelectedObjects( l1 );
824 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
829 Standard_EXPORT CAM_Module* createModule()
831 return new SMESHGUI();
835 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
837 //=============================================================================
841 //=============================================================================
842 SMESHGUI::SMESHGUI() :
843 SalomeApp_Module( "SMESH" )
845 if ( CORBA::is_nil( myComponentSMESH ) )
847 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
848 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
849 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
852 myActiveDialogBox = 0 ;
855 SMESH::GetFilterManager();
858 /* load resources for all available meshers */
859 SMESH::InitAvailableHypotheses();
862 //=============================================================================
866 //=============================================================================
867 SMESHGUI::~SMESHGUI()
869 SMESH::GetFilterManager()->Destroy();
872 //=============================================================================
876 //=============================================================================
877 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
879 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
881 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
886 bool SMESHGUI::automaticUpdate()
888 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
892 return resMgr->booleanValue( "SMESH", "auto_update", false );
895 //=============================================================================
899 //=============================================================================
900 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
902 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
905 //=============================================================================
909 //=============================================================================
910 SMESHGUI* SMESHGUI::GetSMESHGUI()
912 SMESHGUI* smeshMod = 0;
913 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
916 CAM_Module* module = app->module( "Mesh" );
917 smeshMod = dynamic_cast<SMESHGUI*>( module );
920 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
922 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
925 _PTR(Study) aStudy = study->studyDS();
927 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
936 Standard_EXPORT SMESHGUI* GetComponentGUI()
938 return SMESHGUI::GetSMESHGUI();
942 //=============================================================================
946 //=============================================================================
947 void SMESHGUI::SetState(int aState)
952 //=============================================================================
956 //=============================================================================
957 void SMESHGUI::ResetState()
962 //=============================================================================
966 //=============================================================================
967 void SMESHGUI::EmitSignalDeactivateDialog()
969 emit SignalDeactivateActiveDialog();
972 //=============================================================================
976 //=============================================================================
977 void SMESHGUI::EmitSignalStudyFrameChanged()
979 emit SignalStudyFrameChanged();
982 //=============================================================================
986 //=============================================================================
987 void SMESHGUI::EmitSignalCloseAllDialogs()
989 emit SignalCloseAllDialogs();
992 //=============================================================================
996 //=============================================================================
997 QDialog *SMESHGUI::GetActiveDialogBox()
999 return myActiveDialogBox;
1002 //=============================================================================
1006 //=============================================================================
1007 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1009 myActiveDialogBox = (QDialog *) aDlg;
1013 //=============================================================================
1017 //=============================================================================
1018 SUIT_Desktop* SMESHGUI::desktop()
1020 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1022 return app->desktop();
1027 //=============================================================================
1031 //=============================================================================
1032 SalomeApp_Study* SMESHGUI::activeStudy()
1034 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1036 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1041 //=============================================================================
1045 //=============================================================================
1046 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1048 /* Here the position is on the bottom right corner - 10 */
1049 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1051 SUIT_Desktop *PP = desktop();
1052 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1053 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1057 //=============================================================================
1061 //=============================================================================
1062 static int isStudyLocked(_PTR(Study) theStudy){
1063 return theStudy->GetProperties()->IsLocked();
1066 static bool checkLock(_PTR(Study) theStudy) {
1067 if (isStudyLocked(theStudy)) {
1068 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1069 QObject::tr("WRN_WARNING"),
1070 QObject::tr("WRN_STUDY_LOCKED"),
1071 QObject::tr("BUT_OK") );
1077 //=======================================================================
1078 //function : CheckActiveStudyLocked
1080 //=======================================================================
1082 bool SMESHGUI::isActiveStudyLocked()
1084 _PTR(Study) aStudy = activeStudy()->studyDS();
1085 return checkLock( aStudy );
1088 //=============================================================================
1092 //=============================================================================
1093 bool SMESHGUI::OnGUIEvent( int theCommandID )
1095 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1099 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1100 SUIT_ResourceMgr* mgr = resourceMgr();
1104 SUIT_Operation* anOp = getOperation( theCommandID );
1111 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1112 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1114 QAction* act = action( theCommandID );
1116 switch (theCommandID) {
1118 if(checkLock(aStudy)) break;
1126 if(checkLock(aStudy)) break;
1127 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1131 case 122: // EXPORT MED
1138 ::ExportMeshToFile(theCommandID);
1142 case 200: // SCALAR BAR
1144 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1145 SALOME_ListIO selected;
1147 aSel->selectedObjects( selected );
1149 if( selected.Extent() ) {
1150 Handle(SALOME_InteractiveObject) anIO = selected.First();
1151 if( anIO->hasEntry() ) {
1152 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1153 anActor->SetControlMode( SMESH_Actor::eNone );
1161 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1165 case 1134: // Clipping
1166 case 1133: // Tranparency
1167 case 1132: // Colors / Size
1174 ::SetDisplayMode(theCommandID);
1180 case 219: // Volumes
1181 case 220: // All Entity
1182 ::SetDisplayEntity(theCommandID);
1187 if(checkLock(aStudy)) break;
1188 SMESH::UpdateView();
1191 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1192 aSel->setSelectedObjects( l );
1197 case 301: // DISPLAY
1198 case 302: // DISPLAY ONLY
1200 SMESH::EDisplaing anAction;
1201 switch(theCommandID){
1202 case 300: anAction = SMESH::eErase; break;
1203 case 301: anAction = SMESH::eDisplay; break;
1204 case 302: anAction = SMESH::eDisplayOnly; break;
1207 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1208 SALOME_ListIO selected;
1210 aSel->selectedObjects( selected );
1213 SALOME_ListIteratorOfListIO It(selected);
1214 for (; It.More(); It.Next()) {
1215 Handle(SALOME_InteractiveObject) IOS = It.Value();
1216 if (IOS->hasEntry()) {
1217 SMESH::UpdateView(anAction,IOS->getEntry());
1222 aSel->setSelectedObjects( l1 );
1228 if(checkLock(aStudy)) break;
1231 EmitSignalDeactivateDialog();
1233 new SMESHGUI_NodesDlg(this);
1236 SUIT_MessageBox::warn1(desktop(),
1237 tr("SMESH_WRN_WARNING"),
1238 tr("SMESH_WRN_VIEWER_VTK"),
1239 tr("SMESH_BUT_OK"));
1244 case 2151: // FILTER
1248 EmitSignalDeactivateDialog();
1249 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1254 case 406: // MOVE NODE
1258 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1259 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1263 if(checkLock(aStudy)) break;
1264 new SMESHGUI_MoveNodesDlg(this);
1268 case 701: // COMPUTE MESH
1270 if(checkLock(aStudy)) break;
1272 SalomeApp_SelectionMgr *Sel = selectionMgr();
1273 SALOME_ListIO selected; Sel->selectedObjects( selected );
1275 int nbSel = selected.Extent();
1280 SMESH::SMESH_Mesh_var aMesh;
1281 SMESH::SMESH_subMesh_var aSubMesh;
1282 Handle(SALOME_InteractiveObject) IObject = selected.First();
1283 if (IObject->hasEntry()){
1284 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1285 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1286 if ( aShapeObject->_is_nil() ) {
1291 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1292 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1294 if (!aMesh->_is_nil()){
1295 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1296 if (!refShapeObject->_is_nil()) {
1297 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1298 SUIT_MessageBox::warn1(desktop(),
1299 tr("SMESH_WRN_WARNING"),
1300 tr("SMESH_WRN_MISSING_PARAMETERS"),
1301 tr("SMESH_BUT_OK"));
1305 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1306 SMESH::ModifiedMesh(aMeshSObj,true);
1307 // TO Do : change icon of all submeshes
1309 SUIT_MessageBox::warn1(desktop(),
1310 tr("SMESH_WRN_WARNING"),
1311 tr("SMESH_WRN_COMPUTE_FAILED"),
1312 tr("SMESH_BUT_OK"));
1314 catch(const SALOME::SALOME_Exception & S_ex){
1315 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1318 }else if(!aSubMesh->_is_nil()){
1319 aMesh = aSubMesh->GetFather();
1320 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1321 if(!refShapeObject->_is_nil()){
1322 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1324 SUIT_MessageBox::warn1(desktop(),
1325 tr("SMESH_WRN_WARNING"),
1326 tr("SMESH_WRN_MISSING_PARAMETERS"),
1327 tr("SMESH_BUT_OK"));
1331 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1332 SMESH::ModifiedMesh(aMeshSObj,true);
1333 // TO Do : change icon of all submeshes
1335 SUIT_MessageBox::warn1(desktop(),
1336 tr("SMESH_WRN_WARNING"),
1337 tr("SMESH_WRN_COMPUTE_FAILED"),
1338 tr("SMESH_BUT_OK"));
1339 }catch(const SALOME::SALOME_Exception & S_ex){
1340 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1346 CORBA::Long anId = aStudy->StudyId();
1347 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1348 if ( automaticUpdate() && aVisualObj){
1349 aVisualObj->Update();
1350 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1352 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1354 SMESH::DisplayActor(view,anActor); //apo
1360 SUIT_MessageBox::warn1(desktop(),
1361 tr("SMESH_WRN_WARNING"),
1362 tr("SMESH_WRN_VIEWER_VTK"),
1363 tr("SMESH_BUT_OK"));
1369 case 702: // ADD SUB MESH
1371 if(checkLock(aStudy)) break;
1373 EmitSignalDeactivateDialog();
1374 new SMESHGUI_AddSubMeshDlg( this );
1377 SUIT_MessageBox::warn1(desktop(),
1378 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1379 tr("SMESH_BUT_OK"));
1384 case 703: // INIT MESH
1386 if(checkLock(aStudy)) break;
1387 //EmitSignalDeactivateDialog();
1388 //new SMESHGUI_InitMeshDlg( this );
1389 startOperation( 703 );
1393 case 704: // EDIT Hypothesis
1395 if(checkLock(aStudy)) break;
1396 EmitSignalDeactivateDialog();
1397 new SMESHGUI_EditHypothesesDlg( this );
1401 case 705: // EDIT Global Hypothesis
1403 if(checkLock(aStudy)) break;
1404 EmitSignalDeactivateDialog();
1405 new SMESHGUI_EditHypothesesDlg( this );
1409 case 706: // EDIT Local Hypothesis
1411 if(checkLock(aStudy)) break;
1412 EmitSignalDeactivateDialog();
1413 new SMESHGUI_EditHypothesesDlg( this );
1417 case 407: // DIAGONAL INVERSION
1418 case 408: // Delete diagonal
1422 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1423 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1427 if ( checkLock( aStudy ) )
1430 /*Standard_Boolean aRes;
1431 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1432 if ( aMesh->_is_nil() )
1434 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1435 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1439 EmitSignalDeactivateDialog();
1440 if ( theCommandID == 407 )
1441 new SMESHGUI_TrianglesInversionDlg(this);
1443 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1446 case 409: // Change orientation
1447 case 410: // Union of triangles
1448 case 411: // Cutting of quadrangles
1452 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1453 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1457 if ( checkLock( aStudy ) )
1460 EmitSignalDeactivateDialog();
1461 SMESHGUI_MultiEditDlg* aDlg = NULL;
1462 if ( theCommandID == 409 )
1463 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1464 else if ( theCommandID == 410 )
1465 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1467 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1470 DefineDlgPosition( aDlg, x, y );
1475 case 412: // Smoothing
1477 if(checkLock(aStudy)) break;
1479 EmitSignalDeactivateDialog();
1480 new SMESHGUI_SmoothingDlg( this );
1483 SUIT_MessageBox::warn1(desktop(),
1484 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1485 tr("SMESH_BUT_OK"));
1489 case 413: // Extrusion
1491 if (checkLock(aStudy)) break;
1493 EmitSignalDeactivateDialog();
1494 new SMESHGUI_ExtrusionDlg ( this );
1496 SUIT_MessageBox::warn1(desktop(),
1497 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1498 tr("SMESH_BUT_OK"));
1502 case 414: // Revolution
1504 if(checkLock(aStudy)) break;
1506 EmitSignalDeactivateDialog();
1507 new SMESHGUI_RevolutionDlg( this );
1510 SUIT_MessageBox::warn1(desktop(),
1511 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1512 tr("SMESH_BUT_OK"));
1516 case 415: // Pattern mapping
1518 if ( checkLock( aStudy ) )
1522 EmitSignalDeactivateDialog();
1523 new SMESHGUI_MeshPatternDlg( this );
1526 SUIT_MessageBox::warn1(desktop(),
1527 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1528 tr("SMESH_BUT_OK"));
1532 case 416: // Extrusion along a path
1534 if (checkLock(aStudy)) break;
1536 EmitSignalDeactivateDialog();
1537 new SMESHGUI_ExtrusionAlongPathDlg( this );
1539 SUIT_MessageBox::warn1(desktop(),
1540 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1541 tr("SMESH_BUT_OK"));
1545 case 801: // CREATE GROUP
1549 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1550 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1554 if(checkLock(aStudy)) break;
1555 EmitSignalDeactivateDialog();
1556 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1558 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1559 SALOME_ListIO selected;
1561 aSel->selectedObjects( selected );
1563 int nbSel = selected.Extent();
1565 // check if mesh is selected
1566 aMesh = SMESH::GetMeshByIO( selected.First() );
1568 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1573 case 802: // CONSTRUCT GROUP
1577 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1578 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1582 if(checkLock(aStudy)) break;
1583 EmitSignalDeactivateDialog();
1585 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1586 SALOME_ListIO selected;
1588 aSel->selectedObjects( selected );
1590 int nbSel = selected.Extent();
1592 // check if submesh is selected
1593 Handle(SALOME_InteractiveObject) IObject = selected.First();
1594 if (IObject->hasEntry()) {
1595 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1597 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1598 if (!aSubMesh->_is_nil()) {
1600 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1601 // get submesh elements list by types
1602 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1603 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1604 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1605 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1606 // create group for each type o elements
1607 QString aName = IObject->getName();
1608 if (aNodes->length() > 0) {
1609 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1610 aGroup->Add(aNodes.inout());
1612 if (aEdges->length() > 0) {
1613 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1614 aGroup->Add(aEdges.inout());
1616 if (aFaces->length() > 0) {
1617 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1618 aGroup->Add(aFaces.inout());
1620 if (aVolumes->length() > 0) {
1621 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1622 aGroup->Add(aVolumes.inout());
1626 }catch(const SALOME::SALOME_Exception & S_ex){
1627 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1636 case 803: // EDIT GROUP
1640 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1641 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1645 if(checkLock(aStudy)) break;
1646 EmitSignalDeactivateDialog();
1648 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1649 SALOME_ListIO selected;
1651 aSel->selectedObjects( selected );
1653 SALOME_ListIteratorOfListIO It (selected);
1654 int nbSelectedGroups = 0;
1655 for ( ; It.More(); It.Next() )
1657 SMESH::SMESH_Group_var aGroup =
1658 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1659 if (!aGroup->_is_nil()) {
1661 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1665 if (nbSelectedGroups == 0)
1667 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1673 case 804: // Add elements to group
1675 if(checkLock(aStudy)) break;
1676 if (myState == 800) {
1677 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1678 if (aDlg) aDlg->onAdd();
1683 case 805: // Remove elements from group
1685 if(checkLock(aStudy)) break;
1686 if (myState == 800) {
1687 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1688 if (aDlg) aDlg->onRemove();
1693 case 810: // Union Groups
1694 case 811: // Intersect groups
1695 case 812: // Cut groups
1699 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1700 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1704 if ( checkLock( aStudy ) )
1707 EmitSignalDeactivateDialog();
1710 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1711 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1712 else aMode = SMESHGUI_GroupOpDlg::CUT;
1714 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1718 case 813: // Delete groups with their contents
1722 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1723 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1727 if ( checkLock( aStudy ) )
1730 EmitSignalDeactivateDialog();
1732 new SMESHGUI_DeleteGroupDlg( this );
1736 case 900: // MESH INFOS
1738 EmitSignalDeactivateDialog();
1739 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1740 SALOME_ListIO selected;
1742 aSel->selectedObjects( selected );
1744 if ( selected.Extent() > 1 ) { // a dlg for each IO
1746 SALOME_ListIteratorOfListIO It (selected);
1747 for ( ; It.More(); It.Next() ) {
1748 IOs.Clear(); IOs.Append( It.Value() );
1749 aSel->setSelectedObjects( IOs );
1750 new SMESHGUI_MeshInfosDlg(this, "", false);
1752 // restore selection
1753 aSel->setSelectedObjects( selected );
1756 new SMESHGUI_MeshInfosDlg(this, "", false);
1760 case 902: // STANDARD MESH INFOS
1762 EmitSignalDeactivateDialog();
1763 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1764 SALOME_ListIO selected;
1766 aSel->selectedObjects( selected );
1768 if ( selected.Extent() > 1 ) { // a dlg for each IO
1770 SALOME_ListIteratorOfListIO It (selected);
1771 for ( ; It.More(); It.Next() ) {
1773 IOs.Append( It.Value() );
1774 aSel->setSelectedObjects( IOs );
1775 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1777 // restore selection
1778 aSel->setSelectedObjects( selected );
1781 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1785 case 1001: // AUTOMATIC UPDATE PREFERENCES
1787 // if (act->isOn()) {
1788 // mgr->setValue( "SMESH", "AutomaticUpdate", true );
1789 // myAutomaticUpdate = true;
1792 // mgr->setValue( "SMESH", "AutomaticUpdate", false );
1793 // myAutomaticUpdate = false;
1798 case 1003: // MESH PREFERENCES
1800 ::SetDisplaySettings();
1806 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( this );
1812 ( new SMESHGUI_PrecisionDlg( this ) )->exec();
1819 mgr->setValue( "SMESH", "DispayEntity", true );
1822 mgr->setValue( "SMESH", "DispayEntity", false );
1828 SMESHGUI_Preferences_SelectionDlg* aDlg =
1829 new SMESHGUI_Preferences_SelectionDlg( this );
1831 QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
1832 aDlg->SetColor(1, aColor);
1834 aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow );
1835 aDlg->SetColor(2, aColor);
1837 aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white );
1838 aDlg->SetColor(3, aColor);
1840 aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) );
1841 aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) );
1842 aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) );
1843 aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) );
1846 QColor aPreColor = aDlg->GetColor(1),
1847 aSelColor = aDlg->GetColor(2),
1848 aHiColor = aDlg->GetColor(3);
1849 int aPreWidth = aDlg->GetWidth(1),
1850 aSelWidth = aDlg->GetWidth(2);
1851 double aTolNodes = aDlg->GetPrecision(1),
1852 aTolItems = aDlg->GetPrecision(2);
1854 mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor );
1855 mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor );
1856 mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor );
1858 mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth );
1859 mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth );
1860 mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes );
1861 mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems );
1863 // update current study settings
1864 SMESH::UpdateSelectionProp( this );
1867 // update VTK viewer properties
1868 SVTK_RenderWindowInteractor* anInteractor =
1869 dynamic_cast<SVTK_RenderWindowInteractor*>( vtkwnd->getRWInteractor() );
1871 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1872 aSelColor.blue()/255., aSelWidth);
1873 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1874 SVTK_InteractorStyle* aStyle =
1875 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
1878 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1879 aPreColor.blue()/255., aPreWidth);
1882 vtkRenderer* aRenderer = vtkwnd->getRenderer();
1883 vtkActorCollection *aCollection = aRenderer->GetActors();
1884 aCollection->InitTraversal();
1885 while(vtkActor *anAct = aCollection->GetNextActor()){
1886 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1887 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1888 aHiColor.blue()/255.);
1889 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1890 aPreColor.blue()/255.);
1899 case 1100: // EDIT HYPOTHESIS
1901 if(checkLock(aStudy)) break;
1903 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1904 SALOME_ListIO selected;
1906 aSel->selectedObjects( selected );
1908 int nbSel = selected.Extent();
1911 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1913 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1914 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1915 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1916 if ( !Hyp->_is_nil() )
1918 char* sName = Hyp->GetName();
1919 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1922 aCreator->EditHypothesis(Hyp);
1930 updateObjBrowser( true );
1934 case 1101: // RENAME
1936 if ( checkLock( aStudy ) )
1939 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1940 SALOME_ListIO selected;
1942 aSel->selectedObjects( selected );
1944 SALOME_ListIteratorOfListIO It( selected );
1945 for ( ; It.More(); It.Next() )
1947 Handle(SALOME_InteractiveObject) IObject = It.Value();
1948 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1949 _PTR(GenericAttribute) anAttr;
1950 _PTR(AttributeName) aName;
1953 if ( obj->FindAttribute(anAttr, "AttributeName") )
1956 QString newName = QString(aName->Value().c_str());
1957 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1958 if ( !newName.isEmpty() )
1960 //old source: aStudy->renameIObject( IObject, newName );
1961 aName->SetValue( newName.latin1() );
1963 // if current object is group update group's name
1964 SMESH::SMESH_GroupBase_var aGroup =
1965 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1966 if (!aGroup->_is_nil() )
1967 aGroup->SetName( newName.latin1() );
1977 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1979 if(checkLock(aStudy)) break;
1980 SUIT_OverrideCursor wc;
1982 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1983 SALOME_ListIO selected;
1985 aSel->selectedObjects( selected );
1987 SALOME_ListIteratorOfListIO It(selected);
1988 for (int i = 0; It.More(); It.Next(), i++) {
1989 Handle(SALOME_InteractiveObject) IObject = It.Value();
1990 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1993 aSel->setSelectedObjects( l1 );
1998 case 401: // GEOM::EDGE
1999 case 4021: // TRIANGLE
2001 case 4023: // POLYGON
2005 if(checkLock(aStudy)) break;
2007 EmitSignalDeactivateDialog();
2008 SMDSAbs_ElementType type = SMDSAbs_Edge;
2010 switch (theCommandID) {
2011 case 4021: // TRIANGLE
2012 type = SMDSAbs_Face; nbNodes = 3; break;
2014 type = SMDSAbs_Face; nbNodes = 4; break;
2016 type = SMDSAbs_Volume; nbNodes = 4; break;
2017 case 4023: // POLYGON
2018 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2020 type = SMDSAbs_Volume; nbNodes = 8; break;
2021 case 4033: // POLYHEDRE
2022 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2025 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2028 SUIT_MessageBox::warn1(desktop(),
2029 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2030 tr("SMESH_BUT_OK"));
2034 case 4033: // POLYHEDRON
2036 if(checkLock(aStudy)) break;
2038 EmitSignalDeactivateDialog();
2039 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2042 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2043 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2044 tr("SMESH_BUT_OK"));
2048 case 4041: // REMOVES NODES
2050 if(checkLock(aStudy)) break;
2052 EmitSignalDeactivateDialog();
2053 new SMESHGUI_RemoveNodesDlg(this);
2056 SUIT_MessageBox::warn1(desktop(),
2057 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2058 tr("SMESH_BUT_OK"));
2062 case 4042: // REMOVES ELEMENTS
2064 if(checkLock(aStudy)) break;
2066 EmitSignalDeactivateDialog();
2067 new SMESHGUI_RemoveElementsDlg(this);
2071 SUIT_MessageBox::warn1(desktop(),
2072 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2073 tr("SMESH_BUT_OK"));
2077 case 4051: // RENUMBERING NODES
2079 if(checkLock(aStudy)) break;
2081 EmitSignalDeactivateDialog();
2082 new SMESHGUI_RenumberingDlg( this, "", 0);
2086 SUIT_MessageBox::warn1(desktop(),
2087 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2088 tr("SMESH_BUT_OK"));
2092 case 4052: // RENUMBERING ELEMENTS
2094 if(checkLock(aStudy)) break;
2096 EmitSignalDeactivateDialog();
2097 new SMESHGUI_RenumberingDlg( this, "", 1);
2101 SUIT_MessageBox::warn1(desktop(),
2102 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2103 tr("SMESH_BUT_OK"));
2107 case 4061: // TRANSLATION
2109 if(checkLock(aStudy)) break;
2111 EmitSignalDeactivateDialog();
2112 new SMESHGUI_TranslationDlg( this );
2115 SUIT_MessageBox::warn1(desktop(),
2116 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2117 tr("SMESH_BUT_OK"));
2121 case 4062: // ROTATION
2123 if(checkLock(aStudy)) break;
2125 EmitSignalDeactivateDialog();
2126 new SMESHGUI_RotationDlg( this );
2129 SUIT_MessageBox::warn1(desktop(),
2130 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2131 tr("SMESH_BUT_OK"));
2135 case 4063: // SYMMETRY
2137 if(checkLock(aStudy)) break;
2139 EmitSignalDeactivateDialog();
2140 new SMESHGUI_SymmetryDlg( this );
2143 SUIT_MessageBox::warn1(desktop(),
2144 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2145 tr("SMESH_BUT_OK"));
2149 case 4064: // SEWING
2151 if(checkLock(aStudy)) break;
2153 EmitSignalDeactivateDialog();
2154 new SMESHGUI_SewingDlg( this );
2157 SUIT_MessageBox::warn1(desktop(),
2158 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2159 tr("SMESH_BUT_OK"));
2163 case 4065: // MERGE NODES
2165 if(checkLock(aStudy)) break;
2167 EmitSignalDeactivateDialog();
2168 new SMESHGUI_MergeNodesDlg( this );
2171 SUIT_MessageBox::warn1(desktop(),
2172 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2173 tr("SMESH_BUT_OK"));
2179 case 5000: // HYPOTHESIS
2181 if(checkLock(aStudy)) break;
2182 EmitSignalDeactivateDialog();
2183 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2188 if(checkLock(aStudy)) break;
2189 EmitSignalDeactivateDialog();
2190 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2194 case 5105: // Library of selection filters
2196 static QValueList<int> aTypes;
2197 if ( aTypes.isEmpty() )
2199 aTypes.append( SMESH::NODE );
2200 aTypes.append( SMESH::EDGE );
2201 aTypes.append( SMESH::FACE );
2202 aTypes.append( SMESH::VOLUME );
2204 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2208 case 6017: // CONTROLS
2223 SalomeApp_SelectionMgr* mgr = selectionMgr();
2224 SALOME_ListIO selected; mgr->selectedObjects( selected );
2226 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2227 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2229 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2230 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2231 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2232 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2233 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2234 ::Control( theCommandID );
2239 SUIT_MessageBox::warn1(desktop(),
2240 tr( "SMESH_WRN_WARNING" ),
2241 tr( "SMESH_BAD_SELECTION" ),
2242 tr( "SMESH_BUT_OK" ) );
2246 SUIT_MessageBox::warn1(desktop(),
2247 tr( "SMESH_WRN_WARNING" ),
2248 tr( "NOT_A_VTK_VIEWER" ),
2249 tr( "SMESH_BUT_OK" ) );
2254 SalomeApp_SelectionMgr* mgr = selectionMgr();
2255 SALOME_ListIO selected; mgr->selectedObjects( selected );
2257 if (selected.Extent() == 1) {
2258 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2259 if(anIObject->hasEntry())
2260 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2261 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2268 SalomeApp_SelectionMgr* mgr = selectionMgr();
2269 SALOME_ListIO selected; mgr->selectedObjects( selected );
2271 if (selected.Extent() == 1) {
2272 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2273 if(anIObject->hasEntry())
2274 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2275 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2280 case 10001: // DISPLAY MODE PREFERENCE
2284 action( 10002 )->setOn( false );
2285 action( 10004 )->setOn( false );
2286 action( 10003 )->setOn( true );
2287 mgr->setValue( "SMESH", "DisplayMode", "Wireframe");
2293 action( 10001 )->setOn( false );
2294 action( 10004 )->setOn( false );
2295 action( 10003 )->setOn( true );
2296 mgr->setValue( "SMESH", "DisplayMode", "Shading");
2301 mgr->setValue( "SMESH", "Shrink", act->isOn() );
2307 action( 10001 )->setOn( false );
2308 action( 10002 )->setOn( false );
2309 action( 10003 )->setOn( false );
2310 mgr->setValue( "SMESH", "DisplayMode", "Nodes" );
2316 //updateObjBrowser();
2320 //=============================================================================
2324 //=============================================================================
2325 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2330 //=============================================================================
2334 //=============================================================================
2335 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2340 //=============================================================================
2344 //=============================================================================
2345 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2350 //=============================================================================
2354 //=============================================================================
2355 bool SMESHGUI::SetSettings(SUIT_Desktop* parent)
2357 SMESHGUI::GetSMESHGUI();
2359 SUIT_ResourceMgr* mgr = resourceMgr();
2364 QString DisplayMode = "Shading";
2365 if ( mgr->hasValue("SMESH","DisplayMode") )
2366 DisplayMode = mgr->stringValue("SMESH","DisplayMode");
2368 mgr->setValue("SMESH","DisplayMode", "Shading");
2370 bool Shrink = false;
2371 if ( mgr->hasValue("SMESH","Shrink") )
2372 Shrink = mgr->stringValue("SMESH","Shrink") == "yes";
2374 if (DisplayMode == "Wireframe") {
2376 action( 10004 )->setOn( false );
2377 action( 10002 )->setOn( false );
2378 action( 10001 )->setOn( true );
2379 action( 10003 )->setOn( true );
2381 else if (DisplayMode == "Nodes") {
2383 action( 10004 )->setOn( true );
2384 action( 10002 )->setOn( false );
2385 action( 10001 )->setOn( false );
2386 action( 10003 )->setOn( false );
2389 // default is shading
2390 action( 10004 )->setOn( false );
2391 action( 10002 )->setOn( true );
2392 action( 10001 )->setOn( false );
2393 action( 10003 )->setOn( true );
2396 action( 10003 )->setOn( Shrink );
2399 // if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) {
2400 // action( 1001 )->setOn( true );
2401 // myAutomaticUpdate = true;
2404 // action( 1001 )->setOn( false );
2405 // myAutomaticUpdate = false;
2408 if ( mgr->booleanValue( "SMESH","DispayEntity", false ) )
2409 action( 10071 )->setOn( true );
2411 action( 10071 )->setOn( false );
2414 SMESH::UpdateSelectionProp( this );
2417 action( 111 )->setEnabled( false ); // IMPORT DAT
2419 //action( 112 )->setEnabled( false );
2420 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2425 //=============================================================================
2426 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2427 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2429 //=============================================================================
2430 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2431 SUIT_ViewWindow* wnd )
2433 if(theIO->hasEntry()){
2434 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2435 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2439 //=======================================================================
2440 // function : createSMESHAction
2442 //=======================================================================
2443 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2446 QWidget* parent = application()->desktop();
2447 SUIT_ResourceMgr* resMgr = resourceMgr();
2449 if ( icon_id.length() )
2450 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2452 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2453 if ( !pix.isNull() )
2454 icon = QIconSet( pix );
2456 QString tooltip = tr( QString( "TOP_" )+po_id ),
2457 menu = tr( QString( "MEN_" )+po_id ),
2458 status_bar = tr( QString( "STB_" )+po_id );
2460 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2463 //=======================================================================
2464 // function : createPopupItem
2466 //=======================================================================
2467 void SMESHGUI::createPopupItem( const int id,
2468 const QString& clients,
2469 const QString& types,
2470 const QString& theRule,
2475 parentId = popupMgr()->actionId( action( pId ) );
2477 // if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2478 popupMgr()->insert( action( id ), parentId, 0 );
2480 QChar lc = QtxPopupMgr::Selection::defEquality();
2481 QString rule = "(%1) and (%2) and (%3)";
2482 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2483 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2484 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2487 bool cont = myRules.contains( id );
2489 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2491 popupMgr()->setRule( action( id ), rule, true );
2492 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2495 //=======================================================================
2496 // function : initialize
2498 //=======================================================================
2499 void SMESHGUI::initialize( CAM_Application* app )
2501 SalomeApp_Module::initialize( app );
2503 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2505 /* Automatic Update flag */
2506 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2508 // ----- create actions --------------
2510 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2511 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2512 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2513 createSMESHAction( 114, "NUM" );
2514 createSMESHAction( 121, "DAT" );
2515 createSMESHAction( 122, "MED" );
2516 createSMESHAction( 123, "UNV" );
2517 createSMESHAction( 124, "EXPORT_DAT" );
2518 createSMESHAction( 125, "EXPORT_MED" );
2519 createSMESHAction( 126, "EXPORT_UNV" );
2520 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2521 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2522 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2523 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2524 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2525 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2526 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2527 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2528 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2529 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2530 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2531 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2532 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2533 createSMESHAction( 804, "ADD" );
2534 createSMESHAction( 805, "REMOVE" );
2535 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2536 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2537 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2538 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2539 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2540 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2541 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2542 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2543 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2544 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2545 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2546 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2547 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2548 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2549 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2550 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2551 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2552 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2553 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2554 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2555 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2556 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2557 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2558 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2559 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2560 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2561 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2562 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2563 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2564 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2565 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2566 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2567 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2568 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2569 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2570 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2571 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2572 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2573 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2574 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2575 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2576 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2577 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2578 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2579 createSMESHAction( 415, "MAP", "ICON_MAP" );
2580 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2581 createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true );
2582 createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true );
2583 createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true );
2584 createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true );
2585 createSMESHAction( 1001, "AUTO_UPD", "", 0, true );
2586 createSMESHAction( 1003, "COLORS" );
2587 createSMESHAction( 1005, "SCALAR_BAR" );
2588 createSMESHAction( 1006, "SELECTION" );
2589 createSMESHAction( 10070, "PRECISION", "", 0, true );
2590 createSMESHAction( 10071, "DISP_ENT", "", 0, true );
2591 createSMESHAction( 200, "RESET" );
2592 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2593 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2594 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2595 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2596 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2597 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2598 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2599 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2600 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2601 createSMESHAction( 220, "ALL" );
2602 createSMESHAction( 1100, "EDIT_HYPO" );
2603 createSMESHAction( 1101, "RENAME" );
2604 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2605 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2606 createSMESHAction( 1131, "DISPMODE" );
2607 createSMESHAction( 1132, "COLORS" );
2608 createSMESHAction( 1133, "TRANSP" );
2609 createSMESHAction( 1134, "CLIP" );
2610 createSMESHAction( 1135, "DISP_ENT" );
2611 createSMESHAction( 2000, "CTRL" );
2613 createSMESHAction( 300, "ERASE" );
2614 createSMESHAction( 301, "DISPLAY" );
2615 createSMESHAction( 302, "DISPLAY_ONLY" );
2616 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2618 // ----- create menu --------------
2619 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2620 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2621 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2622 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2623 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2624 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2625 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2626 prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ),
2627 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2629 createMenu( separator(), fileId );
2631 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2632 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2634 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2635 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2636 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2637 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
2639 meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ),
2641 dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ),
2642 qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 );
2644 createMenu( 111, importId, -1 );
2645 createMenu( 112, importId, -1 );
2646 createMenu( 113, importId, -1 );
2648 createMenu( 121, exportId, -1 );
2649 createMenu( 122, exportId, -1 );
2650 createMenu( 123, exportId, -1 );
2652 createMenu( separator(), fileId, 10 );
2654 createMenu( 33, editId, -1 );
2656 createMenu( 5105, toolsId, -1 );
2658 createMenu( 5000, hypoId, -1 );
2659 createMenu( 5010, hypoId, -1 );
2661 createMenu( 703, meshId, -1 );
2662 createMenu( 702, meshId, -1 );
2663 createMenu( 704, meshId, -1 );
2664 createMenu( separator(), meshId, -1 );
2665 createMenu( 701, meshId, -1 );
2666 createMenu( separator(), meshId, -1 );
2667 createMenu( 801, meshId, -1 );
2668 createMenu( 802, meshId, -1 );
2669 createMenu( 803, meshId, -1 );
2670 createMenu( separator(), meshId, -1 );
2671 createMenu( 810, meshId, -1 );
2672 createMenu( 811, meshId, -1 );
2673 createMenu( 812, meshId, -1 );
2674 createMenu( separator(), meshId, -1 );
2675 createMenu( 813, meshId, -1 );
2676 createMenu( separator(), meshId, -1 );
2677 createMenu( 900, meshId, -1 );
2678 createMenu( 902, meshId, -1 );
2679 createMenu( separator(), meshId, -1 );
2681 createMenu( 6003, ctrlId, -1 );
2682 createMenu( 6001, ctrlId, -1 );
2683 createMenu( 6004, ctrlId, -1 );
2684 createMenu( separator(), ctrlId, -1 );
2685 createMenu( 6002, ctrlId, -1 );
2686 createMenu( 6018, ctrlId, -1 );
2687 createMenu( 6019, ctrlId, -1 );
2688 createMenu( 6011, ctrlId, -1 );
2689 createMenu( 6012, ctrlId, -1 );
2690 createMenu( 6013, ctrlId, -1 );
2691 createMenu( 6014, ctrlId, -1 );
2692 createMenu( 6015, ctrlId, -1 );
2693 createMenu( 6016, ctrlId, -1 );
2694 createMenu( separator(), ctrlId, -1 );
2695 createMenu( 6017, ctrlId, -1 );
2696 createMenu( separator(), ctrlId, -1 );
2698 createMenu( 400, addId, -1 );
2699 createMenu( 401, addId, -1 );
2700 createMenu( 4021, addId, -1 );
2701 createMenu( 4022, addId, -1 );
2702 createMenu( 4023, addId, -1 );
2703 createMenu( 4031, addId, -1 );
2704 createMenu( 4032, addId, -1 );
2705 createMenu( 4033, addId, -1 );
2707 createMenu( 4041, removeId, -1 );
2708 createMenu( 4042, removeId, -1 );
2710 createMenu( 4051, renumId, -1 );
2711 createMenu( 4052, renumId, -1 );
2713 createMenu( 4061, transfId, -1 );
2714 createMenu( 4062, transfId, -1 );
2715 createMenu( 4063, transfId, -1 );
2716 createMenu( 4064, transfId, -1 );
2717 createMenu( 4065, transfId, -1 );
2719 createMenu( 406, modifyId, -1 );
2720 createMenu( 407, modifyId, -1 );
2721 createMenu( 408, modifyId, -1 );
2722 createMenu( 409, modifyId, -1 );
2723 createMenu( 410, modifyId, -1 );
2724 createMenu( 411, modifyId, -1 );
2725 createMenu( 412, modifyId, -1 );
2726 createMenu( 413, modifyId, -1 );
2727 createMenu( 416, modifyId, -1 );
2728 createMenu( 414, modifyId, -1 );
2729 createMenu( 415, modifyId, -1 );
2731 createMenu( 10001, dispModeId, -1 );
2732 createMenu( 10002, dispModeId, -1 );
2733 createMenu( 10004, dispModeId, -1 );
2734 createMenu( 10003, dispModeId, -1 );
2736 createMenu( 1001, prefId, -1 );
2737 createMenu( separator(), prefId, -1 );
2738 createMenu( 1003, prefId, -1 );
2739 createMenu( separator(), prefId, -1 );
2740 createMenu( 1005, prefId, -1 );
2741 createMenu( separator(), prefId, -1 );
2742 createMenu( 1006, prefId, -1 );
2743 createMenu( separator(), prefId, -1 );
2745 createMenu( 10070, qualityId, -1 );
2746 createMenu( 10071, qualityId, -1 );
2748 createMenu( separator(), prefId, -1 );
2750 createMenu( 214, viewId, -1 );
2752 // ----- create toolbars --------------
2753 int meshTb = createTool( tr( "TB_MESH" ) ),
2754 hypoTb = createTool( tr( "TB_HYPO" ) ),
2755 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2756 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2757 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2758 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2760 createTool( 703, meshTb );
2761 createTool( 702, meshTb );
2762 createTool( 704, meshTb );
2763 createTool( separator(), meshTb );
2764 createTool( 701, meshTb );
2765 createTool( separator(), meshTb );
2766 createTool( 801, meshTb );
2767 createTool( 802, meshTb );
2768 createTool( 803, meshTb );
2769 createTool( separator(), meshTb );
2770 createTool( 900, meshTb );
2771 createTool( 902, meshTb );
2772 createTool( separator(), meshTb );
2774 createTool( 5000, hypoTb );
2775 createTool( 5010, hypoTb );
2777 createTool( 6001, ctrlTb );
2778 createTool( 6003, ctrlTb );
2779 createTool( 6004, ctrlTb );
2780 createTool( separator(), ctrlTb );
2781 createTool( 6002, ctrlTb );
2782 createTool( 6018, ctrlTb );
2783 createTool( 6019, ctrlTb );
2784 createTool( 6011, ctrlTb );
2785 createTool( 6012, ctrlTb );
2786 createTool( 6013, ctrlTb );
2787 createTool( 6014, ctrlTb );
2788 createTool( 6015, ctrlTb );
2789 createTool( 6016, ctrlTb );
2790 createTool( separator(), ctrlTb );
2791 createTool( 6017, ctrlTb );
2792 createTool( separator(), ctrlTb );
2794 createTool( 400, addRemTb );
2795 createTool( 401, addRemTb );
2796 createTool( 4021, addRemTb );
2797 createTool( 4022, addRemTb );
2798 createTool( 4023, addRemTb );
2799 createTool( 4031, addRemTb );
2800 createTool( 4032, addRemTb );
2801 createTool( 4033, addRemTb );
2802 createTool( separator(), addRemTb );
2803 createTool( 4041, addRemTb );
2804 createTool( 4042, addRemTb );
2805 createTool( separator(), addRemTb );
2806 createTool( 4051, addRemTb );
2807 createTool( 4052, addRemTb );
2808 createTool( separator(), addRemTb );
2809 createTool( 4061, addRemTb );
2810 createTool( 4062, addRemTb );
2811 createTool( 4063, addRemTb );
2812 createTool( 4064, addRemTb );
2813 createTool( 4065, addRemTb );
2814 createTool( separator(), addRemTb );
2816 createTool( 406, modifyTb );
2817 createTool( 407, modifyTb );
2818 createTool( 408, modifyTb );
2819 createTool( 409, modifyTb );
2820 createTool( 410, modifyTb );
2821 createTool( 411, modifyTb );
2822 createTool( 412, modifyTb );
2823 createTool( 413, modifyTb );
2824 createTool( 416, modifyTb );
2825 createTool( 414, modifyTb );
2826 createTool( 415, modifyTb );
2828 createTool( 214, dispModeTb );
2832 QString OB = "'ObjectBrowser'",
2833 View = "'" + SVTK_Viewer::Type() + "'",
2835 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2836 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2837 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2838 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2839 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2840 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2841 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2842 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2843 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2844 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2846 mesh_group = mesh + " " + subMesh + " " + group,
2847 hyp_alg = hypo + " " + algo;
2849 // popup for object browser
2851 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2852 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2853 createPopupItem( 803, OB, group ); // EDIT_GROUP
2854 popupMgr()->insert( separator(), -1, 0 );
2855 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2856 createPopupItem( 214, OB, mesh_group ); // UPDATE
2857 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2858 createPopupItem( 902, OB, mesh ); // STD_INFO
2859 popupMgr()->insert( separator(), -1, 0 );
2860 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2861 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2862 popupMgr()->insert( separator(), -1, 0 );
2863 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2864 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2865 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2866 popupMgr()->insert( separator(), -1, 0 );
2867 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2868 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2869 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2870 popupMgr()->insert( separator(), -1, 0 );
2873 createPopupItem( 803, View, group ); // EDIT_GROUP
2874 createPopupItem( 804, View, elems ); // ADD
2875 createPopupItem( 805, View, elems ); // REMOVE
2876 popupMgr()->insert( separator(), -1, 0 );
2877 createPopupItem( 214, View, mesh_group ); // UPDATE
2878 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2879 createPopupItem( 902, View, mesh ); // STD_INFO
2880 popupMgr()->insert( separator(), -1, 0 );
2884 isInvisible("not( isVisible )"),
2885 isEmpty("numberOfNodes = 0"),
2886 isNotEmpty("numberOfNodes <> 0"),
2888 // has nodes, edges, etc in VISIBLE! actor
2889 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2890 hasElems("(count( elemTypes ) > 0)"),
2891 hasDifferentElems("(count( elemTypes ) > 1)"),
2892 hasEdges("({'Edge'} in elemTypes)"),
2893 hasFaces("({'Face'} in elemTypes)"),
2894 hasVolumes("({'Volume'} in elemTypes)");
2896 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2897 QString lc = QtxPopupMgr::Selection::defEquality();
2898 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2899 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2900 QString aMeshInVTK = aClient + "&&" + aType;// + "&&" + aSelCount;
2902 //-------------------------------------------------
2904 //-------------------------------------------------
2905 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2907 popupMgr()->insert( action( 9010 ), anId, -1 );
2908 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true );
2909 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2911 popupMgr()->insert( action( 9011 ), anId, -1 );
2912 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true );
2913 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2915 popupMgr()->insert( separator(), -1, -1 );
2917 //-------------------------------------------------
2919 //-------------------------------------------------
2920 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2922 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2923 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2924 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2926 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2927 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2928 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2930 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2931 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2932 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2934 popupMgr()->insert( separator(), anId, -1 );
2936 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2937 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2938 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2940 //-------------------------------------------------
2942 //-------------------------------------------------
2943 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2945 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2947 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2948 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true );
2949 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2951 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2952 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true );
2953 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2955 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2956 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true );
2957 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2959 popupMgr()->insert( separator(), anId, -1 );
2961 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2962 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true );
2964 //-------------------------------------------------
2966 //-------------------------------------------------
2967 popupMgr()->insert( action( 1132 ), -1, -1 );
2968 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2970 //-------------------------------------------------
2972 //-------------------------------------------------
2973 popupMgr()->insert( action( 1133 ), -1, -1 );
2974 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2976 //-------------------------------------------------
2978 //-------------------------------------------------
2979 popupMgr()->insert( action( 1134 ), -1, -1 );
2980 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2982 popupMgr()->insert( separator(), -1, -1 );
2984 //-------------------------------------------------
2986 //-------------------------------------------------
2988 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2989 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2990 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2992 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2994 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2995 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2997 popupMgr()->insert( separator(), anId, -1 );
2999 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3000 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
3001 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
3003 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3004 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
3005 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
3007 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3008 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
3009 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
3011 popupMgr()->insert( separator(), anId, -1 );
3013 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3014 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
3015 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
3017 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3018 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
3019 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
3021 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3022 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
3023 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
3025 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3026 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
3027 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
3029 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3030 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
3031 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
3033 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3034 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
3035 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
3037 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3038 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3039 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3041 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3042 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3043 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3045 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3046 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3047 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3049 popupMgr()->insert( separator(), anId, -1 );
3051 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3052 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3053 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3055 popupMgr()->insert( separator(), anId, -1 );
3057 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3058 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3060 popupMgr()->insert( separator(), -1, -1 );
3062 //-------------------------------------------------
3064 //-------------------------------------------------
3065 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3066 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
3067 QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
3068 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3069 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
3071 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3072 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
3074 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3075 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
3077 popupMgr()->insert( separator(), -1, -1 );
3079 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
3080 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
3083 bool SMESHGUI::activateModule( SUIT_Study* study )
3085 bool res = SalomeApp_Module::activateModule( study );
3087 setMenuShown( true );
3088 setToolShown( true );
3089 SetSettings( desktop() );
3094 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3096 setMenuShown( false );
3097 setToolShown( false );
3099 EmitSignalCloseAllDialogs();
3101 return SalomeApp_Module::deactivateModule( study );
3104 void SMESHGUI::OnGUIEvent()
3106 const QObject* obj = sender();
3107 if ( !obj || !obj->inherits( "QAction" ) )
3109 int id = actionId((QAction*)obj);
3114 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3116 if ( CORBA::is_nil( myComponentSMESH ) )
3118 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3119 return aGUI.myComponentSMESH;
3121 return myComponentSMESH;
3124 QString SMESHGUI::engineIOR() const
3126 CORBA::ORB_var anORB = getApp()->orb();
3127 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3131 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3133 SMESHGUI_Selection sel;
3134 sel.init( client, selectionMgr() );
3135 popupMgr()->updatePopup( menu, &sel );
3138 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3140 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3141 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3144 void SMESHGUI::viewManagers( QStringList& list ) const
3146 list.append( SVTK_Viewer::Type() );
3149 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
3151 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
3152 SMESH::UpdateSelectionProp( this );
3155 void SMESHGUI::createPreferences()
3157 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3159 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3160 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "display_entity" );
3161 addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "auto_update" );
3163 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3164 setPreferenceProperty( precGroup, "columns", 1 );
3166 addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool );
3167 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3169 setPreferenceProperty( prec, "min", 0 );
3170 setPreferenceProperty( prec, "max", 16 );
3172 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3173 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3175 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
3176 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
3178 setPreferenceProperty( nodeSz, "min", 1 );
3179 setPreferenceProperty( nodeSz, "max", 5 );
3181 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3183 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
3184 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
3185 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
3186 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
3188 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
3189 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3191 setPreferenceProperty( elemW, "min", 1 );
3192 setPreferenceProperty( elemW, "max", 5 );
3194 setPreferenceProperty( shrink, "min", 0 );
3195 setPreferenceProperty( shrink, "max", 100 );
3197 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3199 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3201 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
3202 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
3203 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
3205 setPreferenceProperty( selW, "min", 1 );
3206 setPreferenceProperty( selW, "max", 5 );
3208 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3210 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
3211 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3213 setPreferenceProperty( preW, "min", 1 );
3214 setPreferenceProperty( preW, "max", 5 );
3216 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3218 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
3219 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
3222 void SMESHGUI::preferencesChanged( const QString&, const QString& )
3226 //=======================================================================
3227 // function : onOperationCommited
3228 // purpose : SLOT called when operation commited. Set default selection mode
3229 //=======================================================================
3230 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3232 SVTK_ViewWindow* vtkWnd =
3233 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3235 vtkWnd->SetSelectionMode( ActorSelection );
3238 //=======================================================================
3239 // function : onOperationAborted
3240 // purpose : SLOT called when operation commited. Set default selection mode
3241 //=======================================================================
3242 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3244 SVTK_ViewWindow* vtkWnd =
3245 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3247 vtkWnd->SetSelectionMode( ActorSelection );
3250 //=======================================================================
3251 // function : getOperation
3252 // purpose : Get operation corresponding to the given Id
3253 //=======================================================================
3254 SalomeApp_Operation* SMESHGUI::getOperation( const int theId )
3256 if ( myOperations.contains( theId ) )
3257 return myOperations[ theId ];
3260 SalomeApp_Operation* anOp = 0;
3270 anOp->setModule( this );
3271 connect( anOp, SIGNAL( aborted( SUIT_Operation* ) ),
3272 this, SLOT( onOperationAborted( SUIT_Operation* ) ) );
3273 connect( anOp, SIGNAL( commited( SUIT_Operation* ) ),
3274 this, SLOT( onOperationCommited( SUIT_Operation* ) ) );
3275 myOperations[ theId ] = anOp;
3282 //=======================================================================
3283 // function : update
3284 // purpose : Update something
3285 //=======================================================================
3286 void SMESHGUI::update( const int flags )
3288 if ( flags & UF_Viewer | flags & UF_Forced )
3289 SMESH::UpdateView();
3291 SalomeApp_Module::update( flags );
3294 //=======================================================================
3295 // function : updateControls
3296 // purpose : Update state of controls
3297 //=======================================================================
3298 void SMESHGUI::updateControls()
3303 //=======================================================================
3304 // function : updateControls
3305 // purpose : Update state of controls
3306 //=======================================================================
3307 SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
3310 return new SMESHGUI_InitMeshOp();
3312 return SalomeApp_Module::createOperation( id );