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_InitMeshDlg.h"
29 #include "SMESHGUI_AddSubMeshDlg.h"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_HypothesesUtils.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_EditHypothesesDlg.h"
46 #include "SMESHGUI_CreateHypothesesDlg.h"
47 #include "SMESHGUI_FilterDlg.h"
48 #include "SMESHGUI_FilterLibraryDlg.h"
49 #include "SMESHGUI_SingleEditDlg.h"
50 #include "SMESHGUI_MultiEditDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_DeleteGroupDlg.h"
53 #include "SMESHGUI_SmoothingDlg.h"
54 #include "SMESHGUI_RenumberingDlg.h"
55 #include "SMESHGUI_ExtrusionDlg.h"
56 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
57 #include "SMESHGUI_RevolutionDlg.h"
58 #include "SMESHGUI_TranslationDlg.h"
59 #include "SMESHGUI_RotationDlg.h"
60 #include "SMESHGUI_SymmetryDlg.h"
61 #include "SMESHGUI_SewingDlg.h"
62 #include "SMESHGUI_MergeNodesDlg.h"
63 #include "SMESHGUI_MeshPatternDlg.h"
64 #include "SMESHGUI_PrecisionDlg.h"
65 #include "SMESHGUI_Selection.h"
66 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
68 #include <SVTK_InteractorStyle.h>
69 #include <SVTK_RenderWindowInteractor.h>
71 #include "SMESH_Actor.h"
72 #include "SMESH_Object.h"
73 #include "SMESH_TypeFilter.hxx"
75 #include "SUIT_Tools.h"
76 #include "SUIT_MessageBox.h"
77 #include "SUIT_ResourceMgr.h"
78 #include "SUIT_FileDlg.h"
79 #include "SUIT_Desktop.h"
80 #include "SUIT_ResourceMgr.h"
81 #include "SUIT_OverrideCursor.h"
82 #include "SUIT_Study.h"
83 #include "SUIT_Session.h"
85 #include "SALOME_NamingService.hxx"
86 #include "SALOME_ListIteratorOfListIO.hxx"
87 #include "SALOME_InteractiveObject.hxx"
88 #include "SALOME_ListIO.hxx"
89 #include <SALOME_LifeCycleCORBA.hxx>
91 #include "OB_Browser.h"
93 #include "QtxPopupMgr.h"
95 #include "SalomeApp_Application.h"
96 #include "SalomeApp_NameDlg.h"
97 #include "SalomeApp_DataOwner.h"
98 #include "SalomeApp_ImportOperation.h"
99 #include "SalomeApp_Tools.h"
100 #include "SalomeApp_Study.h"
101 #include "SalomeApp_VTKSelector.h"
103 #include <SVTK_ViewWindow.h>
104 #include <SVTK_ViewModel.h>
106 #include "SMESHGUI_Utils.h"
107 #include "SMESHGUI_GEOMGenUtils.h"
108 #include "SMESHGUI_MeshUtils.h"
109 #include "SMESHGUI_GroupUtils.h"
110 #include "SMESHGUI_FilterUtils.h"
111 #include "SMESHGUI_PatternUtils.h"
112 #include "SMESHGUI_VTKUtils.h"
114 #include "SALOMEconfig.h"
115 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
118 #define INCLUDE_MENUITEM_DEF
119 #include <qapplication.h>
120 #include <qlineedit.h>
121 #include <qmenudata.h>
122 #include <qmenubar.h>
123 #include <qpopupmenu.h>
126 #include <qpainter.h>
127 #include <qcheckbox.h>
128 #include <qcolordialog.h>
129 #include <qspinbox.h>
134 #include <qradiobutton.h>
136 #include <boost/shared_ptr.hpp>
138 #include <vtkRenderer.h>
139 #include <vtkRenderWindow.h>
140 #include <vtkActorCollection.h>
141 #include <vtkScalarBarActor.h>
142 #include <vtkUnstructuredGrid.h>
144 #include "utilities.h"
146 #include "SALOMEDS_Study.hxx"
147 #include "SALOMEDSClient_StudyBuilder.hxx"
148 #include "SALOMEDSClient_SComponent.hxx"
154 //=============================================================
155 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
158 void ExportMeshToFile(int theCommandID);
160 void SetDisplayMode(int theCommandID);
162 void SetDisplayEntity(int theCommandID);
164 void Control( int theCommandID );
166 void SetDisplaySettings();
170 //=============================================================
171 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
177 if(theCommandID == 113){
178 filter.append(QObject::tr("MED files (*.med)"));
179 filter.append(QObject::tr("All files (*)"));
180 }else if (theCommandID == 112){
181 filter.append(QObject::tr("IDEAS files (*.unv)"));
182 }else if (theCommandID == 111){
183 filter.append(QObject::tr("DAT files (*.dat)"));
185 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
188 QObject::tr("Import mesh"),
190 if(!filename.isEmpty()) {
191 SUIT_OverrideCursor wc;
192 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
195 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
196 switch ( theCommandID ) {
199 aMeshes->length( 1 );
200 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
205 SMESH::DriverMED_ReadStatus res;
206 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
207 if ( res != SMESH::DRS_OK ) {
209 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
210 QObject::tr("SMESH_WRN_WARNING"),
211 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
212 QObject::tr("SMESH_BUT_OK"));
213 aMeshes->length( 0 );
220 bool isEmpty = false;
221 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
222 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
224 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
225 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
226 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
227 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
228 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
235 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
236 QObject::tr("SMESH_WRN_WARNING"),
237 QObject::tr("SMESH_DRS_EMPTY"),
238 QObject::tr("SMESH_BUT_OK"));
242 catch (const SALOME::SALOME_Exception& S_ex){
244 SalomeApp_Tools::QtCatchCorbaException(S_ex);
251 void ExportMeshToFile( int theCommandID )
253 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
254 SALOME_ListIO selected;
256 aSel->selectedObjects( selected );
258 if(selected.Extent()){
259 Handle(SALOME_InteractiveObject) anIObject = selected.First();
260 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
261 if ( !aMesh->_is_nil() ) {
262 QString aFilter, aTitle = QObject::tr("Export mesh");
263 QMap<QString, SMESH::MED_VERSION> aFilterMap;
264 switch ( theCommandID ) {
267 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
268 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
272 aFilter = QObject::tr("DAT files (*.dat)");
276 if(aMesh->NbPyramids()){
277 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
278 QObject::tr("SMESH_WRN_WARNING"),
279 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
280 QObject::tr("SMESH_BUT_YES"),
281 QObject::tr("SMESH_BUT_NO"),
286 aFilter = QObject::tr("IDEAS files (*.unv)");
293 SMESH::MED_VERSION aFormat;
295 if ( theCommandID != 122 && theCommandID != 125 )
296 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
300 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
301 filters.push_back( it.key() );
303 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
304 fd->setCaption( aTitle );
305 fd->setFilters( filters );
307 aFilename = fd->selectedFile();
308 aFormat = aFilterMap[fd->selectedFilter()];
311 if ( !aFilename.isEmpty() ) {
312 // Check whether the file already exists and delete it if yes
313 QFile aFile( aFilename );
314 if ( aFile.exists() )
316 SUIT_OverrideCursor wc;
317 switch ( theCommandID ) {
320 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
324 aMesh->ExportDAT( aFilename.latin1() );
328 aMesh->ExportUNV( aFilename.latin1() );
338 inline void InverseEntityMode(unsigned int& theOutputMode,
339 unsigned int theMode)
341 bool anIsNotPresent = ~theOutputMode & theMode;
343 theOutputMode |= theMode;
345 theOutputMode &= ~theMode;
348 void SetDisplayEntity(int theCommandID){
349 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
350 SALOME_ListIO selected;
352 aSel->selectedObjects( selected );
354 if(selected.Extent() >= 1){
355 SALOME_ListIteratorOfListIO It( selected );
356 for(; It.More(); It.Next()){
357 Handle(SALOME_InteractiveObject) IObject = It.Value();
358 if(IObject->hasEntry()){
359 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
360 unsigned int aMode = anActor->GetEntityMode();
361 switch(theCommandID){
363 InverseEntityMode(aMode,SMESH_Actor::eEdges);
366 InverseEntityMode(aMode,SMESH_Actor::eFaces);
369 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
372 aMode = SMESH_Actor::eAllEntity;
376 anActor->SetEntityMode(aMode);
383 void SetDisplayMode(int theCommandID){
384 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
385 SALOME_ListIO selected;
387 aSel->selectedObjects( selected );
389 if(selected.Extent() >= 1){
390 switch(theCommandID){
392 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
393 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
397 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
398 new SMESHGUI_TransparencyDlg( SMESHGUI::desktop(), "", false );
401 SALOME_ListIteratorOfListIO It( selected );
402 for(; It.More(); It.Next()){
403 Handle(SALOME_InteractiveObject) IObject = It.Value();
404 if(IObject->hasEntry()){
405 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
406 switch(theCommandID){
408 anActor->SetRepresentation(SMESH_Actor::eEdge);
411 anActor->SetRepresentation(SMESH_Actor::eSurface);
414 if(anActor->IsShrunk())
417 anActor->SetShrink();
420 anActor->SetRepresentation(SMESH_Actor::ePoint);
424 anActor->GetSufaceColor(color[0], color[1], color[2]);
425 int c0 = int (color[0] * 255);
426 int c1 = int (color[1] * 255);
427 int c2 = int (color[2] * 255);
428 QColor c(c0, c1, c2);
431 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
432 c0 = int (edgecolor[0] * 255);
433 c1 = int (edgecolor[1] * 255);
434 c2 = int (edgecolor[2] * 255);
435 QColor e(c0, c1, c2);
437 float backfacecolor[3];
438 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
439 c0 = int (backfacecolor[0] * 255);
440 c1 = int (backfacecolor[1] * 255);
441 c2 = int (backfacecolor[2] * 255);
442 QColor b(c0, c1, c2);
445 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
446 c0 = int (nodecolor[0] * 255);
447 c1 = int (nodecolor[1] * 255);
448 c2 = int (nodecolor[2] * 255);
449 QColor n(c0, c1, c2);
451 int Edgewidth = (int)anActor->GetLineWidth();
454 int intValue = int(anActor->GetNodeSize());
455 float Shrink = anActor->GetShrinkFactor();
457 SMESHGUI_Preferences_ColorDlg *aDlg =
458 new SMESHGUI_Preferences_ColorDlg(SMESHGUI::desktop(),"");
459 aDlg->SetColor(1, c);
460 aDlg->SetColor(2, e);
461 aDlg->SetColor(3, n);
462 aDlg->SetColor(4, b);
463 aDlg->SetIntValue(1, Edgewidth);
464 aDlg->SetIntValue(2, intValue);
465 aDlg->SetIntValue(3, int(Shrink*100.));
467 QColor color = aDlg->GetColor(1);
468 QColor edgecolor = aDlg->GetColor(2);
469 QColor nodecolor = aDlg->GetColor(3);
470 QColor backfacecolor = aDlg->GetColor(4);
471 /* actor color and backface color */
472 anActor->SetSufaceColor(float (color.red()) / 255.,
473 float (color.green()) / 255.,
474 float (color.blue()) / 255.);
475 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
476 float (backfacecolor.green()) / 255.,
477 float (backfacecolor.blue()) / 255.);
480 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
481 float (edgecolor.green()) / 255.,
482 float (edgecolor.blue()) / 255.);
484 /* Shrink factor and size edges */
485 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
486 anActor->SetLineWidth(aDlg->GetIntValue(1));
488 /* Nodes color and size */
489 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
490 float (nodecolor.green()) / 255.,
491 float (nodecolor.blue()) / 255.);
492 anActor->SetNodeSize(aDlg->GetIntValue(2));
501 SMESH::RepaintCurrentView();
506 void SetDisplaySettings()
508 SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
512 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
513 SMESHGUI_Preferences_ColorDlg *aDlg =
514 new SMESHGUI_Preferences_ColorDlg(SMESHGUI::desktop(), "");
516 QColor color = mgr->colorValue( "SMESH", "SettingsFillColor", QColor(0, 170, 255) );
517 aDlg->SetColor(1, color);
519 color = mgr->colorValue( "SMESH", "SettingsOutlineColor", QColor(0, 170, 255) );
520 aDlg->SetColor(2, color);
522 color = mgr->colorValue( "SMESH", "SettingsNodeColor", Qt::red );
523 aDlg->SetColor(3, color);
525 color = mgr->colorValue( "SMESH", "SettingsBackFaceColor", Qt::blue );
526 aDlg->SetColor(4, color);
528 int iVal = mgr->integerValue( "SMESH", "SettingsWidth", 1 );
529 aDlg->SetIntValue(1, iVal);
531 iVal = mgr->integerValue( "SMESH", "SettingsNodesSize", 3 );
532 aDlg->SetIntValue(2, iVal);
534 iVal = mgr->integerValue( "SMESH", "SettingsShrinkCoeff", 75 );
535 aDlg->SetIntValue(3, iVal);
538 mgr->setValue( "SMESH", "SettingsFillColor", aDlg->GetColor(1) );
539 mgr->setValue( "SMESH", "SettingsOutlineColor", aDlg->GetColor(2) );
540 mgr->setValue( "SMESH", "SettingsNodeColor", aDlg->GetColor(3) );
541 mgr->setValue( "SMESH", "SettingsBackFaceColor", aDlg->GetColor(4) );
543 mgr->setValue( "SMESH", "SettingsWidth", aDlg->GetIntValue(1) );
544 mgr->setValue( "SMESH", "SettingsNodesSize", aDlg->GetIntValue(2) );
545 mgr->setValue( "SMESH", "SettingsShrinkCoeff", aDlg->GetIntValue(3) );
552 void Control( int theCommandID )
554 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
555 SALOME_ListIO selected;
557 aSel->selectedObjects( selected );
559 if( !selected.IsEmpty() ){
560 Handle(SALOME_InteractiveObject) anIO = selected.First();
563 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
564 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
565 switch ( theCommandID ){
567 aTitle = QObject::tr( "LENGTH_EDGES" );
568 aControl = SMESH_Actor::eLength;
571 aTitle = QObject::tr( "LENGTH2D_EDGES" );
572 aControl = SMESH_Actor::eLength2D;
575 aTitle = QObject::tr( "FREE_EDGES" );
576 aControl = SMESH_Actor::eFreeEdges;
579 aTitle = QObject::tr( "FREE_BORDERS" );
580 aControl = SMESH_Actor::eFreeBorders;
583 aTitle = QObject::tr( "MULTI_BORDERS" );
584 aControl = SMESH_Actor::eMultiConnection;
587 aTitle = QObject::tr( "MULTI2D_BORDERS" );
588 aControl = SMESH_Actor::eMultiConnection2D;
591 aTitle = QObject::tr( "AREA_ELEMENTS" );
592 aControl = SMESH_Actor::eArea;
595 aTitle = QObject::tr( "TAPER_ELEMENTS" );
596 aControl = SMESH_Actor::eTaper;
599 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
600 aControl = SMESH_Actor::eAspectRatio;
603 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
604 aControl = SMESH_Actor::eAspectRatio3D;
607 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
608 aControl = SMESH_Actor::eMinimumAngle;
611 aTitle = QObject::tr( "WARP_ELEMENTS" );
612 aControl = SMESH_Actor::eWarping;
615 aTitle = QObject::tr( "SKEW_ELEMENTS" );
616 aControl = SMESH_Actor::eSkew;
619 anActor->SetControlMode(aControl);
620 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
627 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
628 MeshObjectType theType,
629 const QString theInTypeName,
630 QString & theOutTypeName)
632 SMESH_TypeFilter aTypeFilter( theType );
634 if( !theIO.IsNull() )
636 entry = theIO->getEntry();
637 SalomeApp_DataOwner owner( entry );
638 if ( aTypeFilter.isOk( &owner )) {
639 theOutTypeName = theInTypeName;
647 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
649 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
650 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
652 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
653 CORBA::String_var anID = aSComp->GetID().c_str();
654 if (!strcmp(anID.in(),theIO->getEntry()))
660 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
661 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
662 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
663 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
664 CheckOIType ( theIO, GROUP, "Group", aTypeName )
672 QString CheckHomogeneousSelection()
674 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
675 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
676 SALOME_ListIO selected;
678 aSel->selectedObjects( selected );
680 QString RefType = CheckTypeObject(selected.First());
681 SALOME_ListIteratorOfListIO It(selected);
682 for (; It.More(); It.Next())
684 Handle(SALOME_InteractiveObject) IObject = It.Value();
685 QString Type = CheckTypeObject(IObject);
686 if (Type.compare(RefType) != 0)
687 return "Heterogeneous Selection";
695 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
696 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
697 SALOME_ListIO selected; aSel->selectedObjects( selected );
699 QString aParentComponent = QString::null;
700 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
702 QString cur = anIt.Value()->getComponentDataType();
703 if( aParentComponent.isNull() )
704 aParentComponent = cur;
705 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
706 aParentComponent = "";
709 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
710 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
711 QObject::tr("ERR_ERROR"),
712 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
713 QObject::tr("BUT_OK") );
716 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
717 if (SUIT_MessageBox::warn2
718 (SMESHGUI::desktop(),
719 QObject::tr("SMESH_WRN_WARNING"),
720 QObject::tr("SMESH_REALLY_DELETE"),
721 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
724 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
725 SUIT_ViewManager* vm = anApp->activeViewManager();
726 int nbSf = vm->getViewsCount();
728 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
729 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
730 _PTR(GenericAttribute) anAttr;
731 _PTR(AttributeIOR) anIOR;
733 SALOME_ListIteratorOfListIO It(selected);
735 aStudyBuilder->NewCommand(); // There is a transaction
736 for(; It.More(); It.Next()){
737 Handle(SALOME_InteractiveObject) IObject = It.Value();
738 if(IObject->hasEntry()){
739 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
741 /* Erase child graphical objects */
742 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
743 for(it->InitEx(true); it->More(); it->Next()){
744 _PTR(SObject) CSO = it->Value();
745 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
748 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
749 for(int i = 0; i < nbSf; i++){
750 SUIT_ViewWindow *sf = aViews[i];
751 CORBA::String_var anEntry = CSO->GetID().c_str();
752 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
753 SMESH::RemoveActor(sf,anActor);
759 /* Erase main graphical object */
760 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
761 for(int i = 0; i < nbSf; i++){
762 SUIT_ViewWindow *sf = aViews[i];
763 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
764 SMESH::RemoveActor(sf,anActor);
768 // Remove object(s) from data structures
769 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
771 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
772 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
774 if ( !aGroup->_is_nil() ) { // DELETE GROUP
775 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
776 aMesh->RemoveGroup( aGroup );
778 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
779 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
780 aMesh->RemoveSubMesh( aSubMesh );
782 else {// default action: remove SObject from the study
783 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
784 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
786 aStudyBuilder->RemoveObjectWithChildren( obj );
791 } /* IObject->hasEntry() */
793 aStudyBuilder->CommitCommand();
795 /* Clear any previous selection */
796 SALOME_ListIO selected1;
797 aSel->setSelectedObjects( selected1 );
799 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
803 //=============================================================================
807 //=============================================================================
808 class CustomItem : public QCustomMenuItem
811 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
814 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
817 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
818 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
819 p->setFont( myFont );
820 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
826 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
829 bool fullSpan() const
840 Standard_EXPORT CAM_Module* createModule()
842 return SMESHGUI::GetSMESHGUI();
846 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
848 //=============================================================================
852 //=============================================================================
853 SMESHGUI::SMESHGUI() :
854 SalomeApp_Module( "SMESH" )
856 if ( CORBA::is_nil( myComponentSMESH ) )
858 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
859 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
860 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
863 myActiveDialogBox = 0 ;
866 SMESH::GetFilterManager();
869 /* load resources for all available meshers */
870 SMESH::InitAvailableHypotheses();
873 //=============================================================================
877 //=============================================================================
878 SMESHGUI::~SMESHGUI()
880 SMESH::GetFilterManager()->Destroy();
883 //=============================================================================
887 //=============================================================================
888 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
890 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
892 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
897 //=============================================================================
901 //=============================================================================
902 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
904 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
907 //=============================================================================
911 //=============================================================================
912 SMESHGUI* SMESHGUI::GetSMESHGUI()
914 static SMESHGUI* aSMESHGUI = NULL;
916 aSMESHGUI = new SMESHGUI();
918 if(_PTR(Study) aStudy = SMESH::GetActiveStudyDocument())
919 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
921 SUIT_ResourceMgr* mgr = resourceMgr();
923 /* Automatic Update flag */
924 aSMESHGUI->myAutomaticUpdate = ( mgr->stringValue( "SMESH", "AutomaticUpdate" ).compare( "true" ) == 0 );
931 Standard_EXPORT SMESHGUI* GetComponentGUI() {
932 return SMESHGUI::GetSMESHGUI();
936 //=============================================================================
940 //=============================================================================
941 void SMESHGUI::SetState(int aState)
946 //=============================================================================
950 //=============================================================================
951 void SMESHGUI::ResetState()
956 //=============================================================================
960 //=============================================================================
961 void SMESHGUI::EmitSignalDeactivateDialog()
963 emit SignalDeactivateActiveDialog();
966 //=============================================================================
970 //=============================================================================
971 void SMESHGUI::EmitSignalStudyFrameChanged()
973 emit SignalStudyFrameChanged();
976 //=============================================================================
980 //=============================================================================
981 void SMESHGUI::EmitSignalCloseAllDialogs()
983 emit SignalCloseAllDialogs();
986 //=============================================================================
990 //=============================================================================
991 QDialog *SMESHGUI::GetActiveDialogBox()
993 return myActiveDialogBox;
996 //=============================================================================
1000 //=============================================================================
1001 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1003 myActiveDialogBox = (QDialog *) aDlg;
1007 //=============================================================================
1011 //=============================================================================
1012 SUIT_Desktop* SMESHGUI::desktop()
1014 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1016 return app->desktop();
1021 //=============================================================================
1025 //=============================================================================
1026 SalomeApp_Study* SMESHGUI::activeStudy()
1028 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1030 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1035 //=============================================================================
1039 //=============================================================================
1040 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1042 /* Here the position is on the bottom right corner - 10 */
1043 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1045 SUIT_Desktop *PP = desktop();
1046 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1047 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1051 //=============================================================================
1055 //=============================================================================
1056 static int isStudyLocked(_PTR(Study) theStudy){
1057 return theStudy->GetProperties()->IsLocked();
1060 static bool checkLock(_PTR(Study) theStudy) {
1061 if (isStudyLocked(theStudy)) {
1062 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1063 QObject::tr("WRN_WARNING"),
1064 QObject::tr("WRN_STUDY_LOCKED"),
1065 QObject::tr("BUT_OK") );
1071 //=======================================================================
1072 //function : CheckActiveStudyLocked
1074 //=======================================================================
1076 bool SMESHGUI::isActiveStudyLocked()
1078 _PTR(Study) aStudy = activeStudy()->studyDS();
1079 return checkLock( aStudy );
1082 //=============================================================================
1086 //=============================================================================
1087 bool SMESHGUI::OnGUIEvent( int theCommandID )
1089 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1093 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1094 SUIT_ResourceMgr* mgr = resourceMgr();
1098 SUIT_ViewManager* vm = application()->activeViewManager();
1102 SUIT_ViewWindow* view =vm->getActiveView();
1103 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1105 QAction* act = action( theCommandID );
1107 switch (theCommandID) {
1109 if(checkLock(aStudy)) break;
1117 if(checkLock(aStudy)) break;
1118 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1122 case 122: // EXPORT MED
1129 ::ExportMeshToFile(theCommandID);
1133 case 200: // SCALAR BAR
1135 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1136 SALOME_ListIO selected;
1138 aSel->selectedObjects( selected );
1140 if( selected.Extent() ) {
1141 Handle(SALOME_InteractiveObject) anIO = selected.First();
1142 if( anIO->hasEntry() ) {
1143 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1144 anActor->SetControlMode( SMESH_Actor::eNone );
1152 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1153 SALOME_ListIO selected;
1155 aSel->selectedObjects( selected );
1157 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( desktop(), aSel );
1161 case 1134: // Clipping
1162 case 1133: // Tranparency
1163 case 1132: // Colors / Size
1170 ::SetDisplayMode(theCommandID);
1176 case 219: // Volumes
1177 case 220: // All Entity
1178 ::SetDisplayEntity(theCommandID);
1183 if(checkLock(aStudy)) break;
1184 SMESH::UpdateView();
1189 case 301: // DISPLAY
1190 case 302: // DISPLAY ONLY
1192 SMESH::EDisplaing anAction;
1193 switch(theCommandID){
1194 case 300: anAction = SMESH::eErase; break;
1195 case 301: anAction = SMESH::eDisplay; break;
1196 case 302: anAction = SMESH::eDisplayOnly; break;
1199 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1200 SALOME_ListIO selected;
1202 aSel->selectedObjects( selected );
1205 SALOME_ListIteratorOfListIO It(selected);
1206 for (; It.More(); It.Next()) {
1207 Handle(SALOME_InteractiveObject) IOS = It.Value();
1208 if (IOS->hasEntry()) {
1209 SMESH::UpdateView(anAction,IOS->getEntry());
1213 SALOME_ListIO selected1;
1214 aSel->setSelectedObjects( selected1 );
1220 if(checkLock(aStudy)) break;
1223 EmitSignalDeactivateDialog();
1225 new SMESHGUI_NodesDlg(this);
1228 SUIT_MessageBox::warn1(desktop(),
1229 tr("SMESH_WRN_WARNING"),
1230 tr("SMESH_WRN_VIEWER_VTK"),
1231 tr("SMESH_BUT_OK"));
1236 case 2151: // FILTER
1240 EmitSignalDeactivateDialog();
1241 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1246 case 406: // MOVE NODE
1250 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1251 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1255 if(checkLock(aStudy)) break;
1256 new SMESHGUI_MoveNodesDlg(this);
1260 case 701: // COMPUTE MESH
1262 if(checkLock(aStudy)) break;
1264 SalomeApp_SelectionMgr *Sel = selectionMgr();
1265 SALOME_ListIO selected; Sel->selectedObjects( selected );
1267 int nbSel = selected.Extent();
1272 SMESH::SMESH_Mesh_var aMesh;
1273 SMESH::SMESH_subMesh_var aSubMesh;
1274 Handle(SALOME_InteractiveObject) IObject = selected.First();
1275 if (IObject->hasEntry()){
1276 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1277 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1278 if ( aShapeObject->_is_nil() ) {
1283 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1284 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1286 if (!aMesh->_is_nil()){
1287 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1288 if (!refShapeObject->_is_nil()) {
1289 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1290 SUIT_MessageBox::warn1(desktop(),
1291 tr("SMESH_WRN_WARNING"),
1292 tr("SMESH_WRN_MISSING_PARAMETERS"),
1293 tr("SMESH_BUT_OK"));
1297 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1298 SMESH::ModifiedMesh(aMeshSObj,true);
1299 // TO Do : change icon of all submeshes
1301 SUIT_MessageBox::warn1(desktop(),
1302 tr("SMESH_WRN_WARNING"),
1303 tr("SMESH_WRN_COMPUTE_FAILED"),
1304 tr("SMESH_BUT_OK"));
1306 catch(const SALOME::SALOME_Exception & S_ex){
1307 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1310 }else if(!aSubMesh->_is_nil()){
1311 aMesh = aSubMesh->GetFather();
1312 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1313 if(!refShapeObject->_is_nil()){
1314 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1316 SUIT_MessageBox::warn1(desktop(),
1317 tr("SMESH_WRN_WARNING"),
1318 tr("SMESH_WRN_MISSING_PARAMETERS"),
1319 tr("SMESH_BUT_OK"));
1323 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1324 SMESH::ModifiedMesh(aMeshSObj,true);
1325 // TO Do : change icon of all submeshes
1327 SUIT_MessageBox::warn1(desktop(),
1328 tr("SMESH_WRN_WARNING"),
1329 tr("SMESH_WRN_COMPUTE_FAILED"),
1330 tr("SMESH_BUT_OK"));
1331 }catch(const SALOME::SALOME_Exception & S_ex){
1332 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1338 CORBA::Long anId = aStudy->StudyId();
1339 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1340 cout<<"myAutomaticUpdate - "<<myAutomaticUpdate<<endl;
1341 if(myAutomaticUpdate && aVisualObj){
1342 aVisualObj->Update();
1343 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1345 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1347 SMESH::DisplayActor(view,anActor); //apo
1353 SUIT_MessageBox::warn1(desktop(),
1354 tr("SMESH_WRN_WARNING"),
1355 tr("SMESH_WRN_VIEWER_VTK"),
1356 tr("SMESH_BUT_OK"));
1361 case 702: // ADD SUB MESH
1363 if(checkLock(aStudy)) break;
1365 EmitSignalDeactivateDialog();
1366 new SMESHGUI_AddSubMeshDlg( this );
1369 SUIT_MessageBox::warn1(desktop(),
1370 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1371 tr("SMESH_BUT_OK"));
1376 case 703: // INIT MESH
1378 if(checkLock(aStudy)) break;
1379 EmitSignalDeactivateDialog();
1380 new SMESHGUI_InitMeshDlg( this );
1384 case 704: // EDIT Hypothesis
1386 if(checkLock(aStudy)) break;
1387 EmitSignalDeactivateDialog();
1388 new SMESHGUI_EditHypothesesDlg( this );
1392 case 705: // EDIT Global Hypothesis
1394 if(checkLock(aStudy)) break;
1395 EmitSignalDeactivateDialog();
1396 new SMESHGUI_EditHypothesesDlg( this );
1400 case 706: // EDIT Local Hypothesis
1402 if(checkLock(aStudy)) break;
1403 EmitSignalDeactivateDialog();
1404 new SMESHGUI_EditHypothesesDlg( this );
1408 case 407: // DIAGONAL INVERSION
1409 case 408: // Delete diagonal
1413 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1414 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1418 if ( checkLock( aStudy ) )
1421 /*Standard_Boolean aRes;
1422 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1423 if ( aMesh->_is_nil() )
1425 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1426 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1430 EmitSignalDeactivateDialog();
1431 if ( theCommandID == 407 )
1432 new SMESHGUI_TrianglesInversionDlg(this);
1434 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1437 case 409: // Change orientation
1438 case 410: // Union of triangles
1439 case 411: // Cutting of quadrangles
1443 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1444 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1448 if ( checkLock( aStudy ) )
1451 EmitSignalDeactivateDialog();
1452 SMESHGUI_MultiEditDlg* aDlg = NULL;
1453 if ( theCommandID == 409 )
1454 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1455 else if ( theCommandID == 410 )
1456 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1458 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1461 DefineDlgPosition( aDlg, x, y );
1466 case 412: // Smoothing
1468 if(checkLock(aStudy)) break;
1470 EmitSignalDeactivateDialog();
1471 new SMESHGUI_SmoothingDlg( this );
1474 SUIT_MessageBox::warn1(desktop(),
1475 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1476 tr("SMESH_BUT_OK"));
1480 case 413: // Extrusion
1482 if (checkLock(aStudy)) break;
1484 EmitSignalDeactivateDialog();
1485 new SMESHGUI_ExtrusionDlg ( this );
1487 SUIT_MessageBox::warn1(desktop(),
1488 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1489 tr("SMESH_BUT_OK"));
1493 case 414: // Revolution
1495 if(checkLock(aStudy)) break;
1497 EmitSignalDeactivateDialog();
1498 new SMESHGUI_RevolutionDlg( this );
1501 SUIT_MessageBox::warn1(desktop(),
1502 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1503 tr("SMESH_BUT_OK"));
1507 case 415: // Pattern mapping
1509 if ( checkLock( aStudy ) )
1513 EmitSignalDeactivateDialog();
1514 new SMESHGUI_MeshPatternDlg( this );
1517 SUIT_MessageBox::warn1(desktop(),
1518 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1519 tr("SMESH_BUT_OK"));
1523 case 416: // Extrusion along a path
1525 if (checkLock(aStudy)) break;
1527 EmitSignalDeactivateDialog();
1528 new SMESHGUI_ExtrusionAlongPathDlg( this );
1530 SUIT_MessageBox::warn1(desktop(),
1531 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1532 tr("SMESH_BUT_OK"));
1536 case 801: // CREATE GROUP
1538 if(checkLock(aStudy)) break;
1539 EmitSignalDeactivateDialog();
1540 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1542 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1543 SALOME_ListIO selected;
1545 aSel->selectedObjects( selected );
1547 int nbSel = selected.Extent();
1549 // check if mesh is selected
1550 aMesh = SMESH::GetMeshByIO( selected.First() );
1552 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1557 case 802: // CONSTRUCT GROUP
1559 if(checkLock(aStudy)) break;
1560 EmitSignalDeactivateDialog();
1562 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1563 SALOME_ListIO selected;
1565 aSel->selectedObjects( selected );
1567 int nbSel = selected.Extent();
1569 // check if submesh is selected
1570 Handle(SALOME_InteractiveObject) IObject = selected.First();
1571 if (IObject->hasEntry()) {
1572 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1574 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1575 if (!aSubMesh->_is_nil()) {
1577 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1578 // get submesh elements list by types
1579 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1580 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1581 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1582 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1583 // create group for each type o elements
1584 QString aName = IObject->getName();
1585 if (aNodes->length() > 0) {
1586 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1587 aGroup->Add(aNodes.inout());
1589 if (aEdges->length() > 0) {
1590 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1591 aGroup->Add(aEdges.inout());
1593 if (aFaces->length() > 0) {
1594 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1595 aGroup->Add(aFaces.inout());
1597 if (aVolumes->length() > 0) {
1598 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1599 aGroup->Add(aVolumes.inout());
1603 }catch(const SALOME::SALOME_Exception & S_ex){
1604 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1613 case 803: // EDIT GROUP
1615 if(checkLock(aStudy)) break;
1616 EmitSignalDeactivateDialog();
1618 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1619 SALOME_ListIO selected;
1621 aSel->selectedObjects( selected );
1623 SALOME_ListIteratorOfListIO It (selected);
1624 int nbSelectedGroups = 0;
1625 for ( ; It.More(); It.Next() )
1627 SMESH::SMESH_Group_var aGroup =
1628 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1629 if (!aGroup->_is_nil()) {
1631 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1635 if (nbSelectedGroups == 0)
1637 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1643 case 804: // Add elements to group
1645 if(checkLock(aStudy)) break;
1646 if (myState == 800) {
1647 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1648 if (aDlg) aDlg->onAdd();
1653 case 805: // Remove elements from group
1655 if(checkLock(aStudy)) break;
1656 if (myState == 800) {
1657 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1658 if (aDlg) aDlg->onRemove();
1663 case 810: // Union Groups
1664 case 811: // Intersect groups
1665 case 812: // Cut groups
1667 if ( checkLock( aStudy ) )
1670 EmitSignalDeactivateDialog();
1673 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1674 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1675 else aMode = SMESHGUI_GroupOpDlg::CUT;
1677 ( new SMESHGUI_GroupOpDlg( desktop(), SMESHGUI::selectionMgr(), aMode ) )->show();
1681 case 813: // Delete groups with their contents
1683 if ( checkLock( aStudy ) )
1686 EmitSignalDeactivateDialog();
1688 new SMESHGUI_DeleteGroupDlg(this);
1692 case 900: // MESH INFOS
1694 EmitSignalDeactivateDialog();
1695 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1696 SALOME_ListIO selected;
1698 aSel->selectedObjects( selected );
1700 if ( selected.Extent() > 1 ) { // a dlg for each IO
1702 SALOME_ListIteratorOfListIO It (selected);
1703 for ( ; It.More(); It.Next() ) {
1704 IOs.Clear(); IOs.Append( It.Value() );
1705 aSel->setSelectedObjects( IOs );
1706 new SMESHGUI_MeshInfosDlg(this, "", false);
1708 // restore selection
1709 aSel->setSelectedObjects( selected );
1712 new SMESHGUI_MeshInfosDlg(this, "", false);
1716 case 902: // STANDARD MESH INFOS
1718 EmitSignalDeactivateDialog();
1719 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1720 SALOME_ListIO selected;
1722 aSel->selectedObjects( selected );
1724 if ( selected.Extent() > 1 ) { // a dlg for each IO
1726 SALOME_ListIteratorOfListIO It (selected);
1727 for ( ; It.More(); It.Next() ) {
1729 IOs.Append( It.Value() );
1730 aSel->setSelectedObjects( IOs );
1731 new SMESHGUI_StandardMeshInfosDlg(desktop(), "", false);
1733 // restore selection
1734 aSel->setSelectedObjects( selected );
1737 new SMESHGUI_StandardMeshInfosDlg(desktop(), "", false);
1741 case 1001: // AUTOMATIC UPDATE PREFERENCES
1744 mgr->setValue( "SMESH", "AutomaticUpdate", true );
1745 myAutomaticUpdate = true;
1748 mgr->setValue( "SMESH", "AutomaticUpdate", false );
1749 myAutomaticUpdate = false;
1754 case 1003: // MESH PREFERENCES
1756 ::SetDisplaySettings();
1762 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( desktop() );
1768 ( new SMESHGUI_PrecisionDlg( desktop() ) )->exec();
1775 mgr->setValue( "SMESH", "DispayEntity", true );
1778 mgr->setValue( "SMESH", "DispayEntity", false );
1784 SMESHGUI_Preferences_SelectionDlg* aDlg =
1785 new SMESHGUI_Preferences_SelectionDlg(desktop());
1787 QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
1788 aDlg->SetColor(1, aColor);
1790 aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow );
1791 aDlg->SetColor(2, aColor);
1793 aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white );
1794 aDlg->SetColor(3, aColor);
1796 aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) );
1797 aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) );
1798 aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) );
1799 aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) );
1802 QColor aPreColor = aDlg->GetColor(1),
1803 aSelColor = aDlg->GetColor(2),
1804 aHiColor = aDlg->GetColor(3);
1805 int aPreWidth = aDlg->GetWidth(1),
1806 aSelWidth = aDlg->GetWidth(2);
1807 double aTolNodes = aDlg->GetPrecision(1),
1808 aTolItems = aDlg->GetPrecision(2);
1810 mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor );
1811 mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor );
1812 mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor );
1814 mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth );
1815 mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth );
1816 mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes );
1817 mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems );
1819 // update current study settings
1820 SMESH::UpdateSelectionProp();
1823 // update VTK viewer properties
1824 SVTK_RenderWindowInteractor* anInteractor =
1825 dynamic_cast<SVTK_RenderWindowInteractor*>( vtkwnd->getRWInteractor() );
1827 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1828 aSelColor.blue()/255., aSelWidth);
1829 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1830 SVTK_InteractorStyle* aStyle =
1831 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
1834 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1835 aPreColor.blue()/255., aPreWidth);
1838 vtkRenderer* aRenderer = vtkwnd->getRenderer();
1839 vtkActorCollection *aCollection = aRenderer->GetActors();
1840 aCollection->InitTraversal();
1841 while(vtkActor *anAct = aCollection->GetNextActor()){
1842 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1843 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1844 aHiColor.blue()/255.);
1845 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1846 aPreColor.blue()/255.);
1855 case 1100: // EDIT HYPOTHESIS
1857 if(checkLock(aStudy)) break;
1859 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1860 SALOME_ListIO selected;
1862 aSel->selectedObjects( selected );
1864 int nbSel = selected.Extent();
1867 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1869 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1870 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1871 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1872 if ( !Hyp->_is_nil() )
1874 char* sName = Hyp->GetName();
1875 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1878 aCreator->EditHypothesis(Hyp);
1889 case 1101: // RENAME
1891 if ( checkLock( aStudy ) )
1894 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1895 SALOME_ListIO selected;
1897 aSel->selectedObjects( selected );
1899 SALOME_ListIteratorOfListIO It( selected );
1900 for ( ; It.More(); It.Next() )
1902 Handle(SALOME_InteractiveObject) IObject = It.Value();
1903 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1904 _PTR(GenericAttribute) anAttr;
1905 _PTR(AttributeName) aName;
1908 if ( obj->FindAttribute(anAttr, "AttributeName") )
1911 QString newName = QString(aName->Value().c_str());
1912 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1913 if ( !newName.isEmpty() )
1915 //old source: aStudy->renameIObject( IObject, newName );
1916 aName->SetValue( newName.latin1() );
1918 // if current object is group update group's name
1919 SMESH::SMESH_GroupBase_var aGroup =
1920 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1921 if (!aGroup->_is_nil() )
1922 aGroup->SetName( newName.latin1() );
1932 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1934 if(checkLock(aStudy)) break;
1935 SUIT_OverrideCursor wc;
1937 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1938 SALOME_ListIO selected;
1940 aSel->selectedObjects( selected );
1942 SALOME_ListIteratorOfListIO It(selected);
1943 for (int i = 0; It.More(); It.Next(), i++) {
1944 Handle(SALOME_InteractiveObject) IObject = It.Value();
1945 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1947 SALOME_ListIO selected1;
1948 aSel->setSelectedObjects( selected1 );
1953 case 401: // GEOM::EDGE
1954 case 4021: // TRIANGLE
1956 case 4023: // POLYGON
1960 if(checkLock(aStudy)) break;
1962 EmitSignalDeactivateDialog();
1963 SMDSAbs_ElementType type = SMDSAbs_Edge;
1965 switch (theCommandID) {
1966 case 4021: // TRIANGLE
1967 type = SMDSAbs_Face; nbNodes = 3; break;
1969 type = SMDSAbs_Face; nbNodes = 4; break;
1971 type = SMDSAbs_Volume; nbNodes = 4; break;
1972 case 4023: // POLYGON
1973 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1975 type = SMDSAbs_Volume; nbNodes = 8; break;
1976 case 4033: // POLYHEDRE
1977 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1980 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1983 SUIT_MessageBox::warn1(desktop(),
1984 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1985 tr("SMESH_BUT_OK"));
1989 case 4033: // POLYHEDRON
1991 if(checkLock(aStudy)) break;
1993 EmitSignalDeactivateDialog();
1994 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1997 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1998 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1999 tr("SMESH_BUT_OK"));
2003 case 4041: // REMOVES NODES
2005 if(checkLock(aStudy)) break;
2007 EmitSignalDeactivateDialog();
2008 new SMESHGUI_RemoveNodesDlg(this);
2011 SUIT_MessageBox::warn1(desktop(),
2012 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2013 tr("SMESH_BUT_OK"));
2017 case 4042: // REMOVES ELEMENTS
2019 if(checkLock(aStudy)) break;
2021 EmitSignalDeactivateDialog();
2022 new SMESHGUI_RemoveElementsDlg(this);
2026 SUIT_MessageBox::warn1(desktop(),
2027 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2028 tr("SMESH_BUT_OK"));
2032 case 4051: // RENUMBERING NODES
2034 if(checkLock(aStudy)) break;
2036 EmitSignalDeactivateDialog();
2037 new SMESHGUI_RenumberingDlg(desktop(), "", selectionMgr(), 0);
2041 SUIT_MessageBox::warn1(desktop(),
2042 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2043 tr("SMESH_BUT_OK"));
2047 case 4052: // RENUMBERING ELEMENTS
2049 if(checkLock(aStudy)) break;
2051 EmitSignalDeactivateDialog();
2052 new SMESHGUI_RenumberingDlg(desktop(), "", selectionMgr(), 1);
2056 SUIT_MessageBox::warn1(desktop(),
2057 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2058 tr("SMESH_BUT_OK"));
2062 case 4061: // TRANSLATION
2064 if(checkLock(aStudy)) break;
2066 EmitSignalDeactivateDialog();
2067 new SMESHGUI_TranslationDlg( this );
2070 SUIT_MessageBox::warn1(desktop(),
2071 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2072 tr("SMESH_BUT_OK"));
2076 case 4062: // ROTATION
2078 if(checkLock(aStudy)) break;
2080 EmitSignalDeactivateDialog();
2081 new SMESHGUI_RotationDlg( this );
2084 SUIT_MessageBox::warn1(desktop(),
2085 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2086 tr("SMESH_BUT_OK"));
2090 case 4063: // SYMMETRY
2092 if(checkLock(aStudy)) break;
2094 EmitSignalDeactivateDialog();
2095 new SMESHGUI_SymmetryDlg( this );
2098 SUIT_MessageBox::warn1(desktop(),
2099 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2100 tr("SMESH_BUT_OK"));
2104 case 4064: // SEWING
2106 if(checkLock(aStudy)) break;
2108 EmitSignalDeactivateDialog();
2109 new SMESHGUI_SewingDlg( this );
2112 SUIT_MessageBox::warn1(desktop(),
2113 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2114 tr("SMESH_BUT_OK"));
2118 case 4065: // MERGE NODES
2120 if(checkLock(aStudy)) break;
2122 EmitSignalDeactivateDialog();
2123 new SMESHGUI_MergeNodesDlg( this );
2126 SUIT_MessageBox::warn1(desktop(),
2127 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2128 tr("SMESH_BUT_OK"));
2134 case 5000: // HYPOTHESIS
2136 if(checkLock(aStudy)) break;
2137 EmitSignalDeactivateDialog();
2138 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2143 if(checkLock(aStudy)) break;
2144 EmitSignalDeactivateDialog();
2145 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2149 case 5105: // Library of selection filters
2151 static QValueList<int> aTypes;
2152 if ( aTypes.isEmpty() )
2154 aTypes.append( SMESH::NODE );
2155 aTypes.append( SMESH::EDGE );
2156 aTypes.append( SMESH::FACE );
2157 aTypes.append( SMESH::VOLUME );
2159 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2163 case 6017: // CONTROLS
2178 SalomeApp_SelectionMgr* mgr = selectionMgr();
2179 SALOME_ListIO selected; mgr->selectedObjects( selected );
2181 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2182 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2184 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2185 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2186 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2187 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2188 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2189 ::Control( theCommandID );
2194 SUIT_MessageBox::warn1(desktop(),
2195 tr( "SMESH_WRN_WARNING" ),
2196 tr( "SMESH_BAD_SELECTION" ),
2197 tr( "SMESH_BUT_OK" ) );
2201 SUIT_MessageBox::warn1(desktop(),
2202 tr( "SMESH_WRN_WARNING" ),
2203 tr( "NOT_A_VTK_VIEWER" ),
2204 tr( "SMESH_BUT_OK" ) );
2209 SalomeApp_SelectionMgr* mgr = selectionMgr();
2210 SALOME_ListIO selected; mgr->selectedObjects( selected );
2212 if (selected.Extent() == 1) {
2213 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2214 if(anIObject->hasEntry())
2215 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2216 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2223 SalomeApp_SelectionMgr* mgr = selectionMgr();
2224 SALOME_ListIO selected; mgr->selectedObjects( selected );
2226 if (selected.Extent() == 1) {
2227 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2228 if(anIObject->hasEntry())
2229 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2230 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2235 case 10001: // DISPLAY MODE PREFERENCE
2239 action( 10002 )->setOn( false );
2240 action( 10004 )->setOn( false );
2241 action( 10003 )->setOn( true );
2242 mgr->setValue( "SMESH", "DisplayMode", "Wireframe");
2248 action( 10001 )->setOn( false );
2249 action( 10004 )->setOn( false );
2250 action( 10003 )->setOn( true );
2251 mgr->setValue( "SMESH", "DisplayMode", "Shading");
2256 mgr->setValue( "SMESH", "Shrink", act->isOn() );
2262 action( 10001 )->setOn( false );
2263 action( 10002 )->setOn( false );
2264 action( 10003 )->setOn( false );
2265 mgr->setValue( "SMESH", "DisplayMode", "Nodes" );
2275 //=============================================================================
2279 //=============================================================================
2280 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2285 //=============================================================================
2289 //=============================================================================
2290 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2295 //=============================================================================
2299 //=============================================================================
2300 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2305 //=============================================================================
2309 //=============================================================================
2310 bool SMESHGUI::SetSettings(SUIT_Desktop* parent)
2312 MESSAGE("SMESHGUI::SetSettings.");
2313 SMESHGUI::GetSMESHGUI();
2315 SUIT_ResourceMgr* mgr = resourceMgr();
2320 QString DisplayMode = "Shading";
2321 if ( mgr->hasValue("SMESH","DisplayMode") )
2322 DisplayMode = mgr->stringValue("SMESH","DisplayMode");
2324 mgr->setValue("SMESH","DisplayMode", "Shading");
2326 bool Shrink = false;
2327 if ( mgr->hasValue("SMESH","Shrink") )
2328 Shrink = mgr->stringValue("SMESH","Shrink") == "yes";
2330 if (DisplayMode == "Wireframe") {
2332 action( 10004 )->setOn( false );
2333 action( 10002 )->setOn( false );
2334 action( 10001 )->setOn( true );
2335 action( 10003 )->setOn( true );
2337 else if (DisplayMode == "Nodes") {
2339 action( 10004 )->setOn( true );
2340 action( 10002 )->setOn( false );
2341 action( 10001 )->setOn( false );
2342 action( 10003 )->setOn( false );
2345 // default is shading
2346 action( 10004 )->setOn( false );
2347 action( 10002 )->setOn( true );
2348 action( 10001 )->setOn( false );
2349 action( 10003 )->setOn( true );
2351 action( 10003 )->setOn( Shrink );
2354 if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) {
2355 action( 1001 )->setOn( true );
2356 myAutomaticUpdate = true;
2359 action( 1001 )->setOn( false );
2360 myAutomaticUpdate = false;
2363 if ( mgr->booleanValue( "SMESH","DispayEntity", false ) )
2364 action( 10071 )->setOn( true );
2366 action( 10071 )->setOn( false );
2369 SMESH::UpdateSelectionProp();
2372 //action( 111 )->setEnabled( false ); // IMPORT DAT
2373 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2378 //=============================================================================
2379 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2380 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2382 //=============================================================================
2383 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2384 SUIT_ViewWindow* wnd )
2386 if(theIO->hasEntry()){
2387 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2388 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2392 //=======================================================================
2393 // function : createSMESHAction
2395 //=======================================================================
2396 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2399 QWidget* parent = application()->desktop();
2400 SUIT_ResourceMgr* resMgr = resourceMgr();
2402 if ( icon_id.length() )
2403 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2405 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ) );
2406 if ( !pix.isNull() )
2407 icon = QIconSet( pix );
2409 QString tooltip = tr( QString( "TOP_" )+po_id ),
2410 menu = tr( QString( "MEN_" )+po_id ),
2411 status_bar = tr( QString( "STB_" )+po_id );
2413 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2416 //=======================================================================
2417 // function : createPopupItem
2419 //=======================================================================
2420 void SMESHGUI::createPopupItem( const int id,
2421 const QString& clients,
2422 const QString& types,
2423 const QString& theRule,
2428 parentId = popupMgr()->actionId( action( pId ) );
2430 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2431 popupMgr()->insert( action( id ), parentId, 0 );
2433 QChar lc = QtxPopupMgr::Selection::defEquality();
2434 QString rule = "(%1) and (%2) and (%3)";
2435 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2436 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2437 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2440 bool cont = myRules.contains( id );
2442 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2444 popupMgr()->setRule( action( id ), rule, true );
2445 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2448 //=======================================================================
2449 // function : initialize
2451 //=======================================================================
2452 void SMESHGUI::initialize( CAM_Application* app )
2454 SalomeApp_Module::initialize( app );
2456 // ----- create actions --------------
2458 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2459 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2460 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2461 createSMESHAction( 114, "NUM" );
2462 createSMESHAction( 121, "DAT" );
2463 createSMESHAction( 122, "MED" );
2464 createSMESHAction( 123, "UNV" );
2465 createSMESHAction( 124, "EXPORT_DAT" );
2466 createSMESHAction( 125, "EXPORT_MED" );
2467 createSMESHAction( 126, "EXPORT_UNV" );
2468 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2469 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2470 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2471 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2472 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2473 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2474 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2475 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2476 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2477 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2478 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2479 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2480 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2481 createSMESHAction( 804, "ADD" );
2482 createSMESHAction( 805, "REMOVE" );
2483 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2484 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2485 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2486 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2487 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2488 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2489 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2490 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2491 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2492 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2493 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2494 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2495 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2496 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2497 createSMESHAction( 6015, "WRAP", "ICON_WRAP" , 0, true );
2498 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2499 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2500 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2501 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2502 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2503 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2504 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2505 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2506 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2507 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2508 createSMESHAction( 4041, "NODES", "ICON_DLG_REM_NODE" );
2509 createSMESHAction( 4042, "ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2510 createSMESHAction( 4051, "NODES", "ICON_DLG_RENUMBERING_NODES" );
2511 createSMESHAction( 4052, "ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2512 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2513 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2514 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2515 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2516 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2517 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2518 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2519 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2520 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2521 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2522 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2523 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2524 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2525 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2526 createSMESHAction( 415, "MAP", "ICON_MAP" );
2527 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2528 createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true );
2529 createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true );
2530 createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true );
2531 createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true );
2532 createSMESHAction( 1001, "AUTO_UPD", "", 0, true );
2533 createSMESHAction( 1003, "COLORS" );
2534 createSMESHAction( 1005, "SCALAR_BAR" );
2535 createSMESHAction( 1006, "SELECTION" );
2536 createSMESHAction( 10070, "PRECISION", "", 0, true );
2537 createSMESHAction( 10071, "DISP_ENT", "", 0, true );
2538 createSMESHAction( 200, "RESET" );
2539 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2540 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2541 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2542 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2543 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2544 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2545 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2546 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2547 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2548 createSMESHAction( 220, "ALL" );
2549 createSMESHAction( 1100, "EDIT_HYPO" );
2550 createSMESHAction( 1101, "RENAME" );
2551 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2552 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2553 createSMESHAction( 1131, "DISPMODE" );
2554 createSMESHAction( 1132, "COLORS" );
2555 createSMESHAction( 1133, "TRANSP" );
2556 createSMESHAction( 1134, "CLIP" );
2557 createSMESHAction( 1135, "DISP_ENT" );
2558 createSMESHAction( 2000, "CTRL" );
2560 createSMESHAction( 300, "ERASE" );
2561 createSMESHAction( 301, "DISPLAY" );
2562 createSMESHAction( 302, "DISPLAY_ONLY" );
2564 // ----- create menu --------------
2565 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2566 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2567 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2568 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2569 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2570 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2571 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2572 prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ),
2573 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2575 createMenu( separator(), fileId );
2577 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2578 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2580 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2581 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2582 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2583 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
2585 meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ),
2587 dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ),
2588 qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 );
2590 createMenu( 111, importId, -1 );
2591 createMenu( 112, importId, -1 );
2592 createMenu( 113, importId, -1 );
2594 createMenu( 121, exportId, -1 );
2595 createMenu( 122, exportId, -1 );
2596 createMenu( 123, exportId, -1 );
2598 createMenu( separator(), fileId, 10 );
2600 createMenu( 33, editId, -1 );
2602 createMenu( 5105, toolsId, -1 );
2604 createMenu( 5000, hypoId, -1 );
2605 createMenu( 5010, hypoId, -1 );
2607 createMenu( 703, meshId, -1 );
2608 createMenu( 702, meshId, -1 );
2609 createMenu( 704, meshId, -1 );
2610 createMenu( separator(), meshId, -1 );
2611 createMenu( 701, meshId, -1 );
2612 createMenu( separator(), meshId, -1 );
2613 createMenu( 801, meshId, -1 );
2614 createMenu( 802, meshId, -1 );
2615 createMenu( 803, meshId, -1 );
2616 createMenu( separator(), meshId, -1 );
2617 createMenu( 810, meshId, -1 );
2618 createMenu( 811, meshId, -1 );
2619 createMenu( 812, meshId, -1 );
2620 createMenu( separator(), meshId, -1 );
2621 createMenu( 813, meshId, -1 );
2622 createMenu( separator(), meshId, -1 );
2623 createMenu( 900, meshId, -1 );
2624 createMenu( 902, meshId, -1 );
2625 createMenu( separator(), meshId, -1 );
2627 createMenu( 6003, ctrlId, -1 );
2628 createMenu( 6001, ctrlId, -1 );
2629 createMenu( 6004, ctrlId, -1 );
2630 createMenu( separator(), ctrlId, -1 );
2631 createMenu( 6002, ctrlId, -1 );
2632 createMenu( 6018, ctrlId, -1 );
2633 createMenu( 6019, ctrlId, -1 );
2634 createMenu( 6011, ctrlId, -1 );
2635 createMenu( 6012, ctrlId, -1 );
2636 createMenu( 6013, ctrlId, -1 );
2637 createMenu( 6014, ctrlId, -1 );
2638 createMenu( 6015, ctrlId, -1 );
2639 createMenu( 6016, ctrlId, -1 );
2640 createMenu( separator(), ctrlId, -1 );
2641 createMenu( 6017, ctrlId, -1 );
2642 createMenu( separator(), ctrlId, -1 );
2644 createMenu( 400, addId, -1 );
2645 createMenu( 401, addId, -1 );
2646 createMenu( 4021, addId, -1 );
2647 createMenu( 4022, addId, -1 );
2648 createMenu( 4031, addId, -1 );
2649 createMenu( 4032, addId, -1 );
2651 createMenu( 4041, removeId, -1 );
2652 createMenu( 4042, removeId, -1 );
2654 createMenu( 4051, renumId, -1 );
2655 createMenu( 4052, renumId, -1 );
2657 createMenu( 4061, transfId, -1 );
2658 createMenu( 4062, transfId, -1 );
2659 createMenu( 4063, transfId, -1 );
2660 createMenu( 4064, transfId, -1 );
2661 createMenu( 4065, transfId, -1 );
2663 createMenu( 406, modifyId, -1 );
2664 createMenu( 407, modifyId, -1 );
2665 createMenu( 408, modifyId, -1 );
2666 createMenu( 409, modifyId, -1 );
2667 createMenu( 410, modifyId, -1 );
2668 createMenu( 411, modifyId, -1 );
2669 createMenu( 412, modifyId, -1 );
2670 createMenu( 413, modifyId, -1 );
2671 createMenu( 416, modifyId, -1 );
2672 createMenu( 414, modifyId, -1 );
2673 createMenu( 415, modifyId, -1 );
2675 createMenu( 10001, dispModeId, -1 );
2676 createMenu( 10002, dispModeId, -1 );
2677 createMenu( 10004, dispModeId, -1 );
2678 createMenu( 10003, dispModeId, -1 );
2680 createMenu( 1001, prefId, -1 );
2681 createMenu( separator(), prefId, -1 );
2682 createMenu( 1003, prefId, -1 );
2683 createMenu( separator(), prefId, -1 );
2684 createMenu( 1005, prefId, -1 );
2685 createMenu( separator(), prefId, -1 );
2686 createMenu( 1006, prefId, -1 );
2687 createMenu( separator(), prefId, -1 );
2689 createMenu( 10070, qualityId, -1 );
2690 createMenu( 10071, qualityId, -1 );
2692 createMenu( separator(), prefId, -1 );
2694 createMenu( 214, viewId, -1 );
2696 // ----- create toolbars --------------
2697 int meshTb = createTool( tr( "TB_MESH" ) ),
2698 hypoTb = createTool( tr( "TB_HYPO" ) ),
2699 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2700 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2701 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2702 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2704 createTool( 703, meshTb );
2705 createTool( 702, meshTb );
2706 createTool( 704, meshTb );
2707 createTool( separator(), meshTb );
2708 createTool( 701, meshTb );
2709 createTool( separator(), meshTb );
2710 createTool( 801, meshTb );
2711 createTool( 802, meshTb );
2712 createTool( 803, meshTb );
2713 createTool( separator(), meshTb );
2714 createTool( 900, meshTb );
2715 createTool( 902, meshTb );
2716 createTool( separator(), meshTb );
2718 createTool( 5000, hypoTb );
2719 createTool( 5010, hypoTb );
2721 createTool( 6001, ctrlTb );
2722 createTool( 6003, ctrlTb );
2723 createTool( 6004, ctrlTb );
2724 createTool( separator(), ctrlTb );
2725 createTool( 6002, ctrlTb );
2726 createTool( 6018, ctrlTb );
2727 createTool( 6019, ctrlTb );
2728 createTool( 6011, ctrlTb );
2729 createTool( 6012, ctrlTb );
2730 createTool( 6013, ctrlTb );
2731 createTool( 6014, ctrlTb );
2732 createTool( 6015, ctrlTb );
2733 createTool( 6016, ctrlTb );
2734 createTool( separator(), ctrlTb );
2735 createTool( 6017, ctrlTb );
2736 createTool( separator(), ctrlTb );
2738 createTool( 400, addRemTb );
2739 createTool( 401, addRemTb );
2740 createTool( 4021, addRemTb );
2741 createTool( 4022, addRemTb );
2742 createTool( 4031, addRemTb );
2743 createTool( 4032, addRemTb );
2744 createTool( separator(), addRemTb );
2745 createTool( 4041, addRemTb );
2746 createTool( 4042, addRemTb );
2747 createTool( separator(), addRemTb );
2748 createTool( 4051, addRemTb );
2749 createTool( 4052, addRemTb );
2750 createTool( separator(), addRemTb );
2751 createTool( 4061, addRemTb );
2752 createTool( 4062, addRemTb );
2753 createTool( 4063, addRemTb );
2754 createTool( 4064, addRemTb );
2755 createTool( 4065, addRemTb );
2756 createTool( separator(), addRemTb );
2758 createTool( 406, modifyTb );
2759 createTool( 407, modifyTb );
2760 createTool( 408, modifyTb );
2761 createTool( 409, modifyTb );
2762 createTool( 410, modifyTb );
2763 createTool( 411, modifyTb );
2764 createTool( 412, modifyTb );
2765 createTool( 413, modifyTb );
2766 createTool( 416, modifyTb );
2767 createTool( 414, modifyTb );
2768 createTool( 415, modifyTb );
2770 createTool( 214, dispModeTb );
2774 QString OB = "'ObjectBrowser'",
2775 View = "'" + SVTK_Viewer::Type() + "'",
2777 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2778 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2779 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2780 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2781 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2782 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2783 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2784 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2785 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2786 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2788 mesh_group = mesh + " " + subMesh + " " + group,
2789 hyp_alg = hypo + " " + algo;
2791 // popup for object browser
2793 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2794 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2795 createPopupItem( 803, OB, group ); // EDIT_GROUP
2796 popupMgr()->insert( separator(), -1, 0 );
2797 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2798 createPopupItem( 214, OB, mesh_group ); // UPDATE
2799 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2800 createPopupItem( 902, OB, mesh ); // STD_INFO
2801 popupMgr()->insert( separator(), -1, 0 );
2802 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2803 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2804 popupMgr()->insert( separator(), -1, 0 );
2805 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2806 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2807 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2808 popupMgr()->insert( separator(), -1, 0 );
2809 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2810 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2811 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2812 popupMgr()->insert( separator(), -1, 0 );
2815 createPopupItem( 803, View, group ); // EDIT_GROUP
2816 createPopupItem( 804, View, elems ); // ADD
2817 createPopupItem( 805, View, elems ); // REMOVE
2818 popupMgr()->insert( separator(), -1, 0 );
2819 createPopupItem( 214, View, mesh_group ); // UPDATE
2820 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2821 createPopupItem( 902, View, mesh ); // STD_INFO
2822 popupMgr()->insert( separator(), -1, 0 );
2826 isInvisible("not( isVisible )"),
2827 isEmpty("numberOfNodes = 0"),
2828 isNotEmpty("numberOfNodes <> 0"),
2830 // has nodes, edges, etc in VISIBLE! actor
2831 hasNodes("(numberOfNodes > 0 && isVisible)"),
2832 hasElems("count( elemTypes ) > 0"),
2833 hasDifferentElems("count( elemTypes ) > 1"),
2834 hasEdges("{'Edge'} in elemTypes"),
2835 hasFaces("{'Face'} in elemTypes"),
2836 hasVolumes("{'Volume'} in elemTypes");
2838 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2839 QString aClient = QString( "%1client in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( View );
2840 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2841 QString aMeshInVTK = aClient + "&&" + aType + "&&" + aSelCount;
2843 //-------------------------------------------------
2845 //-------------------------------------------------
2846 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2848 popupMgr()->insert( action( 9010 ), anId, -1 );
2849 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true );
2850 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2852 popupMgr()->insert( action( 9011 ), anId, -1 );
2853 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true );
2854 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2856 popupMgr()->insert( separator(), -1, -1 );
2858 //-------------------------------------------------
2860 //-------------------------------------------------
2861 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2863 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2864 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2865 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2867 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2868 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2869 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2871 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2872 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2873 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2875 popupMgr()->insert( separator(), anId, -1 );
2877 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2878 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2879 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2881 //-------------------------------------------------
2883 //-------------------------------------------------
2884 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2886 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2888 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2889 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true );
2890 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2892 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2893 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true );
2894 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2896 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2897 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true );
2898 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2900 popupMgr()->insert( separator(), anId, -1 );
2902 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2903 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true );
2905 //-------------------------------------------------
2907 //-------------------------------------------------
2908 popupMgr()->insert( action( 1132 ), -1, -1 );
2909 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2911 //-------------------------------------------------
2913 //-------------------------------------------------
2914 popupMgr()->insert( action( 1133 ), -1, -1 );
2915 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2917 //-------------------------------------------------
2919 //-------------------------------------------------
2920 popupMgr()->insert( action( 1134 ), -1, -1 );
2921 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2923 popupMgr()->insert( separator(), -1, -1 );
2925 //-------------------------------------------------
2927 //-------------------------------------------------
2929 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2930 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2931 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2933 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2935 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2936 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2938 popupMgr()->insert( separator(), anId, -1 );
2940 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2941 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2942 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2944 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2945 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2946 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2948 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2949 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2950 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2952 popupMgr()->insert( separator(), anId, -1 );
2954 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2955 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2956 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2958 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2959 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2960 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2962 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2963 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2964 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2966 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2967 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2968 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2970 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2971 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2972 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2974 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2975 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2976 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2978 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2979 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2980 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2982 popupMgr()->insert( action( 6015 ), anId, -1 ); // WRAP
2983 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2984 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2986 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2987 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2988 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2990 popupMgr()->insert( separator(), anId, -1 );
2992 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2993 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2994 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2996 popupMgr()->insert( separator(), anId, -1 );
2998 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2999 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3001 popupMgr()->insert( separator(), -1, -1 );
3003 //-------------------------------------------------
3005 //-------------------------------------------------
3006 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3007 QString aRule = aClient + " and " + aType + " and " + aSelCount;
3008 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3009 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
3011 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3012 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
3014 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3015 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
3017 popupMgr()->insert( separator(), -1, -1 );
3020 void SMESHGUI::activateModule( SUIT_Study* study )
3022 SalomeApp_Module::activateModule( study );
3024 setMenuShown( true );
3025 setToolShown( true );
3027 //SetSettings( desktop() );
3030 void SMESHGUI::deactivateModule( SUIT_Study* study )
3032 setMenuShown( false );
3033 setToolShown( false );
3035 EmitSignalCloseAllDialogs();
3037 SalomeApp_Module::deactivateModule( study );
3040 void SMESHGUI::OnGUIEvent()
3042 const QObject* obj = sender();
3043 if ( !obj || !obj->inherits( "QAction" ) )
3045 int id = actionId((QAction*)obj);
3050 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3052 return myComponentSMESH;
3055 QString SMESHGUI::engineIOR() const
3057 CORBA::ORB_var anORB = getApp()->orb();
3058 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3062 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3064 SMESHGUI_Selection sel;
3065 sel.init( client, selectionMgr() );
3066 popupMgr()->updatePopup( menu, &sel );
3069 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3071 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3072 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3075 void SMESHGUI::viewManagers( QStringList& list ) const
3077 list.append( SVTK_Viewer::Type() );