1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
28 #include "SMESHGUI_InitMeshOp.h"
29 #include "SMESHGUI_AddSubMeshOp.h"
30 #include "SMESHGUI_NodesOp.h"
31 #include "SMESHGUI_DeleteOp.h"
32 #include "SMESHGUI_TransparencyDlg.h"
33 #include "SMESHGUI_ClippingDlg.h"
34 #include "SMESHGUI_GroupDlg.h"
35 #include "SMESHGUI_RemoveOp.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_HypothesesUtils.h"
43 #include "SMESHGUI_MoveNodesOp.h"
44 #include "SMESHGUI_AddMeshElementOp.h"
45 #include "SMESHGUI_EditHypothesesOp.h"
46 #include "SMESHGUI_CreateHypothesesDlg.h"
47 #include "SMESHGUI_FilterDlg.h"
48 #include "SMESHGUI_FilterLibraryDlg.h"
49 #include "SMESHGUI_SingleEditDlg.h"
50 #include "SMESHGUI_MultiEditDlg.h"
51 #include "SMESHGUI_GroupOp.h"
52 #include "SMESHGUI_DeleteGroupDlg.h"
53 #include "SMESHGUI_SmoothingDlg.h"
54 #include "SMESHGUI_RenumberingOp.h"
55 #include "SMESHGUI_ExtrusionOp.h"
56 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
57 #include "SMESHGUI_RevolutionDlg.h"
58 #include "SMESHGUI_TranslationDlg.h"
59 #include "SMESHGUI_RotationDlg.h"
60 #include "SMESHGUI_SymmetryDlg.h"
61 #include "SMESHGUI_SewingDlg.h"
62 #include "SMESHGUI_MergeNodesDlg.h"
63 #include "SMESHGUI_MeshPatternDlg.h"
64 #include "SMESHGUI_PrecisionDlg.h"
65 #include "SMESHGUI_Selection.h"
66 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
68 #include <SVTK_InteractorStyle.h>
69 #include <SVTK_RenderWindowInteractor.h>
71 #include "SMESH_Actor.h"
72 #include "SMESH_Object.h"
73 #include "SMESH_TypeFilter.hxx"
75 #include "SUIT_Tools.h"
76 #include "SUIT_MessageBox.h"
77 #include "SUIT_ResourceMgr.h"
78 #include "SUIT_FileDlg.h"
79 #include "SUIT_Desktop.h"
80 #include "SUIT_ResourceMgr.h"
81 #include "SUIT_OverrideCursor.h"
82 #include "SUIT_Study.h"
83 #include "SUIT_Session.h"
85 #include "SALOME_NamingService.hxx"
86 #include "SALOME_ListIteratorOfListIO.hxx"
87 #include "SALOME_InteractiveObject.hxx"
88 #include "SALOME_ListIO.hxx"
89 #include <SALOME_LifeCycleCORBA.hxx>
91 #include "OB_Browser.h"
93 #include "QtxPopupMgr.h"
95 #include "SalomeApp_Tools.h"
96 #include "SalomeApp_Study.h"
97 #include "SalomeApp_NameDlg.h"
98 #include "SalomeApp_DataOwner.h"
99 #include "SalomeApp_Application.h"
100 #include "SalomeApp_Preferences.h"
101 #include "SalomeApp_VTKSelector.h"
102 #include "SalomeApp_Operation.h"
103 #include "SalomeApp_UpdateFlags.h"
105 #include "SalomeApp_ImportOperation.h"
107 #include <SVTK_ViewWindow.h>
108 #include <SVTK_ViewModel.h>
110 #include <VTKViewer_ViewManager.h>
112 #include "SMESHGUI_Utils.h"
113 #include "SMESHGUI_GEOMGenUtils.h"
114 #include "SMESHGUI_MeshUtils.h"
115 #include "SMESHGUI_GroupUtils.h"
116 #include "SMESHGUI_FilterUtils.h"
117 #include "SMESHGUI_PatternUtils.h"
118 #include "SMESHGUI_VTKUtils.h"
120 #include "SALOMEconfig.h"
121 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
124 #define INCLUDE_MENUITEM_DEF
125 #include <qapplication.h>
126 #include <qlineedit.h>
127 #include <qmenudata.h>
128 #include <qmenubar.h>
129 #include <qpopupmenu.h>
132 #include <qpainter.h>
133 #include <qcheckbox.h>
134 #include <qcolordialog.h>
135 #include <qspinbox.h>
140 #include <qradiobutton.h>
142 #include <boost/shared_ptr.hpp>
144 #include <vtkRenderer.h>
145 #include <vtkRenderWindow.h>
146 #include <vtkActorCollection.h>
147 #include <vtkScalarBarActor.h>
148 #include <vtkUnstructuredGrid.h>
150 #include "utilities.h"
152 #include "SALOMEDS_Study.hxx"
153 #include "SALOMEDSClient_StudyBuilder.hxx"
154 #include "SALOMEDSClient_SComponent.hxx"
160 //=============================================================
161 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
164 void ExportMeshToFile(int theCommandID);
166 void SetDisplayMode(int theCommandID);
168 void SetDisplayEntity(int theCommandID);
170 void Control( int theCommandID );
172 void SetDisplaySettings();
176 //=============================================================
177 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
183 if(theCommandID == 113){
184 filter.append(QObject::tr("MED files (*.med)"));
185 filter.append(QObject::tr("All files (*)"));
186 }else if (theCommandID == 112){
187 filter.append(QObject::tr("IDEAS files (*.unv)"));
188 }else if (theCommandID == 111){
189 filter.append(QObject::tr("DAT files (*.dat)"));
191 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
194 QObject::tr("Import mesh"),
196 if(!filename.isEmpty()) {
197 SUIT_OverrideCursor wc;
198 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
201 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
202 switch ( theCommandID ) {
205 aMeshes->length( 1 );
206 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
211 SMESH::DriverMED_ReadStatus res;
212 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
213 if ( res != SMESH::DRS_OK ) {
215 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
216 QObject::tr("SMESH_WRN_WARNING"),
217 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
218 QObject::tr("SMESH_BUT_OK"));
219 aMeshes->length( 0 );
226 bool isEmpty = false;
227 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
228 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
230 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
231 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
232 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
233 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
234 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
241 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
242 QObject::tr("SMESH_WRN_WARNING"),
243 QObject::tr("SMESH_DRS_EMPTY"),
244 QObject::tr("SMESH_BUT_OK"));
248 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
250 catch (const SALOME::SALOME_Exception& S_ex){
252 SalomeApp_Tools::QtCatchCorbaException(S_ex);
259 void ExportMeshToFile( int theCommandID )
261 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
262 SALOME_ListIO selected;
264 aSel->selectedObjects( selected );
266 if(selected.Extent()){
267 Handle(SALOME_InteractiveObject) anIObject = selected.First();
268 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
269 if ( !aMesh->_is_nil() ) {
270 QString aFilter, aTitle = QObject::tr("Export mesh");
271 QMap<QString, SMESH::MED_VERSION> aFilterMap;
272 switch ( theCommandID ) {
275 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
276 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
280 aFilter = QObject::tr("DAT files (*.dat)");
284 if(aMesh->NbPyramids()){
285 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
286 QObject::tr("SMESH_WRN_WARNING"),
287 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
288 QObject::tr("SMESH_BUT_YES"),
289 QObject::tr("SMESH_BUT_NO"),
294 aFilter = QObject::tr("IDEAS files (*.unv)");
301 SMESH::MED_VERSION aFormat;
303 if ( theCommandID != 122 && theCommandID != 125 )
304 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
308 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
309 filters.push_back( it.key() );
311 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
312 fd->setCaption( aTitle );
313 fd->setFilters( filters );
317 aFilename = fd->selectedFile();
318 aFormat = aFilterMap[fd->selectedFilter()];
320 if( !aFilename.isEmpty()
321 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
322 && aFormat==SMESH::MED_V2_1){
323 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
324 QObject::tr("SMESH_WRN_WARNING"),
325 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
326 QObject::tr("SMESH_BUT_YES"),
327 QObject::tr("SMESH_BUT_NO"),
336 if ( !aFilename.isEmpty() ) {
337 // Check whether the file already exists and delete it if yes
338 QFile aFile( aFilename );
339 if ( aFile.exists() )
341 SUIT_OverrideCursor wc;
342 switch ( theCommandID ) {
345 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
349 aMesh->ExportDAT( aFilename.latin1() );
353 aMesh->ExportUNV( aFilename.latin1() );
363 inline void InverseEntityMode(unsigned int& theOutputMode,
364 unsigned int theMode)
366 bool anIsNotPresent = ~theOutputMode & theMode;
368 theOutputMode |= theMode;
370 theOutputMode &= ~theMode;
373 void SetDisplayEntity(int theCommandID){
374 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
375 SALOME_ListIO selected;
377 aSel->selectedObjects( selected );
379 if(selected.Extent() >= 1){
380 SALOME_ListIteratorOfListIO It( selected );
381 for(; It.More(); It.Next()){
382 Handle(SALOME_InteractiveObject) IObject = It.Value();
383 if(IObject->hasEntry()){
384 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
385 unsigned int aMode = anActor->GetEntityMode();
386 switch(theCommandID){
388 InverseEntityMode(aMode,SMESH_Actor::eEdges);
391 InverseEntityMode(aMode,SMESH_Actor::eFaces);
394 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
397 aMode = SMESH_Actor::eAllEntity;
401 anActor->SetEntityMode(aMode);
408 void SetDisplayMode(int theCommandID){
409 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
410 SALOME_ListIO selected;
412 aSel->selectedObjects( selected );
414 if(selected.Extent() >= 1){
415 switch(theCommandID){
417 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
418 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
422 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
423 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
426 SALOME_ListIteratorOfListIO It( selected );
427 for(; It.More(); It.Next()){
428 Handle(SALOME_InteractiveObject) IObject = It.Value();
429 if(IObject->hasEntry()){
430 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
431 switch(theCommandID){
433 anActor->SetRepresentation(SMESH_Actor::eEdge);
436 anActor->SetRepresentation(SMESH_Actor::eSurface);
439 if(anActor->IsShrunk())
442 anActor->SetShrink();
445 anActor->SetRepresentation(SMESH_Actor::ePoint);
449 anActor->GetSufaceColor(color[0], color[1], color[2]);
450 int c0 = int (color[0] * 255);
451 int c1 = int (color[1] * 255);
452 int c2 = int (color[2] * 255);
453 QColor c(c0, c1, c2);
456 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
457 c0 = int (edgecolor[0] * 255);
458 c1 = int (edgecolor[1] * 255);
459 c2 = int (edgecolor[2] * 255);
460 QColor e(c0, c1, c2);
462 float backfacecolor[3];
463 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
464 c0 = int (backfacecolor[0] * 255);
465 c1 = int (backfacecolor[1] * 255);
466 c2 = int (backfacecolor[2] * 255);
467 QColor b(c0, c1, c2);
470 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
471 c0 = int (nodecolor[0] * 255);
472 c1 = int (nodecolor[1] * 255);
473 c2 = int (nodecolor[2] * 255);
474 QColor n(c0, c1, c2);
476 int Edgewidth = (int)anActor->GetLineWidth();
479 int intValue = int(anActor->GetNodeSize());
480 float Shrink = anActor->GetShrinkFactor();
482 SMESHGUI_Preferences_ColorDlg *aDlg =
483 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
484 aDlg->SetColor(1, c);
485 aDlg->SetColor(2, e);
486 aDlg->SetColor(3, n);
487 aDlg->SetColor(4, b);
488 aDlg->SetIntValue(1, Edgewidth);
489 aDlg->SetIntValue(2, intValue);
490 aDlg->SetIntValue(3, int(Shrink*100.));
492 QColor color = aDlg->GetColor(1);
493 QColor edgecolor = aDlg->GetColor(2);
494 QColor nodecolor = aDlg->GetColor(3);
495 QColor backfacecolor = aDlg->GetColor(4);
496 /* actor color and backface color */
497 anActor->SetSufaceColor(float (color.red()) / 255.,
498 float (color.green()) / 255.,
499 float (color.blue()) / 255.);
500 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
501 float (backfacecolor.green()) / 255.,
502 float (backfacecolor.blue()) / 255.);
505 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
506 float (edgecolor.green()) / 255.,
507 float (edgecolor.blue()) / 255.);
509 /* Shrink factor and size edges */
510 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
511 anActor->SetLineWidth(aDlg->GetIntValue(1));
513 /* Nodes color and size */
514 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
515 float (nodecolor.green()) / 255.,
516 float (nodecolor.blue()) / 255.);
517 anActor->SetNodeSize(aDlg->GetIntValue(2));
526 SMESH::RepaintCurrentView();
531 void SetDisplaySettings()
533 SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
537 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
538 SMESHGUI_Preferences_ColorDlg *aDlg =
539 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
541 QColor color = mgr->colorValue( "SMESH", "SettingsFillColor", QColor(0, 170, 255) );
542 aDlg->SetColor(1, color);
544 color = mgr->colorValue( "SMESH", "SettingsOutlineColor", QColor(0, 170, 255) );
545 aDlg->SetColor(2, color);
547 color = mgr->colorValue( "SMESH", "SettingsNodeColor", Qt::red );
548 aDlg->SetColor(3, color);
550 color = mgr->colorValue( "SMESH", "SettingsBackFaceColor", Qt::blue );
551 aDlg->SetColor(4, color);
553 int iVal = mgr->integerValue( "SMESH", "SettingsWidth", 1 );
554 aDlg->SetIntValue(1, iVal);
556 iVal = mgr->integerValue( "SMESH", "SettingsNodesSize", 3 );
557 aDlg->SetIntValue(2, iVal);
559 iVal = mgr->integerValue( "SMESH", "SettingsShrinkCoeff", 75 );
560 aDlg->SetIntValue(3, iVal);
563 mgr->setValue( "SMESH", "SettingsFillColor", aDlg->GetColor(1) );
564 mgr->setValue( "SMESH", "SettingsOutlineColor", aDlg->GetColor(2) );
565 mgr->setValue( "SMESH", "SettingsNodeColor", aDlg->GetColor(3) );
566 mgr->setValue( "SMESH", "SettingsBackFaceColor", aDlg->GetColor(4) );
568 mgr->setValue( "SMESH", "SettingsWidth", aDlg->GetIntValue(1) );
569 mgr->setValue( "SMESH", "SettingsNodesSize", aDlg->GetIntValue(2) );
570 mgr->setValue( "SMESH", "SettingsShrinkCoeff", aDlg->GetIntValue(3) );
577 void Control( int theCommandID )
579 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
580 SALOME_ListIO selected;
582 aSel->selectedObjects( selected );
584 if( !selected.IsEmpty() ){
585 Handle(SALOME_InteractiveObject) anIO = selected.First();
588 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
589 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
590 switch ( theCommandID ){
592 aTitle = QObject::tr( "LENGTH_EDGES" );
593 aControl = SMESH_Actor::eLength;
596 aTitle = QObject::tr( "LENGTH2D_EDGES" );
597 aControl = SMESH_Actor::eLength2D;
600 aTitle = QObject::tr( "FREE_EDGES" );
601 aControl = SMESH_Actor::eFreeEdges;
604 aTitle = QObject::tr( "FREE_BORDERS" );
605 aControl = SMESH_Actor::eFreeBorders;
608 aTitle = QObject::tr( "MULTI_BORDERS" );
609 aControl = SMESH_Actor::eMultiConnection;
612 aTitle = QObject::tr( "MULTI2D_BORDERS" );
613 aControl = SMESH_Actor::eMultiConnection2D;
616 aTitle = QObject::tr( "AREA_ELEMENTS" );
617 aControl = SMESH_Actor::eArea;
620 aTitle = QObject::tr( "TAPER_ELEMENTS" );
621 aControl = SMESH_Actor::eTaper;
624 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
625 aControl = SMESH_Actor::eAspectRatio;
628 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
629 aControl = SMESH_Actor::eAspectRatio3D;
632 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
633 aControl = SMESH_Actor::eMinimumAngle;
636 aTitle = QObject::tr( "WARP_ELEMENTS" );
637 aControl = SMESH_Actor::eWarping;
640 aTitle = QObject::tr( "SKEW_ELEMENTS" );
641 aControl = SMESH_Actor::eSkew;
644 anActor->SetControlMode(aControl);
645 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
652 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
653 MeshObjectType theType,
654 const QString theInTypeName,
655 QString & theOutTypeName)
657 SMESH_TypeFilter aTypeFilter( theType );
659 if( !theIO.IsNull() )
661 entry = theIO->getEntry();
662 SalomeApp_DataOwner owner( entry );
663 if ( aTypeFilter.isOk( &owner )) {
664 theOutTypeName = theInTypeName;
672 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
674 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
675 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
677 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
678 CORBA::String_var anID = aSComp->GetID().c_str();
679 if (!strcmp(anID.in(),theIO->getEntry()))
685 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
686 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
687 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
688 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
689 CheckOIType ( theIO, GROUP, "Group", aTypeName )
697 QString CheckHomogeneousSelection()
699 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
700 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
701 SALOME_ListIO selected;
703 aSel->selectedObjects( selected );
705 QString RefType = CheckTypeObject(selected.First());
706 SALOME_ListIteratorOfListIO It(selected);
707 for (; It.More(); It.Next())
709 Handle(SALOME_InteractiveObject) IObject = It.Value();
710 QString Type = CheckTypeObject(IObject);
711 if (Type.compare(RefType) != 0)
712 return "Heterogeneous Selection";
720 Standard_EXPORT CAM_Module* createModule()
722 return new SMESHGUI();
726 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
728 //=============================================================================
732 //=============================================================================
733 SMESHGUI::SMESHGUI() :
734 SalomeApp_Module( "SMESH" )
736 if ( CORBA::is_nil( myComponentSMESH ) )
738 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
739 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
740 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
743 myActiveDialogBox = 0 ;
746 SMESH::GetFilterManager();
749 /* load resources for all available meshers */
750 SMESH::InitAvailableHypotheses();
753 //=============================================================================
757 //=============================================================================
758 SMESHGUI::~SMESHGUI()
760 SMESH::GetFilterManager()->Destroy();
763 //=============================================================================
767 //=============================================================================
768 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
770 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
772 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
777 bool SMESHGUI::automaticUpdate()
779 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
783 return resMgr->booleanValue( "SMESH", "auto_update", false );
786 //=============================================================================
790 //=============================================================================
791 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
793 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
796 //=============================================================================
800 //=============================================================================
801 SMESHGUI* SMESHGUI::GetSMESHGUI()
803 SMESHGUI* smeshMod = 0;
804 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
807 CAM_Module* module = app->module( "Mesh" );
808 smeshMod = dynamic_cast<SMESHGUI*>( module );
811 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
813 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
816 _PTR(Study) aStudy = study->studyDS();
818 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
827 Standard_EXPORT SMESHGUI* GetComponentGUI()
829 return SMESHGUI::GetSMESHGUI();
833 //=============================================================================
837 //=============================================================================
838 void SMESHGUI::SetState(int aState)
843 //=============================================================================
847 //=============================================================================
848 void SMESHGUI::ResetState()
853 //=============================================================================
857 //=============================================================================
858 void SMESHGUI::EmitSignalDeactivateDialog()
860 printf( "sln: EmitSignalDeactivateDialog EmitSignalDeactivateDialog EmitSignalDeactivateDialog\n" );
861 emit SignalDeactivateActiveDialog();
864 //=============================================================================
868 //=============================================================================
869 void SMESHGUI::EmitSignalStudyFrameChanged()
871 emit SignalStudyFrameChanged();
874 //=============================================================================
878 //=============================================================================
879 void SMESHGUI::EmitSignalCloseAllDialogs()
881 emit SignalCloseAllDialogs();
884 //=============================================================================
888 //=============================================================================
889 QDialog *SMESHGUI::GetActiveDialogBox()
891 return myActiveDialogBox;
894 //=============================================================================
898 //=============================================================================
899 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
901 myActiveDialogBox = (QDialog *) aDlg;
905 //=============================================================================
909 //=============================================================================
910 SUIT_Desktop* SMESHGUI::desktop()
912 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
914 return app->desktop();
919 //=============================================================================
923 //=============================================================================
924 SalomeApp_Study* SMESHGUI::activeStudy()
926 SUIT_Application* app = SUIT_Session::session()->activeApplication();
928 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
933 //=============================================================================
937 //=============================================================================
938 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
940 /* Here the position is on the bottom right corner - 10 */
941 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
943 SUIT_Desktop *PP = desktop();
944 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
945 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
949 //=============================================================================
953 //=============================================================================
954 static int isStudyLocked(_PTR(Study) theStudy){
955 return theStudy->GetProperties()->IsLocked();
958 static bool checkLock(_PTR(Study) theStudy) {
959 if (isStudyLocked(theStudy)) {
960 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
961 QObject::tr("WRN_WARNING"),
962 QObject::tr("WRN_STUDY_LOCKED"),
963 QObject::tr("BUT_OK") );
969 //=======================================================================
970 //function : CheckActiveStudyLocked
972 //=======================================================================
974 bool SMESHGUI::isActiveStudyLocked()
976 _PTR(Study) aStudy = activeStudy()->studyDS();
977 return checkLock( aStudy );
980 //=============================================================================
984 //=============================================================================
985 bool SMESHGUI::OnGUIEvent( int theCommandID )
987 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
991 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
992 SUIT_ResourceMgr* mgr = resourceMgr();
996 SUIT_Operation* anOp = getOperation( theCommandID );
1003 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1004 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1006 QAction* act = action( theCommandID );
1008 switch (theCommandID) {
1010 startOperation( 33 );
1017 if(checkLock(aStudy)) break;
1018 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1022 case 122: // EXPORT MED
1029 ::ExportMeshToFile(theCommandID);
1033 case 200: // SCALAR BAR
1035 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1036 SALOME_ListIO selected;
1038 aSel->selectedObjects( selected );
1040 if( selected.Extent() ) {
1041 Handle(SALOME_InteractiveObject) anIO = selected.First();
1042 if( anIO->hasEntry() ) {
1043 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1044 anActor->SetControlMode( SMESH_Actor::eNone );
1052 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1056 case 1134: // Clipping
1057 case 1133: // Tranparency
1058 case 1132: // Colors / Size
1065 ::SetDisplayMode(theCommandID);
1071 case 219: // Volumes
1072 case 220: // All Entity
1073 ::SetDisplayEntity(theCommandID);
1078 if(checkLock(aStudy)) break;
1079 SMESH::UpdateView();
1082 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1083 aSel->setSelectedObjects( l );
1088 case 301: // DISPLAY
1089 case 302: // DISPLAY ONLY
1091 SMESH::EDisplaing anAction;
1092 switch(theCommandID){
1093 case 300: anAction = SMESH::eErase; break;
1094 case 301: anAction = SMESH::eDisplay; break;
1095 case 302: anAction = SMESH::eDisplayOnly; break;
1098 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1099 SALOME_ListIO selected;
1101 aSel->selectedObjects( selected );
1104 SALOME_ListIteratorOfListIO It(selected);
1105 for (; It.More(); It.Next()) {
1106 Handle(SALOME_InteractiveObject) IOS = It.Value();
1107 if (IOS->hasEntry()) {
1108 SMESH::UpdateView(anAction,IOS->getEntry());
1113 aSel->setSelectedObjects( l1 );
1119 if(checkLock(aStudy)) break;
1120 startOperation( 400 );
1123 EmitSignalDeactivateDialog();
1125 new SMESHGUI_NodesDlg(this);
1128 SUIT_MessageBox::warn1(desktop(),
1129 tr("SMESH_WRN_WARNING"),
1130 tr("SMESH_WRN_VIEWER_VTK"),
1131 tr("SMESH_BUT_OK"));
1136 case 2151: // FILTER
1140 EmitSignalDeactivateDialog();
1141 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1146 case 406: // MOVE NODE
1150 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1151 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1155 if(checkLock(aStudy)) break;
1156 startOperation( 406 );
1157 // new SMESHGUI_MoveNodesDlg(this);
1161 case 701: // COMPUTE MESH
1163 if(checkLock(aStudy)) break;
1165 SalomeApp_SelectionMgr *Sel = selectionMgr();
1166 SALOME_ListIO selected; Sel->selectedObjects( selected );
1168 int nbSel = selected.Extent();
1173 SMESH::SMESH_Mesh_var aMesh;
1174 SMESH::SMESH_subMesh_var aSubMesh;
1175 Handle(SALOME_InteractiveObject) IObject = selected.First();
1176 if (IObject->hasEntry()){
1177 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1178 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1179 if ( aShapeObject->_is_nil() ) {
1184 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1185 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1187 if (!aMesh->_is_nil()){
1188 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1189 if (!refShapeObject->_is_nil()) {
1190 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1191 SUIT_MessageBox::warn1(desktop(),
1192 tr("SMESH_WRN_WARNING"),
1193 tr("SMESH_WRN_MISSING_PARAMETERS"),
1194 tr("SMESH_BUT_OK"));
1198 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1199 SMESH::ModifiedMesh(aMeshSObj,true);
1200 // TO Do : change icon of all submeshes
1202 SUIT_MessageBox::warn1(desktop(),
1203 tr("SMESH_WRN_WARNING"),
1204 tr("SMESH_WRN_COMPUTE_FAILED"),
1205 tr("SMESH_BUT_OK"));
1207 catch(const SALOME::SALOME_Exception & S_ex){
1208 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1211 }else if(!aSubMesh->_is_nil()){
1212 aMesh = aSubMesh->GetFather();
1213 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1214 if(!refShapeObject->_is_nil()){
1215 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1217 SUIT_MessageBox::warn1(desktop(),
1218 tr("SMESH_WRN_WARNING"),
1219 tr("SMESH_WRN_MISSING_PARAMETERS"),
1220 tr("SMESH_BUT_OK"));
1224 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1225 SMESH::ModifiedMesh(aMeshSObj,true);
1226 // TO Do : change icon of all submeshes
1228 SUIT_MessageBox::warn1(desktop(),
1229 tr("SMESH_WRN_WARNING"),
1230 tr("SMESH_WRN_COMPUTE_FAILED"),
1231 tr("SMESH_BUT_OK"));
1232 }catch(const SALOME::SALOME_Exception & S_ex){
1233 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1239 CORBA::Long anId = aStudy->StudyId();
1240 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1241 if ( automaticUpdate() && aVisualObj){
1242 aVisualObj->Update();
1243 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1245 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1247 SMESH::DisplayActor(view,anActor); //apo
1253 SUIT_MessageBox::warn1(desktop(),
1254 tr("SMESH_WRN_WARNING"),
1255 tr("SMESH_WRN_VIEWER_VTK"),
1256 tr("SMESH_BUT_OK"));
1262 case 702: // ADD SUB MESH
1264 if(checkLock(aStudy)) break;
1265 startOperation( 702 );
1267 EmitSignalDeactivateDialog();
1268 new SMESHGUI_AddSubMeshDlg( this );
1271 SUIT_MessageBox::warn1(desktop(),
1272 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1273 tr("SMESH_BUT_OK"));
1278 case 703: // INIT MESH
1280 if(checkLock(aStudy)) break;
1281 startOperation( 703 );
1285 case 704: // EDIT Hypothesis
1287 if(checkLock(aStudy)) break;
1288 startOperation( 704 );
1292 case 705: // EDIT Global Hypothesis
1294 if(checkLock(aStudy)) break;
1295 startOperation( 704 );
1299 case 706: // EDIT Local Hypothesis
1301 if(checkLock(aStudy)) break;
1302 startOperation( 704 );
1306 case 407: // DIAGONAL INVERSION
1307 case 408: // Delete diagonal
1311 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1312 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1316 if ( checkLock( aStudy ) )
1319 /*Standard_Boolean aRes;
1320 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1321 if ( aMesh->_is_nil() )
1323 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1324 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1328 EmitSignalDeactivateDialog();
1329 if ( theCommandID == 407 )
1330 startOperation( 407 );
1332 startOperation( 408 );
1335 case 409: // Change orientation
1336 case 410: // Union of triangles
1337 case 411: // Cutting of quadrangles
1341 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1342 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1346 if ( checkLock( aStudy ) )
1349 startOperation( theCommandID );
1351 /* EmitSignalDeactivateDialog();
1352 SMESHGUI_MultiEditDlg* aDlg = NULL;
1353 if ( theCommandID == 409 )
1354 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1355 else if ( theCommandID == 410 )
1356 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1358 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1361 DefineDlgPosition( aDlg, x, y );
1366 case 412: // Smoothing
1368 if(checkLock(aStudy)) break;
1370 EmitSignalDeactivateDialog();
1371 new SMESHGUI_SmoothingDlg( this );
1374 SUIT_MessageBox::warn1(desktop(),
1375 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1376 tr("SMESH_BUT_OK"));
1380 case 413: // Extrusion
1382 if( checkLock( aStudy) )
1384 startOperation( 413 );
1386 EmitSignalDeactivateDialog();
1387 new SMESHGUI_ExtrusionDlg ( this );
1389 SUIT_MessageBox::warn1(desktop(),
1390 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1391 tr("SMESH_BUT_OK"));
1395 case 414: // Revolution
1397 if(checkLock(aStudy)) break;
1399 EmitSignalDeactivateDialog();
1400 new SMESHGUI_RevolutionDlg( this );
1403 SUIT_MessageBox::warn1(desktop(),
1404 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1405 tr("SMESH_BUT_OK"));
1409 case 415: // Pattern mapping
1411 if ( checkLock( aStudy ) )
1415 EmitSignalDeactivateDialog();
1416 new SMESHGUI_MeshPatternDlg( this );
1419 SUIT_MessageBox::warn1(desktop(),
1420 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1421 tr("SMESH_BUT_OK"));
1425 case 416: // Extrusion along a path
1427 if (checkLock(aStudy)) break;
1429 EmitSignalDeactivateDialog();
1430 new SMESHGUI_ExtrusionAlongPathDlg( this );
1432 SUIT_MessageBox::warn1(desktop(),
1433 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1434 tr("SMESH_BUT_OK"));
1438 case 801: // CREATE GROUP
1442 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1443 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1447 if(checkLock(aStudy)) break;
1448 EmitSignalDeactivateDialog();
1449 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1451 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1452 SALOME_ListIO selected;
1454 aSel->selectedObjects( selected );
1456 int nbSel = selected.Extent();
1458 // check if mesh is selected
1459 aMesh = SMESH::GetMeshByIO( selected.First() );
1461 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1466 case 802: // CONSTRUCT GROUP
1470 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1471 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1475 if(checkLock(aStudy)) break;
1476 EmitSignalDeactivateDialog();
1478 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1479 SALOME_ListIO selected;
1481 aSel->selectedObjects( selected );
1483 int nbSel = selected.Extent();
1485 // check if submesh is selected
1486 Handle(SALOME_InteractiveObject) IObject = selected.First();
1487 if (IObject->hasEntry()) {
1488 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1490 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1491 if (!aSubMesh->_is_nil()) {
1493 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1494 // get submesh elements list by types
1495 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1496 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1497 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1498 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1499 // create group for each type o elements
1500 QString aName = IObject->getName();
1501 if (aNodes->length() > 0) {
1502 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1503 aGroup->Add(aNodes.inout());
1505 if (aEdges->length() > 0) {
1506 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1507 aGroup->Add(aEdges.inout());
1509 if (aFaces->length() > 0) {
1510 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1511 aGroup->Add(aFaces.inout());
1513 if (aVolumes->length() > 0) {
1514 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1515 aGroup->Add(aVolumes.inout());
1519 }catch(const SALOME::SALOME_Exception & S_ex){
1520 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1529 case 803: // EDIT GROUP
1533 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1534 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1538 if(checkLock(aStudy)) break;
1539 EmitSignalDeactivateDialog();
1541 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1542 SALOME_ListIO selected;
1544 aSel->selectedObjects( selected );
1546 SALOME_ListIteratorOfListIO It (selected);
1547 int nbSelectedGroups = 0;
1548 for ( ; It.More(); It.Next() )
1550 SMESH::SMESH_Group_var aGroup =
1551 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1552 if (!aGroup->_is_nil()) {
1554 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1558 if (nbSelectedGroups == 0)
1560 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1566 case 804: // Add elements to group
1568 if(checkLock(aStudy)) break;
1569 if (myState == 800) {
1570 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1571 if (aDlg) aDlg->onAdd();
1576 case 805: // Remove elements from group
1578 if(checkLock(aStudy)) break;
1579 if (myState == 800) {
1580 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1581 if (aDlg) aDlg->onRemove();
1586 case 810: // Union Groups
1587 case 811: // Intersect groups
1588 case 812: // Cut groups
1590 if( !checkLock( aStudy ) )
1591 startOperation( theCommandID );
1595 case 813: // Delete groups with their contents
1599 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1600 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1604 if ( checkLock( aStudy ) )
1607 EmitSignalDeactivateDialog();
1609 new SMESHGUI_DeleteGroupDlg( this );
1613 case 900: // MESH INFOS
1615 EmitSignalDeactivateDialog();
1616 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1617 SALOME_ListIO selected;
1619 aSel->selectedObjects( selected );
1621 if ( selected.Extent() > 1 ) { // a dlg for each IO
1623 SALOME_ListIteratorOfListIO It (selected);
1624 for ( ; It.More(); It.Next() ) {
1625 IOs.Clear(); IOs.Append( It.Value() );
1626 aSel->setSelectedObjects( IOs );
1627 new SMESHGUI_MeshInfosDlg(this, "", false);
1629 // restore selection
1630 aSel->setSelectedObjects( selected );
1633 new SMESHGUI_MeshInfosDlg(this, "", false);
1637 case 902: // STANDARD MESH INFOS
1639 EmitSignalDeactivateDialog();
1640 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1641 SALOME_ListIO selected;
1643 aSel->selectedObjects( selected );
1645 if ( selected.Extent() > 1 ) { // a dlg for each IO
1647 SALOME_ListIteratorOfListIO It (selected);
1648 for ( ; It.More(); It.Next() ) {
1650 IOs.Append( It.Value() );
1651 aSel->setSelectedObjects( IOs );
1652 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1654 // restore selection
1655 aSel->setSelectedObjects( selected );
1658 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1662 case 1001: // AUTOMATIC UPDATE PREFERENCES
1664 // if (act->isOn()) {
1665 // mgr->setValue( "SMESH", "AutomaticUpdate", true );
1666 // myAutomaticUpdate = true;
1669 // mgr->setValue( "SMESH", "AutomaticUpdate", false );
1670 // myAutomaticUpdate = false;
1675 case 1003: // MESH PREFERENCES
1677 ::SetDisplaySettings();
1683 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( this );
1689 ( new SMESHGUI_PrecisionDlg( this ) )->exec();
1696 mgr->setValue( "SMESH", "DispayEntity", true );
1699 mgr->setValue( "SMESH", "DispayEntity", false );
1705 SMESHGUI_Preferences_SelectionDlg* aDlg =
1706 new SMESHGUI_Preferences_SelectionDlg( this );
1708 QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
1709 aDlg->SetColor(1, aColor);
1711 aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow );
1712 aDlg->SetColor(2, aColor);
1714 aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white );
1715 aDlg->SetColor(3, aColor);
1717 aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) );
1718 aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) );
1719 aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) );
1720 aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) );
1723 QColor aPreColor = aDlg->GetColor(1),
1724 aSelColor = aDlg->GetColor(2),
1725 aHiColor = aDlg->GetColor(3);
1726 int aPreWidth = aDlg->GetWidth(1),
1727 aSelWidth = aDlg->GetWidth(2);
1728 double aTolNodes = aDlg->GetPrecision(1),
1729 aTolItems = aDlg->GetPrecision(2);
1731 mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor );
1732 mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor );
1733 mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor );
1735 mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth );
1736 mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth );
1737 mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes );
1738 mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems );
1740 // update current study settings
1741 SMESH::UpdateSelectionProp( this );
1744 // update VTK viewer properties
1745 SVTK_RenderWindowInteractor* anInteractor =
1746 dynamic_cast<SVTK_RenderWindowInteractor*>( vtkwnd->getRWInteractor() );
1748 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1749 aSelColor.blue()/255., aSelWidth);
1750 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1751 SVTK_InteractorStyle* aStyle =
1752 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
1755 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1756 aPreColor.blue()/255., aPreWidth);
1759 vtkRenderer* aRenderer = vtkwnd->getRenderer();
1760 vtkActorCollection *aCollection = aRenderer->GetActors();
1761 aCollection->InitTraversal();
1762 while(vtkActor *anAct = aCollection->GetNextActor()){
1763 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1764 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1765 aHiColor.blue()/255.);
1766 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1767 aPreColor.blue()/255.);
1776 case 1100: // EDIT HYPOTHESIS
1778 if(checkLock(aStudy)) break;
1780 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1781 SALOME_ListIO selected;
1783 aSel->selectedObjects( selected );
1785 int nbSel = selected.Extent();
1788 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1790 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1791 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1792 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1793 if ( !Hyp->_is_nil() )
1795 char* sName = Hyp->GetName();
1796 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1799 aCreator->EditHypothesis(Hyp);
1807 updateObjBrowser( true );
1811 case 1101: // RENAME
1813 if ( checkLock( aStudy ) )
1816 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1817 SALOME_ListIO selected;
1819 aSel->selectedObjects( selected );
1821 SALOME_ListIteratorOfListIO It( selected );
1822 for ( ; It.More(); It.Next() )
1824 Handle(SALOME_InteractiveObject) IObject = It.Value();
1825 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1826 _PTR(GenericAttribute) anAttr;
1827 _PTR(AttributeName) aName;
1830 if ( obj->FindAttribute(anAttr, "AttributeName") )
1833 QString newName = QString(aName->Value().c_str());
1834 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1835 if ( !newName.isEmpty() )
1837 //old source: aStudy->renameIObject( IObject, newName );
1838 aName->SetValue( newName.latin1() );
1840 // if current object is group update group's name
1841 SMESH::SMESH_GroupBase_var aGroup =
1842 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1843 if (!aGroup->_is_nil() )
1844 aGroup->SetName( newName.latin1() );
1854 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1856 if(checkLock(aStudy)) break;
1857 SUIT_OverrideCursor wc;
1859 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1860 SALOME_ListIO selected;
1862 aSel->selectedObjects( selected );
1864 SALOME_ListIteratorOfListIO It(selected);
1865 for (int i = 0; It.More(); It.Next(), i++) {
1866 Handle(SALOME_InteractiveObject) IObject = It.Value();
1867 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1870 aSel->setSelectedObjects( l1 );
1875 case 401: // GEOM::EDGE
1876 case 4021: // TRIANGLE
1878 case 4023: // POLYGON
1882 if(checkLock(aStudy)) break;
1883 startOperation( theCommandID );
1885 EmitSignalDeactivateDialog();
1886 SMDSAbs_ElementType type = SMDSAbs_Edge;
1888 switch (theCommandID) {
1889 case 4021: // TRIANGLE
1890 type = SMDSAbs_Face; nbNodes = 3; break;
1892 type = SMDSAbs_Face; nbNodes = 4; break;
1894 type = SMDSAbs_Volume; nbNodes = 4; break;
1895 case 4023: // POLYGON
1896 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1898 type = SMDSAbs_Volume; nbNodes = 8; break;
1899 case 4033: // POLYHEDRE
1900 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1903 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1906 SUIT_MessageBox::warn1(desktop(),
1907 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1908 tr("SMESH_BUT_OK"));
1912 case 4033: // POLYHEDRON
1914 if(checkLock(aStudy)) break;
1916 EmitSignalDeactivateDialog();
1917 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1920 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1921 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1922 tr("SMESH_BUT_OK"));
1926 case 4041: // REMOVES NODES
1928 if(checkLock(aStudy)) break;
1929 startOperation( 4041 );
1931 EmitSignalDeactivateDialog();
1932 new SMESHGUI_RemoveNodesDlg(this);
1935 SUIT_MessageBox::warn1(desktop(),
1936 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1937 tr("SMESH_BUT_OK"));
1941 case 4042: // REMOVES ELEMENTS
1943 if(checkLock(aStudy)) break;
1944 startOperation( 4042 );
1946 EmitSignalDeactivateDialog();
1947 new SMESHGUI_RemoveElementsDlg(this);
1951 SUIT_MessageBox::warn1(desktop(),
1952 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1953 tr("SMESH_BUT_OK"));
1957 case 4051: // RENUMBERING NODES
1959 if(checkLock(aStudy)) break;
1960 startOperation( 4051 );
1962 EmitSignalDeactivateDialog();
1963 new SMESHGUI_RenumberingDlg( this, "", 0);
1967 SUIT_MessageBox::warn1(desktop(),
1968 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1969 tr("SMESH_BUT_OK"));
1973 case 4052: // RENUMBERING ELEMENTS
1975 if(checkLock(aStudy)) break;
1976 startOperation( 4052 );
1978 EmitSignalDeactivateDialog();
1979 new SMESHGUI_RenumberingDlg( this, "", 1);
1983 SUIT_MessageBox::warn1(desktop(),
1984 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1985 tr("SMESH_BUT_OK"));
1989 case 4061: // TRANSLATION
1991 if(checkLock(aStudy)) break;
1993 EmitSignalDeactivateDialog();
1994 new SMESHGUI_TranslationDlg( this );
1997 SUIT_MessageBox::warn1(desktop(),
1998 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1999 tr("SMESH_BUT_OK"));
2003 case 4062: // ROTATION
2005 if(checkLock(aStudy)) break;
2007 EmitSignalDeactivateDialog();
2008 new SMESHGUI_RotationDlg( this );
2011 SUIT_MessageBox::warn1(desktop(),
2012 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2013 tr("SMESH_BUT_OK"));
2017 case 4063: // SYMMETRY
2019 if(checkLock(aStudy)) break;
2021 EmitSignalDeactivateDialog();
2022 new SMESHGUI_SymmetryDlg( this );
2025 SUIT_MessageBox::warn1(desktop(),
2026 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2027 tr("SMESH_BUT_OK"));
2031 case 4064: // SEWING
2033 if(checkLock(aStudy)) break;
2035 EmitSignalDeactivateDialog();
2036 new SMESHGUI_SewingDlg( this );
2039 SUIT_MessageBox::warn1(desktop(),
2040 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2041 tr("SMESH_BUT_OK"));
2045 case 4065: // MERGE NODES
2047 if(checkLock(aStudy)) break;
2049 EmitSignalDeactivateDialog();
2050 new SMESHGUI_MergeNodesDlg( this );
2053 SUIT_MessageBox::warn1(desktop(),
2054 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2055 tr("SMESH_BUT_OK"));
2061 case 5000: // HYPOTHESIS
2063 if(checkLock(aStudy)) break;
2064 EmitSignalDeactivateDialog();
2065 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2070 if(checkLock(aStudy)) break;
2071 EmitSignalDeactivateDialog();
2072 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2076 case 5105: // Library of selection filters
2078 static QValueList<int> aTypes;
2079 if ( aTypes.isEmpty() )
2081 aTypes.append( SMESH::NODE );
2082 aTypes.append( SMESH::EDGE );
2083 aTypes.append( SMESH::FACE );
2084 aTypes.append( SMESH::VOLUME );
2086 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2090 case 6017: // CONTROLS
2105 SalomeApp_SelectionMgr* mgr = selectionMgr();
2106 SALOME_ListIO selected; mgr->selectedObjects( selected );
2108 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2109 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2111 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2112 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2113 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2114 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2115 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2116 ::Control( theCommandID );
2121 SUIT_MessageBox::warn1(desktop(),
2122 tr( "SMESH_WRN_WARNING" ),
2123 tr( "SMESH_BAD_SELECTION" ),
2124 tr( "SMESH_BUT_OK" ) );
2128 SUIT_MessageBox::warn1(desktop(),
2129 tr( "SMESH_WRN_WARNING" ),
2130 tr( "NOT_A_VTK_VIEWER" ),
2131 tr( "SMESH_BUT_OK" ) );
2136 SalomeApp_SelectionMgr* mgr = selectionMgr();
2137 SALOME_ListIO selected; mgr->selectedObjects( selected );
2139 if (selected.Extent() == 1) {
2140 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2141 if(anIObject->hasEntry())
2142 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2143 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2150 SalomeApp_SelectionMgr* mgr = selectionMgr();
2151 SALOME_ListIO selected; mgr->selectedObjects( selected );
2153 if (selected.Extent() == 1) {
2154 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2155 if(anIObject->hasEntry())
2156 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2157 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2162 case 10001: // DISPLAY MODE PREFERENCE
2166 action( 10002 )->setOn( false );
2167 action( 10004 )->setOn( false );
2168 action( 10003 )->setOn( true );
2169 mgr->setValue( "SMESH", "DisplayMode", "Wireframe");
2175 action( 10001 )->setOn( false );
2176 action( 10004 )->setOn( false );
2177 action( 10003 )->setOn( true );
2178 mgr->setValue( "SMESH", "DisplayMode", "Shading");
2183 mgr->setValue( "SMESH", "Shrink", act->isOn() );
2189 action( 10001 )->setOn( false );
2190 action( 10002 )->setOn( false );
2191 action( 10003 )->setOn( false );
2192 mgr->setValue( "SMESH", "DisplayMode", "Nodes" );
2198 //updateObjBrowser();
2202 //=============================================================================
2206 //=============================================================================
2207 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2212 //=============================================================================
2216 //=============================================================================
2217 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2222 //=============================================================================
2226 //=============================================================================
2227 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2232 //=============================================================================
2236 //=============================================================================
2237 bool SMESHGUI::SetSettings(SUIT_Desktop* parent)
2239 SMESHGUI::GetSMESHGUI();
2241 SUIT_ResourceMgr* mgr = resourceMgr();
2246 QString DisplayMode = "Shading";
2247 if ( mgr->hasValue("SMESH","DisplayMode") )
2248 DisplayMode = mgr->stringValue("SMESH","DisplayMode");
2250 mgr->setValue("SMESH","DisplayMode", "Shading");
2252 bool Shrink = false;
2253 if ( mgr->hasValue("SMESH","Shrink") )
2254 Shrink = mgr->stringValue("SMESH","Shrink") == "yes";
2256 if (DisplayMode == "Wireframe") {
2258 action( 10004 )->setOn( false );
2259 action( 10002 )->setOn( false );
2260 action( 10001 )->setOn( true );
2261 action( 10003 )->setOn( true );
2263 else if (DisplayMode == "Nodes") {
2265 action( 10004 )->setOn( true );
2266 action( 10002 )->setOn( false );
2267 action( 10001 )->setOn( false );
2268 action( 10003 )->setOn( false );
2271 // default is shading
2272 action( 10004 )->setOn( false );
2273 action( 10002 )->setOn( true );
2274 action( 10001 )->setOn( false );
2275 action( 10003 )->setOn( true );
2278 action( 10003 )->setOn( Shrink );
2281 // if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) {
2282 // action( 1001 )->setOn( true );
2283 // myAutomaticUpdate = true;
2286 // action( 1001 )->setOn( false );
2287 // myAutomaticUpdate = false;
2290 if ( mgr->booleanValue( "SMESH","DispayEntity", false ) )
2291 action( 10071 )->setOn( true );
2293 action( 10071 )->setOn( false );
2296 SMESH::UpdateSelectionProp( this );
2299 action( 111 )->setEnabled( false ); // IMPORT DAT
2301 //action( 112 )->setEnabled( false );
2302 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2307 //=============================================================================
2308 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2309 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2311 //=============================================================================
2312 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2313 SUIT_ViewWindow* wnd )
2315 if(theIO->hasEntry()){
2316 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2317 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2321 //=======================================================================
2322 // function : createSMESHAction
2324 //=======================================================================
2325 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2328 QWidget* parent = application()->desktop();
2329 SUIT_ResourceMgr* resMgr = resourceMgr();
2331 if ( icon_id.length() )
2332 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2334 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2335 if ( !pix.isNull() )
2336 icon = QIconSet( pix );
2338 QString tooltip = tr( QString( "TOP_" )+po_id ),
2339 menu = tr( QString( "MEN_" )+po_id ),
2340 status_bar = tr( QString( "STB_" )+po_id );
2342 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2345 //=======================================================================
2346 // function : createPopupItem
2348 //=======================================================================
2349 void SMESHGUI::createPopupItem( const int id,
2350 const QString& clients,
2351 const QString& types,
2352 const QString& theRule,
2357 parentId = popupMgr()->actionId( action( pId ) );
2359 // if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2360 popupMgr()->insert( action( id ), parentId, 0 );
2362 QChar lc = QtxPopupMgr::Selection::defEquality();
2363 QString rule = "(%1) and (%2) and (%3)";
2364 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2365 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2366 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2369 bool cont = myRules.contains( id );
2371 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2373 popupMgr()->setRule( action( id ), rule, true );
2374 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2377 //=======================================================================
2378 // function : initialize
2380 //=======================================================================
2381 void SMESHGUI::initialize( CAM_Application* app )
2383 SalomeApp_Module::initialize( app );
2385 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2387 /* Automatic Update flag */
2388 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2390 // ----- create actions --------------
2392 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2393 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2394 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2395 createSMESHAction( 114, "NUM" );
2396 createSMESHAction( 121, "DAT" );
2397 createSMESHAction( 122, "MED" );
2398 createSMESHAction( 123, "UNV" );
2399 createSMESHAction( 124, "EXPORT_DAT" );
2400 createSMESHAction( 125, "EXPORT_MED" );
2401 createSMESHAction( 126, "EXPORT_UNV" );
2402 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2403 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2404 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2405 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2406 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2407 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2408 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2409 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2410 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2411 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2412 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2413 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2414 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2415 createSMESHAction( 804, "ADD" );
2416 createSMESHAction( 805, "REMOVE" );
2417 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2418 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2419 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2420 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2421 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2422 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2423 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2424 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2425 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2426 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2427 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2428 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2429 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2430 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2431 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2432 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2433 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2434 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2435 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2436 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2437 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2438 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2439 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2440 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2441 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2442 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2443 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2444 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2445 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2446 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2447 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2448 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2449 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2450 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2451 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2452 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2453 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2454 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2455 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2456 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2457 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2458 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2459 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2460 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2461 createSMESHAction( 415, "MAP", "ICON_MAP" );
2462 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2463 createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true );
2464 createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true );
2465 createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true );
2466 createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true );
2467 createSMESHAction( 1001, "AUTO_UPD", "", 0, true );
2468 createSMESHAction( 1003, "COLORS" );
2469 createSMESHAction( 1005, "SCALAR_BAR" );
2470 createSMESHAction( 1006, "SELECTION" );
2471 createSMESHAction( 10070, "PRECISION", "", 0, true );
2472 createSMESHAction( 10071, "DISP_ENT", "", 0, true );
2473 createSMESHAction( 200, "RESET" );
2474 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2475 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2476 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2477 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2478 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2479 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2480 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2481 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2482 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2483 createSMESHAction( 220, "ALL" );
2484 createSMESHAction( 1100, "EDIT_HYPO" );
2485 createSMESHAction( 1101, "RENAME" );
2486 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2487 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2488 createSMESHAction( 1131, "DISPMODE" );
2489 createSMESHAction( 1132, "COLORS" );
2490 createSMESHAction( 1133, "TRANSP" );
2491 createSMESHAction( 1134, "CLIP" );
2492 createSMESHAction( 1135, "DISP_ENT" );
2493 createSMESHAction( 2000, "CTRL" );
2495 createSMESHAction( 300, "ERASE" );
2496 createSMESHAction( 301, "DISPLAY" );
2497 createSMESHAction( 302, "DISPLAY_ONLY" );
2498 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2500 // ----- create menu --------------
2501 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2502 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2503 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2504 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2505 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2506 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2507 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2508 prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ),
2509 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2511 createMenu( separator(), fileId );
2513 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2514 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2516 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2517 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2518 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2519 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
2521 meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ),
2523 dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ),
2524 qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 );
2526 createMenu( 111, importId, -1 );
2527 createMenu( 112, importId, -1 );
2528 createMenu( 113, importId, -1 );
2530 createMenu( 121, exportId, -1 );
2531 createMenu( 122, exportId, -1 );
2532 createMenu( 123, exportId, -1 );
2534 createMenu( separator(), fileId, 10 );
2536 createMenu( 33, editId, -1 );
2538 createMenu( 5105, toolsId, -1 );
2540 createMenu( 5000, hypoId, -1 );
2541 createMenu( 5010, hypoId, -1 );
2543 createMenu( 703, meshId, -1 );
2544 createMenu( 702, meshId, -1 );
2545 createMenu( 704, meshId, -1 );
2546 createMenu( separator(), meshId, -1 );
2547 createMenu( 701, meshId, -1 );
2548 createMenu( separator(), meshId, -1 );
2549 createMenu( 801, meshId, -1 );
2550 createMenu( 802, meshId, -1 );
2551 createMenu( 803, meshId, -1 );
2552 createMenu( separator(), meshId, -1 );
2553 createMenu( 810, meshId, -1 );
2554 createMenu( 811, meshId, -1 );
2555 createMenu( 812, meshId, -1 );
2556 createMenu( separator(), meshId, -1 );
2557 createMenu( 813, meshId, -1 );
2558 createMenu( separator(), meshId, -1 );
2559 createMenu( 900, meshId, -1 );
2560 createMenu( 902, meshId, -1 );
2561 createMenu( separator(), meshId, -1 );
2563 createMenu( 6003, ctrlId, -1 );
2564 createMenu( 6001, ctrlId, -1 );
2565 createMenu( 6004, ctrlId, -1 );
2566 createMenu( separator(), ctrlId, -1 );
2567 createMenu( 6002, ctrlId, -1 );
2568 createMenu( 6018, ctrlId, -1 );
2569 createMenu( 6019, ctrlId, -1 );
2570 createMenu( 6011, ctrlId, -1 );
2571 createMenu( 6012, ctrlId, -1 );
2572 createMenu( 6013, ctrlId, -1 );
2573 createMenu( 6014, ctrlId, -1 );
2574 createMenu( 6015, ctrlId, -1 );
2575 createMenu( 6016, ctrlId, -1 );
2576 createMenu( separator(), ctrlId, -1 );
2577 createMenu( 6017, ctrlId, -1 );
2578 createMenu( separator(), ctrlId, -1 );
2580 createMenu( 400, addId, -1 );
2581 createMenu( 401, addId, -1 );
2582 createMenu( 4021, addId, -1 );
2583 createMenu( 4022, addId, -1 );
2584 createMenu( 4023, addId, -1 );
2585 createMenu( 4031, addId, -1 );
2586 createMenu( 4032, addId, -1 );
2587 createMenu( 4033, addId, -1 );
2589 createMenu( 4041, removeId, -1 );
2590 createMenu( 4042, removeId, -1 );
2592 createMenu( 4051, renumId, -1 );
2593 createMenu( 4052, renumId, -1 );
2595 createMenu( 4061, transfId, -1 );
2596 createMenu( 4062, transfId, -1 );
2597 createMenu( 4063, transfId, -1 );
2598 createMenu( 4064, transfId, -1 );
2599 createMenu( 4065, transfId, -1 );
2601 createMenu( 406, modifyId, -1 );
2602 createMenu( 407, modifyId, -1 );
2603 createMenu( 408, modifyId, -1 );
2604 createMenu( 409, modifyId, -1 );
2605 createMenu( 410, modifyId, -1 );
2606 createMenu( 411, modifyId, -1 );
2607 createMenu( 412, modifyId, -1 );
2608 createMenu( 413, modifyId, -1 );
2609 createMenu( 416, modifyId, -1 );
2610 createMenu( 414, modifyId, -1 );
2611 createMenu( 415, modifyId, -1 );
2613 createMenu( 10001, dispModeId, -1 );
2614 createMenu( 10002, dispModeId, -1 );
2615 createMenu( 10004, dispModeId, -1 );
2616 createMenu( 10003, dispModeId, -1 );
2618 createMenu( 1001, prefId, -1 );
2619 createMenu( separator(), prefId, -1 );
2620 createMenu( 1003, prefId, -1 );
2621 createMenu( separator(), prefId, -1 );
2622 createMenu( 1005, prefId, -1 );
2623 createMenu( separator(), prefId, -1 );
2624 createMenu( 1006, prefId, -1 );
2625 createMenu( separator(), prefId, -1 );
2627 createMenu( 10070, qualityId, -1 );
2628 createMenu( 10071, qualityId, -1 );
2630 createMenu( separator(), prefId, -1 );
2632 createMenu( 214, viewId, -1 );
2634 // ----- create toolbars --------------
2635 int meshTb = createTool( tr( "TB_MESH" ) ),
2636 hypoTb = createTool( tr( "TB_HYPO" ) ),
2637 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2638 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2639 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2640 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2642 createTool( 703, meshTb );
2643 createTool( 702, meshTb );
2644 createTool( 704, meshTb );
2645 createTool( separator(), meshTb );
2646 createTool( 701, meshTb );
2647 createTool( separator(), meshTb );
2648 createTool( 801, meshTb );
2649 createTool( 802, meshTb );
2650 createTool( 803, meshTb );
2651 createTool( separator(), meshTb );
2652 createTool( 900, meshTb );
2653 createTool( 902, meshTb );
2654 createTool( separator(), meshTb );
2656 createTool( 5000, hypoTb );
2657 createTool( 5010, hypoTb );
2659 createTool( 6001, ctrlTb );
2660 createTool( 6003, ctrlTb );
2661 createTool( 6004, ctrlTb );
2662 createTool( separator(), ctrlTb );
2663 createTool( 6002, ctrlTb );
2664 createTool( 6018, ctrlTb );
2665 createTool( 6019, ctrlTb );
2666 createTool( 6011, ctrlTb );
2667 createTool( 6012, ctrlTb );
2668 createTool( 6013, ctrlTb );
2669 createTool( 6014, ctrlTb );
2670 createTool( 6015, ctrlTb );
2671 createTool( 6016, ctrlTb );
2672 createTool( separator(), ctrlTb );
2673 createTool( 6017, ctrlTb );
2674 createTool( separator(), ctrlTb );
2676 createTool( 400, addRemTb );
2677 createTool( 401, addRemTb );
2678 createTool( 4021, addRemTb );
2679 createTool( 4022, addRemTb );
2680 createTool( 4023, addRemTb );
2681 createTool( 4031, addRemTb );
2682 createTool( 4032, addRemTb );
2683 createTool( 4033, addRemTb );
2684 createTool( separator(), addRemTb );
2685 createTool( 4041, addRemTb );
2686 createTool( 4042, addRemTb );
2687 createTool( separator(), addRemTb );
2688 createTool( 4051, addRemTb );
2689 createTool( 4052, addRemTb );
2690 createTool( separator(), addRemTb );
2691 createTool( 4061, addRemTb );
2692 createTool( 4062, addRemTb );
2693 createTool( 4063, addRemTb );
2694 createTool( 4064, addRemTb );
2695 createTool( 4065, addRemTb );
2696 createTool( separator(), addRemTb );
2698 createTool( 406, modifyTb );
2699 createTool( 407, modifyTb );
2700 createTool( 408, modifyTb );
2701 createTool( 409, modifyTb );
2702 createTool( 410, modifyTb );
2703 createTool( 411, modifyTb );
2704 createTool( 412, modifyTb );
2705 createTool( 413, modifyTb );
2706 createTool( 416, modifyTb );
2707 createTool( 414, modifyTb );
2708 createTool( 415, modifyTb );
2710 createTool( 214, dispModeTb );
2714 QString OB = "'ObjectBrowser'",
2715 View = "'" + SVTK_Viewer::Type() + "'",
2717 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2718 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2719 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2720 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2721 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2722 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2723 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2724 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2725 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2726 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2728 mesh_group = mesh + " " + subMesh + " " + group,
2729 hyp_alg = hypo + " " + algo;
2731 // popup for object browser
2733 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2734 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2735 createPopupItem( 803, OB, group ); // EDIT_GROUP
2736 popupMgr()->insert( separator(), -1, 0 );
2737 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2738 createPopupItem( 214, OB, mesh_group ); // UPDATE
2739 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2740 createPopupItem( 902, OB, mesh ); // STD_INFO
2741 popupMgr()->insert( separator(), -1, 0 );
2742 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2743 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2744 popupMgr()->insert( separator(), -1, 0 );
2745 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2746 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2747 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2748 popupMgr()->insert( separator(), -1, 0 );
2749 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2750 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2751 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2752 popupMgr()->insert( separator(), -1, 0 );
2755 createPopupItem( 803, View, group ); // EDIT_GROUP
2756 createPopupItem( 804, View, elems ); // ADD
2757 createPopupItem( 805, View, elems ); // REMOVE
2758 popupMgr()->insert( separator(), -1, 0 );
2759 createPopupItem( 214, View, mesh_group ); // UPDATE
2760 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2761 createPopupItem( 902, View, mesh ); // STD_INFO
2762 popupMgr()->insert( separator(), -1, 0 );
2766 isInvisible("not( isVisible )"),
2767 isEmpty("numberOfNodes = 0"),
2768 isNotEmpty("numberOfNodes <> 0"),
2770 // has nodes, edges, etc in VISIBLE! actor
2771 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2772 hasElems("(count( elemTypes ) > 0)"),
2773 hasDifferentElems("(count( elemTypes ) > 1)"),
2774 hasEdges("({'Edge'} in elemTypes)"),
2775 hasFaces("({'Face'} in elemTypes)"),
2776 hasVolumes("({'Volume'} in elemTypes)");
2778 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2779 QString lc = QtxPopupMgr::Selection::defEquality();
2780 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2781 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2782 QString aMeshInVTK = aClient + "&&" + aType;// + "&&" + aSelCount;
2784 //-------------------------------------------------
2786 //-------------------------------------------------
2787 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2789 popupMgr()->insert( action( 9010 ), anId, -1 );
2790 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true );
2791 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2793 popupMgr()->insert( action( 9011 ), anId, -1 );
2794 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true );
2795 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2797 popupMgr()->insert( separator(), -1, -1 );
2799 //-------------------------------------------------
2801 //-------------------------------------------------
2802 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2804 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2805 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2806 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2808 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2809 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2810 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2812 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2813 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2814 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2816 popupMgr()->insert( separator(), anId, -1 );
2818 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2819 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2820 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2822 //-------------------------------------------------
2824 //-------------------------------------------------
2825 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2827 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2829 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2830 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true );
2831 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2833 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2834 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true );
2835 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2837 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2838 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true );
2839 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2841 popupMgr()->insert( separator(), anId, -1 );
2843 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2844 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true );
2846 //-------------------------------------------------
2848 //-------------------------------------------------
2849 popupMgr()->insert( action( 1132 ), -1, -1 );
2850 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2852 //-------------------------------------------------
2854 //-------------------------------------------------
2855 popupMgr()->insert( action( 1133 ), -1, -1 );
2856 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2858 //-------------------------------------------------
2860 //-------------------------------------------------
2861 popupMgr()->insert( action( 1134 ), -1, -1 );
2862 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2864 popupMgr()->insert( separator(), -1, -1 );
2866 //-------------------------------------------------
2868 //-------------------------------------------------
2870 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2871 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2872 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2874 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2876 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2877 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2879 popupMgr()->insert( separator(), anId, -1 );
2881 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2882 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2883 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2885 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2886 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2887 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2889 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2890 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2891 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2893 popupMgr()->insert( separator(), anId, -1 );
2895 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2896 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2897 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2899 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2900 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2901 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2903 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2904 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2905 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2907 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2908 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2909 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2911 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2912 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2913 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2915 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2916 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2917 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2919 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2920 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2921 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2923 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2924 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2925 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2927 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2928 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2929 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2931 popupMgr()->insert( separator(), anId, -1 );
2933 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2934 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2935 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2937 popupMgr()->insert( separator(), anId, -1 );
2939 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2940 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2942 popupMgr()->insert( separator(), -1, -1 );
2944 //-------------------------------------------------
2946 //-------------------------------------------------
2947 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2948 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
2949 QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
2950 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2951 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
2953 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2954 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
2956 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2957 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
2959 popupMgr()->insert( separator(), -1, -1 );
2961 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
2962 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
2965 bool SMESHGUI::activateModule( SUIT_Study* study )
2967 bool res = SalomeApp_Module::activateModule( study );
2969 setMenuShown( true );
2970 setToolShown( true );
2971 SetSettings( desktop() );
2976 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2978 setMenuShown( false );
2979 setToolShown( false );
2981 EmitSignalCloseAllDialogs();
2983 return SalomeApp_Module::deactivateModule( study );
2986 void SMESHGUI::OnGUIEvent()
2988 const QObject* obj = sender();
2989 if ( !obj || !obj->inherits( "QAction" ) )
2991 int id = actionId((QAction*)obj);
2996 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2998 if ( CORBA::is_nil( myComponentSMESH ) )
3000 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3001 return aGUI.myComponentSMESH;
3003 return myComponentSMESH;
3006 QString SMESHGUI::engineIOR() const
3008 CORBA::ORB_var anORB = getApp()->orb();
3009 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3013 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3015 SMESHGUI_Selection sel;
3016 sel.init( client, selectionMgr() );
3017 popupMgr()->updatePopup( menu, &sel );
3020 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3022 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3023 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3026 void SMESHGUI::viewManagers( QStringList& list ) const
3028 list.append( SVTK_Viewer::Type() );
3031 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
3033 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
3034 SMESH::UpdateSelectionProp( this );
3037 void SMESHGUI::createPreferences()
3039 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3041 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3042 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "display_entity" );
3043 addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "auto_update" );
3045 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3046 setPreferenceProperty( precGroup, "columns", 1 );
3048 addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool );
3049 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3051 setPreferenceProperty( prec, "min", 0 );
3052 setPreferenceProperty( prec, "max", 16 );
3054 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3055 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3057 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
3058 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
3060 setPreferenceProperty( nodeSz, "min", 1 );
3061 setPreferenceProperty( nodeSz, "max", 5 );
3063 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3065 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
3066 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
3067 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
3068 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
3070 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
3071 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3073 setPreferenceProperty( elemW, "min", 1 );
3074 setPreferenceProperty( elemW, "max", 5 );
3076 setPreferenceProperty( shrink, "min", 0 );
3077 setPreferenceProperty( shrink, "max", 100 );
3079 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3081 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3083 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
3084 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
3085 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
3087 setPreferenceProperty( selW, "min", 1 );
3088 setPreferenceProperty( selW, "max", 5 );
3090 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3092 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
3093 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3095 setPreferenceProperty( preW, "min", 1 );
3096 setPreferenceProperty( preW, "max", 5 );
3098 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3100 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
3101 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
3104 void SMESHGUI::preferencesChanged( const QString&, const QString& )
3108 //=======================================================================
3109 // function : onOperationCommited
3110 // purpose : SLOT called when operation commited. Set default selection mode
3111 //=======================================================================
3112 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3114 SVTK_ViewWindow* vtkWnd =
3115 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3117 vtkWnd->SetSelectionMode( ActorSelection );
3120 //=======================================================================
3121 // function : onOperationAborted
3122 // purpose : SLOT called when operation commited. Set default selection mode
3123 //=======================================================================
3124 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3126 SVTK_ViewWindow* vtkWnd =
3127 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3129 vtkWnd->SetSelectionMode( ActorSelection );
3132 //=======================================================================
3133 // function : getOperation
3134 // purpose : Get operation corresponding to the given Id
3135 //=======================================================================
3136 SalomeApp_Operation* SMESHGUI::getOperation( const int theId )
3138 if ( myOperations.contains( theId ) )
3139 return myOperations[ theId ];
3142 SalomeApp_Operation* anOp = 0;
3152 anOp->setModule( this );
3153 connect( anOp, SIGNAL( aborted( SUIT_Operation* ) ),
3154 this, SLOT( onOperationAborted( SUIT_Operation* ) ) );
3155 connect( anOp, SIGNAL( commited( SUIT_Operation* ) ),
3156 this, SLOT( onOperationCommited( SUIT_Operation* ) ) );
3157 myOperations[ theId ] = anOp;
3164 //=======================================================================
3165 // function : update
3166 // purpose : Update something
3167 //=======================================================================
3168 void SMESHGUI::update( const int flags )
3170 if ( flags & UF_Viewer | flags & UF_Forced )
3171 SMESH::UpdateView();
3173 SalomeApp_Module::update( flags );
3176 //=======================================================================
3177 // function : updateControls
3178 // purpose : Update state of controls
3179 //=======================================================================
3180 void SMESHGUI::updateControls()
3185 //=======================================================================
3186 // function : updateControls
3187 // purpose : Update state of controls
3188 //=======================================================================
3189 SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
3191 SalomeApp_Operation* op = 0;
3195 op = new SMESHGUI_DeleteOp();
3199 op = new SMESHGUI_NodesOp();
3203 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Edge, 2 );
3206 case 406: // MOVE NODE
3207 op = new SMESHGUI_MoveNodesOp();
3211 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 3 );
3215 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 4 );
3219 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 5 ); // 5 - identificator for POLYGON
3223 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 4 );
3227 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 8 );
3230 case 4041: //REMOVE NODES
3231 op = new SMESHGUI_RemoveOp( false );
3234 case 4042: //REMOVE ELEMENTS
3235 op = new SMESHGUI_RemoveOp( true );
3238 case 4051: // RENUMBERING NODES
3239 op = new SMESHGUI_RenumberingOp( 0 );
3242 case 4052: // RENUMBERING ELEMENTS
3243 op = new SMESHGUI_RenumberingOp( 1 );
3247 op = new SMESHGUI_AddSubMeshOp();
3251 op = new SMESHGUI_InitMeshOp();
3255 op = new SMESHGUI_EditHypothesesOp();
3259 op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::UNION );
3263 op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::INTERSECT );
3267 op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::CUT );
3270 /* case 409: // Change orientation
3271 op = new SMESHGUI_ChangeOrientationOp();
3274 case 410: // Union of triangles
3275 op = new SMESHGUI_UnionOfTrianglesDlg();
3278 /* case 411: // Cutting of quadrangles
3279 op = new SMESHGUI_CuttingOfQuadsDlg();
3283 op = new SMESHGUI_ExtrusionOp();
3287 op = SalomeApp_Module::createOperation( id );