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_ExportMeshOp.h"
29 #include "SMESHGUI_InitMeshOp.h"
30 #include "SMESHGUI_AddSubMeshOp.h"
31 #include "SMESHGUI_NodesOp.h"
32 #include "SMESHGUI_DeleteOp.h"
33 #include "SMESHGUI_TransparencyDlg.h"
34 #include "SMESHGUI_ClippingDlg.h"
35 #include "SMESHGUI_GroupDlg.h"
36 #include "SMESHGUI_RemoveOp.h"
37 #include "SMESHGUI_MeshInfosDlg.h"
38 #include "SMESHGUI_StandardMeshInfosOp.h"
39 #include "SMESHGUI_Preferences_ColorDlg.h"
40 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
41 #include "SMESHGUI_Preferences_SelectionDlg.h"
42 #include "SMESHGUI_Hypotheses.h"
43 #include "SMESHGUI_HypothesesUtils.h"
44 #include "SMESHGUI_MoveNodesOp.h"
45 #include "SMESHGUI_AddMeshElementOp.h"
46 #include "SMESHGUI_EditHypothesesOp.h"
47 #include "SMESHGUI_CreateHypothesesDlg.h"
48 #include "SMESHGUI_FilterDlg.h"
49 #include "SMESHGUI_FilterLibraryDlg.h"
50 #include "SMESHGUI_SingleEditDlg.h"
51 #include "SMESHGUI_MultiEditDlg.h"
52 #include "SMESHGUI_GroupOp.h"
53 #include "SMESHGUI_DeleteGroupDlg.h"
54 #include "SMESHGUI_SmoothingDlg.h"
55 #include "SMESHGUI_RenumberingOp.h"
56 #include "SMESHGUI_ExtrusionOp.h"
57 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
58 #include "SMESHGUI_RevolutionDlg.h"
59 #include "SMESHGUI_TranslationDlg.h"
60 #include "SMESHGUI_RotationDlg.h"
61 #include "SMESHGUI_SymmetryDlg.h"
62 #include "SMESHGUI_SewingDlg.h"
63 #include "SMESHGUI_MergeNodesDlg.h"
64 #include "SMESHGUI_MeshPatternDlg.h"
65 #include "SMESHGUI_PrecisionDlg.h"
66 #include "SMESHGUI_Selection.h"
67 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
69 #include <SVTK_InteractorStyle.h>
70 #include <SVTK_RenderWindowInteractor.h>
72 #include "SMESH_Actor.h"
73 #include "SMESH_Object.h"
74 #include "SMESH_TypeFilter.hxx"
76 #include "SUIT_Tools.h"
77 #include "SUIT_MessageBox.h"
78 #include "SUIT_ResourceMgr.h"
79 #include "SUIT_FileDlg.h"
80 #include "SUIT_Desktop.h"
81 #include "SUIT_ResourceMgr.h"
82 #include "SUIT_OverrideCursor.h"
83 #include "SUIT_Study.h"
84 #include "SUIT_Session.h"
86 #include "SALOME_NamingService.hxx"
87 #include "SALOME_ListIteratorOfListIO.hxx"
88 #include "SALOME_InteractiveObject.hxx"
89 #include "SALOME_ListIO.hxx"
90 #include <SALOME_LifeCycleCORBA.hxx>
92 #include "OB_Browser.h"
94 #include "QtxPopupMgr.h"
96 #include "SalomeApp_Tools.h"
97 #include "SalomeApp_Study.h"
98 #include "SalomeApp_NameDlg.h"
99 #include "SalomeApp_DataOwner.h"
100 #include "SalomeApp_Application.h"
101 #include "SalomeApp_Preferences.h"
102 #include "SalomeApp_VTKSelector.h"
103 #include "SalomeApp_Operation.h"
104 #include "SalomeApp_UpdateFlags.h"
106 #include "SalomeApp_ImportOperation.h"
108 #include <SVTK_ViewWindow.h>
109 #include <SVTK_ViewModel.h>
111 #include <VTKViewer_ViewManager.h>
113 #include "SMESHGUI_Utils.h"
114 #include "SMESHGUI_GEOMGenUtils.h"
115 #include "SMESHGUI_MeshUtils.h"
116 #include "SMESHGUI_GroupUtils.h"
117 #include "SMESHGUI_FilterUtils.h"
118 #include "SMESHGUI_PatternUtils.h"
119 #include "SMESHGUI_VTKUtils.h"
121 #include "SALOMEconfig.h"
122 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
125 #define INCLUDE_MENUITEM_DEF
126 #include <qapplication.h>
127 #include <qlineedit.h>
128 #include <qmenudata.h>
129 #include <qmenubar.h>
130 #include <qpopupmenu.h>
133 #include <qpainter.h>
134 #include <qcheckbox.h>
135 #include <qcolordialog.h>
136 #include <qspinbox.h>
141 #include <qradiobutton.h>
143 #include <boost/shared_ptr.hpp>
145 #include <vtkRenderer.h>
146 #include <vtkRenderWindow.h>
147 #include <vtkActorCollection.h>
148 #include <vtkScalarBarActor.h>
149 #include <vtkUnstructuredGrid.h>
151 #include "utilities.h"
153 #include "SALOMEDS_Study.hxx"
154 #include "SALOMEDSClient_StudyBuilder.hxx"
155 #include "SALOMEDSClient_SComponent.hxx"
161 //=============================================================
162 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
165 void SetDisplayMode(int theCommandID);
167 void SetDisplayEntity(int theCommandID);
169 void Control( int theCommandID );
171 void SetDisplaySettings();
175 //=============================================================
176 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
182 if(theCommandID == 113){
183 filter.append(QObject::tr("MED files (*.med)"));
184 filter.append(QObject::tr("All files (*)"));
185 }else if (theCommandID == 112){
186 filter.append(QObject::tr("IDEAS files (*.unv)"));
187 }else if (theCommandID == 111){
188 filter.append(QObject::tr("DAT files (*.dat)"));
190 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
193 QObject::tr("Import mesh"),
195 if(!filename.isEmpty()) {
196 SUIT_OverrideCursor wc;
197 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
200 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
201 switch ( theCommandID ) {
204 aMeshes->length( 1 );
205 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
210 SMESH::DriverMED_ReadStatus res;
211 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
212 if ( res != SMESH::DRS_OK ) {
214 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
215 QObject::tr("SMESH_WRN_WARNING"),
216 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
217 QObject::tr("SMESH_BUT_OK"));
218 aMeshes->length( 0 );
225 bool isEmpty = false;
226 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
227 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
229 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
230 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
231 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
232 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
233 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
240 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
241 QObject::tr("SMESH_WRN_WARNING"),
242 QObject::tr("SMESH_DRS_EMPTY"),
243 QObject::tr("SMESH_BUT_OK"));
247 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
249 catch (const SALOME::SALOME_Exception& S_ex){
251 SalomeApp_Tools::QtCatchCorbaException(S_ex);
257 inline void InverseEntityMode(unsigned int& theOutputMode,
258 unsigned int theMode)
260 bool anIsNotPresent = ~theOutputMode & theMode;
262 theOutputMode |= theMode;
264 theOutputMode &= ~theMode;
267 void SetDisplayEntity(int theCommandID){
268 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
269 SALOME_ListIO selected;
271 aSel->selectedObjects( selected );
273 if(selected.Extent() >= 1){
274 SALOME_ListIteratorOfListIO It( selected );
275 for(; It.More(); It.Next()){
276 Handle(SALOME_InteractiveObject) IObject = It.Value();
277 if(IObject->hasEntry()){
278 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
279 unsigned int aMode = anActor->GetEntityMode();
280 switch(theCommandID){
282 InverseEntityMode(aMode,SMESH_Actor::eEdges);
285 InverseEntityMode(aMode,SMESH_Actor::eFaces);
288 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
291 aMode = SMESH_Actor::eAllEntity;
295 anActor->SetEntityMode(aMode);
302 void SetDisplayMode(int theCommandID){
303 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
304 SALOME_ListIO selected;
306 aSel->selectedObjects( selected );
308 if(selected.Extent() >= 1){
309 switch(theCommandID){
311 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
312 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
316 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
317 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
320 SALOME_ListIteratorOfListIO It( selected );
321 for(; It.More(); It.Next()){
322 Handle(SALOME_InteractiveObject) IObject = It.Value();
323 if(IObject->hasEntry()){
324 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
325 switch(theCommandID){
327 anActor->SetRepresentation(SMESH_Actor::eEdge);
330 anActor->SetRepresentation(SMESH_Actor::eSurface);
333 if(anActor->IsShrunk())
336 anActor->SetShrink();
339 anActor->SetRepresentation(SMESH_Actor::ePoint);
343 anActor->GetSufaceColor(color[0], color[1], color[2]);
344 int c0 = int (color[0] * 255);
345 int c1 = int (color[1] * 255);
346 int c2 = int (color[2] * 255);
347 QColor c(c0, c1, c2);
350 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
351 c0 = int (edgecolor[0] * 255);
352 c1 = int (edgecolor[1] * 255);
353 c2 = int (edgecolor[2] * 255);
354 QColor e(c0, c1, c2);
356 float backfacecolor[3];
357 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
358 c0 = int (backfacecolor[0] * 255);
359 c1 = int (backfacecolor[1] * 255);
360 c2 = int (backfacecolor[2] * 255);
361 QColor b(c0, c1, c2);
364 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
365 c0 = int (nodecolor[0] * 255);
366 c1 = int (nodecolor[1] * 255);
367 c2 = int (nodecolor[2] * 255);
368 QColor n(c0, c1, c2);
370 int Edgewidth = (int)anActor->GetLineWidth();
373 int intValue = int(anActor->GetNodeSize());
374 float Shrink = anActor->GetShrinkFactor();
376 SMESHGUI_Preferences_ColorDlg *aDlg =
377 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
378 aDlg->SetColor(1, c);
379 aDlg->SetColor(2, e);
380 aDlg->SetColor(3, n);
381 aDlg->SetColor(4, b);
382 aDlg->SetIntValue(1, Edgewidth);
383 aDlg->SetIntValue(2, intValue);
384 aDlg->SetIntValue(3, int(Shrink*100.));
386 QColor color = aDlg->GetColor(1);
387 QColor edgecolor = aDlg->GetColor(2);
388 QColor nodecolor = aDlg->GetColor(3);
389 QColor backfacecolor = aDlg->GetColor(4);
390 /* actor color and backface color */
391 anActor->SetSufaceColor(float (color.red()) / 255.,
392 float (color.green()) / 255.,
393 float (color.blue()) / 255.);
394 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
395 float (backfacecolor.green()) / 255.,
396 float (backfacecolor.blue()) / 255.);
399 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
400 float (edgecolor.green()) / 255.,
401 float (edgecolor.blue()) / 255.);
403 /* Shrink factor and size edges */
404 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
405 anActor->SetLineWidth(aDlg->GetIntValue(1));
407 /* Nodes color and size */
408 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
409 float (nodecolor.green()) / 255.,
410 float (nodecolor.blue()) / 255.);
411 anActor->SetNodeSize(aDlg->GetIntValue(2));
420 SMESH::RepaintCurrentView();
425 void SetDisplaySettings()
427 SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
431 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
432 SMESHGUI_Preferences_ColorDlg *aDlg =
433 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
435 QColor color = mgr->colorValue( "SMESH", "SettingsFillColor", QColor(0, 170, 255) );
436 aDlg->SetColor(1, color);
438 color = mgr->colorValue( "SMESH", "SettingsOutlineColor", QColor(0, 170, 255) );
439 aDlg->SetColor(2, color);
441 color = mgr->colorValue( "SMESH", "SettingsNodeColor", Qt::red );
442 aDlg->SetColor(3, color);
444 color = mgr->colorValue( "SMESH", "SettingsBackFaceColor", Qt::blue );
445 aDlg->SetColor(4, color);
447 int iVal = mgr->integerValue( "SMESH", "SettingsWidth", 1 );
448 aDlg->SetIntValue(1, iVal);
450 iVal = mgr->integerValue( "SMESH", "SettingsNodesSize", 3 );
451 aDlg->SetIntValue(2, iVal);
453 iVal = mgr->integerValue( "SMESH", "SettingsShrinkCoeff", 75 );
454 aDlg->SetIntValue(3, iVal);
457 mgr->setValue( "SMESH", "SettingsFillColor", aDlg->GetColor(1) );
458 mgr->setValue( "SMESH", "SettingsOutlineColor", aDlg->GetColor(2) );
459 mgr->setValue( "SMESH", "SettingsNodeColor", aDlg->GetColor(3) );
460 mgr->setValue( "SMESH", "SettingsBackFaceColor", aDlg->GetColor(4) );
462 mgr->setValue( "SMESH", "SettingsWidth", aDlg->GetIntValue(1) );
463 mgr->setValue( "SMESH", "SettingsNodesSize", aDlg->GetIntValue(2) );
464 mgr->setValue( "SMESH", "SettingsShrinkCoeff", aDlg->GetIntValue(3) );
471 void Control( int theCommandID )
473 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
474 SALOME_ListIO selected;
476 aSel->selectedObjects( selected );
478 if( !selected.IsEmpty() ){
479 Handle(SALOME_InteractiveObject) anIO = selected.First();
482 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
483 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
484 switch ( theCommandID ){
486 aTitle = QObject::tr( "LENGTH_EDGES" );
487 aControl = SMESH_Actor::eLength;
490 aTitle = QObject::tr( "LENGTH2D_EDGES" );
491 aControl = SMESH_Actor::eLength2D;
494 aTitle = QObject::tr( "FREE_EDGES" );
495 aControl = SMESH_Actor::eFreeEdges;
498 aTitle = QObject::tr( "FREE_BORDERS" );
499 aControl = SMESH_Actor::eFreeBorders;
502 aTitle = QObject::tr( "MULTI_BORDERS" );
503 aControl = SMESH_Actor::eMultiConnection;
506 aTitle = QObject::tr( "MULTI2D_BORDERS" );
507 aControl = SMESH_Actor::eMultiConnection2D;
510 aTitle = QObject::tr( "AREA_ELEMENTS" );
511 aControl = SMESH_Actor::eArea;
514 aTitle = QObject::tr( "TAPER_ELEMENTS" );
515 aControl = SMESH_Actor::eTaper;
518 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
519 aControl = SMESH_Actor::eAspectRatio;
522 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
523 aControl = SMESH_Actor::eAspectRatio3D;
526 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
527 aControl = SMESH_Actor::eMinimumAngle;
530 aTitle = QObject::tr( "WARP_ELEMENTS" );
531 aControl = SMESH_Actor::eWarping;
534 aTitle = QObject::tr( "SKEW_ELEMENTS" );
535 aControl = SMESH_Actor::eSkew;
538 anActor->SetControlMode(aControl);
539 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
546 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
547 MeshObjectType theType,
548 const QString theInTypeName,
549 QString & theOutTypeName)
551 SMESH_TypeFilter aTypeFilter( theType );
553 if( !theIO.IsNull() )
555 entry = theIO->getEntry();
556 SalomeApp_DataOwner owner( entry );
557 if ( aTypeFilter.isOk( &owner )) {
558 theOutTypeName = theInTypeName;
566 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
568 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
569 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
571 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
572 CORBA::String_var anID = aSComp->GetID().c_str();
573 if (!strcmp(anID.in(),theIO->getEntry()))
579 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
580 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
581 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
582 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
583 CheckOIType ( theIO, GROUP, "Group", aTypeName )
591 QString CheckHomogeneousSelection()
593 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
594 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
595 SALOME_ListIO selected;
597 aSel->selectedObjects( selected );
599 QString RefType = CheckTypeObject(selected.First());
600 SALOME_ListIteratorOfListIO It(selected);
601 for (; It.More(); It.Next())
603 Handle(SALOME_InteractiveObject) IObject = It.Value();
604 QString Type = CheckTypeObject(IObject);
605 if (Type.compare(RefType) != 0)
606 return "Heterogeneous Selection";
614 Standard_EXPORT CAM_Module* createModule()
616 return new SMESHGUI();
620 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
622 //=============================================================================
626 //=============================================================================
627 SMESHGUI::SMESHGUI() :
628 SalomeApp_Module( "SMESH" )
630 if ( CORBA::is_nil( myComponentSMESH ) )
632 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
633 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
634 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
637 myActiveDialogBox = 0 ;
640 SMESH::GetFilterManager();
643 /* load resources for all available meshers */
644 SMESH::InitAvailableHypotheses();
647 //=============================================================================
651 //=============================================================================
652 SMESHGUI::~SMESHGUI()
654 SMESH::GetFilterManager()->Destroy();
657 //=============================================================================
661 //=============================================================================
662 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
664 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
666 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
671 bool SMESHGUI::automaticUpdate()
673 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
677 return resMgr->booleanValue( "SMESH", "auto_update", false );
680 //=============================================================================
684 //=============================================================================
685 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
687 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
690 //=============================================================================
694 //=============================================================================
695 SMESHGUI* SMESHGUI::GetSMESHGUI()
697 SMESHGUI* smeshMod = 0;
698 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
701 CAM_Module* module = app->module( "Mesh" );
702 smeshMod = dynamic_cast<SMESHGUI*>( module );
705 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
707 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
710 _PTR(Study) aStudy = study->studyDS();
712 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
721 Standard_EXPORT SMESHGUI* GetComponentGUI()
723 return SMESHGUI::GetSMESHGUI();
727 //=============================================================================
731 //=============================================================================
732 void SMESHGUI::SetState(int aState)
737 //=============================================================================
741 //=============================================================================
742 void SMESHGUI::ResetState()
747 //=============================================================================
751 //=============================================================================
752 void SMESHGUI::EmitSignalDeactivateDialog()
754 printf( "sln: EmitSignalDeactivateDialog EmitSignalDeactivateDialog EmitSignalDeactivateDialog\n" );
755 emit SignalDeactivateActiveDialog();
758 //=============================================================================
762 //=============================================================================
763 void SMESHGUI::EmitSignalStudyFrameChanged()
765 emit SignalStudyFrameChanged();
768 //=============================================================================
772 //=============================================================================
773 void SMESHGUI::EmitSignalCloseAllDialogs()
775 emit SignalCloseAllDialogs();
778 //=============================================================================
782 //=============================================================================
783 QDialog *SMESHGUI::GetActiveDialogBox()
785 return myActiveDialogBox;
788 //=============================================================================
792 //=============================================================================
793 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
795 myActiveDialogBox = (QDialog *) aDlg;
799 //=============================================================================
803 //=============================================================================
804 SUIT_Desktop* SMESHGUI::desktop()
806 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
808 return app->desktop();
813 //=============================================================================
817 //=============================================================================
818 SalomeApp_Study* SMESHGUI::activeStudy()
820 SUIT_Application* app = SUIT_Session::session()->activeApplication();
822 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
827 //=============================================================================
831 //=============================================================================
832 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
834 /* Here the position is on the bottom right corner - 10 */
835 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
837 SUIT_Desktop *PP = desktop();
838 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
839 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
843 //=============================================================================
847 //=============================================================================
848 static int isStudyLocked(_PTR(Study) theStudy){
849 return theStudy->GetProperties()->IsLocked();
852 static bool checkLock(_PTR(Study) theStudy) {
853 if (isStudyLocked(theStudy)) {
854 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
855 QObject::tr("WRN_WARNING"),
856 QObject::tr("WRN_STUDY_LOCKED"),
857 QObject::tr("BUT_OK") );
863 //=======================================================================
864 //function : CheckActiveStudyLocked
866 //=======================================================================
868 bool SMESHGUI::isActiveStudyLocked()
870 _PTR(Study) aStudy = activeStudy()->studyDS();
871 return checkLock( aStudy );
874 //=============================================================================
878 //=============================================================================
879 bool SMESHGUI::OnGUIEvent( int theCommandID )
881 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
885 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
886 SUIT_ResourceMgr* mgr = resourceMgr();
890 SUIT_Operation* anOp = getOperation( theCommandID );
897 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
898 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
900 QAction* act = action( theCommandID );
902 switch (theCommandID) {
904 startOperation( 33 );
911 if(checkLock(aStudy)) break;
912 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
916 case 122: // EXPORT MED
923 startOperation( theCommandID );
924 //::ExportMeshToFile(theCommandID);
928 case 200: // SCALAR BAR
930 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
931 SALOME_ListIO selected;
933 aSel->selectedObjects( selected );
935 if( selected.Extent() ) {
936 Handle(SALOME_InteractiveObject) anIO = selected.First();
937 if( anIO->hasEntry() ) {
938 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
939 anActor->SetControlMode( SMESH_Actor::eNone );
947 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
951 case 1134: // Clipping
952 case 1133: // Tranparency
953 case 1132: // Colors / Size
960 ::SetDisplayMode(theCommandID);
967 case 220: // All Entity
968 ::SetDisplayEntity(theCommandID);
973 if(checkLock(aStudy)) break;
977 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
978 aSel->setSelectedObjects( l );
984 case 302: // DISPLAY ONLY
986 SMESH::EDisplaing anAction;
987 switch(theCommandID){
988 case 300: anAction = SMESH::eErase; break;
989 case 301: anAction = SMESH::eDisplay; break;
990 case 302: anAction = SMESH::eDisplayOnly; break;
993 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
994 SALOME_ListIO selected;
996 aSel->selectedObjects( selected );
999 SALOME_ListIteratorOfListIO It(selected);
1000 for (; It.More(); It.Next()) {
1001 Handle(SALOME_InteractiveObject) IOS = It.Value();
1002 if (IOS->hasEntry()) {
1003 SMESH::UpdateView(anAction,IOS->getEntry());
1008 aSel->setSelectedObjects( l1 );
1014 if(checkLock(aStudy)) break;
1015 startOperation( 400 );
1018 EmitSignalDeactivateDialog();
1020 new SMESHGUI_NodesDlg(this);
1023 SUIT_MessageBox::warn1(desktop(),
1024 tr("SMESH_WRN_WARNING"),
1025 tr("SMESH_WRN_VIEWER_VTK"),
1026 tr("SMESH_BUT_OK"));
1031 case 2151: // FILTER
1035 EmitSignalDeactivateDialog();
1036 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1041 case 406: // MOVE NODE
1045 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1046 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1050 if(checkLock(aStudy)) break;
1051 startOperation( 406 );
1052 // new SMESHGUI_MoveNodesDlg(this);
1056 case 701: // COMPUTE MESH
1058 if(checkLock(aStudy)) break;
1060 SalomeApp_SelectionMgr *Sel = selectionMgr();
1061 SALOME_ListIO selected; Sel->selectedObjects( selected );
1063 int nbSel = selected.Extent();
1068 SMESH::SMESH_Mesh_var aMesh;
1069 SMESH::SMESH_subMesh_var aSubMesh;
1070 Handle(SALOME_InteractiveObject) IObject = selected.First();
1071 if (IObject->hasEntry()){
1072 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1073 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1074 if ( aShapeObject->_is_nil() ) {
1079 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1080 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1082 if (!aMesh->_is_nil()){
1083 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1084 if (!refShapeObject->_is_nil()) {
1085 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1086 SUIT_MessageBox::warn1(desktop(),
1087 tr("SMESH_WRN_WARNING"),
1088 tr("SMESH_WRN_MISSING_PARAMETERS"),
1089 tr("SMESH_BUT_OK"));
1093 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1094 SMESH::ModifiedMesh(aMeshSObj,true);
1095 // TO Do : change icon of all submeshes
1097 SUIT_MessageBox::warn1(desktop(),
1098 tr("SMESH_WRN_WARNING"),
1099 tr("SMESH_WRN_COMPUTE_FAILED"),
1100 tr("SMESH_BUT_OK"));
1102 catch(const SALOME::SALOME_Exception & S_ex){
1103 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1106 }else if(!aSubMesh->_is_nil()){
1107 aMesh = aSubMesh->GetFather();
1108 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1109 if(!refShapeObject->_is_nil()){
1110 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1112 SUIT_MessageBox::warn1(desktop(),
1113 tr("SMESH_WRN_WARNING"),
1114 tr("SMESH_WRN_MISSING_PARAMETERS"),
1115 tr("SMESH_BUT_OK"));
1119 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1120 SMESH::ModifiedMesh(aMeshSObj,true);
1121 // TO Do : change icon of all submeshes
1123 SUIT_MessageBox::warn1(desktop(),
1124 tr("SMESH_WRN_WARNING"),
1125 tr("SMESH_WRN_COMPUTE_FAILED"),
1126 tr("SMESH_BUT_OK"));
1127 }catch(const SALOME::SALOME_Exception & S_ex){
1128 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1134 CORBA::Long anId = aStudy->StudyId();
1135 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1136 if ( automaticUpdate() && aVisualObj){
1137 aVisualObj->Update();
1138 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1140 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1142 SMESH::DisplayActor(view,anActor); //apo
1148 SUIT_MessageBox::warn1(desktop(),
1149 tr("SMESH_WRN_WARNING"),
1150 tr("SMESH_WRN_VIEWER_VTK"),
1151 tr("SMESH_BUT_OK"));
1157 case 702: // ADD SUB MESH
1159 if(checkLock(aStudy)) break;
1160 startOperation( 702 );
1162 EmitSignalDeactivateDialog();
1163 new SMESHGUI_AddSubMeshDlg( this );
1166 SUIT_MessageBox::warn1(desktop(),
1167 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1168 tr("SMESH_BUT_OK"));
1173 case 703: // INIT MESH
1175 if(checkLock(aStudy)) break;
1176 startOperation( 703 );
1180 case 704: // EDIT Hypothesis
1182 if(checkLock(aStudy)) break;
1183 startOperation( 704 );
1187 case 705: // EDIT Global Hypothesis
1189 if(checkLock(aStudy)) break;
1190 startOperation( 704 );
1194 case 706: // EDIT Local Hypothesis
1196 if(checkLock(aStudy)) break;
1197 startOperation( 704 );
1201 case 407: // DIAGONAL INVERSION
1202 case 408: // Delete diagonal
1206 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1207 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1211 if ( checkLock( aStudy ) )
1214 /*Standard_Boolean aRes;
1215 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1216 if ( aMesh->_is_nil() )
1218 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1219 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1223 EmitSignalDeactivateDialog();
1224 if ( theCommandID == 407 )
1225 startOperation( 407 );
1227 startOperation( 408 );
1230 case 409: // Change orientation
1231 case 410: // Union of triangles
1232 case 411: // Cutting of quadrangles
1236 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1237 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1241 if ( checkLock( aStudy ) )
1244 startOperation( theCommandID );
1246 /* EmitSignalDeactivateDialog();
1247 SMESHGUI_MultiEditDlg* aDlg = NULL;
1248 if ( theCommandID == 409 )
1249 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1250 else if ( theCommandID == 410 )
1251 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1253 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1256 DefineDlgPosition( aDlg, x, y );
1261 case 412: // Smoothing
1263 if(checkLock(aStudy)) break;
1265 EmitSignalDeactivateDialog();
1266 new SMESHGUI_SmoothingDlg( this );
1269 SUIT_MessageBox::warn1(desktop(),
1270 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1271 tr("SMESH_BUT_OK"));
1275 case 413: // Extrusion
1277 if( checkLock( aStudy) )
1279 startOperation( 413 );
1281 EmitSignalDeactivateDialog();
1282 new SMESHGUI_ExtrusionDlg ( this );
1284 SUIT_MessageBox::warn1(desktop(),
1285 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1286 tr("SMESH_BUT_OK"));
1290 case 414: // Revolution
1292 if(checkLock(aStudy)) break;
1294 EmitSignalDeactivateDialog();
1295 new SMESHGUI_RevolutionDlg( this );
1298 SUIT_MessageBox::warn1(desktop(),
1299 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1300 tr("SMESH_BUT_OK"));
1304 case 415: // Pattern mapping
1306 if ( checkLock( aStudy ) )
1310 EmitSignalDeactivateDialog();
1311 new SMESHGUI_MeshPatternDlg( this );
1314 SUIT_MessageBox::warn1(desktop(),
1315 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1316 tr("SMESH_BUT_OK"));
1320 case 416: // Extrusion along a path
1322 if (checkLock(aStudy)) break;
1324 EmitSignalDeactivateDialog();
1325 new SMESHGUI_ExtrusionAlongPathDlg( this );
1327 SUIT_MessageBox::warn1(desktop(),
1328 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1329 tr("SMESH_BUT_OK"));
1333 case 801: // CREATE GROUP
1337 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1338 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1342 if(checkLock(aStudy)) break;
1343 EmitSignalDeactivateDialog();
1344 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1346 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1347 SALOME_ListIO selected;
1349 aSel->selectedObjects( selected );
1351 int nbSel = selected.Extent();
1353 // check if mesh is selected
1354 aMesh = SMESH::GetMeshByIO( selected.First() );
1356 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1361 case 802: // CONSTRUCT GROUP
1365 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1366 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1370 if(checkLock(aStudy)) break;
1371 EmitSignalDeactivateDialog();
1373 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1374 SALOME_ListIO selected;
1376 aSel->selectedObjects( selected );
1378 int nbSel = selected.Extent();
1380 // check if submesh is selected
1381 Handle(SALOME_InteractiveObject) IObject = selected.First();
1382 if (IObject->hasEntry()) {
1383 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1385 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1386 if (!aSubMesh->_is_nil()) {
1388 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1389 // get submesh elements list by types
1390 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1391 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1392 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1393 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1394 // create group for each type o elements
1395 QString aName = IObject->getName();
1396 if (aNodes->length() > 0) {
1397 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1398 aGroup->Add(aNodes.inout());
1400 if (aEdges->length() > 0) {
1401 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1402 aGroup->Add(aEdges.inout());
1404 if (aFaces->length() > 0) {
1405 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1406 aGroup->Add(aFaces.inout());
1408 if (aVolumes->length() > 0) {
1409 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1410 aGroup->Add(aVolumes.inout());
1414 }catch(const SALOME::SALOME_Exception & S_ex){
1415 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1424 case 803: // EDIT GROUP
1428 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1429 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1433 if(checkLock(aStudy)) break;
1434 EmitSignalDeactivateDialog();
1436 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1437 SALOME_ListIO selected;
1439 aSel->selectedObjects( selected );
1441 SALOME_ListIteratorOfListIO It (selected);
1442 int nbSelectedGroups = 0;
1443 for ( ; It.More(); It.Next() )
1445 SMESH::SMESH_Group_var aGroup =
1446 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1447 if (!aGroup->_is_nil()) {
1449 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1453 if (nbSelectedGroups == 0)
1455 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1461 case 804: // Add elements to group
1463 if(checkLock(aStudy)) break;
1464 if (myState == 800) {
1465 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1466 if (aDlg) aDlg->onAdd();
1471 case 805: // Remove elements from group
1473 if(checkLock(aStudy)) break;
1474 if (myState == 800) {
1475 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1476 if (aDlg) aDlg->onRemove();
1481 case 810: // Union Groups
1482 case 811: // Intersect groups
1483 case 812: // Cut groups
1485 if( !checkLock( aStudy ) )
1486 startOperation( theCommandID );
1490 case 813: // Delete groups with their contents
1494 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1495 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1499 if ( checkLock( aStudy ) )
1502 EmitSignalDeactivateDialog();
1504 new SMESHGUI_DeleteGroupDlg( this );
1508 case 900: // MESH INFOS
1510 EmitSignalDeactivateDialog();
1511 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1512 SALOME_ListIO selected;
1514 aSel->selectedObjects( selected );
1516 if ( selected.Extent() > 1 ) { // a dlg for each IO
1518 SALOME_ListIteratorOfListIO It (selected);
1519 for ( ; It.More(); It.Next() ) {
1520 IOs.Clear(); IOs.Append( It.Value() );
1521 aSel->setSelectedObjects( IOs );
1522 new SMESHGUI_MeshInfosDlg(this, "", false);
1524 // restore selection
1525 aSel->setSelectedObjects( selected );
1528 new SMESHGUI_MeshInfosDlg(this, "", false);
1529 startOperation( 900 );
1533 case 902: // STANDARD MESH INFOS
1535 /* EmitSignalDeactivateDialog();
1536 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1537 SALOME_ListIO selected;
1539 aSel->selectedObjects( selected );
1541 if ( selected.Extent() > 1 ) { // a dlg for each IO
1543 SALOME_ListIteratorOfListIO It (selected);
1544 for ( ; It.More(); It.Next() ) {
1546 IOs.Append( It.Value() );
1547 aSel->setSelectedObjects( IOs );
1548 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1550 // restore selection
1551 aSel->setSelectedObjects( selected );
1554 new SMESHGUI_StandardMeshInfosDlg( this, "", false);*/
1555 startOperation( 902 );
1559 case 1001: // AUTOMATIC UPDATE PREFERENCES
1561 // if (act->isOn()) {
1562 // mgr->setValue( "SMESH", "AutomaticUpdate", true );
1563 // myAutomaticUpdate = true;
1566 // mgr->setValue( "SMESH", "AutomaticUpdate", false );
1567 // myAutomaticUpdate = false;
1572 case 1003: // MESH PREFERENCES
1574 ::SetDisplaySettings();
1580 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( this );
1586 ( new SMESHGUI_PrecisionDlg( this ) )->exec();
1593 mgr->setValue( "SMESH", "DispayEntity", true );
1596 mgr->setValue( "SMESH", "DispayEntity", false );
1602 SMESHGUI_Preferences_SelectionDlg* aDlg =
1603 new SMESHGUI_Preferences_SelectionDlg( this );
1605 QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
1606 aDlg->SetColor(1, aColor);
1608 aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow );
1609 aDlg->SetColor(2, aColor);
1611 aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white );
1612 aDlg->SetColor(3, aColor);
1614 aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) );
1615 aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) );
1616 aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) );
1617 aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) );
1620 QColor aPreColor = aDlg->GetColor(1),
1621 aSelColor = aDlg->GetColor(2),
1622 aHiColor = aDlg->GetColor(3);
1623 int aPreWidth = aDlg->GetWidth(1),
1624 aSelWidth = aDlg->GetWidth(2);
1625 double aTolNodes = aDlg->GetPrecision(1),
1626 aTolItems = aDlg->GetPrecision(2);
1628 mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor );
1629 mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor );
1630 mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor );
1632 mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth );
1633 mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth );
1634 mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes );
1635 mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems );
1637 // update current study settings
1638 SMESH::UpdateSelectionProp( this );
1641 // update VTK viewer properties
1642 SVTK_RenderWindowInteractor* anInteractor =
1643 dynamic_cast<SVTK_RenderWindowInteractor*>( vtkwnd->getRWInteractor() );
1645 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1646 aSelColor.blue()/255., aSelWidth);
1647 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1648 SVTK_InteractorStyle* aStyle =
1649 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
1652 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1653 aPreColor.blue()/255., aPreWidth);
1656 vtkRenderer* aRenderer = vtkwnd->getRenderer();
1657 vtkActorCollection *aCollection = aRenderer->GetActors();
1658 aCollection->InitTraversal();
1659 while(vtkActor *anAct = aCollection->GetNextActor()){
1660 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1661 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1662 aHiColor.blue()/255.);
1663 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1664 aPreColor.blue()/255.);
1673 case 1100: // EDIT HYPOTHESIS
1675 if(checkLock(aStudy)) break;
1677 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1678 SALOME_ListIO selected;
1680 aSel->selectedObjects( selected );
1682 int nbSel = selected.Extent();
1685 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1687 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1688 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1689 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1690 if ( !Hyp->_is_nil() )
1692 char* sName = Hyp->GetName();
1693 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1696 aCreator->EditHypothesis(Hyp);
1704 updateObjBrowser( true );
1708 case 1101: // RENAME
1710 if ( checkLock( aStudy ) )
1713 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1714 SALOME_ListIO selected;
1716 aSel->selectedObjects( selected );
1718 SALOME_ListIteratorOfListIO It( selected );
1719 for ( ; It.More(); It.Next() )
1721 Handle(SALOME_InteractiveObject) IObject = It.Value();
1722 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1723 _PTR(GenericAttribute) anAttr;
1724 _PTR(AttributeName) aName;
1727 if ( obj->FindAttribute(anAttr, "AttributeName") )
1730 QString newName = QString(aName->Value().c_str());
1731 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1732 if ( !newName.isEmpty() )
1734 //old source: aStudy->renameIObject( IObject, newName );
1735 aName->SetValue( newName.latin1() );
1737 // if current object is group update group's name
1738 SMESH::SMESH_GroupBase_var aGroup =
1739 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1740 if (!aGroup->_is_nil() )
1741 aGroup->SetName( newName.latin1() );
1751 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1753 if(checkLock(aStudy)) break;
1754 SUIT_OverrideCursor wc;
1756 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1757 SALOME_ListIO selected;
1759 aSel->selectedObjects( selected );
1761 SALOME_ListIteratorOfListIO It(selected);
1762 for (int i = 0; It.More(); It.Next(), i++) {
1763 Handle(SALOME_InteractiveObject) IObject = It.Value();
1764 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1767 aSel->setSelectedObjects( l1 );
1772 case 401: // GEOM::EDGE
1773 case 4021: // TRIANGLE
1775 case 4023: // POLYGON
1779 if(checkLock(aStudy)) break;
1780 startOperation( theCommandID );
1782 EmitSignalDeactivateDialog();
1783 SMDSAbs_ElementType type = SMDSAbs_Edge;
1785 switch (theCommandID) {
1786 case 4021: // TRIANGLE
1787 type = SMDSAbs_Face; nbNodes = 3; break;
1789 type = SMDSAbs_Face; nbNodes = 4; break;
1791 type = SMDSAbs_Volume; nbNodes = 4; break;
1792 case 4023: // POLYGON
1793 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1795 type = SMDSAbs_Volume; nbNodes = 8; break;
1796 case 4033: // POLYHEDRE
1797 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1800 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1803 SUIT_MessageBox::warn1(desktop(),
1804 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1805 tr("SMESH_BUT_OK"));
1809 case 4033: // POLYHEDRON
1811 if(checkLock(aStudy)) break;
1813 EmitSignalDeactivateDialog();
1814 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1817 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1818 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1819 tr("SMESH_BUT_OK"));
1823 case 4041: // REMOVES NODES
1825 if(checkLock(aStudy)) break;
1826 startOperation( 4041 );
1828 EmitSignalDeactivateDialog();
1829 new SMESHGUI_RemoveNodesDlg(this);
1832 SUIT_MessageBox::warn1(desktop(),
1833 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1834 tr("SMESH_BUT_OK"));
1838 case 4042: // REMOVES ELEMENTS
1840 if(checkLock(aStudy)) break;
1841 startOperation( 4042 );
1843 EmitSignalDeactivateDialog();
1844 new SMESHGUI_RemoveElementsDlg(this);
1848 SUIT_MessageBox::warn1(desktop(),
1849 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1850 tr("SMESH_BUT_OK"));
1854 case 4051: // RENUMBERING NODES
1856 if(checkLock(aStudy)) break;
1857 startOperation( 4051 );
1859 EmitSignalDeactivateDialog();
1860 new SMESHGUI_RenumberingDlg( this, "", 0);
1864 SUIT_MessageBox::warn1(desktop(),
1865 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1866 tr("SMESH_BUT_OK"));
1870 case 4052: // RENUMBERING ELEMENTS
1872 if(checkLock(aStudy)) break;
1873 startOperation( 4052 );
1875 EmitSignalDeactivateDialog();
1876 new SMESHGUI_RenumberingDlg( this, "", 1);
1880 SUIT_MessageBox::warn1(desktop(),
1881 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1882 tr("SMESH_BUT_OK"));
1886 case 4061: // TRANSLATION
1888 if(checkLock(aStudy)) break;
1890 EmitSignalDeactivateDialog();
1891 new SMESHGUI_TranslationDlg( this );
1894 SUIT_MessageBox::warn1(desktop(),
1895 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1896 tr("SMESH_BUT_OK"));
1900 case 4062: // ROTATION
1902 if(checkLock(aStudy)) break;
1904 EmitSignalDeactivateDialog();
1905 new SMESHGUI_RotationDlg( this );
1908 SUIT_MessageBox::warn1(desktop(),
1909 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1910 tr("SMESH_BUT_OK"));
1914 case 4063: // SYMMETRY
1916 if(checkLock(aStudy)) break;
1918 EmitSignalDeactivateDialog();
1919 new SMESHGUI_SymmetryDlg( this );
1922 SUIT_MessageBox::warn1(desktop(),
1923 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1924 tr("SMESH_BUT_OK"));
1928 case 4064: // SEWING
1930 if(checkLock(aStudy)) break;
1932 EmitSignalDeactivateDialog();
1933 new SMESHGUI_SewingDlg( this );
1936 SUIT_MessageBox::warn1(desktop(),
1937 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1938 tr("SMESH_BUT_OK"));
1942 case 4065: // MERGE NODES
1944 if(checkLock(aStudy)) break;
1946 EmitSignalDeactivateDialog();
1947 new SMESHGUI_MergeNodesDlg( this );
1950 SUIT_MessageBox::warn1(desktop(),
1951 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1952 tr("SMESH_BUT_OK"));
1958 case 5000: // HYPOTHESIS
1960 if(checkLock(aStudy)) break;
1961 EmitSignalDeactivateDialog();
1962 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
1967 if(checkLock(aStudy)) break;
1968 EmitSignalDeactivateDialog();
1969 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
1973 case 5105: // Library of selection filters
1975 static QValueList<int> aTypes;
1976 if ( aTypes.isEmpty() )
1978 aTypes.append( SMESH::NODE );
1979 aTypes.append( SMESH::EDGE );
1980 aTypes.append( SMESH::FACE );
1981 aTypes.append( SMESH::VOLUME );
1983 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
1987 case 6017: // CONTROLS
2002 SalomeApp_SelectionMgr* mgr = selectionMgr();
2003 SALOME_ListIO selected; mgr->selectedObjects( selected );
2005 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2006 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2008 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2009 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2010 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2011 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2012 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2013 ::Control( theCommandID );
2018 SUIT_MessageBox::warn1(desktop(),
2019 tr( "SMESH_WRN_WARNING" ),
2020 tr( "SMESH_BAD_SELECTION" ),
2021 tr( "SMESH_BUT_OK" ) );
2025 SUIT_MessageBox::warn1(desktop(),
2026 tr( "SMESH_WRN_WARNING" ),
2027 tr( "NOT_A_VTK_VIEWER" ),
2028 tr( "SMESH_BUT_OK" ) );
2033 SalomeApp_SelectionMgr* mgr = selectionMgr();
2034 SALOME_ListIO selected; mgr->selectedObjects( selected );
2036 if (selected.Extent() == 1) {
2037 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2038 if(anIObject->hasEntry())
2039 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2040 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2047 SalomeApp_SelectionMgr* mgr = selectionMgr();
2048 SALOME_ListIO selected; mgr->selectedObjects( selected );
2050 if (selected.Extent() == 1) {
2051 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2052 if(anIObject->hasEntry())
2053 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2054 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2059 case 10001: // DISPLAY MODE PREFERENCE
2063 action( 10002 )->setOn( false );
2064 action( 10004 )->setOn( false );
2065 action( 10003 )->setOn( true );
2066 mgr->setValue( "SMESH", "DisplayMode", "Wireframe");
2072 action( 10001 )->setOn( false );
2073 action( 10004 )->setOn( false );
2074 action( 10003 )->setOn( true );
2075 mgr->setValue( "SMESH", "DisplayMode", "Shading");
2080 mgr->setValue( "SMESH", "Shrink", act->isOn() );
2086 action( 10001 )->setOn( false );
2087 action( 10002 )->setOn( false );
2088 action( 10003 )->setOn( false );
2089 mgr->setValue( "SMESH", "DisplayMode", "Nodes" );
2095 //updateObjBrowser();
2099 //=============================================================================
2103 //=============================================================================
2104 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2109 //=============================================================================
2113 //=============================================================================
2114 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2119 //=============================================================================
2123 //=============================================================================
2124 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2129 //=============================================================================
2133 //=============================================================================
2134 bool SMESHGUI::SetSettings(SUIT_Desktop* parent)
2136 SMESHGUI::GetSMESHGUI();
2138 SUIT_ResourceMgr* mgr = resourceMgr();
2143 QString DisplayMode = "Shading";
2144 if ( mgr->hasValue("SMESH","DisplayMode") )
2145 DisplayMode = mgr->stringValue("SMESH","DisplayMode");
2147 mgr->setValue("SMESH","DisplayMode", "Shading");
2149 bool Shrink = false;
2150 if ( mgr->hasValue("SMESH","Shrink") )
2151 Shrink = mgr->stringValue("SMESH","Shrink") == "yes";
2153 if (DisplayMode == "Wireframe") {
2155 action( 10004 )->setOn( false );
2156 action( 10002 )->setOn( false );
2157 action( 10001 )->setOn( true );
2158 action( 10003 )->setOn( true );
2160 else if (DisplayMode == "Nodes") {
2162 action( 10004 )->setOn( true );
2163 action( 10002 )->setOn( false );
2164 action( 10001 )->setOn( false );
2165 action( 10003 )->setOn( false );
2168 // default is shading
2169 action( 10004 )->setOn( false );
2170 action( 10002 )->setOn( true );
2171 action( 10001 )->setOn( false );
2172 action( 10003 )->setOn( true );
2175 action( 10003 )->setOn( Shrink );
2178 // if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) {
2179 // action( 1001 )->setOn( true );
2180 // myAutomaticUpdate = true;
2183 // action( 1001 )->setOn( false );
2184 // myAutomaticUpdate = false;
2187 if ( mgr->booleanValue( "SMESH","DispayEntity", false ) )
2188 action( 10071 )->setOn( true );
2190 action( 10071 )->setOn( false );
2193 SMESH::UpdateSelectionProp( this );
2196 action( 111 )->setEnabled( false ); // IMPORT DAT
2198 //action( 112 )->setEnabled( false );
2199 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2204 //=============================================================================
2205 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2206 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2208 //=============================================================================
2209 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2210 SUIT_ViewWindow* wnd )
2212 if(theIO->hasEntry()){
2213 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2214 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2218 //=======================================================================
2219 // function : createSMESHAction
2221 //=======================================================================
2222 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2225 QWidget* parent = application()->desktop();
2226 SUIT_ResourceMgr* resMgr = resourceMgr();
2228 if ( icon_id.length() )
2229 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2231 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2232 if ( !pix.isNull() )
2233 icon = QIconSet( pix );
2235 QString tooltip = tr( QString( "TOP_" )+po_id ),
2236 menu = tr( QString( "MEN_" )+po_id ),
2237 status_bar = tr( QString( "STB_" )+po_id );
2239 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2242 //=======================================================================
2243 // function : createPopupItem
2245 //=======================================================================
2246 void SMESHGUI::createPopupItem( const int id,
2247 const QString& clients,
2248 const QString& types,
2249 const QString& theRule,
2254 parentId = popupMgr()->actionId( action( pId ) );
2256 // if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2257 popupMgr()->insert( action( id ), parentId, 0 );
2259 QChar lc = QtxPopupMgr::Selection::defEquality();
2260 QString rule = "(%1) and (%2) and (%3)";
2261 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2262 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2263 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2266 bool cont = myRules.contains( id );
2268 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2270 popupMgr()->setRule( action( id ), rule, true );
2271 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2274 //=======================================================================
2275 // function : initialize
2277 //=======================================================================
2278 void SMESHGUI::initialize( CAM_Application* app )
2280 SalomeApp_Module::initialize( app );
2282 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2284 /* Automatic Update flag */
2285 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2287 // ----- create actions --------------
2289 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2290 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2291 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2292 createSMESHAction( 114, "NUM" );
2293 createSMESHAction( 121, "DAT" );
2294 createSMESHAction( 122, "MED" );
2295 createSMESHAction( 123, "UNV" );
2296 createSMESHAction( 124, "EXPORT_DAT" );
2297 createSMESHAction( 125, "EXPORT_MED" );
2298 createSMESHAction( 126, "EXPORT_UNV" );
2299 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2300 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2301 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2302 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2303 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2304 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2305 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2306 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2307 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2308 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2309 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2310 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2311 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2312 createSMESHAction( 804, "ADD" );
2313 createSMESHAction( 805, "REMOVE" );
2314 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2315 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2316 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2317 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2318 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2319 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2320 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2321 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2322 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2323 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2324 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2325 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2326 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2327 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2328 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2329 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2330 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2331 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2332 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2333 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2334 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2335 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2336 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2337 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2338 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2339 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2340 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2341 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2342 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2343 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2344 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2345 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2346 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2347 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2348 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2349 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2350 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2351 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2352 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2353 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2354 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2355 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2356 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2357 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2358 createSMESHAction( 415, "MAP", "ICON_MAP" );
2359 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2360 createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true );
2361 createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true );
2362 createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true );
2363 createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true );
2364 createSMESHAction( 1001, "AUTO_UPD", "", 0, true );
2365 createSMESHAction( 1003, "COLORS" );
2366 createSMESHAction( 1005, "SCALAR_BAR" );
2367 createSMESHAction( 1006, "SELECTION" );
2368 createSMESHAction( 10070, "PRECISION", "", 0, true );
2369 createSMESHAction( 10071, "DISP_ENT", "", 0, true );
2370 createSMESHAction( 200, "RESET" );
2371 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2372 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2373 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2374 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2375 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2376 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2377 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2378 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2379 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2380 createSMESHAction( 220, "ALL" );
2381 createSMESHAction( 1100, "EDIT_HYPO" );
2382 createSMESHAction( 1101, "RENAME" );
2383 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2384 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2385 createSMESHAction( 1131, "DISPMODE" );
2386 createSMESHAction( 1132, "COLORS" );
2387 createSMESHAction( 1133, "TRANSP" );
2388 createSMESHAction( 1134, "CLIP" );
2389 createSMESHAction( 1135, "DISP_ENT" );
2390 createSMESHAction( 2000, "CTRL" );
2392 createSMESHAction( 300, "ERASE" );
2393 createSMESHAction( 301, "DISPLAY" );
2394 createSMESHAction( 302, "DISPLAY_ONLY" );
2395 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2397 // ----- create menu --------------
2398 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2399 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2400 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2401 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2402 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2403 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2404 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2405 prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ),
2406 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2408 createMenu( separator(), fileId );
2410 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2411 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2413 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2414 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2415 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2416 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
2418 meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ),
2420 dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ),
2421 qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 );
2423 createMenu( 111, importId, -1 );
2424 createMenu( 112, importId, -1 );
2425 createMenu( 113, importId, -1 );
2427 createMenu( 121, exportId, -1 );
2428 createMenu( 122, exportId, -1 );
2429 createMenu( 123, exportId, -1 );
2431 createMenu( separator(), fileId, 10 );
2433 createMenu( 33, editId, -1 );
2435 createMenu( 5105, toolsId, -1 );
2437 createMenu( 5000, hypoId, -1 );
2438 createMenu( 5010, hypoId, -1 );
2440 createMenu( 703, meshId, -1 );
2441 createMenu( 702, meshId, -1 );
2442 createMenu( 704, meshId, -1 );
2443 createMenu( separator(), meshId, -1 );
2444 createMenu( 701, meshId, -1 );
2445 createMenu( separator(), meshId, -1 );
2446 createMenu( 801, meshId, -1 );
2447 createMenu( 802, meshId, -1 );
2448 createMenu( 803, meshId, -1 );
2449 createMenu( separator(), meshId, -1 );
2450 createMenu( 810, meshId, -1 );
2451 createMenu( 811, meshId, -1 );
2452 createMenu( 812, meshId, -1 );
2453 createMenu( separator(), meshId, -1 );
2454 createMenu( 813, meshId, -1 );
2455 createMenu( separator(), meshId, -1 );
2456 createMenu( 900, meshId, -1 );
2457 createMenu( 902, meshId, -1 );
2458 createMenu( separator(), meshId, -1 );
2460 createMenu( 6003, ctrlId, -1 );
2461 createMenu( 6001, ctrlId, -1 );
2462 createMenu( 6004, ctrlId, -1 );
2463 createMenu( separator(), ctrlId, -1 );
2464 createMenu( 6002, ctrlId, -1 );
2465 createMenu( 6018, ctrlId, -1 );
2466 createMenu( 6019, ctrlId, -1 );
2467 createMenu( 6011, ctrlId, -1 );
2468 createMenu( 6012, ctrlId, -1 );
2469 createMenu( 6013, ctrlId, -1 );
2470 createMenu( 6014, ctrlId, -1 );
2471 createMenu( 6015, ctrlId, -1 );
2472 createMenu( 6016, ctrlId, -1 );
2473 createMenu( separator(), ctrlId, -1 );
2474 createMenu( 6017, ctrlId, -1 );
2475 createMenu( separator(), ctrlId, -1 );
2477 createMenu( 400, addId, -1 );
2478 createMenu( 401, addId, -1 );
2479 createMenu( 4021, addId, -1 );
2480 createMenu( 4022, addId, -1 );
2481 createMenu( 4023, addId, -1 );
2482 createMenu( 4031, addId, -1 );
2483 createMenu( 4032, addId, -1 );
2484 createMenu( 4033, addId, -1 );
2486 createMenu( 4041, removeId, -1 );
2487 createMenu( 4042, removeId, -1 );
2489 createMenu( 4051, renumId, -1 );
2490 createMenu( 4052, renumId, -1 );
2492 createMenu( 4061, transfId, -1 );
2493 createMenu( 4062, transfId, -1 );
2494 createMenu( 4063, transfId, -1 );
2495 createMenu( 4064, transfId, -1 );
2496 createMenu( 4065, transfId, -1 );
2498 createMenu( 406, modifyId, -1 );
2499 createMenu( 407, modifyId, -1 );
2500 createMenu( 408, modifyId, -1 );
2501 createMenu( 409, modifyId, -1 );
2502 createMenu( 410, modifyId, -1 );
2503 createMenu( 411, modifyId, -1 );
2504 createMenu( 412, modifyId, -1 );
2505 createMenu( 413, modifyId, -1 );
2506 createMenu( 416, modifyId, -1 );
2507 createMenu( 414, modifyId, -1 );
2508 createMenu( 415, modifyId, -1 );
2510 createMenu( 10001, dispModeId, -1 );
2511 createMenu( 10002, dispModeId, -1 );
2512 createMenu( 10004, dispModeId, -1 );
2513 createMenu( 10003, dispModeId, -1 );
2515 createMenu( 1001, prefId, -1 );
2516 createMenu( separator(), prefId, -1 );
2517 createMenu( 1003, prefId, -1 );
2518 createMenu( separator(), prefId, -1 );
2519 createMenu( 1005, prefId, -1 );
2520 createMenu( separator(), prefId, -1 );
2521 createMenu( 1006, prefId, -1 );
2522 createMenu( separator(), prefId, -1 );
2524 createMenu( 10070, qualityId, -1 );
2525 createMenu( 10071, qualityId, -1 );
2527 createMenu( separator(), prefId, -1 );
2529 createMenu( 214, viewId, -1 );
2531 // ----- create toolbars --------------
2532 int meshTb = createTool( tr( "TB_MESH" ) ),
2533 hypoTb = createTool( tr( "TB_HYPO" ) ),
2534 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2535 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2536 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2537 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2539 createTool( 703, meshTb );
2540 createTool( 702, meshTb );
2541 createTool( 704, meshTb );
2542 createTool( separator(), meshTb );
2543 createTool( 701, meshTb );
2544 createTool( separator(), meshTb );
2545 createTool( 801, meshTb );
2546 createTool( 802, meshTb );
2547 createTool( 803, meshTb );
2548 createTool( separator(), meshTb );
2549 createTool( 900, meshTb );
2550 createTool( 902, meshTb );
2551 createTool( separator(), meshTb );
2553 createTool( 5000, hypoTb );
2554 createTool( 5010, hypoTb );
2556 createTool( 6001, ctrlTb );
2557 createTool( 6003, ctrlTb );
2558 createTool( 6004, ctrlTb );
2559 createTool( separator(), ctrlTb );
2560 createTool( 6002, ctrlTb );
2561 createTool( 6018, ctrlTb );
2562 createTool( 6019, ctrlTb );
2563 createTool( 6011, ctrlTb );
2564 createTool( 6012, ctrlTb );
2565 createTool( 6013, ctrlTb );
2566 createTool( 6014, ctrlTb );
2567 createTool( 6015, ctrlTb );
2568 createTool( 6016, ctrlTb );
2569 createTool( separator(), ctrlTb );
2570 createTool( 6017, ctrlTb );
2571 createTool( separator(), ctrlTb );
2573 createTool( 400, addRemTb );
2574 createTool( 401, addRemTb );
2575 createTool( 4021, addRemTb );
2576 createTool( 4022, addRemTb );
2577 createTool( 4023, addRemTb );
2578 createTool( 4031, addRemTb );
2579 createTool( 4032, addRemTb );
2580 createTool( 4033, addRemTb );
2581 createTool( separator(), addRemTb );
2582 createTool( 4041, addRemTb );
2583 createTool( 4042, addRemTb );
2584 createTool( separator(), addRemTb );
2585 createTool( 4051, addRemTb );
2586 createTool( 4052, addRemTb );
2587 createTool( separator(), addRemTb );
2588 createTool( 4061, addRemTb );
2589 createTool( 4062, addRemTb );
2590 createTool( 4063, addRemTb );
2591 createTool( 4064, addRemTb );
2592 createTool( 4065, addRemTb );
2593 createTool( separator(), addRemTb );
2595 createTool( 406, modifyTb );
2596 createTool( 407, modifyTb );
2597 createTool( 408, modifyTb );
2598 createTool( 409, modifyTb );
2599 createTool( 410, modifyTb );
2600 createTool( 411, modifyTb );
2601 createTool( 412, modifyTb );
2602 createTool( 413, modifyTb );
2603 createTool( 416, modifyTb );
2604 createTool( 414, modifyTb );
2605 createTool( 415, modifyTb );
2607 createTool( 214, dispModeTb );
2611 QString OB = "'ObjectBrowser'",
2612 View = "'" + SVTK_Viewer::Type() + "'",
2614 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2615 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2616 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2617 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2618 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2619 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2620 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2621 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2622 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2623 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2625 mesh_group = mesh + " " + subMesh + " " + group,
2626 hyp_alg = hypo + " " + algo;
2628 // popup for object browser
2630 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2631 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2632 createPopupItem( 803, OB, group ); // EDIT_GROUP
2633 popupMgr()->insert( separator(), -1, 0 );
2634 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2635 createPopupItem( 214, OB, mesh_group ); // UPDATE
2636 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2637 createPopupItem( 902, OB, mesh ); // STD_INFO
2638 popupMgr()->insert( separator(), -1, 0 );
2639 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2640 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2641 popupMgr()->insert( separator(), -1, 0 );
2642 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2643 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2644 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2645 popupMgr()->insert( separator(), -1, 0 );
2646 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2647 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2648 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2649 popupMgr()->insert( separator(), -1, 0 );
2652 createPopupItem( 803, View, group ); // EDIT_GROUP
2653 createPopupItem( 804, View, elems ); // ADD
2654 createPopupItem( 805, View, elems ); // REMOVE
2655 popupMgr()->insert( separator(), -1, 0 );
2656 createPopupItem( 214, View, mesh_group ); // UPDATE
2657 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2658 createPopupItem( 902, View, mesh ); // STD_INFO
2659 popupMgr()->insert( separator(), -1, 0 );
2663 isInvisible("not( isVisible )"),
2664 isEmpty("numberOfNodes = 0"),
2665 isNotEmpty("numberOfNodes <> 0"),
2667 // has nodes, edges, etc in VISIBLE! actor
2668 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2669 hasElems("(count( elemTypes ) > 0)"),
2670 hasDifferentElems("(count( elemTypes ) > 1)"),
2671 hasEdges("({'Edge'} in elemTypes)"),
2672 hasFaces("({'Face'} in elemTypes)"),
2673 hasVolumes("({'Volume'} in elemTypes)");
2675 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2676 QString lc = QtxPopupMgr::Selection::defEquality();
2677 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2678 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2679 QString aMeshInVTK = aClient + "&&" + aType;// + "&&" + aSelCount;
2681 //-------------------------------------------------
2683 //-------------------------------------------------
2684 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2686 popupMgr()->insert( action( 9010 ), anId, -1 );
2687 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true );
2688 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2690 popupMgr()->insert( action( 9011 ), anId, -1 );
2691 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true );
2692 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2694 popupMgr()->insert( separator(), -1, -1 );
2696 //-------------------------------------------------
2698 //-------------------------------------------------
2699 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2701 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2702 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2703 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2705 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2706 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2707 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2709 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2710 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2711 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2713 popupMgr()->insert( separator(), anId, -1 );
2715 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2716 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2717 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2719 //-------------------------------------------------
2721 //-------------------------------------------------
2722 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2724 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2726 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2727 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true );
2728 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2730 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2731 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true );
2732 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2734 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2735 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true );
2736 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2738 popupMgr()->insert( separator(), anId, -1 );
2740 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2741 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true );
2743 //-------------------------------------------------
2745 //-------------------------------------------------
2746 popupMgr()->insert( action( 1132 ), -1, -1 );
2747 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2749 //-------------------------------------------------
2751 //-------------------------------------------------
2752 popupMgr()->insert( action( 1133 ), -1, -1 );
2753 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2755 //-------------------------------------------------
2757 //-------------------------------------------------
2758 popupMgr()->insert( action( 1134 ), -1, -1 );
2759 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2761 popupMgr()->insert( separator(), -1, -1 );
2763 //-------------------------------------------------
2765 //-------------------------------------------------
2767 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2768 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2769 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2771 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2773 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2774 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2776 popupMgr()->insert( separator(), anId, -1 );
2778 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2779 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2780 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2782 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2783 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2784 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2786 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2787 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2788 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2790 popupMgr()->insert( separator(), anId, -1 );
2792 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2793 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2794 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2796 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2797 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2798 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2800 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2801 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2802 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2804 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2805 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2806 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2808 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2809 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2810 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2812 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2813 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2814 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2816 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2817 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2818 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2820 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2821 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2822 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2824 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2825 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2826 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2828 popupMgr()->insert( separator(), anId, -1 );
2830 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2831 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2832 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2834 popupMgr()->insert( separator(), anId, -1 );
2836 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2837 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2839 popupMgr()->insert( separator(), -1, -1 );
2841 //-------------------------------------------------
2843 //-------------------------------------------------
2844 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2845 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
2846 QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
2847 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2848 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
2850 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2851 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
2853 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2854 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
2856 popupMgr()->insert( separator(), -1, -1 );
2858 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
2859 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
2862 bool SMESHGUI::activateModule( SUIT_Study* study )
2864 bool res = SalomeApp_Module::activateModule( study );
2866 setMenuShown( true );
2867 setToolShown( true );
2868 SetSettings( desktop() );
2873 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2875 setMenuShown( false );
2876 setToolShown( false );
2878 EmitSignalCloseAllDialogs();
2880 return SalomeApp_Module::deactivateModule( study );
2883 void SMESHGUI::OnGUIEvent()
2885 const QObject* obj = sender();
2886 if ( !obj || !obj->inherits( "QAction" ) )
2888 int id = actionId((QAction*)obj);
2893 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2895 if ( CORBA::is_nil( myComponentSMESH ) )
2897 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2898 return aGUI.myComponentSMESH;
2900 return myComponentSMESH;
2903 QString SMESHGUI::engineIOR() const
2905 CORBA::ORB_var anORB = getApp()->orb();
2906 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2910 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2912 SMESHGUI_Selection sel;
2913 sel.init( client, selectionMgr() );
2914 popupMgr()->updatePopup( menu, &sel );
2917 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2919 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2920 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2923 void SMESHGUI::viewManagers( QStringList& list ) const
2925 list.append( SVTK_Viewer::Type() );
2928 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
2930 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
2931 SMESH::UpdateSelectionProp( this );
2934 void SMESHGUI::createPreferences()
2936 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2938 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2939 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "display_entity" );
2940 addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "auto_update" );
2942 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2943 setPreferenceProperty( precGroup, "columns", 1 );
2945 addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool );
2946 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2948 setPreferenceProperty( prec, "min", 0 );
2949 setPreferenceProperty( prec, "max", 16 );
2951 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2952 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2954 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
2955 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
2957 setPreferenceProperty( nodeSz, "min", 1 );
2958 setPreferenceProperty( nodeSz, "max", 5 );
2960 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2962 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
2963 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
2964 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
2965 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
2967 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
2968 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2970 setPreferenceProperty( elemW, "min", 1 );
2971 setPreferenceProperty( elemW, "max", 5 );
2973 setPreferenceProperty( shrink, "min", 0 );
2974 setPreferenceProperty( shrink, "max", 100 );
2976 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2978 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2980 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
2981 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
2982 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
2984 setPreferenceProperty( selW, "min", 1 );
2985 setPreferenceProperty( selW, "max", 5 );
2987 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2989 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
2990 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2992 setPreferenceProperty( preW, "min", 1 );
2993 setPreferenceProperty( preW, "max", 5 );
2995 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2997 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
2998 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
3001 void SMESHGUI::preferencesChanged( const QString&, const QString& )
3005 //=======================================================================
3006 // function : onOperationCommited
3007 // purpose : SLOT called when operation commited. Set default selection mode
3008 //=======================================================================
3009 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3011 SVTK_ViewWindow* vtkWnd =
3012 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3014 vtkWnd->SetSelectionMode( ActorSelection );
3017 //=======================================================================
3018 // function : onOperationAborted
3019 // purpose : SLOT called when operation commited. Set default selection mode
3020 //=======================================================================
3021 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3023 SVTK_ViewWindow* vtkWnd =
3024 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3026 vtkWnd->SetSelectionMode( ActorSelection );
3029 //=======================================================================
3030 // function : getOperation
3031 // purpose : Get operation corresponding to the given Id
3032 //=======================================================================
3033 SalomeApp_Operation* SMESHGUI::getOperation( const int theId )
3035 if ( myOperations.contains( theId ) )
3036 return myOperations[ theId ];
3039 SalomeApp_Operation* anOp = 0;
3049 anOp->setModule( this );
3050 connect( anOp, SIGNAL( aborted( SUIT_Operation* ) ),
3051 this, SLOT( onOperationAborted( SUIT_Operation* ) ) );
3052 connect( anOp, SIGNAL( commited( SUIT_Operation* ) ),
3053 this, SLOT( onOperationCommited( SUIT_Operation* ) ) );
3054 myOperations[ theId ] = anOp;
3061 //=======================================================================
3062 // function : update
3063 // purpose : Update something
3064 //=======================================================================
3065 void SMESHGUI::update( const int flags )
3067 if ( flags & UF_Viewer | flags & UF_Forced )
3068 SMESH::UpdateView();
3070 SalomeApp_Module::update( flags );
3073 //=======================================================================
3074 // function : updateControls
3075 // purpose : Update state of controls
3076 //=======================================================================
3077 void SMESHGUI::updateControls()
3082 //=======================================================================
3083 // function : updateControls
3084 // purpose : Update state of controls
3085 //=======================================================================
3086 SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
3088 SalomeApp_Operation* op = 0;
3092 op = new SMESHGUI_DeleteOp();
3096 op = new SMESHGUI_NodesOp();
3100 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Edge, 2 );
3103 case 406: // MOVE NODE
3104 op = new SMESHGUI_MoveNodesOp();
3108 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 3 );
3112 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 4 );
3116 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 5 ); // 5 - identificator for POLYGON
3120 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 4 );
3124 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 8 );
3127 case 4041: //REMOVE NODES
3128 op = new SMESHGUI_RemoveOp( false );
3131 case 4042: //REMOVE ELEMENTS
3132 op = new SMESHGUI_RemoveOp( true );
3135 case 4051: // RENUMBERING NODES
3136 op = new SMESHGUI_RenumberingOp( 0 );
3139 case 4052: // RENUMBERING ELEMENTS
3140 op = new SMESHGUI_RenumberingOp( 1 );
3144 op = new SMESHGUI_AddSubMeshOp();
3148 op = new SMESHGUI_InitMeshOp();
3152 op = new SMESHGUI_EditHypothesesOp();
3156 op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::UNION );
3160 op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::INTERSECT );
3164 op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::CUT );
3167 /* case 409: // Change orientation
3168 op = new SMESHGUI_ChangeOrientationOp();
3171 case 410: // Union of triangles
3172 op = new SMESHGUI_UnionOfTrianglesDlg();
3175 /* case 411: // Cutting of quadrangles
3176 op = new SMESHGUI_CuttingOfQuadsDlg();
3180 op = new SMESHGUI_ExtrusionOp();
3184 op = new SMESHGUI_MeshInfosOp();
3188 op = new SMESHGUI_StandardMeshInfosOp();
3192 op = new SMESHGUI_ExportMeshOp( SMESHGUI_ExportMeshOp::DAT );
3196 op = new SMESHGUI_ExportMeshOp( SMESHGUI_ExportMeshOp::MED );
3200 op = new SMESHGUI_ExportMeshOp( SMESHGUI_ExportMeshOp::UNV );
3204 op = SalomeApp_Module::createOperation( id );