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
1621 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1622 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1626 if(checkLock(aStudy)) break;
1627 EmitSignalDeactivateDialog();
1629 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1630 SALOME_ListIO selected;
1632 aSel->selectedObjects( selected );
1634 SALOME_ListIteratorOfListIO It (selected);
1635 int nbSelectedGroups = 0;
1636 for ( ; It.More(); It.Next() )
1638 SMESH::SMESH_Group_var aGroup =
1639 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1640 if (!aGroup->_is_nil()) {
1642 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1646 if (nbSelectedGroups == 0)
1648 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1654 case 804: // Add elements to group
1656 if(checkLock(aStudy)) break;
1657 if (myState == 800) {
1658 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1659 if (aDlg) aDlg->onAdd();
1664 case 805: // Remove elements from group
1666 if(checkLock(aStudy)) break;
1667 if (myState == 800) {
1668 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1669 if (aDlg) aDlg->onRemove();
1674 case 810: // Union Groups
1675 case 811: // Intersect groups
1676 case 812: // Cut groups
1680 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1681 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1685 if ( checkLock( aStudy ) )
1688 EmitSignalDeactivateDialog();
1691 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1692 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1693 else aMode = SMESHGUI_GroupOpDlg::CUT;
1695 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1699 case 813: // Delete groups with their contents
1703 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1704 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1708 if ( checkLock( aStudy ) )
1711 EmitSignalDeactivateDialog();
1713 new SMESHGUI_DeleteGroupDlg( this );
1717 case 900: // MESH INFOS
1719 EmitSignalDeactivateDialog();
1720 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1721 SALOME_ListIO selected;
1723 aSel->selectedObjects( selected );
1725 if ( selected.Extent() > 1 ) { // a dlg for each IO
1727 SALOME_ListIteratorOfListIO It (selected);
1728 for ( ; It.More(); It.Next() ) {
1729 IOs.Clear(); IOs.Append( It.Value() );
1730 aSel->setSelectedObjects( IOs );
1731 new SMESHGUI_MeshInfosDlg(this, "", false);
1733 // restore selection
1734 aSel->setSelectedObjects( selected );
1737 new SMESHGUI_MeshInfosDlg(this, "", false);
1741 case 902: // STANDARD MESH INFOS
1743 EmitSignalDeactivateDialog();
1744 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1745 SALOME_ListIO selected;
1747 aSel->selectedObjects( selected );
1749 if ( selected.Extent() > 1 ) { // a dlg for each IO
1751 SALOME_ListIteratorOfListIO It (selected);
1752 for ( ; It.More(); It.Next() ) {
1754 IOs.Append( It.Value() );
1755 aSel->setSelectedObjects( IOs );
1756 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1758 // restore selection
1759 aSel->setSelectedObjects( selected );
1762 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1766 case 1001: // AUTOMATIC UPDATE PREFERENCES
1769 mgr->setValue( "SMESH", "AutomaticUpdate", true );
1770 myAutomaticUpdate = true;
1773 mgr->setValue( "SMESH", "AutomaticUpdate", false );
1774 myAutomaticUpdate = false;
1779 case 1003: // MESH PREFERENCES
1781 ::SetDisplaySettings();
1787 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( this );
1793 ( new SMESHGUI_PrecisionDlg( this ) )->exec();
1800 mgr->setValue( "SMESH", "DispayEntity", true );
1803 mgr->setValue( "SMESH", "DispayEntity", false );
1809 SMESHGUI_Preferences_SelectionDlg* aDlg =
1810 new SMESHGUI_Preferences_SelectionDlg( this );
1812 QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
1813 aDlg->SetColor(1, aColor);
1815 aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow );
1816 aDlg->SetColor(2, aColor);
1818 aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white );
1819 aDlg->SetColor(3, aColor);
1821 aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) );
1822 aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) );
1823 aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) );
1824 aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) );
1827 QColor aPreColor = aDlg->GetColor(1),
1828 aSelColor = aDlg->GetColor(2),
1829 aHiColor = aDlg->GetColor(3);
1830 int aPreWidth = aDlg->GetWidth(1),
1831 aSelWidth = aDlg->GetWidth(2);
1832 double aTolNodes = aDlg->GetPrecision(1),
1833 aTolItems = aDlg->GetPrecision(2);
1835 mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor );
1836 mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor );
1837 mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor );
1839 mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth );
1840 mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth );
1841 mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes );
1842 mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems );
1844 // update current study settings
1845 SMESH::UpdateSelectionProp( this );
1848 // update VTK viewer properties
1849 SVTK_RenderWindowInteractor* anInteractor =
1850 dynamic_cast<SVTK_RenderWindowInteractor*>( vtkwnd->getRWInteractor() );
1852 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1853 aSelColor.blue()/255., aSelWidth);
1854 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1855 SVTK_InteractorStyle* aStyle =
1856 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
1859 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1860 aPreColor.blue()/255., aPreWidth);
1863 vtkRenderer* aRenderer = vtkwnd->getRenderer();
1864 vtkActorCollection *aCollection = aRenderer->GetActors();
1865 aCollection->InitTraversal();
1866 while(vtkActor *anAct = aCollection->GetNextActor()){
1867 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1868 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1869 aHiColor.blue()/255.);
1870 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1871 aPreColor.blue()/255.);
1880 case 1100: // EDIT HYPOTHESIS
1882 if(checkLock(aStudy)) break;
1884 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1885 SALOME_ListIO selected;
1887 aSel->selectedObjects( selected );
1889 int nbSel = selected.Extent();
1892 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1894 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1895 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1896 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1897 if ( !Hyp->_is_nil() )
1899 char* sName = Hyp->GetName();
1900 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1903 aCreator->EditHypothesis(Hyp);
1911 updateObjBrowser( true );
1915 case 1101: // RENAME
1917 if ( checkLock( aStudy ) )
1920 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1921 SALOME_ListIO selected;
1923 aSel->selectedObjects( selected );
1925 SALOME_ListIteratorOfListIO It( selected );
1926 for ( ; It.More(); It.Next() )
1928 Handle(SALOME_InteractiveObject) IObject = It.Value();
1929 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1930 _PTR(GenericAttribute) anAttr;
1931 _PTR(AttributeName) aName;
1934 if ( obj->FindAttribute(anAttr, "AttributeName") )
1937 QString newName = QString(aName->Value().c_str());
1938 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1939 if ( !newName.isEmpty() )
1941 //old source: aStudy->renameIObject( IObject, newName );
1942 aName->SetValue( newName.latin1() );
1944 // if current object is group update group's name
1945 SMESH::SMESH_GroupBase_var aGroup =
1946 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1947 if (!aGroup->_is_nil() )
1948 aGroup->SetName( newName.latin1() );
1958 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1960 if(checkLock(aStudy)) break;
1961 SUIT_OverrideCursor wc;
1963 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1964 SALOME_ListIO selected;
1966 aSel->selectedObjects( selected );
1968 SALOME_ListIteratorOfListIO It(selected);
1969 for (int i = 0; It.More(); It.Next(), i++) {
1970 Handle(SALOME_InteractiveObject) IObject = It.Value();
1971 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1974 aSel->setSelectedObjects( l1 );
1979 case 401: // GEOM::EDGE
1980 case 4021: // TRIANGLE
1982 case 4023: // POLYGON
1986 if(checkLock(aStudy)) break;
1988 EmitSignalDeactivateDialog();
1989 SMDSAbs_ElementType type = SMDSAbs_Edge;
1991 switch (theCommandID) {
1992 case 4021: // TRIANGLE
1993 type = SMDSAbs_Face; nbNodes = 3; break;
1995 type = SMDSAbs_Face; nbNodes = 4; break;
1997 type = SMDSAbs_Volume; nbNodes = 4; break;
1998 case 4023: // POLYGON
1999 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2001 type = SMDSAbs_Volume; nbNodes = 8; break;
2002 case 4033: // POLYHEDRE
2003 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2006 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2009 SUIT_MessageBox::warn1(desktop(),
2010 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2011 tr("SMESH_BUT_OK"));
2015 case 4033: // POLYHEDRON
2017 if(checkLock(aStudy)) break;
2019 EmitSignalDeactivateDialog();
2020 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2023 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2024 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2025 tr("SMESH_BUT_OK"));
2029 case 4041: // REMOVES NODES
2031 if(checkLock(aStudy)) break;
2033 EmitSignalDeactivateDialog();
2034 new SMESHGUI_RemoveNodesDlg(this);
2037 SUIT_MessageBox::warn1(desktop(),
2038 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2039 tr("SMESH_BUT_OK"));
2043 case 4042: // REMOVES ELEMENTS
2045 if(checkLock(aStudy)) break;
2047 EmitSignalDeactivateDialog();
2048 new SMESHGUI_RemoveElementsDlg(this);
2052 SUIT_MessageBox::warn1(desktop(),
2053 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2054 tr("SMESH_BUT_OK"));
2058 case 4051: // RENUMBERING NODES
2060 if(checkLock(aStudy)) break;
2062 EmitSignalDeactivateDialog();
2063 new SMESHGUI_RenumberingDlg( this, "", 0);
2067 SUIT_MessageBox::warn1(desktop(),
2068 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2069 tr("SMESH_BUT_OK"));
2073 case 4052: // RENUMBERING ELEMENTS
2075 if(checkLock(aStudy)) break;
2077 EmitSignalDeactivateDialog();
2078 new SMESHGUI_RenumberingDlg( this, "", 1);
2082 SUIT_MessageBox::warn1(desktop(),
2083 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2084 tr("SMESH_BUT_OK"));
2088 case 4061: // TRANSLATION
2090 if(checkLock(aStudy)) break;
2092 EmitSignalDeactivateDialog();
2093 new SMESHGUI_TranslationDlg( this );
2096 SUIT_MessageBox::warn1(desktop(),
2097 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2098 tr("SMESH_BUT_OK"));
2102 case 4062: // ROTATION
2104 if(checkLock(aStudy)) break;
2106 EmitSignalDeactivateDialog();
2107 new SMESHGUI_RotationDlg( this );
2110 SUIT_MessageBox::warn1(desktop(),
2111 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2112 tr("SMESH_BUT_OK"));
2116 case 4063: // SYMMETRY
2118 if(checkLock(aStudy)) break;
2120 EmitSignalDeactivateDialog();
2121 new SMESHGUI_SymmetryDlg( this );
2124 SUIT_MessageBox::warn1(desktop(),
2125 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2126 tr("SMESH_BUT_OK"));
2130 case 4064: // SEWING
2132 if(checkLock(aStudy)) break;
2134 EmitSignalDeactivateDialog();
2135 new SMESHGUI_SewingDlg( this );
2138 SUIT_MessageBox::warn1(desktop(),
2139 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2140 tr("SMESH_BUT_OK"));
2144 case 4065: // MERGE NODES
2146 if(checkLock(aStudy)) break;
2148 EmitSignalDeactivateDialog();
2149 new SMESHGUI_MergeNodesDlg( this );
2152 SUIT_MessageBox::warn1(desktop(),
2153 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2154 tr("SMESH_BUT_OK"));
2160 case 5000: // HYPOTHESIS
2162 if(checkLock(aStudy)) break;
2163 EmitSignalDeactivateDialog();
2164 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2169 if(checkLock(aStudy)) break;
2170 EmitSignalDeactivateDialog();
2171 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2175 case 5105: // Library of selection filters
2177 static QValueList<int> aTypes;
2178 if ( aTypes.isEmpty() )
2180 aTypes.append( SMESH::NODE );
2181 aTypes.append( SMESH::EDGE );
2182 aTypes.append( SMESH::FACE );
2183 aTypes.append( SMESH::VOLUME );
2185 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2189 case 6017: // CONTROLS
2204 SalomeApp_SelectionMgr* mgr = selectionMgr();
2205 SALOME_ListIO selected; mgr->selectedObjects( selected );
2207 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2208 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2210 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2211 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2212 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2213 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2214 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2215 ::Control( theCommandID );
2220 SUIT_MessageBox::warn1(desktop(),
2221 tr( "SMESH_WRN_WARNING" ),
2222 tr( "SMESH_BAD_SELECTION" ),
2223 tr( "SMESH_BUT_OK" ) );
2227 SUIT_MessageBox::warn1(desktop(),
2228 tr( "SMESH_WRN_WARNING" ),
2229 tr( "NOT_A_VTK_VIEWER" ),
2230 tr( "SMESH_BUT_OK" ) );
2235 SalomeApp_SelectionMgr* mgr = selectionMgr();
2236 SALOME_ListIO selected; mgr->selectedObjects( selected );
2238 if (selected.Extent() == 1) {
2239 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2240 if(anIObject->hasEntry())
2241 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2242 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2249 SalomeApp_SelectionMgr* mgr = selectionMgr();
2250 SALOME_ListIO selected; mgr->selectedObjects( selected );
2252 if (selected.Extent() == 1) {
2253 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2254 if(anIObject->hasEntry())
2255 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2256 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2261 case 10001: // DISPLAY MODE PREFERENCE
2265 action( 10002 )->setOn( false );
2266 action( 10004 )->setOn( false );
2267 action( 10003 )->setOn( true );
2268 mgr->setValue( "SMESH", "DisplayMode", "Wireframe");
2274 action( 10001 )->setOn( false );
2275 action( 10004 )->setOn( false );
2276 action( 10003 )->setOn( true );
2277 mgr->setValue( "SMESH", "DisplayMode", "Shading");
2282 mgr->setValue( "SMESH", "Shrink", act->isOn() );
2288 action( 10001 )->setOn( false );
2289 action( 10002 )->setOn( false );
2290 action( 10003 )->setOn( false );
2291 mgr->setValue( "SMESH", "DisplayMode", "Nodes" );
2297 //updateObjBrowser();
2301 //=============================================================================
2305 //=============================================================================
2306 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2311 //=============================================================================
2315 //=============================================================================
2316 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2321 //=============================================================================
2325 //=============================================================================
2326 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2331 //=============================================================================
2335 //=============================================================================
2336 bool SMESHGUI::SetSettings(SUIT_Desktop* parent)
2338 SMESHGUI::GetSMESHGUI();
2340 SUIT_ResourceMgr* mgr = resourceMgr();
2345 QString DisplayMode = "Shading";
2346 if ( mgr->hasValue("SMESH","DisplayMode") )
2347 DisplayMode = mgr->stringValue("SMESH","DisplayMode");
2349 mgr->setValue("SMESH","DisplayMode", "Shading");
2351 bool Shrink = false;
2352 if ( mgr->hasValue("SMESH","Shrink") )
2353 Shrink = mgr->stringValue("SMESH","Shrink") == "yes";
2355 if (DisplayMode == "Wireframe") {
2357 action( 10004 )->setOn( false );
2358 action( 10002 )->setOn( false );
2359 action( 10001 )->setOn( true );
2360 action( 10003 )->setOn( true );
2362 else if (DisplayMode == "Nodes") {
2364 action( 10004 )->setOn( true );
2365 action( 10002 )->setOn( false );
2366 action( 10001 )->setOn( false );
2367 action( 10003 )->setOn( false );
2370 // default is shading
2371 action( 10004 )->setOn( false );
2372 action( 10002 )->setOn( true );
2373 action( 10001 )->setOn( false );
2374 action( 10003 )->setOn( true );
2377 action( 10003 )->setOn( Shrink );
2380 if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) {
2381 action( 1001 )->setOn( true );
2382 myAutomaticUpdate = true;
2385 action( 1001 )->setOn( false );
2386 myAutomaticUpdate = false;
2389 if ( mgr->booleanValue( "SMESH","DispayEntity", false ) )
2390 action( 10071 )->setOn( true );
2392 action( 10071 )->setOn( false );
2395 SMESH::UpdateSelectionProp( this );
2398 action( 111 )->setEnabled( false ); // IMPORT DAT
2400 //action( 112 )->setEnabled( false );
2401 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2406 //=============================================================================
2407 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2408 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2410 //=============================================================================
2411 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2412 SUIT_ViewWindow* wnd )
2414 if(theIO->hasEntry()){
2415 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2416 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2420 //=======================================================================
2421 // function : createSMESHAction
2423 //=======================================================================
2424 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2427 QWidget* parent = application()->desktop();
2428 SUIT_ResourceMgr* resMgr = resourceMgr();
2430 if ( icon_id.length() )
2431 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2433 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2434 if ( !pix.isNull() )
2435 icon = QIconSet( pix );
2437 QString tooltip = tr( QString( "TOP_" )+po_id ),
2438 menu = tr( QString( "MEN_" )+po_id ),
2439 status_bar = tr( QString( "STB_" )+po_id );
2441 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2444 //=======================================================================
2445 // function : createPopupItem
2447 //=======================================================================
2448 void SMESHGUI::createPopupItem( const int id,
2449 const QString& clients,
2450 const QString& types,
2451 const QString& theRule,
2456 parentId = popupMgr()->actionId( action( pId ) );
2458 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2459 popupMgr()->insert( action( id ), parentId, 0 );
2461 QChar lc = QtxPopupMgr::Selection::defEquality();
2462 QString rule = "(%1) and (%2) and (%3)";
2463 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2464 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2465 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2468 bool cont = myRules.contains( id );
2470 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2472 popupMgr()->setRule( action( id ), rule, true );
2473 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2476 //=======================================================================
2477 // function : initialize
2479 //=======================================================================
2480 void SMESHGUI::initialize( CAM_Application* app )
2482 SalomeApp_Module::initialize( app );
2484 SUIT_ResourceMgr* mgr = app->resourceMgr();
2486 /* Automatic Update flag */
2487 myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2489 // ----- create actions --------------
2491 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2492 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2493 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2494 createSMESHAction( 114, "NUM" );
2495 createSMESHAction( 121, "DAT" );
2496 createSMESHAction( 122, "MED" );
2497 createSMESHAction( 123, "UNV" );
2498 createSMESHAction( 124, "EXPORT_DAT" );
2499 createSMESHAction( 125, "EXPORT_MED" );
2500 createSMESHAction( 126, "EXPORT_UNV" );
2501 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2502 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2503 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2504 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2505 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2506 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2507 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2508 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2509 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2510 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2511 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2512 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2513 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2514 createSMESHAction( 804, "ADD" );
2515 createSMESHAction( 805, "REMOVE" );
2516 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2517 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2518 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2519 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2520 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2521 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2522 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2523 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2524 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2525 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2526 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2527 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2528 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2529 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2530 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2531 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2532 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2533 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2534 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2535 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2536 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2537 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2538 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2539 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2540 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2541 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2542 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2543 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2544 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2545 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2546 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2547 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2548 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2549 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2550 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2551 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2552 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2553 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2554 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2555 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2556 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2557 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2558 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2559 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2560 createSMESHAction( 415, "MAP", "ICON_MAP" );
2561 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2562 createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true );
2563 createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true );
2564 createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true );
2565 createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true );
2566 createSMESHAction( 1001, "AUTO_UPD", "", 0, true );
2567 createSMESHAction( 1003, "COLORS" );
2568 createSMESHAction( 1005, "SCALAR_BAR" );
2569 createSMESHAction( 1006, "SELECTION" );
2570 createSMESHAction( 10070, "PRECISION", "", 0, true );
2571 createSMESHAction( 10071, "DISP_ENT", "", 0, true );
2572 createSMESHAction( 200, "RESET" );
2573 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2574 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2575 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2576 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2577 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2578 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2579 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2580 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2581 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2582 createSMESHAction( 220, "ALL" );
2583 createSMESHAction( 1100, "EDIT_HYPO" );
2584 createSMESHAction( 1101, "RENAME" );
2585 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2586 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2587 createSMESHAction( 1131, "DISPMODE" );
2588 createSMESHAction( 1132, "COLORS" );
2589 createSMESHAction( 1133, "TRANSP" );
2590 createSMESHAction( 1134, "CLIP" );
2591 createSMESHAction( 1135, "DISP_ENT" );
2592 createSMESHAction( 2000, "CTRL" );
2594 createSMESHAction( 300, "ERASE" );
2595 createSMESHAction( 301, "DISPLAY" );
2596 createSMESHAction( 302, "DISPLAY_ONLY" );
2597 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2599 // ----- create menu --------------
2600 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2601 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2602 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2603 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2604 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2605 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2606 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2607 prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ),
2608 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2610 createMenu( separator(), fileId );
2612 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2613 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2615 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2616 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2617 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2618 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
2620 meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ),
2622 dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ),
2623 qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 );
2625 createMenu( 111, importId, -1 );
2626 createMenu( 112, importId, -1 );
2627 createMenu( 113, importId, -1 );
2629 createMenu( 121, exportId, -1 );
2630 createMenu( 122, exportId, -1 );
2631 createMenu( 123, exportId, -1 );
2633 createMenu( separator(), fileId, 10 );
2635 createMenu( 33, editId, -1 );
2637 createMenu( 5105, toolsId, -1 );
2639 createMenu( 5000, hypoId, -1 );
2640 createMenu( 5010, hypoId, -1 );
2642 createMenu( 703, meshId, -1 );
2643 createMenu( 702, meshId, -1 );
2644 createMenu( 704, meshId, -1 );
2645 createMenu( separator(), meshId, -1 );
2646 createMenu( 701, meshId, -1 );
2647 createMenu( separator(), meshId, -1 );
2648 createMenu( 801, meshId, -1 );
2649 createMenu( 802, meshId, -1 );
2650 createMenu( 803, meshId, -1 );
2651 createMenu( separator(), meshId, -1 );
2652 createMenu( 810, meshId, -1 );
2653 createMenu( 811, meshId, -1 );
2654 createMenu( 812, meshId, -1 );
2655 createMenu( separator(), meshId, -1 );
2656 createMenu( 813, meshId, -1 );
2657 createMenu( separator(), meshId, -1 );
2658 createMenu( 900, meshId, -1 );
2659 createMenu( 902, meshId, -1 );
2660 createMenu( separator(), meshId, -1 );
2662 createMenu( 6003, ctrlId, -1 );
2663 createMenu( 6001, ctrlId, -1 );
2664 createMenu( 6004, ctrlId, -1 );
2665 createMenu( separator(), ctrlId, -1 );
2666 createMenu( 6002, ctrlId, -1 );
2667 createMenu( 6018, ctrlId, -1 );
2668 createMenu( 6019, ctrlId, -1 );
2669 createMenu( 6011, ctrlId, -1 );
2670 createMenu( 6012, ctrlId, -1 );
2671 createMenu( 6013, ctrlId, -1 );
2672 createMenu( 6014, ctrlId, -1 );
2673 createMenu( 6015, ctrlId, -1 );
2674 createMenu( 6016, ctrlId, -1 );
2675 createMenu( separator(), ctrlId, -1 );
2676 createMenu( 6017, ctrlId, -1 );
2677 createMenu( separator(), ctrlId, -1 );
2679 createMenu( 400, addId, -1 );
2680 createMenu( 401, addId, -1 );
2681 createMenu( 4021, addId, -1 );
2682 createMenu( 4022, addId, -1 );
2683 createMenu( 4023, addId, -1 );
2684 createMenu( 4031, addId, -1 );
2685 createMenu( 4032, addId, -1 );
2686 createMenu( 4033, addId, -1 );
2688 createMenu( 4041, removeId, -1 );
2689 createMenu( 4042, removeId, -1 );
2691 createMenu( 4051, renumId, -1 );
2692 createMenu( 4052, renumId, -1 );
2694 createMenu( 4061, transfId, -1 );
2695 createMenu( 4062, transfId, -1 );
2696 createMenu( 4063, transfId, -1 );
2697 createMenu( 4064, transfId, -1 );
2698 createMenu( 4065, transfId, -1 );
2700 createMenu( 406, modifyId, -1 );
2701 createMenu( 407, modifyId, -1 );
2702 createMenu( 408, modifyId, -1 );
2703 createMenu( 409, modifyId, -1 );
2704 createMenu( 410, modifyId, -1 );
2705 createMenu( 411, modifyId, -1 );
2706 createMenu( 412, modifyId, -1 );
2707 createMenu( 413, modifyId, -1 );
2708 createMenu( 416, modifyId, -1 );
2709 createMenu( 414, modifyId, -1 );
2710 createMenu( 415, modifyId, -1 );
2712 createMenu( 10001, dispModeId, -1 );
2713 createMenu( 10002, dispModeId, -1 );
2714 createMenu( 10004, dispModeId, -1 );
2715 createMenu( 10003, dispModeId, -1 );
2717 createMenu( 1001, prefId, -1 );
2718 createMenu( separator(), prefId, -1 );
2719 createMenu( 1003, prefId, -1 );
2720 createMenu( separator(), prefId, -1 );
2721 createMenu( 1005, prefId, -1 );
2722 createMenu( separator(), prefId, -1 );
2723 createMenu( 1006, prefId, -1 );
2724 createMenu( separator(), prefId, -1 );
2726 createMenu( 10070, qualityId, -1 );
2727 createMenu( 10071, qualityId, -1 );
2729 createMenu( separator(), prefId, -1 );
2731 createMenu( 214, viewId, -1 );
2733 // ----- create toolbars --------------
2734 int meshTb = createTool( tr( "TB_MESH" ) ),
2735 hypoTb = createTool( tr( "TB_HYPO" ) ),
2736 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2737 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2738 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2739 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2741 createTool( 703, meshTb );
2742 createTool( 702, meshTb );
2743 createTool( 704, meshTb );
2744 createTool( separator(), meshTb );
2745 createTool( 701, meshTb );
2746 createTool( separator(), meshTb );
2747 createTool( 801, meshTb );
2748 createTool( 802, meshTb );
2749 createTool( 803, meshTb );
2750 createTool( separator(), meshTb );
2751 createTool( 900, meshTb );
2752 createTool( 902, meshTb );
2753 createTool( separator(), meshTb );
2755 createTool( 5000, hypoTb );
2756 createTool( 5010, hypoTb );
2758 createTool( 6001, ctrlTb );
2759 createTool( 6003, ctrlTb );
2760 createTool( 6004, ctrlTb );
2761 createTool( separator(), ctrlTb );
2762 createTool( 6002, ctrlTb );
2763 createTool( 6018, ctrlTb );
2764 createTool( 6019, ctrlTb );
2765 createTool( 6011, ctrlTb );
2766 createTool( 6012, ctrlTb );
2767 createTool( 6013, ctrlTb );
2768 createTool( 6014, ctrlTb );
2769 createTool( 6015, ctrlTb );
2770 createTool( 6016, ctrlTb );
2771 createTool( separator(), ctrlTb );
2772 createTool( 6017, ctrlTb );
2773 createTool( separator(), ctrlTb );
2775 createTool( 400, addRemTb );
2776 createTool( 401, addRemTb );
2777 createTool( 4021, addRemTb );
2778 createTool( 4022, addRemTb );
2779 createTool( 4023, addRemTb );
2780 createTool( 4031, addRemTb );
2781 createTool( 4032, addRemTb );
2782 createTool( 4033, addRemTb );
2783 createTool( separator(), addRemTb );
2784 createTool( 4041, addRemTb );
2785 createTool( 4042, addRemTb );
2786 createTool( separator(), addRemTb );
2787 createTool( 4051, addRemTb );
2788 createTool( 4052, addRemTb );
2789 createTool( separator(), addRemTb );
2790 createTool( 4061, addRemTb );
2791 createTool( 4062, addRemTb );
2792 createTool( 4063, addRemTb );
2793 createTool( 4064, addRemTb );
2794 createTool( 4065, addRemTb );
2795 createTool( separator(), addRemTb );
2797 createTool( 406, modifyTb );
2798 createTool( 407, modifyTb );
2799 createTool( 408, modifyTb );
2800 createTool( 409, modifyTb );
2801 createTool( 410, modifyTb );
2802 createTool( 411, modifyTb );
2803 createTool( 412, modifyTb );
2804 createTool( 413, modifyTb );
2805 createTool( 416, modifyTb );
2806 createTool( 414, modifyTb );
2807 createTool( 415, modifyTb );
2809 createTool( 214, dispModeTb );
2813 QString OB = "'ObjectBrowser'",
2814 View = "'" + SVTK_Viewer::Type() + "'",
2816 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2817 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2818 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2819 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2820 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2821 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2822 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2823 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2824 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2825 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2827 mesh_group = mesh + " " + subMesh + " " + group,
2828 hyp_alg = hypo + " " + algo;
2830 // popup for object browser
2832 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2833 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2834 createPopupItem( 803, OB, group ); // EDIT_GROUP
2835 popupMgr()->insert( separator(), -1, 0 );
2836 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2837 createPopupItem( 214, OB, mesh_group ); // UPDATE
2838 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2839 createPopupItem( 902, OB, mesh ); // STD_INFO
2840 popupMgr()->insert( separator(), -1, 0 );
2841 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2842 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2843 popupMgr()->insert( separator(), -1, 0 );
2844 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2845 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2846 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2847 popupMgr()->insert( separator(), -1, 0 );
2848 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2849 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2850 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2851 popupMgr()->insert( separator(), -1, 0 );
2854 createPopupItem( 803, View, group ); // EDIT_GROUP
2855 createPopupItem( 804, View, elems ); // ADD
2856 createPopupItem( 805, View, elems ); // REMOVE
2857 popupMgr()->insert( separator(), -1, 0 );
2858 createPopupItem( 214, View, mesh_group ); // UPDATE
2859 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2860 createPopupItem( 902, View, mesh ); // STD_INFO
2861 popupMgr()->insert( separator(), -1, 0 );
2865 isInvisible("not( isVisible )"),
2866 isEmpty("numberOfNodes = 0"),
2867 isNotEmpty("numberOfNodes <> 0"),
2869 // has nodes, edges, etc in VISIBLE! actor
2870 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2871 hasElems("(count( elemTypes ) > 0)"),
2872 hasDifferentElems("(count( elemTypes ) > 1)"),
2873 hasEdges("({'Edge'} in elemTypes)"),
2874 hasFaces("({'Face'} in elemTypes)"),
2875 hasVolumes("({'Volume'} in elemTypes)");
2877 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2878 QString lc = QtxPopupMgr::Selection::defEquality();
2879 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2880 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2881 QString aMeshInVTK = aClient + "&&" + aType;// + "&&" + aSelCount;
2883 //-------------------------------------------------
2885 //-------------------------------------------------
2886 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2888 popupMgr()->insert( action( 9010 ), anId, -1 );
2889 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true );
2890 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2892 popupMgr()->insert( action( 9011 ), anId, -1 );
2893 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true );
2894 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2896 popupMgr()->insert( separator(), -1, -1 );
2898 //-------------------------------------------------
2900 //-------------------------------------------------
2901 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2903 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2904 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2905 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2907 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2908 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2909 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2911 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2912 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2913 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2915 popupMgr()->insert( separator(), anId, -1 );
2917 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2918 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2919 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2921 //-------------------------------------------------
2923 //-------------------------------------------------
2924 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2926 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2928 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2929 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true );
2930 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2932 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2933 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true );
2934 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2936 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2937 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true );
2938 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2940 popupMgr()->insert( separator(), anId, -1 );
2942 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2943 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true );
2945 //-------------------------------------------------
2947 //-------------------------------------------------
2948 popupMgr()->insert( action( 1132 ), -1, -1 );
2949 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2951 //-------------------------------------------------
2953 //-------------------------------------------------
2954 popupMgr()->insert( action( 1133 ), -1, -1 );
2955 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2957 //-------------------------------------------------
2959 //-------------------------------------------------
2960 popupMgr()->insert( action( 1134 ), -1, -1 );
2961 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2963 popupMgr()->insert( separator(), -1, -1 );
2965 //-------------------------------------------------
2967 //-------------------------------------------------
2969 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2970 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2971 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2973 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2975 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2976 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2978 popupMgr()->insert( separator(), anId, -1 );
2980 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2981 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2982 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2984 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2985 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2986 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2988 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2989 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2990 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2992 popupMgr()->insert( separator(), anId, -1 );
2994 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2995 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2996 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2998 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2999 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
3000 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
3002 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3003 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
3004 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
3006 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3007 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
3008 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
3010 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3011 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
3012 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
3014 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3015 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
3016 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
3018 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3019 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3020 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3022 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3023 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3024 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3026 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3027 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3028 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3030 popupMgr()->insert( separator(), anId, -1 );
3032 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3033 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3034 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3036 popupMgr()->insert( separator(), anId, -1 );
3038 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3039 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3041 popupMgr()->insert( separator(), -1, -1 );
3043 //-------------------------------------------------
3045 //-------------------------------------------------
3046 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3047 QString aRule = aClient + " and " + aType + " and " + aSelCount;
3048 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3049 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
3051 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3052 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
3054 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3055 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
3057 popupMgr()->insert( separator(), -1, -1 );
3059 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
3060 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
3063 bool SMESHGUI::activateModule( SUIT_Study* study )
3065 bool res = SalomeApp_Module::activateModule( study );
3067 setMenuShown( true );
3068 setToolShown( true );
3069 SetSettings( desktop() );
3074 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3076 setMenuShown( false );
3077 setToolShown( false );
3079 EmitSignalCloseAllDialogs();
3081 return SalomeApp_Module::deactivateModule( study );
3084 void SMESHGUI::OnGUIEvent()
3086 const QObject* obj = sender();
3087 if ( !obj || !obj->inherits( "QAction" ) )
3089 int id = actionId((QAction*)obj);
3094 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3096 if ( CORBA::is_nil( myComponentSMESH ) )
3098 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3099 return aGUI.myComponentSMESH;
3101 return myComponentSMESH;
3104 QString SMESHGUI::engineIOR() const
3106 CORBA::ORB_var anORB = getApp()->orb();
3107 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3111 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3113 SMESHGUI_Selection sel;
3114 sel.init( client, selectionMgr() );
3115 popupMgr()->updatePopup( menu, &sel );
3118 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3120 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3121 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3124 void SMESHGUI::viewManagers( QStringList& list ) const
3126 list.append( SVTK_Viewer::Type() );
3129 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
3131 if( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
3132 SMESH::UpdateSelectionProp( this );