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_CreateHypothesesOp.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 emit SignalDeactivateActiveDialog();
757 //=============================================================================
761 //=============================================================================
762 void SMESHGUI::EmitSignalStudyFrameChanged()
764 emit SignalStudyFrameChanged();
767 //=============================================================================
771 //=============================================================================
772 void SMESHGUI::EmitSignalCloseAllDialogs()
774 emit SignalCloseAllDialogs();
777 //=============================================================================
781 //=============================================================================
782 QDialog *SMESHGUI::GetActiveDialogBox()
784 return myActiveDialogBox;
787 //=============================================================================
791 //=============================================================================
792 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
794 myActiveDialogBox = (QDialog *) aDlg;
798 //=============================================================================
802 //=============================================================================
803 SUIT_Desktop* SMESHGUI::desktop()
805 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
807 return app->desktop();
812 //=============================================================================
816 //=============================================================================
817 SalomeApp_Study* SMESHGUI::activeStudy()
819 SUIT_Application* app = SUIT_Session::session()->activeApplication();
821 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
826 //=============================================================================
830 //=============================================================================
831 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
833 /* Here the position is on the bottom right corner - 10 */
834 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
836 SUIT_Desktop *PP = desktop();
837 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
838 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
842 //=============================================================================
846 //=============================================================================
847 static int isStudyLocked(_PTR(Study) theStudy){
848 return theStudy->GetProperties()->IsLocked();
851 static bool checkLock(_PTR(Study) theStudy) {
852 if (isStudyLocked(theStudy)) {
853 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
854 QObject::tr("WRN_WARNING"),
855 QObject::tr("WRN_STUDY_LOCKED"),
856 QObject::tr("BUT_OK") );
862 //=======================================================================
863 //function : CheckActiveStudyLocked
865 //=======================================================================
867 bool SMESHGUI::isActiveStudyLocked()
869 _PTR(Study) aStudy = activeStudy()->studyDS();
870 return checkLock( aStudy );
873 //=============================================================================
877 //=============================================================================
878 bool SMESHGUI::OnGUIEvent( int theCommandID )
880 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
884 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
885 SUIT_ResourceMgr* mgr = resourceMgr();
889 SUIT_Operation* anOp = getOperation( theCommandID );
896 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
897 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
899 QAction* act = action( theCommandID );
901 switch (theCommandID) {
903 startOperation( 33 );
910 if(checkLock(aStudy)) break;
911 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
915 case 122: // EXPORT MED
922 startOperation( theCommandID );
923 //::ExportMeshToFile(theCommandID);
927 case 200: // SCALAR BAR
929 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
930 SALOME_ListIO selected;
932 aSel->selectedObjects( selected );
934 if( selected.Extent() ) {
935 Handle(SALOME_InteractiveObject) anIO = selected.First();
936 if( anIO->hasEntry() ) {
937 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
938 anActor->SetControlMode( SMESH_Actor::eNone );
946 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
950 case 1134: // Clipping
951 case 1133: // Tranparency
952 case 1132: // Colors / Size
959 ::SetDisplayMode(theCommandID);
966 case 220: // All Entity
967 ::SetDisplayEntity(theCommandID);
972 if(checkLock(aStudy)) break;
976 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
977 aSel->setSelectedObjects( l );
983 case 302: // DISPLAY ONLY
985 SMESH::EDisplaing anAction;
986 switch(theCommandID){
987 case 300: anAction = SMESH::eErase; break;
988 case 301: anAction = SMESH::eDisplay; break;
989 case 302: anAction = SMESH::eDisplayOnly; break;
992 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
993 SALOME_ListIO selected;
995 aSel->selectedObjects( selected );
998 SALOME_ListIteratorOfListIO It(selected);
999 for (; It.More(); It.Next()) {
1000 Handle(SALOME_InteractiveObject) IOS = It.Value();
1001 if (IOS->hasEntry()) {
1002 SMESH::UpdateView(anAction,IOS->getEntry());
1007 aSel->setSelectedObjects( l1 );
1013 if(checkLock(aStudy)) break;
1014 startOperation( 400 );
1017 EmitSignalDeactivateDialog();
1019 new SMESHGUI_NodesDlg(this);
1022 SUIT_MessageBox::warn1(desktop(),
1023 tr("SMESH_WRN_WARNING"),
1024 tr("SMESH_WRN_VIEWER_VTK"),
1025 tr("SMESH_BUT_OK"));
1030 case 2151: // FILTER
1034 EmitSignalDeactivateDialog();
1035 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1040 case 406: // MOVE NODE
1044 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1045 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1049 if(checkLock(aStudy)) break;
1050 startOperation( 406 );
1051 // new SMESHGUI_MoveNodesDlg(this);
1055 case 701: // COMPUTE MESH
1057 if(checkLock(aStudy)) break;
1059 SalomeApp_SelectionMgr *Sel = selectionMgr();
1060 SALOME_ListIO selected; Sel->selectedObjects( selected );
1062 int nbSel = selected.Extent();
1067 SMESH::SMESH_Mesh_var aMesh;
1068 SMESH::SMESH_subMesh_var aSubMesh;
1069 Handle(SALOME_InteractiveObject) IObject = selected.First();
1070 if (IObject->hasEntry()){
1071 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1072 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1073 if ( aShapeObject->_is_nil() ) {
1078 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1079 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1081 if (!aMesh->_is_nil()){
1082 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1083 if (!refShapeObject->_is_nil()) {
1084 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1085 SUIT_MessageBox::warn1(desktop(),
1086 tr("SMESH_WRN_WARNING"),
1087 tr("SMESH_WRN_MISSING_PARAMETERS"),
1088 tr("SMESH_BUT_OK"));
1092 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1093 SMESH::ModifiedMesh(aMeshSObj,true);
1094 // TO Do : change icon of all submeshes
1096 SUIT_MessageBox::warn1(desktop(),
1097 tr("SMESH_WRN_WARNING"),
1098 tr("SMESH_WRN_COMPUTE_FAILED"),
1099 tr("SMESH_BUT_OK"));
1101 catch(const SALOME::SALOME_Exception & S_ex){
1102 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1105 }else if(!aSubMesh->_is_nil()){
1106 aMesh = aSubMesh->GetFather();
1107 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1108 if(!refShapeObject->_is_nil()){
1109 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1111 SUIT_MessageBox::warn1(desktop(),
1112 tr("SMESH_WRN_WARNING"),
1113 tr("SMESH_WRN_MISSING_PARAMETERS"),
1114 tr("SMESH_BUT_OK"));
1118 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1119 SMESH::ModifiedMesh(aMeshSObj,true);
1120 // TO Do : change icon of all submeshes
1122 SUIT_MessageBox::warn1(desktop(),
1123 tr("SMESH_WRN_WARNING"),
1124 tr("SMESH_WRN_COMPUTE_FAILED"),
1125 tr("SMESH_BUT_OK"));
1126 }catch(const SALOME::SALOME_Exception & S_ex){
1127 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1133 CORBA::Long anId = aStudy->StudyId();
1134 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1135 if ( automaticUpdate() && aVisualObj){
1136 aVisualObj->Update();
1137 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1139 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1141 SMESH::DisplayActor(view,anActor); //apo
1147 SUIT_MessageBox::warn1(desktop(),
1148 tr("SMESH_WRN_WARNING"),
1149 tr("SMESH_WRN_VIEWER_VTK"),
1150 tr("SMESH_BUT_OK"));
1156 case 702: // ADD SUB MESH
1158 if(checkLock(aStudy)) break;
1159 startOperation( 702 );
1161 EmitSignalDeactivateDialog();
1162 new SMESHGUI_AddSubMeshDlg( this );
1165 SUIT_MessageBox::warn1(desktop(),
1166 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1167 tr("SMESH_BUT_OK"));
1172 case 703: // INIT MESH
1174 if(checkLock(aStudy)) break;
1175 startOperation( 703 );
1179 case 704: // EDIT Hypothesis
1181 if(checkLock(aStudy)) break;
1182 startOperation( 704 );
1186 case 705: // EDIT Global Hypothesis
1188 if(checkLock(aStudy)) break;
1189 startOperation( 704 );
1193 case 706: // EDIT Local Hypothesis
1195 if(checkLock(aStudy)) break;
1196 startOperation( 704 );
1200 case 407: // DIAGONAL INVERSION
1201 case 408: // Delete diagonal
1205 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1206 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1210 if ( checkLock( aStudy ) )
1213 /*Standard_Boolean aRes;
1214 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1215 if ( aMesh->_is_nil() )
1217 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1218 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1222 EmitSignalDeactivateDialog();
1223 if ( theCommandID == 407 )
1224 startOperation( 407 );
1226 startOperation( 408 );
1229 case 409: // Change orientation
1230 case 410: // Union of triangles
1231 case 411: // Cutting of quadrangles
1235 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1236 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1240 if ( checkLock( aStudy ) )
1243 startOperation( theCommandID );
1245 /* EmitSignalDeactivateDialog();
1246 SMESHGUI_MultiEditDlg* aDlg = NULL;
1247 if ( theCommandID == 409 )
1248 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1249 else if ( theCommandID == 410 )
1250 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1252 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1255 DefineDlgPosition( aDlg, x, y );
1260 case 412: // Smoothing
1262 if(checkLock(aStudy)) break;
1264 EmitSignalDeactivateDialog();
1265 new SMESHGUI_SmoothingDlg( this );
1268 SUIT_MessageBox::warn1(desktop(),
1269 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1270 tr("SMESH_BUT_OK"));
1274 case 413: // Extrusion
1276 if( checkLock( aStudy) )
1278 startOperation( 413 );
1280 EmitSignalDeactivateDialog();
1281 new SMESHGUI_ExtrusionDlg ( this );
1283 SUIT_MessageBox::warn1(desktop(),
1284 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1285 tr("SMESH_BUT_OK"));
1289 case 414: // Revolution
1291 if(checkLock(aStudy)) break;
1293 EmitSignalDeactivateDialog();
1294 new SMESHGUI_RevolutionDlg( this );
1297 SUIT_MessageBox::warn1(desktop(),
1298 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1299 tr("SMESH_BUT_OK"));
1303 case 415: // Pattern mapping
1305 if ( checkLock( aStudy ) )
1309 EmitSignalDeactivateDialog();
1310 new SMESHGUI_MeshPatternDlg( this );
1313 SUIT_MessageBox::warn1(desktop(),
1314 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1315 tr("SMESH_BUT_OK"));
1319 case 416: // Extrusion along a path
1321 if (checkLock(aStudy)) break;
1323 EmitSignalDeactivateDialog();
1324 new SMESHGUI_ExtrusionAlongPathDlg( this );
1326 SUIT_MessageBox::warn1(desktop(),
1327 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1328 tr("SMESH_BUT_OK"));
1332 case 801: // CREATE GROUP
1336 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1337 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1341 if(checkLock(aStudy)) break;
1342 EmitSignalDeactivateDialog();
1343 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1345 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1346 SALOME_ListIO selected;
1348 aSel->selectedObjects( selected );
1350 int nbSel = selected.Extent();
1352 // check if mesh is selected
1353 aMesh = SMESH::GetMeshByIO( selected.First() );
1355 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1360 case 802: // CONSTRUCT GROUP
1364 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1365 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1369 if(checkLock(aStudy)) break;
1370 EmitSignalDeactivateDialog();
1372 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1373 SALOME_ListIO selected;
1375 aSel->selectedObjects( selected );
1377 int nbSel = selected.Extent();
1379 // check if submesh is selected
1380 Handle(SALOME_InteractiveObject) IObject = selected.First();
1381 if (IObject->hasEntry()) {
1382 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1384 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1385 if (!aSubMesh->_is_nil()) {
1387 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1388 // get submesh elements list by types
1389 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1390 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1391 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1392 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1393 // create group for each type o elements
1394 QString aName = IObject->getName();
1395 if (aNodes->length() > 0) {
1396 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1397 aGroup->Add(aNodes.inout());
1399 if (aEdges->length() > 0) {
1400 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1401 aGroup->Add(aEdges.inout());
1403 if (aFaces->length() > 0) {
1404 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1405 aGroup->Add(aFaces.inout());
1407 if (aVolumes->length() > 0) {
1408 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1409 aGroup->Add(aVolumes.inout());
1413 }catch(const SALOME::SALOME_Exception & S_ex){
1414 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1423 case 803: // EDIT GROUP
1427 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1428 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1432 if(checkLock(aStudy)) break;
1433 EmitSignalDeactivateDialog();
1435 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1436 SALOME_ListIO selected;
1438 aSel->selectedObjects( selected );
1440 SALOME_ListIteratorOfListIO It (selected);
1441 int nbSelectedGroups = 0;
1442 for ( ; It.More(); It.Next() )
1444 SMESH::SMESH_Group_var aGroup =
1445 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1446 if (!aGroup->_is_nil()) {
1448 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1452 if (nbSelectedGroups == 0)
1454 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1460 case 804: // Add elements to group
1462 if(checkLock(aStudy)) break;
1463 if (myState == 800) {
1464 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1465 if (aDlg) aDlg->onAdd();
1470 case 805: // Remove elements from group
1472 if(checkLock(aStudy)) break;
1473 if (myState == 800) {
1474 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1475 if (aDlg) aDlg->onRemove();
1480 case 810: // Union Groups
1481 case 811: // Intersect groups
1482 case 812: // Cut groups
1484 if( !checkLock( aStudy ) )
1485 startOperation( theCommandID );
1489 case 813: // Delete groups with their contents
1493 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1494 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1498 if ( checkLock( aStudy ) )
1501 EmitSignalDeactivateDialog();
1503 new SMESHGUI_DeleteGroupDlg( this );
1507 case 900: // MESH INFOS
1509 EmitSignalDeactivateDialog();
1510 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1511 SALOME_ListIO selected;
1513 aSel->selectedObjects( selected );
1515 if ( selected.Extent() > 1 ) { // a dlg for each IO
1517 SALOME_ListIteratorOfListIO It (selected);
1518 for ( ; It.More(); It.Next() ) {
1519 IOs.Clear(); IOs.Append( It.Value() );
1520 aSel->setSelectedObjects( IOs );
1521 new SMESHGUI_MeshInfosDlg(this, "", false);
1523 // restore selection
1524 aSel->setSelectedObjects( selected );
1527 new SMESHGUI_MeshInfosDlg(this, "", false);
1528 startOperation( 900 );
1532 case 902: // STANDARD MESH INFOS
1534 /* EmitSignalDeactivateDialog();
1535 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1536 SALOME_ListIO selected;
1538 aSel->selectedObjects( selected );
1540 if ( selected.Extent() > 1 ) { // a dlg for each IO
1542 SALOME_ListIteratorOfListIO It (selected);
1543 for ( ; It.More(); It.Next() ) {
1545 IOs.Append( It.Value() );
1546 aSel->setSelectedObjects( IOs );
1547 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1549 // restore selection
1550 aSel->setSelectedObjects( selected );
1553 new SMESHGUI_StandardMeshInfosDlg( this, "", false);*/
1554 startOperation( 902 );
1558 case 1001: // AUTOMATIC UPDATE PREFERENCES
1560 // if (act->isOn()) {
1561 // mgr->setValue( "SMESH", "AutomaticUpdate", true );
1562 // myAutomaticUpdate = true;
1565 // mgr->setValue( "SMESH", "AutomaticUpdate", false );
1566 // myAutomaticUpdate = false;
1571 case 1003: // MESH PREFERENCES
1573 ::SetDisplaySettings();
1579 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( this );
1585 ( new SMESHGUI_PrecisionDlg( this ) )->exec();
1592 mgr->setValue( "SMESH", "DispayEntity", true );
1595 mgr->setValue( "SMESH", "DispayEntity", false );
1601 SMESHGUI_Preferences_SelectionDlg* aDlg =
1602 new SMESHGUI_Preferences_SelectionDlg( this );
1604 QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
1605 aDlg->SetColor(1, aColor);
1607 aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow );
1608 aDlg->SetColor(2, aColor);
1610 aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white );
1611 aDlg->SetColor(3, aColor);
1613 aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) );
1614 aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) );
1615 aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) );
1616 aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) );
1619 QColor aPreColor = aDlg->GetColor(1),
1620 aSelColor = aDlg->GetColor(2),
1621 aHiColor = aDlg->GetColor(3);
1622 int aPreWidth = aDlg->GetWidth(1),
1623 aSelWidth = aDlg->GetWidth(2);
1624 double aTolNodes = aDlg->GetPrecision(1),
1625 aTolItems = aDlg->GetPrecision(2);
1627 mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor );
1628 mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor );
1629 mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor );
1631 mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth );
1632 mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth );
1633 mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes );
1634 mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems );
1636 // update current study settings
1637 SMESH::UpdateSelectionProp( this );
1640 // update VTK viewer properties
1641 SVTK_RenderWindowInteractor* anInteractor =
1642 dynamic_cast<SVTK_RenderWindowInteractor*>( vtkwnd->getRWInteractor() );
1644 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1645 aSelColor.blue()/255., aSelWidth);
1646 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1647 SVTK_InteractorStyle* aStyle =
1648 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
1651 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1652 aPreColor.blue()/255., aPreWidth);
1655 vtkRenderer* aRenderer = vtkwnd->getRenderer();
1656 vtkActorCollection *aCollection = aRenderer->GetActors();
1657 aCollection->InitTraversal();
1658 while(vtkActor *anAct = aCollection->GetNextActor()){
1659 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1660 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1661 aHiColor.blue()/255.);
1662 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1663 aPreColor.blue()/255.);
1672 case 1100: // EDIT HYPOTHESIS
1674 if(checkLock(aStudy)) break;
1676 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1677 SALOME_ListIO selected;
1679 aSel->selectedObjects( selected );
1681 int nbSel = selected.Extent();
1684 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1686 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1687 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1688 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1689 if ( !Hyp->_is_nil() )
1691 char* sName = Hyp->GetName();
1692 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1695 aCreator->EditHypothesis(Hyp);
1703 updateObjBrowser( true );
1707 case 1101: // RENAME
1709 if ( checkLock( aStudy ) )
1712 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1713 SALOME_ListIO selected;
1715 aSel->selectedObjects( selected );
1717 SALOME_ListIteratorOfListIO It( selected );
1718 for ( ; It.More(); It.Next() )
1720 Handle(SALOME_InteractiveObject) IObject = It.Value();
1721 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1722 _PTR(GenericAttribute) anAttr;
1723 _PTR(AttributeName) aName;
1726 if ( obj->FindAttribute(anAttr, "AttributeName") )
1729 QString newName = QString(aName->Value().c_str());
1730 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1731 if ( !newName.isEmpty() )
1733 //old source: aStudy->renameIObject( IObject, newName );
1734 aName->SetValue( newName.latin1() );
1736 // if current object is group update group's name
1737 SMESH::SMESH_GroupBase_var aGroup =
1738 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1739 if (!aGroup->_is_nil() )
1740 aGroup->SetName( newName.latin1() );
1750 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1752 if(checkLock(aStudy)) break;
1753 SUIT_OverrideCursor wc;
1755 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1756 SALOME_ListIO selected;
1758 aSel->selectedObjects( selected );
1760 SALOME_ListIteratorOfListIO It(selected);
1761 for (int i = 0; It.More(); It.Next(), i++) {
1762 Handle(SALOME_InteractiveObject) IObject = It.Value();
1763 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1766 aSel->setSelectedObjects( l1 );
1771 case 401: // GEOM::EDGE
1772 case 4021: // TRIANGLE
1774 case 4023: // POLYGON
1778 if(checkLock(aStudy)) break;
1779 startOperation( theCommandID );
1781 EmitSignalDeactivateDialog();
1782 SMDSAbs_ElementType type = SMDSAbs_Edge;
1784 switch (theCommandID) {
1785 case 4021: // TRIANGLE
1786 type = SMDSAbs_Face; nbNodes = 3; break;
1788 type = SMDSAbs_Face; nbNodes = 4; break;
1790 type = SMDSAbs_Volume; nbNodes = 4; break;
1791 case 4023: // POLYGON
1792 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1794 type = SMDSAbs_Volume; nbNodes = 8; break;
1795 case 4033: // POLYHEDRE
1796 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1799 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1802 SUIT_MessageBox::warn1(desktop(),
1803 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1804 tr("SMESH_BUT_OK"));
1808 case 4033: // POLYHEDRON
1810 if(checkLock(aStudy)) break;
1812 EmitSignalDeactivateDialog();
1813 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1816 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1817 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1818 tr("SMESH_BUT_OK"));
1822 case 4041: // REMOVES NODES
1824 if(checkLock(aStudy)) break;
1825 startOperation( 4041 );
1827 EmitSignalDeactivateDialog();
1828 new SMESHGUI_RemoveNodesDlg(this);
1831 SUIT_MessageBox::warn1(desktop(),
1832 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1833 tr("SMESH_BUT_OK"));
1837 case 4042: // REMOVES ELEMENTS
1839 if(checkLock(aStudy)) break;
1840 startOperation( 4042 );
1842 EmitSignalDeactivateDialog();
1843 new SMESHGUI_RemoveElementsDlg(this);
1847 SUIT_MessageBox::warn1(desktop(),
1848 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1849 tr("SMESH_BUT_OK"));
1853 case 4051: // RENUMBERING NODES
1855 if(checkLock(aStudy)) break;
1856 startOperation( 4051 );
1858 EmitSignalDeactivateDialog();
1859 new SMESHGUI_RenumberingDlg( this, "", 0);
1863 SUIT_MessageBox::warn1(desktop(),
1864 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1865 tr("SMESH_BUT_OK"));
1869 case 4052: // RENUMBERING ELEMENTS
1871 if(checkLock(aStudy)) break;
1872 startOperation( 4052 );
1874 EmitSignalDeactivateDialog();
1875 new SMESHGUI_RenumberingDlg( this, "", 1);
1879 SUIT_MessageBox::warn1(desktop(),
1880 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1881 tr("SMESH_BUT_OK"));
1885 case 4061: // TRANSLATION
1887 if(checkLock(aStudy)) break;
1889 EmitSignalDeactivateDialog();
1890 new SMESHGUI_TranslationDlg( this );
1893 SUIT_MessageBox::warn1(desktop(),
1894 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1895 tr("SMESH_BUT_OK"));
1899 case 4062: // ROTATION
1901 if(checkLock(aStudy)) break;
1903 EmitSignalDeactivateDialog();
1904 new SMESHGUI_RotationDlg( this );
1907 SUIT_MessageBox::warn1(desktop(),
1908 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1909 tr("SMESH_BUT_OK"));
1913 case 4063: // SYMMETRY
1915 if(checkLock(aStudy)) break;
1917 EmitSignalDeactivateDialog();
1918 new SMESHGUI_SymmetryDlg( this );
1921 SUIT_MessageBox::warn1(desktop(),
1922 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1923 tr("SMESH_BUT_OK"));
1927 case 4064: // SEWING
1929 if(checkLock(aStudy)) break;
1931 EmitSignalDeactivateDialog();
1932 new SMESHGUI_SewingDlg( this );
1935 SUIT_MessageBox::warn1(desktop(),
1936 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1937 tr("SMESH_BUT_OK"));
1941 case 4065: // MERGE NODES
1943 if(checkLock(aStudy)) break;
1945 EmitSignalDeactivateDialog();
1946 new SMESHGUI_MergeNodesDlg( this );
1949 SUIT_MessageBox::warn1(desktop(),
1950 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1951 tr("SMESH_BUT_OK"));
1957 case 5000: // HYPOTHESIS
1958 startOperation( 5000 );
1961 startOperation( 5010 );
1963 case 5105: // Library of selection filters
1965 static QValueList<int> aTypes;
1966 if ( aTypes.isEmpty() )
1968 aTypes.append( SMESH::NODE );
1969 aTypes.append( SMESH::EDGE );
1970 aTypes.append( SMESH::FACE );
1971 aTypes.append( SMESH::VOLUME );
1973 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
1977 case 6017: // CONTROLS
1992 SalomeApp_SelectionMgr* mgr = selectionMgr();
1993 SALOME_ListIO selected; mgr->selectedObjects( selected );
1995 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
1996 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
1998 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1999 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2000 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2001 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2002 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2003 ::Control( theCommandID );
2008 SUIT_MessageBox::warn1(desktop(),
2009 tr( "SMESH_WRN_WARNING" ),
2010 tr( "SMESH_BAD_SELECTION" ),
2011 tr( "SMESH_BUT_OK" ) );
2015 SUIT_MessageBox::warn1(desktop(),
2016 tr( "SMESH_WRN_WARNING" ),
2017 tr( "NOT_A_VTK_VIEWER" ),
2018 tr( "SMESH_BUT_OK" ) );
2023 SalomeApp_SelectionMgr* mgr = selectionMgr();
2024 SALOME_ListIO selected; mgr->selectedObjects( selected );
2026 if (selected.Extent() == 1) {
2027 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2028 if(anIObject->hasEntry())
2029 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2030 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2037 SalomeApp_SelectionMgr* mgr = selectionMgr();
2038 SALOME_ListIO selected; mgr->selectedObjects( selected );
2040 if (selected.Extent() == 1) {
2041 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2042 if(anIObject->hasEntry())
2043 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2044 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2049 case 10001: // DISPLAY MODE PREFERENCE
2053 action( 10002 )->setOn( false );
2054 action( 10004 )->setOn( false );
2055 action( 10003 )->setOn( true );
2056 mgr->setValue( "SMESH", "DisplayMode", "Wireframe");
2062 action( 10001 )->setOn( false );
2063 action( 10004 )->setOn( false );
2064 action( 10003 )->setOn( true );
2065 mgr->setValue( "SMESH", "DisplayMode", "Shading");
2070 mgr->setValue( "SMESH", "Shrink", act->isOn() );
2076 action( 10001 )->setOn( false );
2077 action( 10002 )->setOn( false );
2078 action( 10003 )->setOn( false );
2079 mgr->setValue( "SMESH", "DisplayMode", "Nodes" );
2085 //updateObjBrowser();
2089 //=============================================================================
2093 //=============================================================================
2094 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2099 //=============================================================================
2103 //=============================================================================
2104 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2109 //=============================================================================
2113 //=============================================================================
2114 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2119 //=============================================================================
2123 //=============================================================================
2124 bool SMESHGUI::SetSettings(SUIT_Desktop* parent)
2126 SMESHGUI::GetSMESHGUI();
2128 SUIT_ResourceMgr* mgr = resourceMgr();
2133 QString DisplayMode = "Shading";
2134 if ( mgr->hasValue("SMESH","DisplayMode") )
2135 DisplayMode = mgr->stringValue("SMESH","DisplayMode");
2137 mgr->setValue("SMESH","DisplayMode", "Shading");
2139 bool Shrink = false;
2140 if ( mgr->hasValue("SMESH","Shrink") )
2141 Shrink = mgr->stringValue("SMESH","Shrink") == "yes";
2143 if (DisplayMode == "Wireframe") {
2145 action( 10004 )->setOn( false );
2146 action( 10002 )->setOn( false );
2147 action( 10001 )->setOn( true );
2148 action( 10003 )->setOn( true );
2150 else if (DisplayMode == "Nodes") {
2152 action( 10004 )->setOn( true );
2153 action( 10002 )->setOn( false );
2154 action( 10001 )->setOn( false );
2155 action( 10003 )->setOn( false );
2158 // default is shading
2159 action( 10004 )->setOn( false );
2160 action( 10002 )->setOn( true );
2161 action( 10001 )->setOn( false );
2162 action( 10003 )->setOn( true );
2165 action( 10003 )->setOn( Shrink );
2168 // if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) {
2169 // action( 1001 )->setOn( true );
2170 // myAutomaticUpdate = true;
2173 // action( 1001 )->setOn( false );
2174 // myAutomaticUpdate = false;
2177 if ( mgr->booleanValue( "SMESH","DispayEntity", false ) )
2178 action( 10071 )->setOn( true );
2180 action( 10071 )->setOn( false );
2183 SMESH::UpdateSelectionProp( this );
2186 action( 111 )->setEnabled( false ); // IMPORT DAT
2188 //action( 112 )->setEnabled( false );
2189 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2194 //=============================================================================
2195 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2196 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2198 //=============================================================================
2199 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2200 SUIT_ViewWindow* wnd )
2202 if(theIO->hasEntry()){
2203 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2204 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2208 //=======================================================================
2209 // function : createSMESHAction
2211 //=======================================================================
2212 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2215 QWidget* parent = application()->desktop();
2216 SUIT_ResourceMgr* resMgr = resourceMgr();
2218 if ( icon_id.length() )
2219 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2221 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2222 if ( !pix.isNull() )
2223 icon = QIconSet( pix );
2225 QString tooltip = tr( QString( "TOP_" )+po_id ),
2226 menu = tr( QString( "MEN_" )+po_id ),
2227 status_bar = tr( QString( "STB_" )+po_id );
2229 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2232 //=======================================================================
2233 // function : createPopupItem
2235 //=======================================================================
2236 void SMESHGUI::createPopupItem( const int id,
2237 const QString& clients,
2238 const QString& types,
2239 const QString& theRule,
2244 parentId = popupMgr()->actionId( action( pId ) );
2246 // if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2247 popupMgr()->insert( action( id ), parentId, 0 );
2249 QChar lc = QtxPopupMgr::Selection::defEquality();
2250 QString rule = "(%1) and (%2) and (%3)";
2251 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2252 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2253 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2256 bool cont = myRules.contains( id );
2258 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2260 popupMgr()->setRule( action( id ), rule, true );
2261 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2264 //=======================================================================
2265 // function : initialize
2267 //=======================================================================
2268 void SMESHGUI::initialize( CAM_Application* app )
2270 SalomeApp_Module::initialize( app );
2272 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2274 /* Automatic Update flag */
2275 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2277 // ----- create actions --------------
2279 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2280 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2281 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2282 createSMESHAction( 114, "NUM" );
2283 createSMESHAction( 121, "DAT" );
2284 createSMESHAction( 122, "MED" );
2285 createSMESHAction( 123, "UNV" );
2286 createSMESHAction( 124, "EXPORT_DAT" );
2287 createSMESHAction( 125, "EXPORT_MED" );
2288 createSMESHAction( 126, "EXPORT_UNV" );
2289 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2290 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2291 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2292 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2293 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2294 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2295 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2296 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2297 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2298 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2299 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2300 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2301 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2302 createSMESHAction( 804, "ADD" );
2303 createSMESHAction( 805, "REMOVE" );
2304 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2305 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2306 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2307 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2308 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2309 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2310 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2311 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2312 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2313 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2314 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2315 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2316 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2317 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2318 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2319 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2320 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2321 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2322 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2323 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2324 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2325 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2326 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2327 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2328 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2329 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2330 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2331 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2332 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2333 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2334 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2335 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2336 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2337 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2338 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2339 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2340 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2341 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2342 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2343 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2344 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2345 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2346 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2347 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2348 createSMESHAction( 415, "MAP", "ICON_MAP" );
2349 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2350 createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true );
2351 createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true );
2352 createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true );
2353 createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true );
2354 createSMESHAction( 1001, "AUTO_UPD", "", 0, true );
2355 createSMESHAction( 1003, "COLORS" );
2356 createSMESHAction( 1005, "SCALAR_BAR" );
2357 createSMESHAction( 1006, "SELECTION" );
2358 createSMESHAction( 10070, "PRECISION", "", 0, true );
2359 createSMESHAction( 10071, "DISP_ENT", "", 0, true );
2360 createSMESHAction( 200, "RESET" );
2361 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2362 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2363 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2364 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2365 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2366 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2367 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2368 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2369 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2370 createSMESHAction( 220, "ALL" );
2371 createSMESHAction( 1100, "EDIT_HYPO" );
2372 createSMESHAction( 1101, "RENAME" );
2373 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2374 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2375 createSMESHAction( 1131, "DISPMODE" );
2376 createSMESHAction( 1132, "COLORS" );
2377 createSMESHAction( 1133, "TRANSP" );
2378 createSMESHAction( 1134, "CLIP" );
2379 createSMESHAction( 1135, "DISP_ENT" );
2380 createSMESHAction( 2000, "CTRL" );
2382 createSMESHAction( 300, "ERASE" );
2383 createSMESHAction( 301, "DISPLAY" );
2384 createSMESHAction( 302, "DISPLAY_ONLY" );
2385 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2387 // ----- create menu --------------
2388 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2389 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2390 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2391 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2392 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2393 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2394 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2395 prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ),
2396 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2398 createMenu( separator(), fileId );
2400 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2401 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2403 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2404 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2405 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2406 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
2408 meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ),
2410 dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ),
2411 qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 );
2413 createMenu( 111, importId, -1 );
2414 createMenu( 112, importId, -1 );
2415 createMenu( 113, importId, -1 );
2417 createMenu( 121, exportId, -1 );
2418 createMenu( 122, exportId, -1 );
2419 createMenu( 123, exportId, -1 );
2421 createMenu( separator(), fileId, 10 );
2423 createMenu( 33, editId, -1 );
2425 createMenu( 5105, toolsId, -1 );
2427 createMenu( 5000, hypoId, -1 );
2428 createMenu( 5010, hypoId, -1 );
2430 createMenu( 703, meshId, -1 );
2431 createMenu( 702, meshId, -1 );
2432 createMenu( 704, meshId, -1 );
2433 createMenu( separator(), meshId, -1 );
2434 createMenu( 701, meshId, -1 );
2435 createMenu( separator(), meshId, -1 );
2436 createMenu( 801, meshId, -1 );
2437 createMenu( 802, meshId, -1 );
2438 createMenu( 803, meshId, -1 );
2439 createMenu( separator(), meshId, -1 );
2440 createMenu( 810, meshId, -1 );
2441 createMenu( 811, meshId, -1 );
2442 createMenu( 812, meshId, -1 );
2443 createMenu( separator(), meshId, -1 );
2444 createMenu( 813, meshId, -1 );
2445 createMenu( separator(), meshId, -1 );
2446 createMenu( 900, meshId, -1 );
2447 createMenu( 902, meshId, -1 );
2448 createMenu( separator(), meshId, -1 );
2450 createMenu( 6003, ctrlId, -1 );
2451 createMenu( 6001, ctrlId, -1 );
2452 createMenu( 6004, ctrlId, -1 );
2453 createMenu( separator(), ctrlId, -1 );
2454 createMenu( 6002, ctrlId, -1 );
2455 createMenu( 6018, ctrlId, -1 );
2456 createMenu( 6019, ctrlId, -1 );
2457 createMenu( 6011, ctrlId, -1 );
2458 createMenu( 6012, ctrlId, -1 );
2459 createMenu( 6013, ctrlId, -1 );
2460 createMenu( 6014, ctrlId, -1 );
2461 createMenu( 6015, ctrlId, -1 );
2462 createMenu( 6016, ctrlId, -1 );
2463 createMenu( separator(), ctrlId, -1 );
2464 createMenu( 6017, ctrlId, -1 );
2465 createMenu( separator(), ctrlId, -1 );
2467 createMenu( 400, addId, -1 );
2468 createMenu( 401, addId, -1 );
2469 createMenu( 4021, addId, -1 );
2470 createMenu( 4022, addId, -1 );
2471 createMenu( 4023, addId, -1 );
2472 createMenu( 4031, addId, -1 );
2473 createMenu( 4032, addId, -1 );
2474 createMenu( 4033, addId, -1 );
2476 createMenu( 4041, removeId, -1 );
2477 createMenu( 4042, removeId, -1 );
2479 createMenu( 4051, renumId, -1 );
2480 createMenu( 4052, renumId, -1 );
2482 createMenu( 4061, transfId, -1 );
2483 createMenu( 4062, transfId, -1 );
2484 createMenu( 4063, transfId, -1 );
2485 createMenu( 4064, transfId, -1 );
2486 createMenu( 4065, transfId, -1 );
2488 createMenu( 406, modifyId, -1 );
2489 createMenu( 407, modifyId, -1 );
2490 createMenu( 408, modifyId, -1 );
2491 createMenu( 409, modifyId, -1 );
2492 createMenu( 410, modifyId, -1 );
2493 createMenu( 411, modifyId, -1 );
2494 createMenu( 412, modifyId, -1 );
2495 createMenu( 413, modifyId, -1 );
2496 createMenu( 416, modifyId, -1 );
2497 createMenu( 414, modifyId, -1 );
2498 createMenu( 415, modifyId, -1 );
2500 createMenu( 10001, dispModeId, -1 );
2501 createMenu( 10002, dispModeId, -1 );
2502 createMenu( 10004, dispModeId, -1 );
2503 createMenu( 10003, dispModeId, -1 );
2505 createMenu( 1001, prefId, -1 );
2506 createMenu( separator(), prefId, -1 );
2507 createMenu( 1003, prefId, -1 );
2508 createMenu( separator(), prefId, -1 );
2509 createMenu( 1005, prefId, -1 );
2510 createMenu( separator(), prefId, -1 );
2511 createMenu( 1006, prefId, -1 );
2512 createMenu( separator(), prefId, -1 );
2514 createMenu( 10070, qualityId, -1 );
2515 createMenu( 10071, qualityId, -1 );
2517 createMenu( separator(), prefId, -1 );
2519 createMenu( 214, viewId, -1 );
2521 // ----- create toolbars --------------
2522 int meshTb = createTool( tr( "TB_MESH" ) ),
2523 hypoTb = createTool( tr( "TB_HYPO" ) ),
2524 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2525 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2526 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2527 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2529 createTool( 703, meshTb );
2530 createTool( 702, meshTb );
2531 createTool( 704, meshTb );
2532 createTool( separator(), meshTb );
2533 createTool( 701, meshTb );
2534 createTool( separator(), meshTb );
2535 createTool( 801, meshTb );
2536 createTool( 802, meshTb );
2537 createTool( 803, meshTb );
2538 createTool( separator(), meshTb );
2539 createTool( 900, meshTb );
2540 createTool( 902, meshTb );
2541 createTool( separator(), meshTb );
2543 createTool( 5000, hypoTb );
2544 createTool( 5010, hypoTb );
2546 createTool( 6001, ctrlTb );
2547 createTool( 6003, ctrlTb );
2548 createTool( 6004, ctrlTb );
2549 createTool( separator(), ctrlTb );
2550 createTool( 6002, ctrlTb );
2551 createTool( 6018, ctrlTb );
2552 createTool( 6019, ctrlTb );
2553 createTool( 6011, ctrlTb );
2554 createTool( 6012, ctrlTb );
2555 createTool( 6013, ctrlTb );
2556 createTool( 6014, ctrlTb );
2557 createTool( 6015, ctrlTb );
2558 createTool( 6016, ctrlTb );
2559 createTool( separator(), ctrlTb );
2560 createTool( 6017, ctrlTb );
2561 createTool( separator(), ctrlTb );
2563 createTool( 400, addRemTb );
2564 createTool( 401, addRemTb );
2565 createTool( 4021, addRemTb );
2566 createTool( 4022, addRemTb );
2567 createTool( 4023, addRemTb );
2568 createTool( 4031, addRemTb );
2569 createTool( 4032, addRemTb );
2570 createTool( 4033, addRemTb );
2571 createTool( separator(), addRemTb );
2572 createTool( 4041, addRemTb );
2573 createTool( 4042, addRemTb );
2574 createTool( separator(), addRemTb );
2575 createTool( 4051, addRemTb );
2576 createTool( 4052, addRemTb );
2577 createTool( separator(), addRemTb );
2578 createTool( 4061, addRemTb );
2579 createTool( 4062, addRemTb );
2580 createTool( 4063, addRemTb );
2581 createTool( 4064, addRemTb );
2582 createTool( 4065, addRemTb );
2583 createTool( separator(), addRemTb );
2585 createTool( 406, modifyTb );
2586 createTool( 407, modifyTb );
2587 createTool( 408, modifyTb );
2588 createTool( 409, modifyTb );
2589 createTool( 410, modifyTb );
2590 createTool( 411, modifyTb );
2591 createTool( 412, modifyTb );
2592 createTool( 413, modifyTb );
2593 createTool( 416, modifyTb );
2594 createTool( 414, modifyTb );
2595 createTool( 415, modifyTb );
2597 createTool( 214, dispModeTb );
2601 QString OB = "'ObjectBrowser'",
2602 View = "'" + SVTK_Viewer::Type() + "'",
2604 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2605 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2606 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2607 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2608 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2609 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2610 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2611 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2612 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2613 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2615 mesh_group = mesh + " " + subMesh + " " + group,
2616 hyp_alg = hypo + " " + algo;
2618 // popup for object browser
2620 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2621 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2622 createPopupItem( 803, OB, group ); // EDIT_GROUP
2623 popupMgr()->insert( separator(), -1, 0 );
2624 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2625 createPopupItem( 214, OB, mesh_group ); // UPDATE
2626 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2627 createPopupItem( 902, OB, mesh ); // STD_INFO
2628 popupMgr()->insert( separator(), -1, 0 );
2629 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2630 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2631 popupMgr()->insert( separator(), -1, 0 );
2632 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2633 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2634 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2635 popupMgr()->insert( separator(), -1, 0 );
2636 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2637 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2638 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2639 popupMgr()->insert( separator(), -1, 0 );
2642 createPopupItem( 803, View, group ); // EDIT_GROUP
2643 createPopupItem( 804, View, elems ); // ADD
2644 createPopupItem( 805, View, elems ); // REMOVE
2645 popupMgr()->insert( separator(), -1, 0 );
2646 createPopupItem( 214, View, mesh_group ); // UPDATE
2647 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2648 createPopupItem( 902, View, mesh ); // STD_INFO
2649 popupMgr()->insert( separator(), -1, 0 );
2653 isInvisible("not( isVisible )"),
2654 isEmpty("numberOfNodes = 0"),
2655 isNotEmpty("numberOfNodes <> 0"),
2657 // has nodes, edges, etc in VISIBLE! actor
2658 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2659 hasElems("(count( elemTypes ) > 0)"),
2660 hasDifferentElems("(count( elemTypes ) > 1)"),
2661 hasEdges("({'Edge'} in elemTypes)"),
2662 hasFaces("({'Face'} in elemTypes)"),
2663 hasVolumes("({'Volume'} in elemTypes)");
2665 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2666 QString lc = QtxPopupMgr::Selection::defEquality();
2667 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2668 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2669 QString aMeshInVTK = aClient + "&&" + aType;// + "&&" + aSelCount;
2671 //-------------------------------------------------
2673 //-------------------------------------------------
2674 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2676 popupMgr()->insert( action( 9010 ), anId, -1 );
2677 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true );
2678 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2680 popupMgr()->insert( action( 9011 ), anId, -1 );
2681 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true );
2682 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2684 popupMgr()->insert( separator(), -1, -1 );
2686 //-------------------------------------------------
2688 //-------------------------------------------------
2689 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2691 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2692 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2693 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2695 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2696 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2697 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2699 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2700 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2701 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2703 popupMgr()->insert( separator(), anId, -1 );
2705 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2706 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2707 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2709 //-------------------------------------------------
2711 //-------------------------------------------------
2712 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2714 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2716 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2717 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true );
2718 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2720 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2721 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true );
2722 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2724 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2725 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true );
2726 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2728 popupMgr()->insert( separator(), anId, -1 );
2730 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2731 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true );
2733 //-------------------------------------------------
2735 //-------------------------------------------------
2736 popupMgr()->insert( action( 1132 ), -1, -1 );
2737 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2739 //-------------------------------------------------
2741 //-------------------------------------------------
2742 popupMgr()->insert( action( 1133 ), -1, -1 );
2743 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2745 //-------------------------------------------------
2747 //-------------------------------------------------
2748 popupMgr()->insert( action( 1134 ), -1, -1 );
2749 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2751 popupMgr()->insert( separator(), -1, -1 );
2753 //-------------------------------------------------
2755 //-------------------------------------------------
2757 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2758 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2759 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2761 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2763 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2764 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2766 popupMgr()->insert( separator(), anId, -1 );
2768 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2769 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2770 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2772 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2773 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2774 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2776 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2777 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2778 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2780 popupMgr()->insert( separator(), anId, -1 );
2782 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2783 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2784 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2786 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2787 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2788 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2790 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2791 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2792 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2794 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2795 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2796 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2798 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2799 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2800 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2802 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2803 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2804 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2806 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2807 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2808 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2810 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2811 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2812 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2814 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2815 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2816 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2818 popupMgr()->insert( separator(), anId, -1 );
2820 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2821 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2822 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2824 popupMgr()->insert( separator(), anId, -1 );
2826 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2827 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2829 popupMgr()->insert( separator(), -1, -1 );
2831 //-------------------------------------------------
2833 //-------------------------------------------------
2834 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2835 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
2836 QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
2837 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2838 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
2840 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2841 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
2843 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2844 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
2846 popupMgr()->insert( separator(), -1, -1 );
2848 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
2849 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
2852 bool SMESHGUI::activateModule( SUIT_Study* study )
2854 bool res = SalomeApp_Module::activateModule( study );
2856 setMenuShown( true );
2857 setToolShown( true );
2858 SetSettings( desktop() );
2863 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2865 setMenuShown( false );
2866 setToolShown( false );
2868 EmitSignalCloseAllDialogs();
2870 return SalomeApp_Module::deactivateModule( study );
2873 void SMESHGUI::OnGUIEvent()
2875 const QObject* obj = sender();
2876 if ( !obj || !obj->inherits( "QAction" ) )
2878 int id = actionId((QAction*)obj);
2883 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2885 if ( CORBA::is_nil( myComponentSMESH ) )
2887 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2888 return aGUI.myComponentSMESH;
2890 return myComponentSMESH;
2893 QString SMESHGUI::engineIOR() const
2895 CORBA::ORB_var anORB = getApp()->orb();
2896 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2900 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2902 SMESHGUI_Selection sel;
2903 sel.init( client, selectionMgr() );
2904 popupMgr()->updatePopup( menu, &sel );
2907 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2909 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2910 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2913 void SMESHGUI::viewManagers( QStringList& list ) const
2915 list.append( SVTK_Viewer::Type() );
2918 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
2920 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
2921 SMESH::UpdateSelectionProp( this );
2924 void SMESHGUI::createPreferences()
2926 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2928 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2929 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "display_entity" );
2930 addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "auto_update" );
2932 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2933 setPreferenceProperty( precGroup, "columns", 1 );
2935 addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool );
2936 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2938 setPreferenceProperty( prec, "min", 0 );
2939 setPreferenceProperty( prec, "max", 16 );
2941 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2942 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2944 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
2945 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
2947 setPreferenceProperty( nodeSz, "min", 1 );
2948 setPreferenceProperty( nodeSz, "max", 5 );
2950 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2952 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
2953 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
2954 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
2955 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
2957 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
2958 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2960 setPreferenceProperty( elemW, "min", 1 );
2961 setPreferenceProperty( elemW, "max", 5 );
2963 setPreferenceProperty( shrink, "min", 0 );
2964 setPreferenceProperty( shrink, "max", 100 );
2966 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2968 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2970 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
2971 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
2972 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
2974 setPreferenceProperty( selW, "min", 1 );
2975 setPreferenceProperty( selW, "max", 5 );
2977 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2979 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
2980 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2982 setPreferenceProperty( preW, "min", 1 );
2983 setPreferenceProperty( preW, "max", 5 );
2985 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2987 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
2988 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
2991 void SMESHGUI::preferencesChanged( const QString&, const QString& )
2995 //=======================================================================
2996 // function : onOperationCommited
2997 // purpose : SLOT called when operation commited. Set default selection mode
2998 //=======================================================================
2999 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3001 SVTK_ViewWindow* vtkWnd =
3002 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3004 vtkWnd->SetSelectionMode( ActorSelection );
3007 //=======================================================================
3008 // function : onOperationAborted
3009 // purpose : SLOT called when operation commited. Set default selection mode
3010 //=======================================================================
3011 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3013 SVTK_ViewWindow* vtkWnd =
3014 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3016 vtkWnd->SetSelectionMode( ActorSelection );
3019 //=======================================================================
3020 // function : getOperation
3021 // purpose : Get operation corresponding to the given Id
3022 //=======================================================================
3023 SalomeApp_Operation* SMESHGUI::getOperation( const int theId )
3025 if ( myOperations.contains( theId ) )
3026 return myOperations[ theId ];
3029 SalomeApp_Operation* anOp = 0;
3039 anOp->setModule( this );
3040 connect( anOp, SIGNAL( aborted( SUIT_Operation* ) ),
3041 this, SLOT( onOperationAborted( SUIT_Operation* ) ) );
3042 connect( anOp, SIGNAL( commited( SUIT_Operation* ) ),
3043 this, SLOT( onOperationCommited( SUIT_Operation* ) ) );
3044 myOperations[ theId ] = anOp;
3051 //=======================================================================
3052 // function : update
3053 // purpose : Update something
3054 //=======================================================================
3055 void SMESHGUI::update( const int flags )
3057 if ( flags & UF_Viewer | flags & UF_Forced )
3058 SMESH::UpdateView();
3060 SalomeApp_Module::update( flags );
3063 //=======================================================================
3064 // function : updateControls
3065 // purpose : Update state of controls
3066 //=======================================================================
3067 void SMESHGUI::updateControls()
3072 //=======================================================================
3073 // function : updateControls
3074 // purpose : Update state of controls
3075 //=======================================================================
3076 SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
3078 SalomeApp_Operation* op = 0;
3082 op = new SMESHGUI_DeleteOp();
3086 op = new SMESHGUI_NodesOp();
3090 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Edge, 2 );
3093 case 406: // MOVE NODE
3094 op = new SMESHGUI_MoveNodesOp();
3098 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 3 );
3102 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 4 );
3106 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 5 ); // 5 - identificator for POLYGON
3110 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 4 );
3114 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 8 );
3117 case 4041: //REMOVE NODES
3118 op = new SMESHGUI_RemoveOp( false );
3121 case 4042: //REMOVE ELEMENTS
3122 op = new SMESHGUI_RemoveOp( true );
3125 case 4051: // RENUMBERING NODES
3126 op = new SMESHGUI_RenumberingOp( 0 );
3129 case 4052: // RENUMBERING ELEMENTS
3130 op = new SMESHGUI_RenumberingOp( 1 );
3134 op = new SMESHGUI_AddSubMeshOp();
3138 op = new SMESHGUI_InitMeshOp();
3142 op = new SMESHGUI_EditHypothesesOp();
3146 op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::UNION );
3150 op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::INTERSECT );
3154 op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::CUT );
3157 /* case 409: // Change orientation
3158 op = new SMESHGUI_ChangeOrientationOp();
3161 case 410: // Union of triangles
3162 op = new SMESHGUI_UnionOfTrianglesDlg();
3165 /* case 411: // Cutting of quadrangles
3166 op = new SMESHGUI_CuttingOfQuadsDlg();
3170 op = new SMESHGUI_ExtrusionOp();
3174 op = new SMESHGUI_CreateHypothesesOp( false );
3178 op = new SMESHGUI_CreateHypothesesOp( true );
3182 op = new SMESHGUI_MeshInfosOp();
3186 op = new SMESHGUI_StandardMeshInfosOp();
3190 op = new SMESHGUI_ExportMeshOp( SMESHGUI_ExportMeshOp::DAT );
3194 op = new SMESHGUI_ExportMeshOp( SMESHGUI_ExportMeshOp::MED );
3198 op = new SMESHGUI_ExportMeshOp( SMESHGUI_ExportMeshOp::UNV );
3202 op = SalomeApp_Module::createOperation( id );