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_RemoveNodesOp.h"
36 #include "SMESHGUI_RemoveElementsDlg.h"
37 #include "SMESHGUI_MeshInfosDlg.h"
38 #include "SMESHGUI_StandardMeshInfosDlg.h"
39 #include "SMESHGUI_Preferences_ColorDlg.h"
40 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
41 #include "SMESHGUI_Preferences_SelectionDlg.h"
42 #include "SMESHGUI_Hypotheses.h"
43 #include "SMESHGUI_HypothesesUtils.h"
44 #include "SMESHGUI_MoveNodesDlg.h"
45 #include "SMESHGUI_AddMeshElementOp.h"
46 #include "SMESHGUI_EditHypothesesOp.h"
47 #include "SMESHGUI_CreateHypothesesDlg.h"
48 #include "SMESHGUI_FilterDlg.h"
49 #include "SMESHGUI_FilterLibraryDlg.h"
50 #include "SMESHGUI_SingleEditDlg.h"
51 #include "SMESHGUI_MultiEditDlg.h"
52 #include "SMESHGUI_GroupOp.h"
53 #include "SMESHGUI_DeleteGroupDlg.h"
54 #include "SMESHGUI_SmoothingDlg.h"
55 #include "SMESHGUI_RenumberingDlg.h"
56 #include "SMESHGUI_ExtrusionDlg.h"
57 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
58 #include "SMESHGUI_RevolutionDlg.h"
59 #include "SMESHGUI_TranslationDlg.h"
60 #include "SMESHGUI_RotationDlg.h"
61 #include "SMESHGUI_SymmetryDlg.h"
62 #include "SMESHGUI_SewingDlg.h"
63 #include "SMESHGUI_MergeNodesDlg.h"
64 #include "SMESHGUI_MeshPatternDlg.h"
65 #include "SMESHGUI_PrecisionDlg.h"
66 #include "SMESHGUI_Selection.h"
67 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
69 #include <SVTK_InteractorStyle.h>
70 #include <SVTK_RenderWindowInteractor.h>
72 #include "SMESH_Actor.h"
73 #include "SMESH_Object.h"
74 #include "SMESH_TypeFilter.hxx"
76 #include "SUIT_Tools.h"
77 #include "SUIT_MessageBox.h"
78 #include "SUIT_ResourceMgr.h"
79 #include "SUIT_FileDlg.h"
80 #include "SUIT_Desktop.h"
81 #include "SUIT_ResourceMgr.h"
82 #include "SUIT_OverrideCursor.h"
83 #include "SUIT_Study.h"
84 #include "SUIT_Session.h"
86 #include "SALOME_NamingService.hxx"
87 #include "SALOME_ListIteratorOfListIO.hxx"
88 #include "SALOME_InteractiveObject.hxx"
89 #include "SALOME_ListIO.hxx"
90 #include <SALOME_LifeCycleCORBA.hxx>
92 #include "OB_Browser.h"
94 #include "QtxPopupMgr.h"
96 #include "SalomeApp_Tools.h"
97 #include "SalomeApp_Study.h"
98 #include "SalomeApp_NameDlg.h"
99 #include "SalomeApp_DataOwner.h"
100 #include "SalomeApp_Application.h"
101 #include "SalomeApp_Preferences.h"
102 #include "SalomeApp_VTKSelector.h"
103 #include "SalomeApp_Operation.h"
104 #include "SalomeApp_UpdateFlags.h"
106 #include "SalomeApp_ImportOperation.h"
108 #include <SVTK_ViewWindow.h>
109 #include <SVTK_ViewModel.h>
111 #include <VTKViewer_ViewManager.h>
113 #include "SMESHGUI_Utils.h"
114 #include "SMESHGUI_GEOMGenUtils.h"
115 #include "SMESHGUI_MeshUtils.h"
116 #include "SMESHGUI_GroupUtils.h"
117 #include "SMESHGUI_FilterUtils.h"
118 #include "SMESHGUI_PatternUtils.h"
119 #include "SMESHGUI_VTKUtils.h"
121 #include "SALOMEconfig.h"
122 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
125 #define INCLUDE_MENUITEM_DEF
126 #include <qapplication.h>
127 #include <qlineedit.h>
128 #include <qmenudata.h>
129 #include <qmenubar.h>
130 #include <qpopupmenu.h>
133 #include <qpainter.h>
134 #include <qcheckbox.h>
135 #include <qcolordialog.h>
136 #include <qspinbox.h>
141 #include <qradiobutton.h>
143 #include <boost/shared_ptr.hpp>
145 #include <vtkRenderer.h>
146 #include <vtkRenderWindow.h>
147 #include <vtkActorCollection.h>
148 #include <vtkScalarBarActor.h>
149 #include <vtkUnstructuredGrid.h>
151 #include "utilities.h"
153 #include "SALOMEDS_Study.hxx"
154 #include "SALOMEDSClient_StudyBuilder.hxx"
155 #include "SALOMEDSClient_SComponent.hxx"
161 //=============================================================
162 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
165 void ExportMeshToFile(int theCommandID);
167 void SetDisplayMode(int theCommandID);
169 void SetDisplayEntity(int theCommandID);
171 void Control( int theCommandID );
173 void SetDisplaySettings();
177 //=============================================================
178 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
184 if(theCommandID == 113){
185 filter.append(QObject::tr("MED files (*.med)"));
186 filter.append(QObject::tr("All files (*)"));
187 }else if (theCommandID == 112){
188 filter.append(QObject::tr("IDEAS files (*.unv)"));
189 }else if (theCommandID == 111){
190 filter.append(QObject::tr("DAT files (*.dat)"));
192 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
195 QObject::tr("Import mesh"),
197 if(!filename.isEmpty()) {
198 SUIT_OverrideCursor wc;
199 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
202 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
203 switch ( theCommandID ) {
206 aMeshes->length( 1 );
207 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
212 SMESH::DriverMED_ReadStatus res;
213 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
214 if ( res != SMESH::DRS_OK ) {
216 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
217 QObject::tr("SMESH_WRN_WARNING"),
218 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
219 QObject::tr("SMESH_BUT_OK"));
220 aMeshes->length( 0 );
227 bool isEmpty = false;
228 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
229 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
231 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
232 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
233 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
234 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
235 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
242 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
243 QObject::tr("SMESH_WRN_WARNING"),
244 QObject::tr("SMESH_DRS_EMPTY"),
245 QObject::tr("SMESH_BUT_OK"));
249 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
251 catch (const SALOME::SALOME_Exception& S_ex){
253 SalomeApp_Tools::QtCatchCorbaException(S_ex);
260 void ExportMeshToFile( int theCommandID )
262 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
263 SALOME_ListIO selected;
265 aSel->selectedObjects( selected );
267 if(selected.Extent()){
268 Handle(SALOME_InteractiveObject) anIObject = selected.First();
269 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
270 if ( !aMesh->_is_nil() ) {
271 QString aFilter, aTitle = QObject::tr("Export mesh");
272 QMap<QString, SMESH::MED_VERSION> aFilterMap;
273 switch ( theCommandID ) {
276 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
277 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
281 aFilter = QObject::tr("DAT files (*.dat)");
285 if(aMesh->NbPyramids()){
286 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
287 QObject::tr("SMESH_WRN_WARNING"),
288 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
289 QObject::tr("SMESH_BUT_YES"),
290 QObject::tr("SMESH_BUT_NO"),
295 aFilter = QObject::tr("IDEAS files (*.unv)");
302 SMESH::MED_VERSION aFormat;
304 if ( theCommandID != 122 && theCommandID != 125 )
305 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
309 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
310 filters.push_back( it.key() );
312 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
313 fd->setCaption( aTitle );
314 fd->setFilters( filters );
318 aFilename = fd->selectedFile();
319 aFormat = aFilterMap[fd->selectedFilter()];
321 if( !aFilename.isEmpty()
322 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
323 && aFormat==SMESH::MED_V2_1){
324 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
325 QObject::tr("SMESH_WRN_WARNING"),
326 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
327 QObject::tr("SMESH_BUT_YES"),
328 QObject::tr("SMESH_BUT_NO"),
337 if ( !aFilename.isEmpty() ) {
338 // Check whether the file already exists and delete it if yes
339 QFile aFile( aFilename );
340 if ( aFile.exists() )
342 SUIT_OverrideCursor wc;
343 switch ( theCommandID ) {
346 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
350 aMesh->ExportDAT( aFilename.latin1() );
354 aMesh->ExportUNV( aFilename.latin1() );
364 inline void InverseEntityMode(unsigned int& theOutputMode,
365 unsigned int theMode)
367 bool anIsNotPresent = ~theOutputMode & theMode;
369 theOutputMode |= theMode;
371 theOutputMode &= ~theMode;
374 void SetDisplayEntity(int theCommandID){
375 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
376 SALOME_ListIO selected;
378 aSel->selectedObjects( selected );
380 if(selected.Extent() >= 1){
381 SALOME_ListIteratorOfListIO It( selected );
382 for(; It.More(); It.Next()){
383 Handle(SALOME_InteractiveObject) IObject = It.Value();
384 if(IObject->hasEntry()){
385 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
386 unsigned int aMode = anActor->GetEntityMode();
387 switch(theCommandID){
389 InverseEntityMode(aMode,SMESH_Actor::eEdges);
392 InverseEntityMode(aMode,SMESH_Actor::eFaces);
395 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
398 aMode = SMESH_Actor::eAllEntity;
402 anActor->SetEntityMode(aMode);
409 void SetDisplayMode(int theCommandID){
410 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
411 SALOME_ListIO selected;
413 aSel->selectedObjects( selected );
415 if(selected.Extent() >= 1){
416 switch(theCommandID){
418 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
419 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
423 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
424 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
427 SALOME_ListIteratorOfListIO It( selected );
428 for(; It.More(); It.Next()){
429 Handle(SALOME_InteractiveObject) IObject = It.Value();
430 if(IObject->hasEntry()){
431 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
432 switch(theCommandID){
434 anActor->SetRepresentation(SMESH_Actor::eEdge);
437 anActor->SetRepresentation(SMESH_Actor::eSurface);
440 if(anActor->IsShrunk())
443 anActor->SetShrink();
446 anActor->SetRepresentation(SMESH_Actor::ePoint);
450 anActor->GetSufaceColor(color[0], color[1], color[2]);
451 int c0 = int (color[0] * 255);
452 int c1 = int (color[1] * 255);
453 int c2 = int (color[2] * 255);
454 QColor c(c0, c1, c2);
457 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
458 c0 = int (edgecolor[0] * 255);
459 c1 = int (edgecolor[1] * 255);
460 c2 = int (edgecolor[2] * 255);
461 QColor e(c0, c1, c2);
463 float backfacecolor[3];
464 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
465 c0 = int (backfacecolor[0] * 255);
466 c1 = int (backfacecolor[1] * 255);
467 c2 = int (backfacecolor[2] * 255);
468 QColor b(c0, c1, c2);
471 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
472 c0 = int (nodecolor[0] * 255);
473 c1 = int (nodecolor[1] * 255);
474 c2 = int (nodecolor[2] * 255);
475 QColor n(c0, c1, c2);
477 int Edgewidth = (int)anActor->GetLineWidth();
480 int intValue = int(anActor->GetNodeSize());
481 float Shrink = anActor->GetShrinkFactor();
483 SMESHGUI_Preferences_ColorDlg *aDlg =
484 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
485 aDlg->SetColor(1, c);
486 aDlg->SetColor(2, e);
487 aDlg->SetColor(3, n);
488 aDlg->SetColor(4, b);
489 aDlg->SetIntValue(1, Edgewidth);
490 aDlg->SetIntValue(2, intValue);
491 aDlg->SetIntValue(3, int(Shrink*100.));
493 QColor color = aDlg->GetColor(1);
494 QColor edgecolor = aDlg->GetColor(2);
495 QColor nodecolor = aDlg->GetColor(3);
496 QColor backfacecolor = aDlg->GetColor(4);
497 /* actor color and backface color */
498 anActor->SetSufaceColor(float (color.red()) / 255.,
499 float (color.green()) / 255.,
500 float (color.blue()) / 255.);
501 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
502 float (backfacecolor.green()) / 255.,
503 float (backfacecolor.blue()) / 255.);
506 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
507 float (edgecolor.green()) / 255.,
508 float (edgecolor.blue()) / 255.);
510 /* Shrink factor and size edges */
511 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
512 anActor->SetLineWidth(aDlg->GetIntValue(1));
514 /* Nodes color and size */
515 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
516 float (nodecolor.green()) / 255.,
517 float (nodecolor.blue()) / 255.);
518 anActor->SetNodeSize(aDlg->GetIntValue(2));
527 SMESH::RepaintCurrentView();
532 void SetDisplaySettings()
534 SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
538 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
539 SMESHGUI_Preferences_ColorDlg *aDlg =
540 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
542 QColor color = mgr->colorValue( "SMESH", "SettingsFillColor", QColor(0, 170, 255) );
543 aDlg->SetColor(1, color);
545 color = mgr->colorValue( "SMESH", "SettingsOutlineColor", QColor(0, 170, 255) );
546 aDlg->SetColor(2, color);
548 color = mgr->colorValue( "SMESH", "SettingsNodeColor", Qt::red );
549 aDlg->SetColor(3, color);
551 color = mgr->colorValue( "SMESH", "SettingsBackFaceColor", Qt::blue );
552 aDlg->SetColor(4, color);
554 int iVal = mgr->integerValue( "SMESH", "SettingsWidth", 1 );
555 aDlg->SetIntValue(1, iVal);
557 iVal = mgr->integerValue( "SMESH", "SettingsNodesSize", 3 );
558 aDlg->SetIntValue(2, iVal);
560 iVal = mgr->integerValue( "SMESH", "SettingsShrinkCoeff", 75 );
561 aDlg->SetIntValue(3, iVal);
564 mgr->setValue( "SMESH", "SettingsFillColor", aDlg->GetColor(1) );
565 mgr->setValue( "SMESH", "SettingsOutlineColor", aDlg->GetColor(2) );
566 mgr->setValue( "SMESH", "SettingsNodeColor", aDlg->GetColor(3) );
567 mgr->setValue( "SMESH", "SettingsBackFaceColor", aDlg->GetColor(4) );
569 mgr->setValue( "SMESH", "SettingsWidth", aDlg->GetIntValue(1) );
570 mgr->setValue( "SMESH", "SettingsNodesSize", aDlg->GetIntValue(2) );
571 mgr->setValue( "SMESH", "SettingsShrinkCoeff", aDlg->GetIntValue(3) );
578 void Control( int theCommandID )
580 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
581 SALOME_ListIO selected;
583 aSel->selectedObjects( selected );
585 if( !selected.IsEmpty() ){
586 Handle(SALOME_InteractiveObject) anIO = selected.First();
589 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
590 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
591 switch ( theCommandID ){
593 aTitle = QObject::tr( "LENGTH_EDGES" );
594 aControl = SMESH_Actor::eLength;
597 aTitle = QObject::tr( "LENGTH2D_EDGES" );
598 aControl = SMESH_Actor::eLength2D;
601 aTitle = QObject::tr( "FREE_EDGES" );
602 aControl = SMESH_Actor::eFreeEdges;
605 aTitle = QObject::tr( "FREE_BORDERS" );
606 aControl = SMESH_Actor::eFreeBorders;
609 aTitle = QObject::tr( "MULTI_BORDERS" );
610 aControl = SMESH_Actor::eMultiConnection;
613 aTitle = QObject::tr( "MULTI2D_BORDERS" );
614 aControl = SMESH_Actor::eMultiConnection2D;
617 aTitle = QObject::tr( "AREA_ELEMENTS" );
618 aControl = SMESH_Actor::eArea;
621 aTitle = QObject::tr( "TAPER_ELEMENTS" );
622 aControl = SMESH_Actor::eTaper;
625 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
626 aControl = SMESH_Actor::eAspectRatio;
629 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
630 aControl = SMESH_Actor::eAspectRatio3D;
633 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
634 aControl = SMESH_Actor::eMinimumAngle;
637 aTitle = QObject::tr( "WARP_ELEMENTS" );
638 aControl = SMESH_Actor::eWarping;
641 aTitle = QObject::tr( "SKEW_ELEMENTS" );
642 aControl = SMESH_Actor::eSkew;
645 anActor->SetControlMode(aControl);
646 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
653 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
654 MeshObjectType theType,
655 const QString theInTypeName,
656 QString & theOutTypeName)
658 SMESH_TypeFilter aTypeFilter( theType );
660 if( !theIO.IsNull() )
662 entry = theIO->getEntry();
663 SalomeApp_DataOwner owner( entry );
664 if ( aTypeFilter.isOk( &owner )) {
665 theOutTypeName = theInTypeName;
673 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
675 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
676 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
678 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
679 CORBA::String_var anID = aSComp->GetID().c_str();
680 if (!strcmp(anID.in(),theIO->getEntry()))
686 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
687 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
688 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
689 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
690 CheckOIType ( theIO, GROUP, "Group", aTypeName )
698 QString CheckHomogeneousSelection()
700 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
701 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
702 SALOME_ListIO selected;
704 aSel->selectedObjects( selected );
706 QString RefType = CheckTypeObject(selected.First());
707 SALOME_ListIteratorOfListIO It(selected);
708 for (; It.More(); It.Next())
710 Handle(SALOME_InteractiveObject) IObject = It.Value();
711 QString Type = CheckTypeObject(IObject);
712 if (Type.compare(RefType) != 0)
713 return "Heterogeneous Selection";
721 Standard_EXPORT CAM_Module* createModule()
723 return new SMESHGUI();
727 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
729 //=============================================================================
733 //=============================================================================
734 SMESHGUI::SMESHGUI() :
735 SalomeApp_Module( "SMESH" )
737 if ( CORBA::is_nil( myComponentSMESH ) )
739 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
740 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
741 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
744 myActiveDialogBox = 0 ;
747 SMESH::GetFilterManager();
750 /* load resources for all available meshers */
751 SMESH::InitAvailableHypotheses();
754 //=============================================================================
758 //=============================================================================
759 SMESHGUI::~SMESHGUI()
761 SMESH::GetFilterManager()->Destroy();
764 //=============================================================================
768 //=============================================================================
769 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
771 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
773 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
778 bool SMESHGUI::automaticUpdate()
780 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
784 return resMgr->booleanValue( "SMESH", "auto_update", false );
787 //=============================================================================
791 //=============================================================================
792 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
794 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
797 //=============================================================================
801 //=============================================================================
802 SMESHGUI* SMESHGUI::GetSMESHGUI()
804 SMESHGUI* smeshMod = 0;
805 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
808 CAM_Module* module = app->module( "Mesh" );
809 smeshMod = dynamic_cast<SMESHGUI*>( module );
812 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
814 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
817 _PTR(Study) aStudy = study->studyDS();
819 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
828 Standard_EXPORT SMESHGUI* GetComponentGUI()
830 return SMESHGUI::GetSMESHGUI();
834 //=============================================================================
838 //=============================================================================
839 void SMESHGUI::SetState(int aState)
844 //=============================================================================
848 //=============================================================================
849 void SMESHGUI::ResetState()
854 //=============================================================================
858 //=============================================================================
859 void SMESHGUI::EmitSignalDeactivateDialog()
861 printf( "sln: EmitSignalDeactivateDialog EmitSignalDeactivateDialog EmitSignalDeactivateDialog\n" );
862 emit SignalDeactivateActiveDialog();
865 //=============================================================================
869 //=============================================================================
870 void SMESHGUI::EmitSignalStudyFrameChanged()
872 emit SignalStudyFrameChanged();
875 //=============================================================================
879 //=============================================================================
880 void SMESHGUI::EmitSignalCloseAllDialogs()
882 emit SignalCloseAllDialogs();
885 //=============================================================================
889 //=============================================================================
890 QDialog *SMESHGUI::GetActiveDialogBox()
892 return myActiveDialogBox;
895 //=============================================================================
899 //=============================================================================
900 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
902 myActiveDialogBox = (QDialog *) aDlg;
906 //=============================================================================
910 //=============================================================================
911 SUIT_Desktop* SMESHGUI::desktop()
913 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
915 return app->desktop();
920 //=============================================================================
924 //=============================================================================
925 SalomeApp_Study* SMESHGUI::activeStudy()
927 SUIT_Application* app = SUIT_Session::session()->activeApplication();
929 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
934 //=============================================================================
938 //=============================================================================
939 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
941 /* Here the position is on the bottom right corner - 10 */
942 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
944 SUIT_Desktop *PP = desktop();
945 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
946 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
950 //=============================================================================
954 //=============================================================================
955 static int isStudyLocked(_PTR(Study) theStudy){
956 return theStudy->GetProperties()->IsLocked();
959 static bool checkLock(_PTR(Study) theStudy) {
960 if (isStudyLocked(theStudy)) {
961 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
962 QObject::tr("WRN_WARNING"),
963 QObject::tr("WRN_STUDY_LOCKED"),
964 QObject::tr("BUT_OK") );
970 //=======================================================================
971 //function : CheckActiveStudyLocked
973 //=======================================================================
975 bool SMESHGUI::isActiveStudyLocked()
977 _PTR(Study) aStudy = activeStudy()->studyDS();
978 return checkLock( aStudy );
981 //=============================================================================
985 //=============================================================================
986 bool SMESHGUI::OnGUIEvent( int theCommandID )
988 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
992 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
993 SUIT_ResourceMgr* mgr = resourceMgr();
997 SUIT_Operation* anOp = getOperation( theCommandID );
1004 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1005 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1007 QAction* act = action( theCommandID );
1009 switch (theCommandID) {
1011 startOperation( 33 );
1018 if(checkLock(aStudy)) break;
1019 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1023 case 122: // EXPORT MED
1030 ::ExportMeshToFile(theCommandID);
1034 case 200: // SCALAR BAR
1036 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1037 SALOME_ListIO selected;
1039 aSel->selectedObjects( selected );
1041 if( selected.Extent() ) {
1042 Handle(SALOME_InteractiveObject) anIO = selected.First();
1043 if( anIO->hasEntry() ) {
1044 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1045 anActor->SetControlMode( SMESH_Actor::eNone );
1053 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1057 case 1134: // Clipping
1058 case 1133: // Tranparency
1059 case 1132: // Colors / Size
1066 ::SetDisplayMode(theCommandID);
1072 case 219: // Volumes
1073 case 220: // All Entity
1074 ::SetDisplayEntity(theCommandID);
1079 if(checkLock(aStudy)) break;
1080 SMESH::UpdateView();
1083 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1084 aSel->setSelectedObjects( l );
1089 case 301: // DISPLAY
1090 case 302: // DISPLAY ONLY
1092 SMESH::EDisplaing anAction;
1093 switch(theCommandID){
1094 case 300: anAction = SMESH::eErase; break;
1095 case 301: anAction = SMESH::eDisplay; break;
1096 case 302: anAction = SMESH::eDisplayOnly; break;
1099 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1100 SALOME_ListIO selected;
1102 aSel->selectedObjects( selected );
1105 SALOME_ListIteratorOfListIO It(selected);
1106 for (; It.More(); It.Next()) {
1107 Handle(SALOME_InteractiveObject) IOS = It.Value();
1108 if (IOS->hasEntry()) {
1109 SMESH::UpdateView(anAction,IOS->getEntry());
1114 aSel->setSelectedObjects( l1 );
1120 if(checkLock(aStudy)) break;
1121 startOperation( 400 );
1124 EmitSignalDeactivateDialog();
1126 new SMESHGUI_NodesDlg(this);
1129 SUIT_MessageBox::warn1(desktop(),
1130 tr("SMESH_WRN_WARNING"),
1131 tr("SMESH_WRN_VIEWER_VTK"),
1132 tr("SMESH_BUT_OK"));
1137 case 2151: // FILTER
1141 EmitSignalDeactivateDialog();
1142 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1147 case 406: // MOVE NODE
1151 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1152 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1156 if(checkLock(aStudy)) break;
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 EmitSignalDeactivateDialog();
1350 SMESHGUI_MultiEditDlg* aDlg = NULL;
1351 if ( theCommandID == 409 )
1352 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1353 else if ( theCommandID == 410 )
1354 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1356 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1359 DefineDlgPosition( aDlg, x, y );
1364 case 412: // Smoothing
1366 if(checkLock(aStudy)) break;
1368 EmitSignalDeactivateDialog();
1369 new SMESHGUI_SmoothingDlg( this );
1372 SUIT_MessageBox::warn1(desktop(),
1373 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1374 tr("SMESH_BUT_OK"));
1378 case 413: // Extrusion
1380 if (checkLock(aStudy)) break;
1382 EmitSignalDeactivateDialog();
1383 new SMESHGUI_ExtrusionDlg ( this );
1385 SUIT_MessageBox::warn1(desktop(),
1386 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1387 tr("SMESH_BUT_OK"));
1391 case 414: // Revolution
1393 if(checkLock(aStudy)) break;
1395 EmitSignalDeactivateDialog();
1396 new SMESHGUI_RevolutionDlg( this );
1399 SUIT_MessageBox::warn1(desktop(),
1400 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1401 tr("SMESH_BUT_OK"));
1405 case 415: // Pattern mapping
1407 if ( checkLock( aStudy ) )
1411 EmitSignalDeactivateDialog();
1412 new SMESHGUI_MeshPatternDlg( this );
1415 SUIT_MessageBox::warn1(desktop(),
1416 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1417 tr("SMESH_BUT_OK"));
1421 case 416: // Extrusion along a path
1423 if (checkLock(aStudy)) break;
1425 EmitSignalDeactivateDialog();
1426 new SMESHGUI_ExtrusionAlongPathDlg( this );
1428 SUIT_MessageBox::warn1(desktop(),
1429 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1430 tr("SMESH_BUT_OK"));
1434 case 801: // CREATE GROUP
1438 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1439 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1443 if(checkLock(aStudy)) break;
1444 EmitSignalDeactivateDialog();
1445 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1447 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1448 SALOME_ListIO selected;
1450 aSel->selectedObjects( selected );
1452 int nbSel = selected.Extent();
1454 // check if mesh is selected
1455 aMesh = SMESH::GetMeshByIO( selected.First() );
1457 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1462 case 802: // CONSTRUCT GROUP
1466 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1467 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1471 if(checkLock(aStudy)) break;
1472 EmitSignalDeactivateDialog();
1474 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1475 SALOME_ListIO selected;
1477 aSel->selectedObjects( selected );
1479 int nbSel = selected.Extent();
1481 // check if submesh is selected
1482 Handle(SALOME_InteractiveObject) IObject = selected.First();
1483 if (IObject->hasEntry()) {
1484 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1486 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1487 if (!aSubMesh->_is_nil()) {
1489 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1490 // get submesh elements list by types
1491 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1492 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1493 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1494 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1495 // create group for each type o elements
1496 QString aName = IObject->getName();
1497 if (aNodes->length() > 0) {
1498 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1499 aGroup->Add(aNodes.inout());
1501 if (aEdges->length() > 0) {
1502 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1503 aGroup->Add(aEdges.inout());
1505 if (aFaces->length() > 0) {
1506 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1507 aGroup->Add(aFaces.inout());
1509 if (aVolumes->length() > 0) {
1510 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1511 aGroup->Add(aVolumes.inout());
1515 }catch(const SALOME::SALOME_Exception & S_ex){
1516 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1525 case 803: // EDIT GROUP
1529 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1530 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1534 if(checkLock(aStudy)) break;
1535 EmitSignalDeactivateDialog();
1537 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1538 SALOME_ListIO selected;
1540 aSel->selectedObjects( selected );
1542 SALOME_ListIteratorOfListIO It (selected);
1543 int nbSelectedGroups = 0;
1544 for ( ; It.More(); It.Next() )
1546 SMESH::SMESH_Group_var aGroup =
1547 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1548 if (!aGroup->_is_nil()) {
1550 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1554 if (nbSelectedGroups == 0)
1556 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1562 case 804: // Add elements to group
1564 if(checkLock(aStudy)) break;
1565 if (myState == 800) {
1566 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1567 if (aDlg) aDlg->onAdd();
1572 case 805: // Remove elements from group
1574 if(checkLock(aStudy)) break;
1575 if (myState == 800) {
1576 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1577 if (aDlg) aDlg->onRemove();
1582 case 810: // Union Groups
1583 case 811: // Intersect groups
1584 case 812: // Cut groups
1586 if( !checkLock( aStudy ) )
1587 startOperation( theCommandID );
1591 case 813: // Delete groups with their contents
1595 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1596 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1600 if ( checkLock( aStudy ) )
1603 EmitSignalDeactivateDialog();
1605 new SMESHGUI_DeleteGroupDlg( this );
1609 case 900: // MESH INFOS
1611 EmitSignalDeactivateDialog();
1612 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1613 SALOME_ListIO selected;
1615 aSel->selectedObjects( selected );
1617 if ( selected.Extent() > 1 ) { // a dlg for each IO
1619 SALOME_ListIteratorOfListIO It (selected);
1620 for ( ; It.More(); It.Next() ) {
1621 IOs.Clear(); IOs.Append( It.Value() );
1622 aSel->setSelectedObjects( IOs );
1623 new SMESHGUI_MeshInfosDlg(this, "", false);
1625 // restore selection
1626 aSel->setSelectedObjects( selected );
1629 new SMESHGUI_MeshInfosDlg(this, "", false);
1633 case 902: // STANDARD MESH INFOS
1635 EmitSignalDeactivateDialog();
1636 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1637 SALOME_ListIO selected;
1639 aSel->selectedObjects( selected );
1641 if ( selected.Extent() > 1 ) { // a dlg for each IO
1643 SALOME_ListIteratorOfListIO It (selected);
1644 for ( ; It.More(); It.Next() ) {
1646 IOs.Append( It.Value() );
1647 aSel->setSelectedObjects( IOs );
1648 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1650 // restore selection
1651 aSel->setSelectedObjects( selected );
1654 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1658 case 1001: // AUTOMATIC UPDATE PREFERENCES
1660 // if (act->isOn()) {
1661 // mgr->setValue( "SMESH", "AutomaticUpdate", true );
1662 // myAutomaticUpdate = true;
1665 // mgr->setValue( "SMESH", "AutomaticUpdate", false );
1666 // myAutomaticUpdate = false;
1671 case 1003: // MESH PREFERENCES
1673 ::SetDisplaySettings();
1679 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( this );
1685 ( new SMESHGUI_PrecisionDlg( this ) )->exec();
1692 mgr->setValue( "SMESH", "DispayEntity", true );
1695 mgr->setValue( "SMESH", "DispayEntity", false );
1701 SMESHGUI_Preferences_SelectionDlg* aDlg =
1702 new SMESHGUI_Preferences_SelectionDlg( this );
1704 QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
1705 aDlg->SetColor(1, aColor);
1707 aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow );
1708 aDlg->SetColor(2, aColor);
1710 aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white );
1711 aDlg->SetColor(3, aColor);
1713 aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) );
1714 aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) );
1715 aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) );
1716 aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) );
1719 QColor aPreColor = aDlg->GetColor(1),
1720 aSelColor = aDlg->GetColor(2),
1721 aHiColor = aDlg->GetColor(3);
1722 int aPreWidth = aDlg->GetWidth(1),
1723 aSelWidth = aDlg->GetWidth(2);
1724 double aTolNodes = aDlg->GetPrecision(1),
1725 aTolItems = aDlg->GetPrecision(2);
1727 mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor );
1728 mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor );
1729 mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor );
1731 mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth );
1732 mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth );
1733 mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes );
1734 mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems );
1736 // update current study settings
1737 SMESH::UpdateSelectionProp( this );
1740 // update VTK viewer properties
1741 SVTK_RenderWindowInteractor* anInteractor =
1742 dynamic_cast<SVTK_RenderWindowInteractor*>( vtkwnd->getRWInteractor() );
1744 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1745 aSelColor.blue()/255., aSelWidth);
1746 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1747 SVTK_InteractorStyle* aStyle =
1748 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
1751 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1752 aPreColor.blue()/255., aPreWidth);
1755 vtkRenderer* aRenderer = vtkwnd->getRenderer();
1756 vtkActorCollection *aCollection = aRenderer->GetActors();
1757 aCollection->InitTraversal();
1758 while(vtkActor *anAct = aCollection->GetNextActor()){
1759 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1760 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1761 aHiColor.blue()/255.);
1762 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1763 aPreColor.blue()/255.);
1772 case 1100: // EDIT HYPOTHESIS
1774 if(checkLock(aStudy)) break;
1776 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1777 SALOME_ListIO selected;
1779 aSel->selectedObjects( selected );
1781 int nbSel = selected.Extent();
1784 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1786 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1787 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1788 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1789 if ( !Hyp->_is_nil() )
1791 char* sName = Hyp->GetName();
1792 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1795 aCreator->EditHypothesis(Hyp);
1803 updateObjBrowser( true );
1807 case 1101: // RENAME
1809 if ( checkLock( aStudy ) )
1812 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1813 SALOME_ListIO selected;
1815 aSel->selectedObjects( selected );
1817 SALOME_ListIteratorOfListIO It( selected );
1818 for ( ; It.More(); It.Next() )
1820 Handle(SALOME_InteractiveObject) IObject = It.Value();
1821 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1822 _PTR(GenericAttribute) anAttr;
1823 _PTR(AttributeName) aName;
1826 if ( obj->FindAttribute(anAttr, "AttributeName") )
1829 QString newName = QString(aName->Value().c_str());
1830 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1831 if ( !newName.isEmpty() )
1833 //old source: aStudy->renameIObject( IObject, newName );
1834 aName->SetValue( newName.latin1() );
1836 // if current object is group update group's name
1837 SMESH::SMESH_GroupBase_var aGroup =
1838 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1839 if (!aGroup->_is_nil() )
1840 aGroup->SetName( newName.latin1() );
1850 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1852 if(checkLock(aStudy)) break;
1853 SUIT_OverrideCursor wc;
1855 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1856 SALOME_ListIO selected;
1858 aSel->selectedObjects( selected );
1860 SALOME_ListIteratorOfListIO It(selected);
1861 for (int i = 0; It.More(); It.Next(), i++) {
1862 Handle(SALOME_InteractiveObject) IObject = It.Value();
1863 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1866 aSel->setSelectedObjects( l1 );
1871 case 401: // GEOM::EDGE
1872 case 4021: // TRIANGLE
1874 case 4023: // POLYGON
1878 if(checkLock(aStudy)) break;
1879 startOperation( theCommandID );
1881 EmitSignalDeactivateDialog();
1882 SMDSAbs_ElementType type = SMDSAbs_Edge;
1884 switch (theCommandID) {
1885 case 4021: // TRIANGLE
1886 type = SMDSAbs_Face; nbNodes = 3; break;
1888 type = SMDSAbs_Face; nbNodes = 4; break;
1890 type = SMDSAbs_Volume; nbNodes = 4; break;
1891 case 4023: // POLYGON
1892 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1894 type = SMDSAbs_Volume; nbNodes = 8; break;
1895 case 4033: // POLYHEDRE
1896 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1899 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1902 SUIT_MessageBox::warn1(desktop(),
1903 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1904 tr("SMESH_BUT_OK"));
1908 case 4033: // POLYHEDRON
1910 if(checkLock(aStudy)) break;
1912 EmitSignalDeactivateDialog();
1913 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1916 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1917 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1918 tr("SMESH_BUT_OK"));
1922 case 4041: // REMOVES NODES
1924 if(checkLock(aStudy)) break;
1925 startOperation( 4041 );
1927 EmitSignalDeactivateDialog();
1928 new SMESHGUI_RemoveNodesDlg(this);
1931 SUIT_MessageBox::warn1(desktop(),
1932 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1933 tr("SMESH_BUT_OK"));
1937 case 4042: // REMOVES ELEMENTS
1939 if(checkLock(aStudy)) break;
1941 EmitSignalDeactivateDialog();
1942 new SMESHGUI_RemoveElementsDlg(this);
1946 SUIT_MessageBox::warn1(desktop(),
1947 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1948 tr("SMESH_BUT_OK"));
1952 case 4051: // RENUMBERING NODES
1954 if(checkLock(aStudy)) break;
1956 EmitSignalDeactivateDialog();
1957 new SMESHGUI_RenumberingDlg( this, "", 0);
1961 SUIT_MessageBox::warn1(desktop(),
1962 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1963 tr("SMESH_BUT_OK"));
1967 case 4052: // RENUMBERING ELEMENTS
1969 if(checkLock(aStudy)) break;
1971 EmitSignalDeactivateDialog();
1972 new SMESHGUI_RenumberingDlg( this, "", 1);
1976 SUIT_MessageBox::warn1(desktop(),
1977 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1978 tr("SMESH_BUT_OK"));
1982 case 4061: // TRANSLATION
1984 if(checkLock(aStudy)) break;
1986 EmitSignalDeactivateDialog();
1987 new SMESHGUI_TranslationDlg( this );
1990 SUIT_MessageBox::warn1(desktop(),
1991 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1992 tr("SMESH_BUT_OK"));
1996 case 4062: // ROTATION
1998 if(checkLock(aStudy)) break;
2000 EmitSignalDeactivateDialog();
2001 new SMESHGUI_RotationDlg( this );
2004 SUIT_MessageBox::warn1(desktop(),
2005 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2006 tr("SMESH_BUT_OK"));
2010 case 4063: // SYMMETRY
2012 if(checkLock(aStudy)) break;
2014 EmitSignalDeactivateDialog();
2015 new SMESHGUI_SymmetryDlg( this );
2018 SUIT_MessageBox::warn1(desktop(),
2019 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2020 tr("SMESH_BUT_OK"));
2024 case 4064: // SEWING
2026 if(checkLock(aStudy)) break;
2028 EmitSignalDeactivateDialog();
2029 new SMESHGUI_SewingDlg( this );
2032 SUIT_MessageBox::warn1(desktop(),
2033 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2034 tr("SMESH_BUT_OK"));
2038 case 4065: // MERGE NODES
2040 if(checkLock(aStudy)) break;
2042 EmitSignalDeactivateDialog();
2043 new SMESHGUI_MergeNodesDlg( this );
2046 SUIT_MessageBox::warn1(desktop(),
2047 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2048 tr("SMESH_BUT_OK"));
2054 case 5000: // HYPOTHESIS
2056 if(checkLock(aStudy)) break;
2057 EmitSignalDeactivateDialog();
2058 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2063 if(checkLock(aStudy)) break;
2064 EmitSignalDeactivateDialog();
2065 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2069 case 5105: // Library of selection filters
2071 static QValueList<int> aTypes;
2072 if ( aTypes.isEmpty() )
2074 aTypes.append( SMESH::NODE );
2075 aTypes.append( SMESH::EDGE );
2076 aTypes.append( SMESH::FACE );
2077 aTypes.append( SMESH::VOLUME );
2079 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2083 case 6017: // CONTROLS
2098 SalomeApp_SelectionMgr* mgr = selectionMgr();
2099 SALOME_ListIO selected; mgr->selectedObjects( selected );
2101 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2102 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2104 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2105 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2106 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2107 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2108 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2109 ::Control( theCommandID );
2114 SUIT_MessageBox::warn1(desktop(),
2115 tr( "SMESH_WRN_WARNING" ),
2116 tr( "SMESH_BAD_SELECTION" ),
2117 tr( "SMESH_BUT_OK" ) );
2121 SUIT_MessageBox::warn1(desktop(),
2122 tr( "SMESH_WRN_WARNING" ),
2123 tr( "NOT_A_VTK_VIEWER" ),
2124 tr( "SMESH_BUT_OK" ) );
2129 SalomeApp_SelectionMgr* mgr = selectionMgr();
2130 SALOME_ListIO selected; mgr->selectedObjects( selected );
2132 if (selected.Extent() == 1) {
2133 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2134 if(anIObject->hasEntry())
2135 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2136 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2143 SalomeApp_SelectionMgr* mgr = selectionMgr();
2144 SALOME_ListIO selected; mgr->selectedObjects( selected );
2146 if (selected.Extent() == 1) {
2147 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2148 if(anIObject->hasEntry())
2149 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2150 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2155 case 10001: // DISPLAY MODE PREFERENCE
2159 action( 10002 )->setOn( false );
2160 action( 10004 )->setOn( false );
2161 action( 10003 )->setOn( true );
2162 mgr->setValue( "SMESH", "DisplayMode", "Wireframe");
2168 action( 10001 )->setOn( false );
2169 action( 10004 )->setOn( false );
2170 action( 10003 )->setOn( true );
2171 mgr->setValue( "SMESH", "DisplayMode", "Shading");
2176 mgr->setValue( "SMESH", "Shrink", act->isOn() );
2182 action( 10001 )->setOn( false );
2183 action( 10002 )->setOn( false );
2184 action( 10003 )->setOn( false );
2185 mgr->setValue( "SMESH", "DisplayMode", "Nodes" );
2191 //updateObjBrowser();
2195 //=============================================================================
2199 //=============================================================================
2200 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2205 //=============================================================================
2209 //=============================================================================
2210 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2215 //=============================================================================
2219 //=============================================================================
2220 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2225 //=============================================================================
2229 //=============================================================================
2230 bool SMESHGUI::SetSettings(SUIT_Desktop* parent)
2232 SMESHGUI::GetSMESHGUI();
2234 SUIT_ResourceMgr* mgr = resourceMgr();
2239 QString DisplayMode = "Shading";
2240 if ( mgr->hasValue("SMESH","DisplayMode") )
2241 DisplayMode = mgr->stringValue("SMESH","DisplayMode");
2243 mgr->setValue("SMESH","DisplayMode", "Shading");
2245 bool Shrink = false;
2246 if ( mgr->hasValue("SMESH","Shrink") )
2247 Shrink = mgr->stringValue("SMESH","Shrink") == "yes";
2249 if (DisplayMode == "Wireframe") {
2251 action( 10004 )->setOn( false );
2252 action( 10002 )->setOn( false );
2253 action( 10001 )->setOn( true );
2254 action( 10003 )->setOn( true );
2256 else if (DisplayMode == "Nodes") {
2258 action( 10004 )->setOn( true );
2259 action( 10002 )->setOn( false );
2260 action( 10001 )->setOn( false );
2261 action( 10003 )->setOn( false );
2264 // default is shading
2265 action( 10004 )->setOn( false );
2266 action( 10002 )->setOn( true );
2267 action( 10001 )->setOn( false );
2268 action( 10003 )->setOn( true );
2271 action( 10003 )->setOn( Shrink );
2274 // if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) {
2275 // action( 1001 )->setOn( true );
2276 // myAutomaticUpdate = true;
2279 // action( 1001 )->setOn( false );
2280 // myAutomaticUpdate = false;
2283 if ( mgr->booleanValue( "SMESH","DispayEntity", false ) )
2284 action( 10071 )->setOn( true );
2286 action( 10071 )->setOn( false );
2289 SMESH::UpdateSelectionProp( this );
2292 action( 111 )->setEnabled( false ); // IMPORT DAT
2294 //action( 112 )->setEnabled( false );
2295 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2300 //=============================================================================
2301 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2302 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2304 //=============================================================================
2305 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2306 SUIT_ViewWindow* wnd )
2308 if(theIO->hasEntry()){
2309 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2310 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2314 //=======================================================================
2315 // function : createSMESHAction
2317 //=======================================================================
2318 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2321 QWidget* parent = application()->desktop();
2322 SUIT_ResourceMgr* resMgr = resourceMgr();
2324 if ( icon_id.length() )
2325 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2327 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2328 if ( !pix.isNull() )
2329 icon = QIconSet( pix );
2331 QString tooltip = tr( QString( "TOP_" )+po_id ),
2332 menu = tr( QString( "MEN_" )+po_id ),
2333 status_bar = tr( QString( "STB_" )+po_id );
2335 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2338 //=======================================================================
2339 // function : createPopupItem
2341 //=======================================================================
2342 void SMESHGUI::createPopupItem( const int id,
2343 const QString& clients,
2344 const QString& types,
2345 const QString& theRule,
2350 parentId = popupMgr()->actionId( action( pId ) );
2352 // if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2353 popupMgr()->insert( action( id ), parentId, 0 );
2355 QChar lc = QtxPopupMgr::Selection::defEquality();
2356 QString rule = "(%1) and (%2) and (%3)";
2357 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2358 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2359 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2362 bool cont = myRules.contains( id );
2364 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2366 popupMgr()->setRule( action( id ), rule, true );
2367 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2370 //=======================================================================
2371 // function : initialize
2373 //=======================================================================
2374 void SMESHGUI::initialize( CAM_Application* app )
2376 SalomeApp_Module::initialize( app );
2378 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2380 /* Automatic Update flag */
2381 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2383 // ----- create actions --------------
2385 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2386 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2387 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2388 createSMESHAction( 114, "NUM" );
2389 createSMESHAction( 121, "DAT" );
2390 createSMESHAction( 122, "MED" );
2391 createSMESHAction( 123, "UNV" );
2392 createSMESHAction( 124, "EXPORT_DAT" );
2393 createSMESHAction( 125, "EXPORT_MED" );
2394 createSMESHAction( 126, "EXPORT_UNV" );
2395 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2396 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2397 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2398 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2399 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2400 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2401 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2402 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2403 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2404 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2405 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2406 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2407 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2408 createSMESHAction( 804, "ADD" );
2409 createSMESHAction( 805, "REMOVE" );
2410 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2411 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2412 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2413 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2414 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2415 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2416 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2417 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2418 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2419 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2420 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2421 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2422 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2423 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2424 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2425 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2426 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2427 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2428 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2429 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2430 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2431 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2432 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2433 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2434 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2435 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2436 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2437 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2438 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2439 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2440 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2441 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2442 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2443 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2444 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2445 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2446 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2447 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2448 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2449 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2450 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2451 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2452 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2453 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2454 createSMESHAction( 415, "MAP", "ICON_MAP" );
2455 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2456 createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true );
2457 createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true );
2458 createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true );
2459 createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true );
2460 createSMESHAction( 1001, "AUTO_UPD", "", 0, true );
2461 createSMESHAction( 1003, "COLORS" );
2462 createSMESHAction( 1005, "SCALAR_BAR" );
2463 createSMESHAction( 1006, "SELECTION" );
2464 createSMESHAction( 10070, "PRECISION", "", 0, true );
2465 createSMESHAction( 10071, "DISP_ENT", "", 0, true );
2466 createSMESHAction( 200, "RESET" );
2467 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2468 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2469 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2470 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2471 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2472 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2473 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2474 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2475 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2476 createSMESHAction( 220, "ALL" );
2477 createSMESHAction( 1100, "EDIT_HYPO" );
2478 createSMESHAction( 1101, "RENAME" );
2479 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2480 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2481 createSMESHAction( 1131, "DISPMODE" );
2482 createSMESHAction( 1132, "COLORS" );
2483 createSMESHAction( 1133, "TRANSP" );
2484 createSMESHAction( 1134, "CLIP" );
2485 createSMESHAction( 1135, "DISP_ENT" );
2486 createSMESHAction( 2000, "CTRL" );
2488 createSMESHAction( 300, "ERASE" );
2489 createSMESHAction( 301, "DISPLAY" );
2490 createSMESHAction( 302, "DISPLAY_ONLY" );
2491 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2493 // ----- create menu --------------
2494 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2495 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2496 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2497 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2498 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2499 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2500 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2501 prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ),
2502 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2504 createMenu( separator(), fileId );
2506 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2507 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2509 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2510 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2511 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2512 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
2514 meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ),
2516 dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ),
2517 qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 );
2519 createMenu( 111, importId, -1 );
2520 createMenu( 112, importId, -1 );
2521 createMenu( 113, importId, -1 );
2523 createMenu( 121, exportId, -1 );
2524 createMenu( 122, exportId, -1 );
2525 createMenu( 123, exportId, -1 );
2527 createMenu( separator(), fileId, 10 );
2529 createMenu( 33, editId, -1 );
2531 createMenu( 5105, toolsId, -1 );
2533 createMenu( 5000, hypoId, -1 );
2534 createMenu( 5010, hypoId, -1 );
2536 createMenu( 703, meshId, -1 );
2537 createMenu( 702, meshId, -1 );
2538 createMenu( 704, meshId, -1 );
2539 createMenu( separator(), meshId, -1 );
2540 createMenu( 701, meshId, -1 );
2541 createMenu( separator(), meshId, -1 );
2542 createMenu( 801, meshId, -1 );
2543 createMenu( 802, meshId, -1 );
2544 createMenu( 803, meshId, -1 );
2545 createMenu( separator(), meshId, -1 );
2546 createMenu( 810, meshId, -1 );
2547 createMenu( 811, meshId, -1 );
2548 createMenu( 812, meshId, -1 );
2549 createMenu( separator(), meshId, -1 );
2550 createMenu( 813, meshId, -1 );
2551 createMenu( separator(), meshId, -1 );
2552 createMenu( 900, meshId, -1 );
2553 createMenu( 902, meshId, -1 );
2554 createMenu( separator(), meshId, -1 );
2556 createMenu( 6003, ctrlId, -1 );
2557 createMenu( 6001, ctrlId, -1 );
2558 createMenu( 6004, ctrlId, -1 );
2559 createMenu( separator(), ctrlId, -1 );
2560 createMenu( 6002, ctrlId, -1 );
2561 createMenu( 6018, ctrlId, -1 );
2562 createMenu( 6019, ctrlId, -1 );
2563 createMenu( 6011, ctrlId, -1 );
2564 createMenu( 6012, ctrlId, -1 );
2565 createMenu( 6013, ctrlId, -1 );
2566 createMenu( 6014, ctrlId, -1 );
2567 createMenu( 6015, ctrlId, -1 );
2568 createMenu( 6016, ctrlId, -1 );
2569 createMenu( separator(), ctrlId, -1 );
2570 createMenu( 6017, ctrlId, -1 );
2571 createMenu( separator(), ctrlId, -1 );
2573 createMenu( 400, addId, -1 );
2574 createMenu( 401, addId, -1 );
2575 createMenu( 4021, addId, -1 );
2576 createMenu( 4022, addId, -1 );
2577 createMenu( 4023, addId, -1 );
2578 createMenu( 4031, addId, -1 );
2579 createMenu( 4032, addId, -1 );
2580 createMenu( 4033, addId, -1 );
2582 createMenu( 4041, removeId, -1 );
2583 createMenu( 4042, removeId, -1 );
2585 createMenu( 4051, renumId, -1 );
2586 createMenu( 4052, renumId, -1 );
2588 createMenu( 4061, transfId, -1 );
2589 createMenu( 4062, transfId, -1 );
2590 createMenu( 4063, transfId, -1 );
2591 createMenu( 4064, transfId, -1 );
2592 createMenu( 4065, transfId, -1 );
2594 createMenu( 406, modifyId, -1 );
2595 createMenu( 407, modifyId, -1 );
2596 createMenu( 408, modifyId, -1 );
2597 createMenu( 409, modifyId, -1 );
2598 createMenu( 410, modifyId, -1 );
2599 createMenu( 411, modifyId, -1 );
2600 createMenu( 412, modifyId, -1 );
2601 createMenu( 413, modifyId, -1 );
2602 createMenu( 416, modifyId, -1 );
2603 createMenu( 414, modifyId, -1 );
2604 createMenu( 415, modifyId, -1 );
2606 createMenu( 10001, dispModeId, -1 );
2607 createMenu( 10002, dispModeId, -1 );
2608 createMenu( 10004, dispModeId, -1 );
2609 createMenu( 10003, dispModeId, -1 );
2611 createMenu( 1001, prefId, -1 );
2612 createMenu( separator(), prefId, -1 );
2613 createMenu( 1003, prefId, -1 );
2614 createMenu( separator(), prefId, -1 );
2615 createMenu( 1005, prefId, -1 );
2616 createMenu( separator(), prefId, -1 );
2617 createMenu( 1006, prefId, -1 );
2618 createMenu( separator(), prefId, -1 );
2620 createMenu( 10070, qualityId, -1 );
2621 createMenu( 10071, qualityId, -1 );
2623 createMenu( separator(), prefId, -1 );
2625 createMenu( 214, viewId, -1 );
2627 // ----- create toolbars --------------
2628 int meshTb = createTool( tr( "TB_MESH" ) ),
2629 hypoTb = createTool( tr( "TB_HYPO" ) ),
2630 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2631 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2632 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2633 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2635 createTool( 703, meshTb );
2636 createTool( 702, meshTb );
2637 createTool( 704, meshTb );
2638 createTool( separator(), meshTb );
2639 createTool( 701, meshTb );
2640 createTool( separator(), meshTb );
2641 createTool( 801, meshTb );
2642 createTool( 802, meshTb );
2643 createTool( 803, meshTb );
2644 createTool( separator(), meshTb );
2645 createTool( 900, meshTb );
2646 createTool( 902, meshTb );
2647 createTool( separator(), meshTb );
2649 createTool( 5000, hypoTb );
2650 createTool( 5010, hypoTb );
2652 createTool( 6001, ctrlTb );
2653 createTool( 6003, ctrlTb );
2654 createTool( 6004, ctrlTb );
2655 createTool( separator(), ctrlTb );
2656 createTool( 6002, ctrlTb );
2657 createTool( 6018, ctrlTb );
2658 createTool( 6019, ctrlTb );
2659 createTool( 6011, ctrlTb );
2660 createTool( 6012, ctrlTb );
2661 createTool( 6013, ctrlTb );
2662 createTool( 6014, ctrlTb );
2663 createTool( 6015, ctrlTb );
2664 createTool( 6016, ctrlTb );
2665 createTool( separator(), ctrlTb );
2666 createTool( 6017, ctrlTb );
2667 createTool( separator(), ctrlTb );
2669 createTool( 400, addRemTb );
2670 createTool( 401, addRemTb );
2671 createTool( 4021, addRemTb );
2672 createTool( 4022, addRemTb );
2673 createTool( 4023, addRemTb );
2674 createTool( 4031, addRemTb );
2675 createTool( 4032, addRemTb );
2676 createTool( 4033, addRemTb );
2677 createTool( separator(), addRemTb );
2678 createTool( 4041, addRemTb );
2679 createTool( 4042, addRemTb );
2680 createTool( separator(), addRemTb );
2681 createTool( 4051, addRemTb );
2682 createTool( 4052, addRemTb );
2683 createTool( separator(), addRemTb );
2684 createTool( 4061, addRemTb );
2685 createTool( 4062, addRemTb );
2686 createTool( 4063, addRemTb );
2687 createTool( 4064, addRemTb );
2688 createTool( 4065, addRemTb );
2689 createTool( separator(), addRemTb );
2691 createTool( 406, modifyTb );
2692 createTool( 407, modifyTb );
2693 createTool( 408, modifyTb );
2694 createTool( 409, modifyTb );
2695 createTool( 410, modifyTb );
2696 createTool( 411, modifyTb );
2697 createTool( 412, modifyTb );
2698 createTool( 413, modifyTb );
2699 createTool( 416, modifyTb );
2700 createTool( 414, modifyTb );
2701 createTool( 415, modifyTb );
2703 createTool( 214, dispModeTb );
2707 QString OB = "'ObjectBrowser'",
2708 View = "'" + SVTK_Viewer::Type() + "'",
2710 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2711 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2712 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2713 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2714 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2715 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2716 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2717 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2718 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2719 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2721 mesh_group = mesh + " " + subMesh + " " + group,
2722 hyp_alg = hypo + " " + algo;
2724 // popup for object browser
2726 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2727 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2728 createPopupItem( 803, OB, group ); // EDIT_GROUP
2729 popupMgr()->insert( separator(), -1, 0 );
2730 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2731 createPopupItem( 214, OB, mesh_group ); // UPDATE
2732 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2733 createPopupItem( 902, OB, mesh ); // STD_INFO
2734 popupMgr()->insert( separator(), -1, 0 );
2735 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2736 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2737 popupMgr()->insert( separator(), -1, 0 );
2738 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2739 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2740 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2741 popupMgr()->insert( separator(), -1, 0 );
2742 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2743 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2744 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2745 popupMgr()->insert( separator(), -1, 0 );
2748 createPopupItem( 803, View, group ); // EDIT_GROUP
2749 createPopupItem( 804, View, elems ); // ADD
2750 createPopupItem( 805, View, elems ); // REMOVE
2751 popupMgr()->insert( separator(), -1, 0 );
2752 createPopupItem( 214, View, mesh_group ); // UPDATE
2753 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2754 createPopupItem( 902, View, mesh ); // STD_INFO
2755 popupMgr()->insert( separator(), -1, 0 );
2759 isInvisible("not( isVisible )"),
2760 isEmpty("numberOfNodes = 0"),
2761 isNotEmpty("numberOfNodes <> 0"),
2763 // has nodes, edges, etc in VISIBLE! actor
2764 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2765 hasElems("(count( elemTypes ) > 0)"),
2766 hasDifferentElems("(count( elemTypes ) > 1)"),
2767 hasEdges("({'Edge'} in elemTypes)"),
2768 hasFaces("({'Face'} in elemTypes)"),
2769 hasVolumes("({'Volume'} in elemTypes)");
2771 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2772 QString lc = QtxPopupMgr::Selection::defEquality();
2773 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2774 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2775 QString aMeshInVTK = aClient + "&&" + aType;// + "&&" + aSelCount;
2777 //-------------------------------------------------
2779 //-------------------------------------------------
2780 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2782 popupMgr()->insert( action( 9010 ), anId, -1 );
2783 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true );
2784 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2786 popupMgr()->insert( action( 9011 ), anId, -1 );
2787 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true );
2788 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2790 popupMgr()->insert( separator(), -1, -1 );
2792 //-------------------------------------------------
2794 //-------------------------------------------------
2795 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2797 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2798 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2799 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2801 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2802 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2803 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2805 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2806 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2807 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2809 popupMgr()->insert( separator(), anId, -1 );
2811 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2812 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2813 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2815 //-------------------------------------------------
2817 //-------------------------------------------------
2818 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2820 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2822 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2823 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true );
2824 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2826 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2827 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true );
2828 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2830 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2831 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true );
2832 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2834 popupMgr()->insert( separator(), anId, -1 );
2836 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2837 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true );
2839 //-------------------------------------------------
2841 //-------------------------------------------------
2842 popupMgr()->insert( action( 1132 ), -1, -1 );
2843 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2845 //-------------------------------------------------
2847 //-------------------------------------------------
2848 popupMgr()->insert( action( 1133 ), -1, -1 );
2849 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2851 //-------------------------------------------------
2853 //-------------------------------------------------
2854 popupMgr()->insert( action( 1134 ), -1, -1 );
2855 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2857 popupMgr()->insert( separator(), -1, -1 );
2859 //-------------------------------------------------
2861 //-------------------------------------------------
2863 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2864 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2865 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2867 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2869 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2870 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2872 popupMgr()->insert( separator(), anId, -1 );
2874 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2875 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2876 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2878 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2879 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2880 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2882 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2883 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2884 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2886 popupMgr()->insert( separator(), anId, -1 );
2888 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2889 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2890 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2892 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2893 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2894 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2896 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2897 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2898 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2900 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2901 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2902 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2904 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2905 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2906 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2908 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2909 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2910 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2912 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2913 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2914 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2916 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2917 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2918 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2920 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2921 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2922 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2924 popupMgr()->insert( separator(), anId, -1 );
2926 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2927 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2928 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2930 popupMgr()->insert( separator(), anId, -1 );
2932 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2933 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2935 popupMgr()->insert( separator(), -1, -1 );
2937 //-------------------------------------------------
2939 //-------------------------------------------------
2940 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2941 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
2942 QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
2943 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2944 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
2946 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2947 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
2949 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2950 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
2952 popupMgr()->insert( separator(), -1, -1 );
2954 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
2955 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
2958 bool SMESHGUI::activateModule( SUIT_Study* study )
2960 bool res = SalomeApp_Module::activateModule( study );
2962 setMenuShown( true );
2963 setToolShown( true );
2964 SetSettings( desktop() );
2969 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2971 setMenuShown( false );
2972 setToolShown( false );
2974 EmitSignalCloseAllDialogs();
2976 return SalomeApp_Module::deactivateModule( study );
2979 void SMESHGUI::OnGUIEvent()
2981 const QObject* obj = sender();
2982 if ( !obj || !obj->inherits( "QAction" ) )
2984 int id = actionId((QAction*)obj);
2989 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2991 if ( CORBA::is_nil( myComponentSMESH ) )
2993 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2994 return aGUI.myComponentSMESH;
2996 return myComponentSMESH;
2999 QString SMESHGUI::engineIOR() const
3001 CORBA::ORB_var anORB = getApp()->orb();
3002 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3006 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3008 SMESHGUI_Selection sel;
3009 sel.init( client, selectionMgr() );
3010 popupMgr()->updatePopup( menu, &sel );
3013 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3015 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3016 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3019 void SMESHGUI::viewManagers( QStringList& list ) const
3021 list.append( SVTK_Viewer::Type() );
3024 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
3026 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
3027 SMESH::UpdateSelectionProp( this );
3030 void SMESHGUI::createPreferences()
3032 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3034 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3035 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "display_entity" );
3036 addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "auto_update" );
3038 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3039 setPreferenceProperty( precGroup, "columns", 1 );
3041 addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool );
3042 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3044 setPreferenceProperty( prec, "min", 0 );
3045 setPreferenceProperty( prec, "max", 16 );
3047 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3048 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3050 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
3051 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
3053 setPreferenceProperty( nodeSz, "min", 1 );
3054 setPreferenceProperty( nodeSz, "max", 5 );
3056 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3058 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
3059 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
3060 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
3061 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
3063 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
3064 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3066 setPreferenceProperty( elemW, "min", 1 );
3067 setPreferenceProperty( elemW, "max", 5 );
3069 setPreferenceProperty( shrink, "min", 0 );
3070 setPreferenceProperty( shrink, "max", 100 );
3072 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3074 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3076 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
3077 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
3078 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
3080 setPreferenceProperty( selW, "min", 1 );
3081 setPreferenceProperty( selW, "max", 5 );
3083 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3085 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
3086 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3088 setPreferenceProperty( preW, "min", 1 );
3089 setPreferenceProperty( preW, "max", 5 );
3091 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3093 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
3094 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
3097 void SMESHGUI::preferencesChanged( const QString&, const QString& )
3101 //=======================================================================
3102 // function : onOperationCommited
3103 // purpose : SLOT called when operation commited. Set default selection mode
3104 //=======================================================================
3105 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3107 SVTK_ViewWindow* vtkWnd =
3108 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3110 vtkWnd->SetSelectionMode( ActorSelection );
3113 //=======================================================================
3114 // function : onOperationAborted
3115 // purpose : SLOT called when operation commited. Set default selection mode
3116 //=======================================================================
3117 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3119 SVTK_ViewWindow* vtkWnd =
3120 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3122 vtkWnd->SetSelectionMode( ActorSelection );
3125 //=======================================================================
3126 // function : getOperation
3127 // purpose : Get operation corresponding to the given Id
3128 //=======================================================================
3129 SalomeApp_Operation* SMESHGUI::getOperation( const int theId )
3131 if ( myOperations.contains( theId ) )
3132 return myOperations[ theId ];
3135 SalomeApp_Operation* anOp = 0;
3145 anOp->setModule( this );
3146 connect( anOp, SIGNAL( aborted( SUIT_Operation* ) ),
3147 this, SLOT( onOperationAborted( SUIT_Operation* ) ) );
3148 connect( anOp, SIGNAL( commited( SUIT_Operation* ) ),
3149 this, SLOT( onOperationCommited( SUIT_Operation* ) ) );
3150 myOperations[ theId ] = anOp;
3157 //=======================================================================
3158 // function : update
3159 // purpose : Update something
3160 //=======================================================================
3161 void SMESHGUI::update( const int flags )
3163 if ( flags & UF_Viewer | flags & UF_Forced )
3164 SMESH::UpdateView();
3166 SalomeApp_Module::update( flags );
3169 //=======================================================================
3170 // function : updateControls
3171 // purpose : Update state of controls
3172 //=======================================================================
3173 void SMESHGUI::updateControls()
3178 //=======================================================================
3179 // function : updateControls
3180 // purpose : Update state of controls
3181 //=======================================================================
3182 SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
3184 SalomeApp_Operation* op = 0;
3188 op = new SMESHGUI_DeleteOp();
3192 op = new SMESHGUI_NodesOp();
3196 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Edge, 2 );
3200 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 3 );
3204 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 4 );
3208 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 5 ); // 5 - identificator for POLYGON
3212 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 4 );
3216 op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 8 );
3220 op = new SMESHGUI_RemoveNodesOp();
3224 op = new SMESHGUI_AddSubMeshOp();
3228 op = new SMESHGUI_InitMeshOp();
3232 op = new SMESHGUI_EditHypothesesOp();
3236 op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::UNION );
3240 op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::INTERSECT );
3244 op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::CUT );
3248 op = SalomeApp_Module::createOperation( id );