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 <VTKViewer_ViewManager.h>
108 #include "SMESHGUI_Utils.h"
109 #include "SMESHGUI_GEOMGenUtils.h"
110 #include "SMESHGUI_MeshUtils.h"
111 #include "SMESHGUI_GroupUtils.h"
112 #include "SMESHGUI_FilterUtils.h"
113 #include "SMESHGUI_PatternUtils.h"
114 #include "SMESHGUI_VTKUtils.h"
116 #include "SALOMEconfig.h"
117 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
120 #define INCLUDE_MENUITEM_DEF
121 #include <qapplication.h>
122 #include <qlineedit.h>
123 #include <qmenudata.h>
124 #include <qmenubar.h>
125 #include <qpopupmenu.h>
128 #include <qpainter.h>
129 #include <qcheckbox.h>
130 #include <qcolordialog.h>
131 #include <qspinbox.h>
136 #include <qradiobutton.h>
138 #include <boost/shared_ptr.hpp>
140 #include <vtkRenderer.h>
141 #include <vtkRenderWindow.h>
142 #include <vtkActorCollection.h>
143 #include <vtkScalarBarActor.h>
144 #include <vtkUnstructuredGrid.h>
146 #include "utilities.h"
148 #include "SALOMEDS_Study.hxx"
149 #include "SALOMEDSClient_StudyBuilder.hxx"
150 #include "SALOMEDSClient_SComponent.hxx"
156 //=============================================================
157 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
160 void ExportMeshToFile(int theCommandID);
162 void SetDisplayMode(int theCommandID);
164 void SetDisplayEntity(int theCommandID);
166 void Control( int theCommandID );
168 void SetDisplaySettings();
172 //=============================================================
173 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
179 if(theCommandID == 113){
180 filter.append(QObject::tr("MED files (*.med)"));
181 filter.append(QObject::tr("All files (*)"));
182 }else if (theCommandID == 112){
183 filter.append(QObject::tr("IDEAS files (*.unv)"));
184 }else if (theCommandID == 111){
185 filter.append(QObject::tr("DAT files (*.dat)"));
187 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
190 QObject::tr("Import mesh"),
192 if(!filename.isEmpty()) {
193 SUIT_OverrideCursor wc;
194 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
197 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
198 switch ( theCommandID ) {
201 aMeshes->length( 1 );
202 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
207 SMESH::DriverMED_ReadStatus res;
208 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
209 if ( res != SMESH::DRS_OK ) {
211 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
212 QObject::tr("SMESH_WRN_WARNING"),
213 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
214 QObject::tr("SMESH_BUT_OK"));
215 aMeshes->length( 0 );
222 bool isEmpty = false;
223 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
224 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
226 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
227 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
228 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
229 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
230 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
237 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
238 QObject::tr("SMESH_WRN_WARNING"),
239 QObject::tr("SMESH_DRS_EMPTY"),
240 QObject::tr("SMESH_BUT_OK"));
244 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
246 catch (const SALOME::SALOME_Exception& S_ex){
248 SalomeApp_Tools::QtCatchCorbaException(S_ex);
255 void ExportMeshToFile( int theCommandID )
257 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
258 SALOME_ListIO selected;
260 aSel->selectedObjects( selected );
262 if(selected.Extent()){
263 Handle(SALOME_InteractiveObject) anIObject = selected.First();
264 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
265 if ( !aMesh->_is_nil() ) {
266 QString aFilter, aTitle = QObject::tr("Export mesh");
267 QMap<QString, SMESH::MED_VERSION> aFilterMap;
268 switch ( theCommandID ) {
271 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
272 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
276 aFilter = QObject::tr("DAT files (*.dat)");
280 if(aMesh->NbPyramids()){
281 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
282 QObject::tr("SMESH_WRN_WARNING"),
283 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
284 QObject::tr("SMESH_BUT_YES"),
285 QObject::tr("SMESH_BUT_NO"),
290 aFilter = QObject::tr("IDEAS files (*.unv)");
297 SMESH::MED_VERSION aFormat;
299 if ( theCommandID != 122 && theCommandID != 125 )
300 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
304 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
305 filters.push_back( it.key() );
307 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
308 fd->setCaption( aTitle );
309 fd->setFilters( filters );
313 aFilename = fd->selectedFile();
314 aFormat = aFilterMap[fd->selectedFilter()];
316 if( !aFilename.isEmpty()
317 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
318 && aFormat==SMESH::MED_V2_1){
319 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
320 QObject::tr("SMESH_WRN_WARNING"),
321 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
322 QObject::tr("SMESH_BUT_YES"),
323 QObject::tr("SMESH_BUT_NO"),
332 if ( !aFilename.isEmpty() ) {
333 // Check whether the file already exists and delete it if yes
334 QFile aFile( aFilename );
335 if ( aFile.exists() )
337 SUIT_OverrideCursor wc;
338 switch ( theCommandID ) {
341 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
345 aMesh->ExportDAT( aFilename.latin1() );
349 aMesh->ExportUNV( aFilename.latin1() );
359 inline void InverseEntityMode(unsigned int& theOutputMode,
360 unsigned int theMode)
362 bool anIsNotPresent = ~theOutputMode & theMode;
364 theOutputMode |= theMode;
366 theOutputMode &= ~theMode;
369 void SetDisplayEntity(int theCommandID){
370 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
371 SALOME_ListIO selected;
373 aSel->selectedObjects( selected );
375 if(selected.Extent() >= 1){
376 SALOME_ListIteratorOfListIO It( selected );
377 for(; It.More(); It.Next()){
378 Handle(SALOME_InteractiveObject) IObject = It.Value();
379 if(IObject->hasEntry()){
380 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
381 unsigned int aMode = anActor->GetEntityMode();
382 switch(theCommandID){
384 InverseEntityMode(aMode,SMESH_Actor::eEdges);
387 InverseEntityMode(aMode,SMESH_Actor::eFaces);
390 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
393 aMode = SMESH_Actor::eAllEntity;
397 anActor->SetEntityMode(aMode);
404 void SetDisplayMode(int theCommandID){
405 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
406 SALOME_ListIO selected;
408 aSel->selectedObjects( selected );
410 if(selected.Extent() >= 1){
411 switch(theCommandID){
413 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
414 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
418 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
419 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
422 SALOME_ListIteratorOfListIO It( selected );
423 for(; It.More(); It.Next()){
424 Handle(SALOME_InteractiveObject) IObject = It.Value();
425 if(IObject->hasEntry()){
426 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
427 switch(theCommandID){
429 anActor->SetRepresentation(SMESH_Actor::eEdge);
432 anActor->SetRepresentation(SMESH_Actor::eSurface);
435 if(anActor->IsShrunk())
438 anActor->SetShrink();
441 anActor->SetRepresentation(SMESH_Actor::ePoint);
445 anActor->GetSufaceColor(color[0], color[1], color[2]);
446 int c0 = int (color[0] * 255);
447 int c1 = int (color[1] * 255);
448 int c2 = int (color[2] * 255);
449 QColor c(c0, c1, c2);
452 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
453 c0 = int (edgecolor[0] * 255);
454 c1 = int (edgecolor[1] * 255);
455 c2 = int (edgecolor[2] * 255);
456 QColor e(c0, c1, c2);
458 float backfacecolor[3];
459 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
460 c0 = int (backfacecolor[0] * 255);
461 c1 = int (backfacecolor[1] * 255);
462 c2 = int (backfacecolor[2] * 255);
463 QColor b(c0, c1, c2);
466 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
467 c0 = int (nodecolor[0] * 255);
468 c1 = int (nodecolor[1] * 255);
469 c2 = int (nodecolor[2] * 255);
470 QColor n(c0, c1, c2);
472 int Edgewidth = (int)anActor->GetLineWidth();
475 int intValue = int(anActor->GetNodeSize());
476 float Shrink = anActor->GetShrinkFactor();
478 SMESHGUI_Preferences_ColorDlg *aDlg =
479 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
480 aDlg->SetColor(1, c);
481 aDlg->SetColor(2, e);
482 aDlg->SetColor(3, n);
483 aDlg->SetColor(4, b);
484 aDlg->SetIntValue(1, Edgewidth);
485 aDlg->SetIntValue(2, intValue);
486 aDlg->SetIntValue(3, int(Shrink*100.));
488 QColor color = aDlg->GetColor(1);
489 QColor edgecolor = aDlg->GetColor(2);
490 QColor nodecolor = aDlg->GetColor(3);
491 QColor backfacecolor = aDlg->GetColor(4);
492 /* actor color and backface color */
493 anActor->SetSufaceColor(float (color.red()) / 255.,
494 float (color.green()) / 255.,
495 float (color.blue()) / 255.);
496 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
497 float (backfacecolor.green()) / 255.,
498 float (backfacecolor.blue()) / 255.);
501 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
502 float (edgecolor.green()) / 255.,
503 float (edgecolor.blue()) / 255.);
505 /* Shrink factor and size edges */
506 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
507 anActor->SetLineWidth(aDlg->GetIntValue(1));
509 /* Nodes color and size */
510 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
511 float (nodecolor.green()) / 255.,
512 float (nodecolor.blue()) / 255.);
513 anActor->SetNodeSize(aDlg->GetIntValue(2));
522 SMESH::RepaintCurrentView();
527 void SetDisplaySettings()
529 SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
533 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
534 SMESHGUI_Preferences_ColorDlg *aDlg =
535 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
537 QColor color = mgr->colorValue( "SMESH", "SettingsFillColor", QColor(0, 170, 255) );
538 aDlg->SetColor(1, color);
540 color = mgr->colorValue( "SMESH", "SettingsOutlineColor", QColor(0, 170, 255) );
541 aDlg->SetColor(2, color);
543 color = mgr->colorValue( "SMESH", "SettingsNodeColor", Qt::red );
544 aDlg->SetColor(3, color);
546 color = mgr->colorValue( "SMESH", "SettingsBackFaceColor", Qt::blue );
547 aDlg->SetColor(4, color);
549 int iVal = mgr->integerValue( "SMESH", "SettingsWidth", 1 );
550 aDlg->SetIntValue(1, iVal);
552 iVal = mgr->integerValue( "SMESH", "SettingsNodesSize", 3 );
553 aDlg->SetIntValue(2, iVal);
555 iVal = mgr->integerValue( "SMESH", "SettingsShrinkCoeff", 75 );
556 aDlg->SetIntValue(3, iVal);
559 mgr->setValue( "SMESH", "SettingsFillColor", aDlg->GetColor(1) );
560 mgr->setValue( "SMESH", "SettingsOutlineColor", aDlg->GetColor(2) );
561 mgr->setValue( "SMESH", "SettingsNodeColor", aDlg->GetColor(3) );
562 mgr->setValue( "SMESH", "SettingsBackFaceColor", aDlg->GetColor(4) );
564 mgr->setValue( "SMESH", "SettingsWidth", aDlg->GetIntValue(1) );
565 mgr->setValue( "SMESH", "SettingsNodesSize", aDlg->GetIntValue(2) );
566 mgr->setValue( "SMESH", "SettingsShrinkCoeff", aDlg->GetIntValue(3) );
573 void Control( int theCommandID )
575 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
576 SALOME_ListIO selected;
578 aSel->selectedObjects( selected );
580 if( !selected.IsEmpty() ){
581 Handle(SALOME_InteractiveObject) anIO = selected.First();
584 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
585 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
586 switch ( theCommandID ){
588 aTitle = QObject::tr( "LENGTH_EDGES" );
589 aControl = SMESH_Actor::eLength;
592 aTitle = QObject::tr( "LENGTH2D_EDGES" );
593 aControl = SMESH_Actor::eLength2D;
596 aTitle = QObject::tr( "FREE_EDGES" );
597 aControl = SMESH_Actor::eFreeEdges;
600 aTitle = QObject::tr( "FREE_BORDERS" );
601 aControl = SMESH_Actor::eFreeBorders;
604 aTitle = QObject::tr( "MULTI_BORDERS" );
605 aControl = SMESH_Actor::eMultiConnection;
608 aTitle = QObject::tr( "MULTI2D_BORDERS" );
609 aControl = SMESH_Actor::eMultiConnection2D;
612 aTitle = QObject::tr( "AREA_ELEMENTS" );
613 aControl = SMESH_Actor::eArea;
616 aTitle = QObject::tr( "TAPER_ELEMENTS" );
617 aControl = SMESH_Actor::eTaper;
620 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
621 aControl = SMESH_Actor::eAspectRatio;
624 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
625 aControl = SMESH_Actor::eAspectRatio3D;
628 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
629 aControl = SMESH_Actor::eMinimumAngle;
632 aTitle = QObject::tr( "WARP_ELEMENTS" );
633 aControl = SMESH_Actor::eWarping;
636 aTitle = QObject::tr( "SKEW_ELEMENTS" );
637 aControl = SMESH_Actor::eSkew;
640 anActor->SetControlMode(aControl);
641 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
648 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
649 MeshObjectType theType,
650 const QString theInTypeName,
651 QString & theOutTypeName)
653 SMESH_TypeFilter aTypeFilter( theType );
655 if( !theIO.IsNull() )
657 entry = theIO->getEntry();
658 SalomeApp_DataOwner owner( entry );
659 if ( aTypeFilter.isOk( &owner )) {
660 theOutTypeName = theInTypeName;
668 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
670 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
671 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
673 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
674 CORBA::String_var anID = aSComp->GetID().c_str();
675 if (!strcmp(anID.in(),theIO->getEntry()))
681 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
682 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
683 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
684 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
685 CheckOIType ( theIO, GROUP, "Group", aTypeName )
693 QString CheckHomogeneousSelection()
695 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
696 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
697 SALOME_ListIO selected;
699 aSel->selectedObjects( selected );
701 QString RefType = CheckTypeObject(selected.First());
702 SALOME_ListIteratorOfListIO It(selected);
703 for (; It.More(); It.Next())
705 Handle(SALOME_InteractiveObject) IObject = It.Value();
706 QString Type = CheckTypeObject(IObject);
707 if (Type.compare(RefType) != 0)
708 return "Heterogeneous Selection";
716 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
717 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
718 SALOME_ListIO selected; aSel->selectedObjects( selected );
720 QString aParentComponent = QString::null;
721 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
723 QString cur = anIt.Value()->getComponentDataType();
724 if( aParentComponent.isNull() )
725 aParentComponent = cur;
726 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
727 aParentComponent = "";
730 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
731 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
732 QObject::tr("ERR_ERROR"),
733 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
734 QObject::tr("BUT_OK") );
737 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
738 if (SUIT_MessageBox::warn2
739 (SMESHGUI::desktop(),
740 QObject::tr("SMESH_WRN_WARNING"),
741 QObject::tr("SMESH_REALLY_DELETE"),
742 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
745 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
746 SUIT_ViewManager* vm = anApp->activeViewManager();
747 int nbSf = vm->getViewsCount();
749 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
750 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
751 _PTR(GenericAttribute) anAttr;
752 _PTR(AttributeIOR) anIOR;
754 SALOME_ListIteratorOfListIO It(selected);
756 aStudyBuilder->NewCommand(); // There is a transaction
757 for(; It.More(); It.Next()){
758 Handle(SALOME_InteractiveObject) IObject = It.Value();
759 if(IObject->hasEntry()){
760 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
762 /* Erase child graphical objects */
763 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
764 for(it->InitEx(true); it->More(); it->Next()){
765 _PTR(SObject) CSO = it->Value();
766 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
769 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
770 for(int i = 0; i < nbSf; i++){
771 SUIT_ViewWindow *sf = aViews[i];
772 CORBA::String_var anEntry = CSO->GetID().c_str();
773 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
774 SMESH::RemoveActor(sf,anActor);
780 /* Erase main graphical object */
781 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
782 for(int i = 0; i < nbSf; i++){
783 SUIT_ViewWindow *sf = aViews[i];
784 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
785 SMESH::RemoveActor(sf,anActor);
789 // Remove object(s) from data structures
790 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
792 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
793 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
795 if ( !aGroup->_is_nil() ) { // DELETE GROUP
796 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
797 aMesh->RemoveGroup( aGroup );
799 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
800 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
801 aMesh->RemoveSubMesh( aSubMesh );
803 else {// default action: remove SObject from the study
804 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
805 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
807 aStudyBuilder->RemoveObjectWithChildren( obj );
812 } /* IObject->hasEntry() */
814 aStudyBuilder->CommitCommand();
816 /* Clear any previous selection */
818 aSel->setSelectedObjects( l1 );
820 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
825 Standard_EXPORT CAM_Module* createModule()
827 return new SMESHGUI();
831 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
833 //=============================================================================
837 //=============================================================================
838 SMESHGUI::SMESHGUI() :
839 SalomeApp_Module( "SMESH" )
841 if ( CORBA::is_nil( myComponentSMESH ) )
843 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
844 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
845 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
848 myAutomaticUpdate = false;
849 myActiveDialogBox = 0 ;
852 SMESH::GetFilterManager();
855 /* load resources for all available meshers */
856 SMESH::InitAvailableHypotheses();
859 //=============================================================================
863 //=============================================================================
864 SMESHGUI::~SMESHGUI()
866 SMESH::GetFilterManager()->Destroy();
869 //=============================================================================
873 //=============================================================================
874 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
876 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
878 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
883 //=============================================================================
887 //=============================================================================
888 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
890 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
893 //=============================================================================
897 //=============================================================================
898 SMESHGUI* SMESHGUI::GetSMESHGUI()
900 SMESHGUI* smeshMod = 0;
901 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
904 CAM_Module* module = app->module( "Mesh" );
905 smeshMod = dynamic_cast<SMESHGUI*>( module );
908 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
910 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
913 _PTR(Study) aStudy = study->studyDS();
915 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
924 Standard_EXPORT SMESHGUI* GetComponentGUI()
926 return SMESHGUI::GetSMESHGUI();
930 //=============================================================================
934 //=============================================================================
935 void SMESHGUI::SetState(int aState)
940 //=============================================================================
944 //=============================================================================
945 void SMESHGUI::ResetState()
950 //=============================================================================
954 //=============================================================================
955 void SMESHGUI::EmitSignalDeactivateDialog()
957 emit SignalDeactivateActiveDialog();
960 //=============================================================================
964 //=============================================================================
965 void SMESHGUI::EmitSignalStudyFrameChanged()
967 emit SignalStudyFrameChanged();
970 //=============================================================================
974 //=============================================================================
975 void SMESHGUI::EmitSignalCloseAllDialogs()
977 emit SignalCloseAllDialogs();
980 //=============================================================================
984 //=============================================================================
985 QDialog *SMESHGUI::GetActiveDialogBox()
987 return myActiveDialogBox;
990 //=============================================================================
994 //=============================================================================
995 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
997 myActiveDialogBox = (QDialog *) aDlg;
1001 //=============================================================================
1005 //=============================================================================
1006 SUIT_Desktop* SMESHGUI::desktop()
1008 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1010 return app->desktop();
1015 //=============================================================================
1019 //=============================================================================
1020 SalomeApp_Study* SMESHGUI::activeStudy()
1022 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1024 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1029 //=============================================================================
1033 //=============================================================================
1034 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1036 /* Here the position is on the bottom right corner - 10 */
1037 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1039 SUIT_Desktop *PP = desktop();
1040 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1041 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1045 //=============================================================================
1049 //=============================================================================
1050 static int isStudyLocked(_PTR(Study) theStudy){
1051 return theStudy->GetProperties()->IsLocked();
1054 static bool checkLock(_PTR(Study) theStudy) {
1055 if (isStudyLocked(theStudy)) {
1056 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1057 QObject::tr("WRN_WARNING"),
1058 QObject::tr("WRN_STUDY_LOCKED"),
1059 QObject::tr("BUT_OK") );
1065 //=======================================================================
1066 //function : CheckActiveStudyLocked
1068 //=======================================================================
1070 bool SMESHGUI::isActiveStudyLocked()
1072 _PTR(Study) aStudy = activeStudy()->studyDS();
1073 return checkLock( aStudy );
1076 //=============================================================================
1080 //=============================================================================
1081 bool SMESHGUI::OnGUIEvent( int theCommandID )
1083 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1087 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1088 SUIT_ResourceMgr* mgr = resourceMgr();
1092 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1093 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1095 QAction* act = action( theCommandID );
1097 switch (theCommandID) {
1099 if(checkLock(aStudy)) break;
1107 if(checkLock(aStudy)) break;
1108 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1112 case 122: // EXPORT MED
1119 ::ExportMeshToFile(theCommandID);
1123 case 200: // SCALAR BAR
1125 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1126 SALOME_ListIO selected;
1128 aSel->selectedObjects( selected );
1130 if( selected.Extent() ) {
1131 Handle(SALOME_InteractiveObject) anIO = selected.First();
1132 if( anIO->hasEntry() ) {
1133 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1134 anActor->SetControlMode( SMESH_Actor::eNone );
1142 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1146 case 1134: // Clipping
1147 case 1133: // Tranparency
1148 case 1132: // Colors / Size
1155 ::SetDisplayMode(theCommandID);
1161 case 219: // Volumes
1162 case 220: // All Entity
1163 ::SetDisplayEntity(theCommandID);
1168 if(checkLock(aStudy)) break;
1169 SMESH::UpdateView();
1172 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1173 aSel->setSelectedObjects( l );
1178 case 301: // DISPLAY
1179 case 302: // DISPLAY ONLY
1181 SMESH::EDisplaing anAction;
1182 switch(theCommandID){
1183 case 300: anAction = SMESH::eErase; break;
1184 case 301: anAction = SMESH::eDisplay; break;
1185 case 302: anAction = SMESH::eDisplayOnly; break;
1188 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1189 SALOME_ListIO selected;
1191 aSel->selectedObjects( selected );
1194 SALOME_ListIteratorOfListIO It(selected);
1195 for (; It.More(); It.Next()) {
1196 Handle(SALOME_InteractiveObject) IOS = It.Value();
1197 if (IOS->hasEntry()) {
1198 SMESH::UpdateView(anAction,IOS->getEntry());
1203 aSel->setSelectedObjects( l1 );
1209 if(checkLock(aStudy)) break;
1212 EmitSignalDeactivateDialog();
1214 new SMESHGUI_NodesDlg(this);
1217 SUIT_MessageBox::warn1(desktop(),
1218 tr("SMESH_WRN_WARNING"),
1219 tr("SMESH_WRN_VIEWER_VTK"),
1220 tr("SMESH_BUT_OK"));
1225 case 2151: // FILTER
1229 EmitSignalDeactivateDialog();
1230 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1235 case 406: // MOVE NODE
1239 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1240 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1244 if(checkLock(aStudy)) break;
1245 new SMESHGUI_MoveNodesDlg(this);
1249 case 701: // COMPUTE MESH
1251 if(checkLock(aStudy)) break;
1253 SalomeApp_SelectionMgr *Sel = selectionMgr();
1254 SALOME_ListIO selected; Sel->selectedObjects( selected );
1256 int nbSel = selected.Extent();
1261 SMESH::SMESH_Mesh_var aMesh;
1262 SMESH::SMESH_subMesh_var aSubMesh;
1263 Handle(SALOME_InteractiveObject) IObject = selected.First();
1264 if (IObject->hasEntry()){
1265 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1266 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1267 if ( aShapeObject->_is_nil() ) {
1272 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1273 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1275 if (!aMesh->_is_nil()){
1276 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1277 if (!refShapeObject->_is_nil()) {
1278 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1279 SUIT_MessageBox::warn1(desktop(),
1280 tr("SMESH_WRN_WARNING"),
1281 tr("SMESH_WRN_MISSING_PARAMETERS"),
1282 tr("SMESH_BUT_OK"));
1286 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1287 SMESH::ModifiedMesh(aMeshSObj,true);
1288 // TO Do : change icon of all submeshes
1290 SUIT_MessageBox::warn1(desktop(),
1291 tr("SMESH_WRN_WARNING"),
1292 tr("SMESH_WRN_COMPUTE_FAILED"),
1293 tr("SMESH_BUT_OK"));
1295 catch(const SALOME::SALOME_Exception & S_ex){
1296 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1299 }else if(!aSubMesh->_is_nil()){
1300 aMesh = aSubMesh->GetFather();
1301 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1302 if(!refShapeObject->_is_nil()){
1303 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1305 SUIT_MessageBox::warn1(desktop(),
1306 tr("SMESH_WRN_WARNING"),
1307 tr("SMESH_WRN_MISSING_PARAMETERS"),
1308 tr("SMESH_BUT_OK"));
1312 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1313 SMESH::ModifiedMesh(aMeshSObj,true);
1314 // TO Do : change icon of all submeshes
1316 SUIT_MessageBox::warn1(desktop(),
1317 tr("SMESH_WRN_WARNING"),
1318 tr("SMESH_WRN_COMPUTE_FAILED"),
1319 tr("SMESH_BUT_OK"));
1320 }catch(const SALOME::SALOME_Exception & S_ex){
1321 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1327 CORBA::Long anId = aStudy->StudyId();
1328 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1329 cout<<"myAutomaticUpdate - "<<myAutomaticUpdate<<endl;
1330 if(myAutomaticUpdate && aVisualObj){
1331 aVisualObj->Update();
1332 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1334 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1336 SMESH::DisplayActor(view,anActor); //apo
1342 SUIT_MessageBox::warn1(desktop(),
1343 tr("SMESH_WRN_WARNING"),
1344 tr("SMESH_WRN_VIEWER_VTK"),
1345 tr("SMESH_BUT_OK"));
1351 case 702: // ADD SUB MESH
1353 if(checkLock(aStudy)) break;
1355 EmitSignalDeactivateDialog();
1356 new SMESHGUI_AddSubMeshDlg( this );
1359 SUIT_MessageBox::warn1(desktop(),
1360 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1361 tr("SMESH_BUT_OK"));
1366 case 703: // INIT MESH
1368 if(checkLock(aStudy)) break;
1369 EmitSignalDeactivateDialog();
1370 new SMESHGUI_InitMeshDlg( this );
1374 case 704: // EDIT Hypothesis
1376 if(checkLock(aStudy)) break;
1377 EmitSignalDeactivateDialog();
1378 new SMESHGUI_EditHypothesesDlg( this );
1382 case 705: // EDIT Global Hypothesis
1384 if(checkLock(aStudy)) break;
1385 EmitSignalDeactivateDialog();
1386 new SMESHGUI_EditHypothesesDlg( this );
1390 case 706: // EDIT Local Hypothesis
1392 if(checkLock(aStudy)) break;
1393 EmitSignalDeactivateDialog();
1394 new SMESHGUI_EditHypothesesDlg( this );
1398 case 407: // DIAGONAL INVERSION
1399 case 408: // Delete diagonal
1403 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1404 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1408 if ( checkLock( aStudy ) )
1411 /*Standard_Boolean aRes;
1412 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1413 if ( aMesh->_is_nil() )
1415 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1416 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1420 EmitSignalDeactivateDialog();
1421 if ( theCommandID == 407 )
1422 new SMESHGUI_TrianglesInversionDlg(this);
1424 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1427 case 409: // Change orientation
1428 case 410: // Union of triangles
1429 case 411: // Cutting of quadrangles
1433 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1434 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1438 if ( checkLock( aStudy ) )
1441 EmitSignalDeactivateDialog();
1442 SMESHGUI_MultiEditDlg* aDlg = NULL;
1443 if ( theCommandID == 409 )
1444 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1445 else if ( theCommandID == 410 )
1446 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1448 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1451 DefineDlgPosition( aDlg, x, y );
1456 case 412: // Smoothing
1458 if(checkLock(aStudy)) break;
1460 EmitSignalDeactivateDialog();
1461 new SMESHGUI_SmoothingDlg( this );
1464 SUIT_MessageBox::warn1(desktop(),
1465 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1466 tr("SMESH_BUT_OK"));
1470 case 413: // Extrusion
1472 if (checkLock(aStudy)) break;
1474 EmitSignalDeactivateDialog();
1475 new SMESHGUI_ExtrusionDlg ( this );
1477 SUIT_MessageBox::warn1(desktop(),
1478 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1479 tr("SMESH_BUT_OK"));
1483 case 414: // Revolution
1485 if(checkLock(aStudy)) break;
1487 EmitSignalDeactivateDialog();
1488 new SMESHGUI_RevolutionDlg( this );
1491 SUIT_MessageBox::warn1(desktop(),
1492 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1493 tr("SMESH_BUT_OK"));
1497 case 415: // Pattern mapping
1499 if ( checkLock( aStudy ) )
1503 EmitSignalDeactivateDialog();
1504 new SMESHGUI_MeshPatternDlg( this );
1507 SUIT_MessageBox::warn1(desktop(),
1508 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1509 tr("SMESH_BUT_OK"));
1513 case 416: // Extrusion along a path
1515 if (checkLock(aStudy)) break;
1517 EmitSignalDeactivateDialog();
1518 new SMESHGUI_ExtrusionAlongPathDlg( this );
1520 SUIT_MessageBox::warn1(desktop(),
1521 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1522 tr("SMESH_BUT_OK"));
1526 case 801: // CREATE GROUP
1530 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1531 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1535 if(checkLock(aStudy)) break;
1536 EmitSignalDeactivateDialog();
1537 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1539 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1540 SALOME_ListIO selected;
1542 aSel->selectedObjects( selected );
1544 int nbSel = selected.Extent();
1546 // check if mesh is selected
1547 aMesh = SMESH::GetMeshByIO( selected.First() );
1549 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1554 case 802: // CONSTRUCT GROUP
1558 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1559 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1563 if(checkLock(aStudy)) break;
1564 EmitSignalDeactivateDialog();
1566 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1567 SALOME_ListIO selected;
1569 aSel->selectedObjects( selected );
1571 int nbSel = selected.Extent();
1573 // check if submesh is selected
1574 Handle(SALOME_InteractiveObject) IObject = selected.First();
1575 if (IObject->hasEntry()) {
1576 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1578 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1579 if (!aSubMesh->_is_nil()) {
1581 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1582 // get submesh elements list by types
1583 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1584 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1585 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1586 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1587 // create group for each type o elements
1588 QString aName = IObject->getName();
1589 if (aNodes->length() > 0) {
1590 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1591 aGroup->Add(aNodes.inout());
1593 if (aEdges->length() > 0) {
1594 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1595 aGroup->Add(aEdges.inout());
1597 if (aFaces->length() > 0) {
1598 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1599 aGroup->Add(aFaces.inout());
1601 if (aVolumes->length() > 0) {
1602 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1603 aGroup->Add(aVolumes.inout());
1607 }catch(const SALOME::SALOME_Exception & S_ex){
1608 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1617 case 803: // EDIT GROUP
1619 if(checkLock(aStudy)) break;
1620 EmitSignalDeactivateDialog();
1622 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1623 SALOME_ListIO selected;
1625 aSel->selectedObjects( selected );
1627 SALOME_ListIteratorOfListIO It (selected);
1628 int nbSelectedGroups = 0;
1629 for ( ; It.More(); It.Next() )
1631 SMESH::SMESH_Group_var aGroup =
1632 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1633 if (!aGroup->_is_nil()) {
1635 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1639 if (nbSelectedGroups == 0)
1641 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1647 case 804: // Add elements to group
1649 if(checkLock(aStudy)) break;
1650 if (myState == 800) {
1651 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1652 if (aDlg) aDlg->onAdd();
1657 case 805: // Remove elements from group
1659 if(checkLock(aStudy)) break;
1660 if (myState == 800) {
1661 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1662 if (aDlg) aDlg->onRemove();
1667 case 810: // Union Groups
1668 case 811: // Intersect groups
1669 case 812: // Cut groups
1671 if ( checkLock( aStudy ) )
1674 EmitSignalDeactivateDialog();
1677 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1678 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1679 else aMode = SMESHGUI_GroupOpDlg::CUT;
1681 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1685 case 813: // Delete groups with their contents
1687 if ( checkLock( aStudy ) )
1690 EmitSignalDeactivateDialog();
1692 new SMESHGUI_DeleteGroupDlg( this );
1696 case 900: // MESH INFOS
1698 EmitSignalDeactivateDialog();
1699 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1700 SALOME_ListIO selected;
1702 aSel->selectedObjects( selected );
1704 if ( selected.Extent() > 1 ) { // a dlg for each IO
1706 SALOME_ListIteratorOfListIO It (selected);
1707 for ( ; It.More(); It.Next() ) {
1708 IOs.Clear(); IOs.Append( It.Value() );
1709 aSel->setSelectedObjects( IOs );
1710 new SMESHGUI_MeshInfosDlg(this, "", false);
1712 // restore selection
1713 aSel->setSelectedObjects( selected );
1716 new SMESHGUI_MeshInfosDlg(this, "", false);
1720 case 902: // STANDARD MESH INFOS
1722 EmitSignalDeactivateDialog();
1723 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1724 SALOME_ListIO selected;
1726 aSel->selectedObjects( selected );
1728 if ( selected.Extent() > 1 ) { // a dlg for each IO
1730 SALOME_ListIteratorOfListIO It (selected);
1731 for ( ; It.More(); It.Next() ) {
1733 IOs.Append( It.Value() );
1734 aSel->setSelectedObjects( IOs );
1735 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1737 // restore selection
1738 aSel->setSelectedObjects( selected );
1741 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1745 case 1001: // AUTOMATIC UPDATE PREFERENCES
1748 mgr->setValue( "SMESH", "AutomaticUpdate", true );
1749 myAutomaticUpdate = true;
1752 mgr->setValue( "SMESH", "AutomaticUpdate", false );
1753 myAutomaticUpdate = false;
1758 case 1003: // MESH PREFERENCES
1760 ::SetDisplaySettings();
1766 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( this );
1772 ( new SMESHGUI_PrecisionDlg( this ) )->exec();
1779 mgr->setValue( "SMESH", "DispayEntity", true );
1782 mgr->setValue( "SMESH", "DispayEntity", false );
1788 SMESHGUI_Preferences_SelectionDlg* aDlg =
1789 new SMESHGUI_Preferences_SelectionDlg( this );
1791 QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
1792 aDlg->SetColor(1, aColor);
1794 aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow );
1795 aDlg->SetColor(2, aColor);
1797 aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white );
1798 aDlg->SetColor(3, aColor);
1800 aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) );
1801 aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) );
1802 aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) );
1803 aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) );
1806 QColor aPreColor = aDlg->GetColor(1),
1807 aSelColor = aDlg->GetColor(2),
1808 aHiColor = aDlg->GetColor(3);
1809 int aPreWidth = aDlg->GetWidth(1),
1810 aSelWidth = aDlg->GetWidth(2);
1811 double aTolNodes = aDlg->GetPrecision(1),
1812 aTolItems = aDlg->GetPrecision(2);
1814 mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor );
1815 mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor );
1816 mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor );
1818 mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth );
1819 mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth );
1820 mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes );
1821 mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems );
1823 // update current study settings
1824 SMESH::UpdateSelectionProp( this );
1827 // update VTK viewer properties
1828 SVTK_RenderWindowInteractor* anInteractor =
1829 dynamic_cast<SVTK_RenderWindowInteractor*>( vtkwnd->getRWInteractor() );
1831 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1832 aSelColor.blue()/255., aSelWidth);
1833 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1834 SVTK_InteractorStyle* aStyle =
1835 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
1838 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1839 aPreColor.blue()/255., aPreWidth);
1842 vtkRenderer* aRenderer = vtkwnd->getRenderer();
1843 vtkActorCollection *aCollection = aRenderer->GetActors();
1844 aCollection->InitTraversal();
1845 while(vtkActor *anAct = aCollection->GetNextActor()){
1846 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1847 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1848 aHiColor.blue()/255.);
1849 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1850 aPreColor.blue()/255.);
1859 case 1100: // EDIT HYPOTHESIS
1861 if(checkLock(aStudy)) break;
1863 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1864 SALOME_ListIO selected;
1866 aSel->selectedObjects( selected );
1868 int nbSel = selected.Extent();
1871 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1873 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1874 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1875 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1876 if ( !Hyp->_is_nil() )
1878 char* sName = Hyp->GetName();
1879 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1882 aCreator->EditHypothesis(Hyp);
1890 updateObjBrowser( true );
1894 case 1101: // RENAME
1896 if ( checkLock( aStudy ) )
1899 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1900 SALOME_ListIO selected;
1902 aSel->selectedObjects( selected );
1904 SALOME_ListIteratorOfListIO It( selected );
1905 for ( ; It.More(); It.Next() )
1907 Handle(SALOME_InteractiveObject) IObject = It.Value();
1908 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1909 _PTR(GenericAttribute) anAttr;
1910 _PTR(AttributeName) aName;
1913 if ( obj->FindAttribute(anAttr, "AttributeName") )
1916 QString newName = QString(aName->Value().c_str());
1917 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1918 if ( !newName.isEmpty() )
1920 //old source: aStudy->renameIObject( IObject, newName );
1921 aName->SetValue( newName.latin1() );
1923 // if current object is group update group's name
1924 SMESH::SMESH_GroupBase_var aGroup =
1925 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1926 if (!aGroup->_is_nil() )
1927 aGroup->SetName( newName.latin1() );
1937 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1939 if(checkLock(aStudy)) break;
1940 SUIT_OverrideCursor wc;
1942 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1943 SALOME_ListIO selected;
1945 aSel->selectedObjects( selected );
1947 SALOME_ListIteratorOfListIO It(selected);
1948 for (int i = 0; It.More(); It.Next(), i++) {
1949 Handle(SALOME_InteractiveObject) IObject = It.Value();
1950 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1953 aSel->setSelectedObjects( l1 );
1958 case 401: // GEOM::EDGE
1959 case 4021: // TRIANGLE
1961 case 4023: // POLYGON
1965 if(checkLock(aStudy)) break;
1967 EmitSignalDeactivateDialog();
1968 SMDSAbs_ElementType type = SMDSAbs_Edge;
1970 switch (theCommandID) {
1971 case 4021: // TRIANGLE
1972 type = SMDSAbs_Face; nbNodes = 3; break;
1974 type = SMDSAbs_Face; nbNodes = 4; break;
1976 type = SMDSAbs_Volume; nbNodes = 4; break;
1977 case 4023: // POLYGON
1978 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1980 type = SMDSAbs_Volume; nbNodes = 8; break;
1981 case 4033: // POLYHEDRE
1982 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1985 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1988 SUIT_MessageBox::warn1(desktop(),
1989 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1990 tr("SMESH_BUT_OK"));
1994 case 4033: // POLYHEDRON
1996 if(checkLock(aStudy)) break;
1998 EmitSignalDeactivateDialog();
1999 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2002 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2003 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2004 tr("SMESH_BUT_OK"));
2008 case 4041: // REMOVES NODES
2010 if(checkLock(aStudy)) break;
2012 EmitSignalDeactivateDialog();
2013 new SMESHGUI_RemoveNodesDlg(this);
2016 SUIT_MessageBox::warn1(desktop(),
2017 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2018 tr("SMESH_BUT_OK"));
2022 case 4042: // REMOVES ELEMENTS
2024 if(checkLock(aStudy)) break;
2026 EmitSignalDeactivateDialog();
2027 new SMESHGUI_RemoveElementsDlg(this);
2031 SUIT_MessageBox::warn1(desktop(),
2032 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2033 tr("SMESH_BUT_OK"));
2037 case 4051: // RENUMBERING NODES
2039 if(checkLock(aStudy)) break;
2041 EmitSignalDeactivateDialog();
2042 new SMESHGUI_RenumberingDlg( this, "", 0);
2046 SUIT_MessageBox::warn1(desktop(),
2047 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2048 tr("SMESH_BUT_OK"));
2052 case 4052: // RENUMBERING ELEMENTS
2054 if(checkLock(aStudy)) break;
2056 EmitSignalDeactivateDialog();
2057 new SMESHGUI_RenumberingDlg( this, "", 1);
2061 SUIT_MessageBox::warn1(desktop(),
2062 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2063 tr("SMESH_BUT_OK"));
2067 case 4061: // TRANSLATION
2069 if(checkLock(aStudy)) break;
2071 EmitSignalDeactivateDialog();
2072 new SMESHGUI_TranslationDlg( this );
2075 SUIT_MessageBox::warn1(desktop(),
2076 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2077 tr("SMESH_BUT_OK"));
2081 case 4062: // ROTATION
2083 if(checkLock(aStudy)) break;
2085 EmitSignalDeactivateDialog();
2086 new SMESHGUI_RotationDlg( this );
2089 SUIT_MessageBox::warn1(desktop(),
2090 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2091 tr("SMESH_BUT_OK"));
2095 case 4063: // SYMMETRY
2097 if(checkLock(aStudy)) break;
2099 EmitSignalDeactivateDialog();
2100 new SMESHGUI_SymmetryDlg( this );
2103 SUIT_MessageBox::warn1(desktop(),
2104 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2105 tr("SMESH_BUT_OK"));
2109 case 4064: // SEWING
2111 if(checkLock(aStudy)) break;
2113 EmitSignalDeactivateDialog();
2114 new SMESHGUI_SewingDlg( this );
2117 SUIT_MessageBox::warn1(desktop(),
2118 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2119 tr("SMESH_BUT_OK"));
2123 case 4065: // MERGE NODES
2125 if(checkLock(aStudy)) break;
2127 EmitSignalDeactivateDialog();
2128 new SMESHGUI_MergeNodesDlg( this );
2131 SUIT_MessageBox::warn1(desktop(),
2132 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2133 tr("SMESH_BUT_OK"));
2139 case 5000: // HYPOTHESIS
2141 if(checkLock(aStudy)) break;
2142 EmitSignalDeactivateDialog();
2143 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2148 if(checkLock(aStudy)) break;
2149 EmitSignalDeactivateDialog();
2150 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2154 case 5105: // Library of selection filters
2156 static QValueList<int> aTypes;
2157 if ( aTypes.isEmpty() )
2159 aTypes.append( SMESH::NODE );
2160 aTypes.append( SMESH::EDGE );
2161 aTypes.append( SMESH::FACE );
2162 aTypes.append( SMESH::VOLUME );
2164 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2168 case 6017: // CONTROLS
2183 SalomeApp_SelectionMgr* mgr = selectionMgr();
2184 SALOME_ListIO selected; mgr->selectedObjects( selected );
2186 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2187 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2189 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2190 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2191 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2192 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2193 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2194 ::Control( theCommandID );
2199 SUIT_MessageBox::warn1(desktop(),
2200 tr( "SMESH_WRN_WARNING" ),
2201 tr( "SMESH_BAD_SELECTION" ),
2202 tr( "SMESH_BUT_OK" ) );
2206 SUIT_MessageBox::warn1(desktop(),
2207 tr( "SMESH_WRN_WARNING" ),
2208 tr( "NOT_A_VTK_VIEWER" ),
2209 tr( "SMESH_BUT_OK" ) );
2214 SalomeApp_SelectionMgr* mgr = selectionMgr();
2215 SALOME_ListIO selected; mgr->selectedObjects( selected );
2217 if (selected.Extent() == 1) {
2218 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2219 if(anIObject->hasEntry())
2220 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2221 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2228 SalomeApp_SelectionMgr* mgr = selectionMgr();
2229 SALOME_ListIO selected; mgr->selectedObjects( selected );
2231 if (selected.Extent() == 1) {
2232 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2233 if(anIObject->hasEntry())
2234 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2235 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2240 case 10001: // DISPLAY MODE PREFERENCE
2244 action( 10002 )->setOn( false );
2245 action( 10004 )->setOn( false );
2246 action( 10003 )->setOn( true );
2247 mgr->setValue( "SMESH", "DisplayMode", "Wireframe");
2253 action( 10001 )->setOn( false );
2254 action( 10004 )->setOn( false );
2255 action( 10003 )->setOn( true );
2256 mgr->setValue( "SMESH", "DisplayMode", "Shading");
2261 mgr->setValue( "SMESH", "Shrink", act->isOn() );
2267 action( 10001 )->setOn( false );
2268 action( 10002 )->setOn( false );
2269 action( 10003 )->setOn( false );
2270 mgr->setValue( "SMESH", "DisplayMode", "Nodes" );
2276 //updateObjBrowser();
2280 //=============================================================================
2284 //=============================================================================
2285 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2290 //=============================================================================
2294 //=============================================================================
2295 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2300 //=============================================================================
2304 //=============================================================================
2305 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2310 //=============================================================================
2314 //=============================================================================
2315 bool SMESHGUI::SetSettings(SUIT_Desktop* parent)
2317 SMESHGUI::GetSMESHGUI();
2319 SUIT_ResourceMgr* mgr = resourceMgr();
2324 QString DisplayMode = "Shading";
2325 if ( mgr->hasValue("SMESH","DisplayMode") )
2326 DisplayMode = mgr->stringValue("SMESH","DisplayMode");
2328 mgr->setValue("SMESH","DisplayMode", "Shading");
2330 bool Shrink = false;
2331 if ( mgr->hasValue("SMESH","Shrink") )
2332 Shrink = mgr->stringValue("SMESH","Shrink") == "yes";
2334 if (DisplayMode == "Wireframe") {
2336 action( 10004 )->setOn( false );
2337 action( 10002 )->setOn( false );
2338 action( 10001 )->setOn( true );
2339 action( 10003 )->setOn( true );
2341 else if (DisplayMode == "Nodes") {
2343 action( 10004 )->setOn( true );
2344 action( 10002 )->setOn( false );
2345 action( 10001 )->setOn( false );
2346 action( 10003 )->setOn( false );
2349 // default is shading
2350 action( 10004 )->setOn( false );
2351 action( 10002 )->setOn( true );
2352 action( 10001 )->setOn( false );
2353 action( 10003 )->setOn( true );
2356 action( 10003 )->setOn( Shrink );
2359 if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) {
2360 action( 1001 )->setOn( true );
2361 myAutomaticUpdate = true;
2364 action( 1001 )->setOn( false );
2365 myAutomaticUpdate = false;
2368 if ( mgr->booleanValue( "SMESH","DispayEntity", false ) )
2369 action( 10071 )->setOn( true );
2371 action( 10071 )->setOn( false );
2374 SMESH::UpdateSelectionProp( this );
2377 action( 111 )->setEnabled( false ); // IMPORT DAT
2379 //action( 112 )->setEnabled( false );
2380 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2385 //=============================================================================
2386 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2387 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2389 //=============================================================================
2390 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2391 SUIT_ViewWindow* wnd )
2393 if(theIO->hasEntry()){
2394 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2395 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2399 //=======================================================================
2400 // function : createSMESHAction
2402 //=======================================================================
2403 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2406 QWidget* parent = application()->desktop();
2407 SUIT_ResourceMgr* resMgr = resourceMgr();
2409 if ( icon_id.length() )
2410 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2412 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ) );
2413 if ( !pix.isNull() )
2414 icon = QIconSet( pix );
2416 QString tooltip = tr( QString( "TOP_" )+po_id ),
2417 menu = tr( QString( "MEN_" )+po_id ),
2418 status_bar = tr( QString( "STB_" )+po_id );
2420 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2423 //=======================================================================
2424 // function : createPopupItem
2426 //=======================================================================
2427 void SMESHGUI::createPopupItem( const int id,
2428 const QString& clients,
2429 const QString& types,
2430 const QString& theRule,
2435 parentId = popupMgr()->actionId( action( pId ) );
2437 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2438 popupMgr()->insert( action( id ), parentId, 0 );
2440 QChar lc = QtxPopupMgr::Selection::defEquality();
2441 QString rule = "(%1) and (%2) and (%3)";
2442 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2443 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2444 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2447 bool cont = myRules.contains( id );
2449 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2451 popupMgr()->setRule( action( id ), rule, true );
2452 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2455 //=======================================================================
2456 // function : initialize
2458 //=======================================================================
2459 void SMESHGUI::initialize( CAM_Application* app )
2461 SalomeApp_Module::initialize( app );
2463 SUIT_ResourceMgr* mgr = app->resourceMgr();
2465 /* Automatic Update flag */
2466 myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2468 // ----- create actions --------------
2470 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2471 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2472 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2473 createSMESHAction( 114, "NUM" );
2474 createSMESHAction( 121, "DAT" );
2475 createSMESHAction( 122, "MED" );
2476 createSMESHAction( 123, "UNV" );
2477 createSMESHAction( 124, "EXPORT_DAT" );
2478 createSMESHAction( 125, "EXPORT_MED" );
2479 createSMESHAction( 126, "EXPORT_UNV" );
2480 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2481 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2482 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2483 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2484 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2485 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2486 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2487 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2488 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2489 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2490 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2491 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2492 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2493 createSMESHAction( 804, "ADD" );
2494 createSMESHAction( 805, "REMOVE" );
2495 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2496 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2497 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2498 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2499 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2500 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2501 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2502 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2503 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2504 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2505 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2506 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2507 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2508 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2509 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2510 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2511 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2512 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2513 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2514 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2515 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2516 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2517 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2518 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2519 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2520 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2521 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2522 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2523 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2524 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2525 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2526 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2527 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2528 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2529 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2530 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2531 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2532 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2533 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2534 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2535 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2536 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2537 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2538 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2539 createSMESHAction( 415, "MAP", "ICON_MAP" );
2540 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2541 createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true );
2542 createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true );
2543 createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true );
2544 createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true );
2545 createSMESHAction( 1001, "AUTO_UPD", "", 0, true );
2546 createSMESHAction( 1003, "COLORS" );
2547 createSMESHAction( 1005, "SCALAR_BAR" );
2548 createSMESHAction( 1006, "SELECTION" );
2549 createSMESHAction( 10070, "PRECISION", "", 0, true );
2550 createSMESHAction( 10071, "DISP_ENT", "", 0, true );
2551 createSMESHAction( 200, "RESET" );
2552 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2553 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2554 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2555 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2556 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2557 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2558 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2559 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2560 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2561 createSMESHAction( 220, "ALL" );
2562 createSMESHAction( 1100, "EDIT_HYPO" );
2563 createSMESHAction( 1101, "RENAME" );
2564 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2565 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2566 createSMESHAction( 1131, "DISPMODE" );
2567 createSMESHAction( 1132, "COLORS" );
2568 createSMESHAction( 1133, "TRANSP" );
2569 createSMESHAction( 1134, "CLIP" );
2570 createSMESHAction( 1135, "DISP_ENT" );
2571 createSMESHAction( 2000, "CTRL" );
2573 createSMESHAction( 300, "ERASE" );
2574 createSMESHAction( 301, "DISPLAY" );
2575 createSMESHAction( 302, "DISPLAY_ONLY" );
2576 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2578 // ----- create menu --------------
2579 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2580 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2581 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2582 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2583 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2584 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2585 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2586 prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ),
2587 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2589 createMenu( separator(), fileId );
2591 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2592 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2594 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2595 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2596 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2597 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
2599 meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ),
2601 dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ),
2602 qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 );
2604 createMenu( 111, importId, -1 );
2605 createMenu( 112, importId, -1 );
2606 createMenu( 113, importId, -1 );
2608 createMenu( 121, exportId, -1 );
2609 createMenu( 122, exportId, -1 );
2610 createMenu( 123, exportId, -1 );
2612 createMenu( separator(), fileId, 10 );
2614 createMenu( 33, editId, -1 );
2616 createMenu( 5105, toolsId, -1 );
2618 createMenu( 5000, hypoId, -1 );
2619 createMenu( 5010, hypoId, -1 );
2621 createMenu( 703, meshId, -1 );
2622 createMenu( 702, meshId, -1 );
2623 createMenu( 704, meshId, -1 );
2624 createMenu( separator(), meshId, -1 );
2625 createMenu( 701, meshId, -1 );
2626 createMenu( separator(), meshId, -1 );
2627 createMenu( 801, meshId, -1 );
2628 createMenu( 802, meshId, -1 );
2629 createMenu( 803, meshId, -1 );
2630 createMenu( separator(), meshId, -1 );
2631 createMenu( 810, meshId, -1 );
2632 createMenu( 811, meshId, -1 );
2633 createMenu( 812, meshId, -1 );
2634 createMenu( separator(), meshId, -1 );
2635 createMenu( 813, meshId, -1 );
2636 createMenu( separator(), meshId, -1 );
2637 createMenu( 900, meshId, -1 );
2638 createMenu( 902, meshId, -1 );
2639 createMenu( separator(), meshId, -1 );
2641 createMenu( 6003, ctrlId, -1 );
2642 createMenu( 6001, ctrlId, -1 );
2643 createMenu( 6004, ctrlId, -1 );
2644 createMenu( separator(), ctrlId, -1 );
2645 createMenu( 6002, ctrlId, -1 );
2646 createMenu( 6018, ctrlId, -1 );
2647 createMenu( 6019, ctrlId, -1 );
2648 createMenu( 6011, ctrlId, -1 );
2649 createMenu( 6012, ctrlId, -1 );
2650 createMenu( 6013, ctrlId, -1 );
2651 createMenu( 6014, ctrlId, -1 );
2652 createMenu( 6015, ctrlId, -1 );
2653 createMenu( 6016, ctrlId, -1 );
2654 createMenu( separator(), ctrlId, -1 );
2655 createMenu( 6017, ctrlId, -1 );
2656 createMenu( separator(), ctrlId, -1 );
2658 createMenu( 400, addId, -1 );
2659 createMenu( 401, addId, -1 );
2660 createMenu( 4021, addId, -1 );
2661 createMenu( 4022, addId, -1 );
2662 createMenu( 4023, addId, -1 );
2663 createMenu( 4031, addId, -1 );
2664 createMenu( 4032, addId, -1 );
2665 createMenu( 4033, addId, -1 );
2667 createMenu( 4041, removeId, -1 );
2668 createMenu( 4042, removeId, -1 );
2670 createMenu( 4051, renumId, -1 );
2671 createMenu( 4052, renumId, -1 );
2673 createMenu( 4061, transfId, -1 );
2674 createMenu( 4062, transfId, -1 );
2675 createMenu( 4063, transfId, -1 );
2676 createMenu( 4064, transfId, -1 );
2677 createMenu( 4065, transfId, -1 );
2679 createMenu( 406, modifyId, -1 );
2680 createMenu( 407, modifyId, -1 );
2681 createMenu( 408, modifyId, -1 );
2682 createMenu( 409, modifyId, -1 );
2683 createMenu( 410, modifyId, -1 );
2684 createMenu( 411, modifyId, -1 );
2685 createMenu( 412, modifyId, -1 );
2686 createMenu( 413, modifyId, -1 );
2687 createMenu( 416, modifyId, -1 );
2688 createMenu( 414, modifyId, -1 );
2689 createMenu( 415, modifyId, -1 );
2691 createMenu( 10001, dispModeId, -1 );
2692 createMenu( 10002, dispModeId, -1 );
2693 createMenu( 10004, dispModeId, -1 );
2694 createMenu( 10003, dispModeId, -1 );
2696 createMenu( 1001, prefId, -1 );
2697 createMenu( separator(), prefId, -1 );
2698 createMenu( 1003, prefId, -1 );
2699 createMenu( separator(), prefId, -1 );
2700 createMenu( 1005, prefId, -1 );
2701 createMenu( separator(), prefId, -1 );
2702 createMenu( 1006, prefId, -1 );
2703 createMenu( separator(), prefId, -1 );
2705 createMenu( 10070, qualityId, -1 );
2706 createMenu( 10071, qualityId, -1 );
2708 createMenu( separator(), prefId, -1 );
2710 createMenu( 214, viewId, -1 );
2712 // ----- create toolbars --------------
2713 int meshTb = createTool( tr( "TB_MESH" ) ),
2714 hypoTb = createTool( tr( "TB_HYPO" ) ),
2715 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2716 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2717 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2718 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2720 createTool( 703, meshTb );
2721 createTool( 702, meshTb );
2722 createTool( 704, meshTb );
2723 createTool( separator(), meshTb );
2724 createTool( 701, meshTb );
2725 createTool( separator(), meshTb );
2726 createTool( 801, meshTb );
2727 createTool( 802, meshTb );
2728 createTool( 803, meshTb );
2729 createTool( separator(), meshTb );
2730 createTool( 900, meshTb );
2731 createTool( 902, meshTb );
2732 createTool( separator(), meshTb );
2734 createTool( 5000, hypoTb );
2735 createTool( 5010, hypoTb );
2737 createTool( 6001, ctrlTb );
2738 createTool( 6003, ctrlTb );
2739 createTool( 6004, ctrlTb );
2740 createTool( separator(), ctrlTb );
2741 createTool( 6002, ctrlTb );
2742 createTool( 6018, ctrlTb );
2743 createTool( 6019, ctrlTb );
2744 createTool( 6011, ctrlTb );
2745 createTool( 6012, ctrlTb );
2746 createTool( 6013, ctrlTb );
2747 createTool( 6014, ctrlTb );
2748 createTool( 6015, ctrlTb );
2749 createTool( 6016, ctrlTb );
2750 createTool( separator(), ctrlTb );
2751 createTool( 6017, ctrlTb );
2752 createTool( separator(), ctrlTb );
2754 createTool( 400, addRemTb );
2755 createTool( 401, addRemTb );
2756 createTool( 4021, addRemTb );
2757 createTool( 4022, addRemTb );
2758 createTool( 4023, addRemTb );
2759 createTool( 4031, addRemTb );
2760 createTool( 4032, addRemTb );
2761 createTool( 4033, addRemTb );
2762 createTool( separator(), addRemTb );
2763 createTool( 4041, addRemTb );
2764 createTool( 4042, addRemTb );
2765 createTool( separator(), addRemTb );
2766 createTool( 4051, addRemTb );
2767 createTool( 4052, addRemTb );
2768 createTool( separator(), addRemTb );
2769 createTool( 4061, addRemTb );
2770 createTool( 4062, addRemTb );
2771 createTool( 4063, addRemTb );
2772 createTool( 4064, addRemTb );
2773 createTool( 4065, addRemTb );
2774 createTool( separator(), addRemTb );
2776 createTool( 406, modifyTb );
2777 createTool( 407, modifyTb );
2778 createTool( 408, modifyTb );
2779 createTool( 409, modifyTb );
2780 createTool( 410, modifyTb );
2781 createTool( 411, modifyTb );
2782 createTool( 412, modifyTb );
2783 createTool( 413, modifyTb );
2784 createTool( 416, modifyTb );
2785 createTool( 414, modifyTb );
2786 createTool( 415, modifyTb );
2788 createTool( 214, dispModeTb );
2792 QString OB = "'ObjectBrowser'",
2793 View = "'" + SVTK_Viewer::Type() + "'",
2795 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2796 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2797 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2798 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2799 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2800 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2801 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2802 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2803 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2804 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2806 mesh_group = mesh + " " + subMesh + " " + group,
2807 hyp_alg = hypo + " " + algo;
2809 // popup for object browser
2811 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2812 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2813 createPopupItem( 803, OB, group ); // EDIT_GROUP
2814 popupMgr()->insert( separator(), -1, 0 );
2815 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2816 createPopupItem( 214, OB, mesh_group ); // UPDATE
2817 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2818 createPopupItem( 902, OB, mesh ); // STD_INFO
2819 popupMgr()->insert( separator(), -1, 0 );
2820 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2821 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2822 popupMgr()->insert( separator(), -1, 0 );
2823 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2824 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2825 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2826 popupMgr()->insert( separator(), -1, 0 );
2827 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2828 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2829 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2830 popupMgr()->insert( separator(), -1, 0 );
2833 createPopupItem( 803, View, group ); // EDIT_GROUP
2834 createPopupItem( 804, View, elems ); // ADD
2835 createPopupItem( 805, View, elems ); // REMOVE
2836 popupMgr()->insert( separator(), -1, 0 );
2837 createPopupItem( 214, View, mesh_group ); // UPDATE
2838 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2839 createPopupItem( 902, View, mesh ); // STD_INFO
2840 popupMgr()->insert( separator(), -1, 0 );
2844 isInvisible("not( isVisible )"),
2845 isEmpty("numberOfNodes = 0"),
2846 isNotEmpty("numberOfNodes <> 0"),
2848 // has nodes, edges, etc in VISIBLE! actor
2849 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2850 hasElems("(count( elemTypes ) > 0)"),
2851 hasDifferentElems("(count( elemTypes ) > 1)"),
2852 hasEdges("({'Edge'} in elemTypes)"),
2853 hasFaces("({'Face'} in elemTypes)"),
2854 hasVolumes("({'Volume'} in elemTypes)");
2856 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2857 QString lc = QtxPopupMgr::Selection::defEquality();
2858 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2859 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2860 QString aMeshInVTK = aClient + "&&" + aType;// + "&&" + aSelCount;
2862 //-------------------------------------------------
2864 //-------------------------------------------------
2865 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2867 popupMgr()->insert( action( 9010 ), anId, -1 );
2868 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true );
2869 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2871 popupMgr()->insert( action( 9011 ), anId, -1 );
2872 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true );
2873 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2875 popupMgr()->insert( separator(), -1, -1 );
2877 //-------------------------------------------------
2879 //-------------------------------------------------
2880 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2882 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2883 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2884 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2886 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2887 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2888 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2890 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2891 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2892 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2894 popupMgr()->insert( separator(), anId, -1 );
2896 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2897 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2898 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2900 //-------------------------------------------------
2902 //-------------------------------------------------
2903 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2905 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2907 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2908 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true );
2909 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2911 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2912 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true );
2913 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2915 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2916 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true );
2917 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2919 popupMgr()->insert( separator(), anId, -1 );
2921 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2922 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true );
2924 //-------------------------------------------------
2926 //-------------------------------------------------
2927 popupMgr()->insert( action( 1132 ), -1, -1 );
2928 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2930 //-------------------------------------------------
2932 //-------------------------------------------------
2933 popupMgr()->insert( action( 1133 ), -1, -1 );
2934 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2936 //-------------------------------------------------
2938 //-------------------------------------------------
2939 popupMgr()->insert( action( 1134 ), -1, -1 );
2940 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2942 popupMgr()->insert( separator(), -1, -1 );
2944 //-------------------------------------------------
2946 //-------------------------------------------------
2948 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2949 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2950 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2952 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2954 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2955 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2957 popupMgr()->insert( separator(), anId, -1 );
2959 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2960 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2961 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2963 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2964 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2965 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2967 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2968 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2969 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2971 popupMgr()->insert( separator(), anId, -1 );
2973 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2974 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2975 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2977 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2978 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2979 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2981 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2982 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2983 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2985 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2986 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2987 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2989 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2990 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2991 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2993 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2994 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2995 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2997 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2998 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2999 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3001 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3002 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3003 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3005 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3006 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3007 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3009 popupMgr()->insert( separator(), anId, -1 );
3011 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3012 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3013 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3015 popupMgr()->insert( separator(), anId, -1 );
3017 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3018 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3020 popupMgr()->insert( separator(), -1, -1 );
3022 //-------------------------------------------------
3024 //-------------------------------------------------
3025 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3026 QString aRule = aClient + " and " + aType + " and " + aSelCount;
3027 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3028 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
3030 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3031 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
3033 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3034 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
3036 popupMgr()->insert( separator(), -1, -1 );
3038 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
3039 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
3042 bool SMESHGUI::activateModule( SUIT_Study* study )
3044 bool res = SalomeApp_Module::activateModule( study );
3046 setMenuShown( true );
3047 setToolShown( true );
3048 SetSettings( desktop() );
3053 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3055 setMenuShown( false );
3056 setToolShown( false );
3058 EmitSignalCloseAllDialogs();
3060 return SalomeApp_Module::deactivateModule( study );
3063 void SMESHGUI::OnGUIEvent()
3065 const QObject* obj = sender();
3066 if ( !obj || !obj->inherits( "QAction" ) )
3068 int id = actionId((QAction*)obj);
3073 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3075 if ( CORBA::is_nil( myComponentSMESH ) )
3077 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3078 return aGUI.myComponentSMESH;
3080 return myComponentSMESH;
3083 QString SMESHGUI::engineIOR() const
3085 CORBA::ORB_var anORB = getApp()->orb();
3086 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3090 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3092 SMESHGUI_Selection sel;
3093 sel.init( client, selectionMgr() );
3094 popupMgr()->updatePopup( menu, &sel );
3097 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3099 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3100 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3103 void SMESHGUI::viewManagers( QStringList& list ) const
3105 list.append( SVTK_Viewer::Type() );
3108 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
3110 if( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
3111 SMESH::UpdateSelectionProp( this );