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_Tools.h"
96 #include "SalomeApp_Study.h"
97 #include "SalomeApp_NameDlg.h"
98 #include "SalomeApp_DataOwner.h"
99 #include "SalomeApp_Application.h"
100 #include "SalomeApp_Preferences.h"
101 #include "SalomeApp_VTKSelector.h"
103 #include "SalomeApp_ImportOperation.h"
105 #include <SVTK_ViewWindow.h>
106 #include <SVTK_ViewModel.h>
108 #include <VTKViewer_ViewManager.h>
110 #include "SMESHGUI_Utils.h"
111 #include "SMESHGUI_GEOMGenUtils.h"
112 #include "SMESHGUI_MeshUtils.h"
113 #include "SMESHGUI_GroupUtils.h"
114 #include "SMESHGUI_FilterUtils.h"
115 #include "SMESHGUI_PatternUtils.h"
116 #include "SMESHGUI_VTKUtils.h"
118 #include "SALOMEconfig.h"
119 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
122 #define INCLUDE_MENUITEM_DEF
123 #include <qapplication.h>
124 #include <qlineedit.h>
125 #include <qmenudata.h>
126 #include <qmenubar.h>
127 #include <qpopupmenu.h>
130 #include <qpainter.h>
131 #include <qcheckbox.h>
132 #include <qcolordialog.h>
133 #include <qspinbox.h>
138 #include <qradiobutton.h>
140 #include <boost/shared_ptr.hpp>
142 #include <vtkRenderer.h>
143 #include <vtkRenderWindow.h>
144 #include <vtkActorCollection.h>
145 #include <vtkScalarBarActor.h>
146 #include <vtkUnstructuredGrid.h>
148 #include "utilities.h"
150 #include "SALOMEDS_Study.hxx"
151 #include "SALOMEDSClient_StudyBuilder.hxx"
152 #include "SALOMEDSClient_SComponent.hxx"
158 //=============================================================
159 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
162 void ExportMeshToFile(int theCommandID);
164 void SetDisplayMode(int theCommandID);
166 void SetDisplayEntity(int theCommandID);
168 void Control( int theCommandID );
170 void SetDisplaySettings();
174 //=============================================================
175 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
181 if(theCommandID == 113){
182 filter.append(QObject::tr("MED files (*.med)"));
183 filter.append(QObject::tr("All files (*)"));
184 }else if (theCommandID == 112){
185 filter.append(QObject::tr("IDEAS files (*.unv)"));
186 }else if (theCommandID == 111){
187 filter.append(QObject::tr("DAT files (*.dat)"));
189 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
192 QObject::tr("Import mesh"),
194 if(!filename.isEmpty()) {
195 SUIT_OverrideCursor wc;
196 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
199 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
200 switch ( theCommandID ) {
203 aMeshes->length( 1 );
204 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
209 SMESH::DriverMED_ReadStatus res;
210 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
211 if ( res != SMESH::DRS_OK ) {
213 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
214 QObject::tr("SMESH_WRN_WARNING"),
215 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
216 QObject::tr("SMESH_BUT_OK"));
217 aMeshes->length( 0 );
224 bool isEmpty = false;
225 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
226 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
228 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
229 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
230 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
231 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
232 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
239 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
240 QObject::tr("SMESH_WRN_WARNING"),
241 QObject::tr("SMESH_DRS_EMPTY"),
242 QObject::tr("SMESH_BUT_OK"));
246 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
248 catch (const SALOME::SALOME_Exception& S_ex){
250 SalomeApp_Tools::QtCatchCorbaException(S_ex);
257 void ExportMeshToFile( int theCommandID )
259 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
260 SALOME_ListIO selected;
262 aSel->selectedObjects( selected );
264 if(selected.Extent()){
265 Handle(SALOME_InteractiveObject) anIObject = selected.First();
266 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
267 if ( !aMesh->_is_nil() ) {
268 QString aFilter, aTitle = QObject::tr("Export mesh");
269 QMap<QString, SMESH::MED_VERSION> aFilterMap;
270 switch ( theCommandID ) {
273 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
274 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
278 aFilter = QObject::tr("DAT files (*.dat)");
282 if(aMesh->NbPyramids()){
283 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
284 QObject::tr("SMESH_WRN_WARNING"),
285 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
286 QObject::tr("SMESH_BUT_YES"),
287 QObject::tr("SMESH_BUT_NO"),
292 aFilter = QObject::tr("IDEAS files (*.unv)");
299 SMESH::MED_VERSION aFormat;
301 if ( theCommandID != 122 && theCommandID != 125 )
302 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
306 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
307 filters.push_back( it.key() );
309 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
310 fd->setCaption( aTitle );
311 fd->setFilters( filters );
315 aFilename = fd->selectedFile();
316 aFormat = aFilterMap[fd->selectedFilter()];
318 if( !aFilename.isEmpty()
319 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
320 && aFormat==SMESH::MED_V2_1){
321 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
322 QObject::tr("SMESH_WRN_WARNING"),
323 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
324 QObject::tr("SMESH_BUT_YES"),
325 QObject::tr("SMESH_BUT_NO"),
334 if ( !aFilename.isEmpty() ) {
335 // Check whether the file already exists and delete it if yes
336 QFile aFile( aFilename );
337 if ( aFile.exists() )
339 SUIT_OverrideCursor wc;
340 switch ( theCommandID ) {
343 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
347 aMesh->ExportDAT( aFilename.latin1() );
351 aMesh->ExportUNV( aFilename.latin1() );
361 inline void InverseEntityMode(unsigned int& theOutputMode,
362 unsigned int theMode)
364 bool anIsNotPresent = ~theOutputMode & theMode;
366 theOutputMode |= theMode;
368 theOutputMode &= ~theMode;
371 void SetDisplayEntity(int theCommandID){
372 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
373 SALOME_ListIO selected;
375 aSel->selectedObjects( selected );
377 if(selected.Extent() >= 1){
378 SALOME_ListIteratorOfListIO It( selected );
379 for(; It.More(); It.Next()){
380 Handle(SALOME_InteractiveObject) IObject = It.Value();
381 if(IObject->hasEntry()){
382 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
383 unsigned int aMode = anActor->GetEntityMode();
384 switch(theCommandID){
386 InverseEntityMode(aMode,SMESH_Actor::eEdges);
389 InverseEntityMode(aMode,SMESH_Actor::eFaces);
392 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
395 aMode = SMESH_Actor::eAllEntity;
399 anActor->SetEntityMode(aMode);
406 void SetDisplayMode(int theCommandID){
407 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
408 SALOME_ListIO selected;
410 aSel->selectedObjects( selected );
412 if(selected.Extent() >= 1){
413 switch(theCommandID){
415 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
416 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
420 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
421 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
424 SALOME_ListIteratorOfListIO It( selected );
425 for(; It.More(); It.Next()){
426 Handle(SALOME_InteractiveObject) IObject = It.Value();
427 if(IObject->hasEntry()){
428 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
429 switch(theCommandID){
431 anActor->SetRepresentation(SMESH_Actor::eEdge);
434 anActor->SetRepresentation(SMESH_Actor::eSurface);
437 if(anActor->IsShrunk())
440 anActor->SetShrink();
443 anActor->SetRepresentation(SMESH_Actor::ePoint);
447 anActor->GetSufaceColor(color[0], color[1], color[2]);
448 int c0 = int (color[0] * 255);
449 int c1 = int (color[1] * 255);
450 int c2 = int (color[2] * 255);
451 QColor c(c0, c1, c2);
454 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
455 c0 = int (edgecolor[0] * 255);
456 c1 = int (edgecolor[1] * 255);
457 c2 = int (edgecolor[2] * 255);
458 QColor e(c0, c1, c2);
460 float backfacecolor[3];
461 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
462 c0 = int (backfacecolor[0] * 255);
463 c1 = int (backfacecolor[1] * 255);
464 c2 = int (backfacecolor[2] * 255);
465 QColor b(c0, c1, c2);
468 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
469 c0 = int (nodecolor[0] * 255);
470 c1 = int (nodecolor[1] * 255);
471 c2 = int (nodecolor[2] * 255);
472 QColor n(c0, c1, c2);
474 int Edgewidth = (int)anActor->GetLineWidth();
477 int intValue = int(anActor->GetNodeSize());
478 float Shrink = anActor->GetShrinkFactor();
480 SMESHGUI_Preferences_ColorDlg *aDlg =
481 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
482 aDlg->SetColor(1, c);
483 aDlg->SetColor(2, e);
484 aDlg->SetColor(3, n);
485 aDlg->SetColor(4, b);
486 aDlg->SetIntValue(1, Edgewidth);
487 aDlg->SetIntValue(2, intValue);
488 aDlg->SetIntValue(3, int(Shrink*100.));
490 QColor color = aDlg->GetColor(1);
491 QColor edgecolor = aDlg->GetColor(2);
492 QColor nodecolor = aDlg->GetColor(3);
493 QColor backfacecolor = aDlg->GetColor(4);
494 /* actor color and backface color */
495 anActor->SetSufaceColor(float (color.red()) / 255.,
496 float (color.green()) / 255.,
497 float (color.blue()) / 255.);
498 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
499 float (backfacecolor.green()) / 255.,
500 float (backfacecolor.blue()) / 255.);
503 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
504 float (edgecolor.green()) / 255.,
505 float (edgecolor.blue()) / 255.);
507 /* Shrink factor and size edges */
508 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
509 anActor->SetLineWidth(aDlg->GetIntValue(1));
511 /* Nodes color and size */
512 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
513 float (nodecolor.green()) / 255.,
514 float (nodecolor.blue()) / 255.);
515 anActor->SetNodeSize(aDlg->GetIntValue(2));
524 SMESH::RepaintCurrentView();
529 void SetDisplaySettings()
531 SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
535 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
536 SMESHGUI_Preferences_ColorDlg *aDlg =
537 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
539 QColor color = mgr->colorValue( "SMESH", "SettingsFillColor", QColor(0, 170, 255) );
540 aDlg->SetColor(1, color);
542 color = mgr->colorValue( "SMESH", "SettingsOutlineColor", QColor(0, 170, 255) );
543 aDlg->SetColor(2, color);
545 color = mgr->colorValue( "SMESH", "SettingsNodeColor", Qt::red );
546 aDlg->SetColor(3, color);
548 color = mgr->colorValue( "SMESH", "SettingsBackFaceColor", Qt::blue );
549 aDlg->SetColor(4, color);
551 int iVal = mgr->integerValue( "SMESH", "SettingsWidth", 1 );
552 aDlg->SetIntValue(1, iVal);
554 iVal = mgr->integerValue( "SMESH", "SettingsNodesSize", 3 );
555 aDlg->SetIntValue(2, iVal);
557 iVal = mgr->integerValue( "SMESH", "SettingsShrinkCoeff", 75 );
558 aDlg->SetIntValue(3, iVal);
561 mgr->setValue( "SMESH", "SettingsFillColor", aDlg->GetColor(1) );
562 mgr->setValue( "SMESH", "SettingsOutlineColor", aDlg->GetColor(2) );
563 mgr->setValue( "SMESH", "SettingsNodeColor", aDlg->GetColor(3) );
564 mgr->setValue( "SMESH", "SettingsBackFaceColor", aDlg->GetColor(4) );
566 mgr->setValue( "SMESH", "SettingsWidth", aDlg->GetIntValue(1) );
567 mgr->setValue( "SMESH", "SettingsNodesSize", aDlg->GetIntValue(2) );
568 mgr->setValue( "SMESH", "SettingsShrinkCoeff", aDlg->GetIntValue(3) );
575 void Control( int theCommandID )
577 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
578 SALOME_ListIO selected;
580 aSel->selectedObjects( selected );
582 if( !selected.IsEmpty() ){
583 Handle(SALOME_InteractiveObject) anIO = selected.First();
586 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
587 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
588 switch ( theCommandID ){
590 aTitle = QObject::tr( "LENGTH_EDGES" );
591 aControl = SMESH_Actor::eLength;
594 aTitle = QObject::tr( "LENGTH2D_EDGES" );
595 aControl = SMESH_Actor::eLength2D;
598 aTitle = QObject::tr( "FREE_EDGES" );
599 aControl = SMESH_Actor::eFreeEdges;
602 aTitle = QObject::tr( "FREE_BORDERS" );
603 aControl = SMESH_Actor::eFreeBorders;
606 aTitle = QObject::tr( "MULTI_BORDERS" );
607 aControl = SMESH_Actor::eMultiConnection;
610 aTitle = QObject::tr( "MULTI2D_BORDERS" );
611 aControl = SMESH_Actor::eMultiConnection2D;
614 aTitle = QObject::tr( "AREA_ELEMENTS" );
615 aControl = SMESH_Actor::eArea;
618 aTitle = QObject::tr( "TAPER_ELEMENTS" );
619 aControl = SMESH_Actor::eTaper;
622 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
623 aControl = SMESH_Actor::eAspectRatio;
626 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
627 aControl = SMESH_Actor::eAspectRatio3D;
630 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
631 aControl = SMESH_Actor::eMinimumAngle;
634 aTitle = QObject::tr( "WARP_ELEMENTS" );
635 aControl = SMESH_Actor::eWarping;
638 aTitle = QObject::tr( "SKEW_ELEMENTS" );
639 aControl = SMESH_Actor::eSkew;
642 anActor->SetControlMode(aControl);
643 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
650 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
651 MeshObjectType theType,
652 const QString theInTypeName,
653 QString & theOutTypeName)
655 SMESH_TypeFilter aTypeFilter( theType );
657 if( !theIO.IsNull() )
659 entry = theIO->getEntry();
660 SalomeApp_DataOwner owner( entry );
661 if ( aTypeFilter.isOk( &owner )) {
662 theOutTypeName = theInTypeName;
670 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
672 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
673 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
675 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
676 CORBA::String_var anID = aSComp->GetID().c_str();
677 if (!strcmp(anID.in(),theIO->getEntry()))
683 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
684 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
685 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
686 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
687 CheckOIType ( theIO, GROUP, "Group", aTypeName )
695 QString CheckHomogeneousSelection()
697 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
698 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
699 SALOME_ListIO selected;
701 aSel->selectedObjects( selected );
703 QString RefType = CheckTypeObject(selected.First());
704 SALOME_ListIteratorOfListIO It(selected);
705 for (; It.More(); It.Next())
707 Handle(SALOME_InteractiveObject) IObject = It.Value();
708 QString Type = CheckTypeObject(IObject);
709 if (Type.compare(RefType) != 0)
710 return "Heterogeneous Selection";
718 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
719 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
720 SALOME_ListIO selected; aSel->selectedObjects( selected );
722 QString aParentComponent = QString::null;
723 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
725 QString cur = anIt.Value()->getComponentDataType();
726 if( aParentComponent.isNull() )
727 aParentComponent = cur;
728 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
729 aParentComponent = "";
732 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
733 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
734 QObject::tr("ERR_ERROR"),
735 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
736 QObject::tr("BUT_OK") );
739 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
740 if (SUIT_MessageBox::warn2
741 (SMESHGUI::desktop(),
742 QObject::tr("SMESH_WRN_WARNING"),
743 QObject::tr("SMESH_REALLY_DELETE"),
744 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
747 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
748 SUIT_ViewManager* vm = anApp->activeViewManager();
749 int nbSf = vm->getViewsCount();
751 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
752 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
753 _PTR(GenericAttribute) anAttr;
754 _PTR(AttributeIOR) anIOR;
756 SALOME_ListIteratorOfListIO It(selected);
758 aStudyBuilder->NewCommand(); // There is a transaction
759 for(; It.More(); It.Next()){
760 Handle(SALOME_InteractiveObject) IObject = It.Value();
761 if(IObject->hasEntry()){
762 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
764 /* Erase child graphical objects */
765 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
766 for(it->InitEx(true); it->More(); it->Next()){
767 _PTR(SObject) CSO = it->Value();
768 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
771 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
772 for(int i = 0; i < nbSf; i++){
773 SUIT_ViewWindow *sf = aViews[i];
774 CORBA::String_var anEntry = CSO->GetID().c_str();
775 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
776 SMESH::RemoveActor(sf,anActor);
782 /* Erase main graphical object */
783 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
784 for(int i = 0; i < nbSf; i++){
785 SUIT_ViewWindow *sf = aViews[i];
786 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
787 SMESH::RemoveActor(sf,anActor);
791 // Remove object(s) from data structures
792 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
794 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
795 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
797 if ( !aGroup->_is_nil() ) { // DELETE GROUP
798 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
799 aMesh->RemoveGroup( aGroup );
801 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
802 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
803 aMesh->RemoveSubMesh( aSubMesh );
805 else {// default action: remove SObject from the study
806 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
807 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
809 aStudyBuilder->RemoveObjectWithChildren( obj );
814 } /* IObject->hasEntry() */
816 aStudyBuilder->CommitCommand();
818 /* Clear any previous selection */
820 aSel->setSelectedObjects( l1 );
822 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
827 Standard_EXPORT CAM_Module* createModule()
829 return new SMESHGUI();
833 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
835 //=============================================================================
839 //=============================================================================
840 SMESHGUI::SMESHGUI() :
841 SalomeApp_Module( "SMESH" )
843 if ( CORBA::is_nil( myComponentSMESH ) )
845 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
846 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
847 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
850 myActiveDialogBox = 0 ;
853 SMESH::GetFilterManager();
856 /* load resources for all available meshers */
857 SMESH::InitAvailableHypotheses();
860 //=============================================================================
864 //=============================================================================
865 SMESHGUI::~SMESHGUI()
867 SMESH::GetFilterManager()->Destroy();
870 //=============================================================================
874 //=============================================================================
875 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
877 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
879 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
884 bool SMESHGUI::automaticUpdate()
886 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
890 return resMgr->booleanValue( "SMESH", "auto_update", false );
893 //=============================================================================
897 //=============================================================================
898 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
900 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
903 //=============================================================================
907 //=============================================================================
908 SMESHGUI* SMESHGUI::GetSMESHGUI()
910 SMESHGUI* smeshMod = 0;
911 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
914 CAM_Module* module = app->module( "Mesh" );
915 smeshMod = dynamic_cast<SMESHGUI*>( module );
918 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
920 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
923 _PTR(Study) aStudy = study->studyDS();
925 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
934 Standard_EXPORT SMESHGUI* GetComponentGUI()
936 return SMESHGUI::GetSMESHGUI();
940 //=============================================================================
944 //=============================================================================
945 void SMESHGUI::SetState(int aState)
950 //=============================================================================
954 //=============================================================================
955 void SMESHGUI::ResetState()
960 //=============================================================================
964 //=============================================================================
965 void SMESHGUI::EmitSignalDeactivateDialog()
967 emit SignalDeactivateActiveDialog();
970 //=============================================================================
974 //=============================================================================
975 void SMESHGUI::EmitSignalStudyFrameChanged()
977 emit SignalStudyFrameChanged();
980 //=============================================================================
984 //=============================================================================
985 void SMESHGUI::EmitSignalCloseAllDialogs()
987 emit SignalCloseAllDialogs();
990 //=============================================================================
994 //=============================================================================
995 QDialog *SMESHGUI::GetActiveDialogBox()
997 return myActiveDialogBox;
1000 //=============================================================================
1004 //=============================================================================
1005 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1007 myActiveDialogBox = (QDialog *) aDlg;
1011 //=============================================================================
1015 //=============================================================================
1016 SUIT_Desktop* SMESHGUI::desktop()
1018 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1020 return app->desktop();
1025 //=============================================================================
1029 //=============================================================================
1030 SalomeApp_Study* SMESHGUI::activeStudy()
1032 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1034 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1039 //=============================================================================
1043 //=============================================================================
1044 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1046 /* Here the position is on the bottom right corner - 10 */
1047 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1049 SUIT_Desktop *PP = desktop();
1050 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1051 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1055 //=============================================================================
1059 //=============================================================================
1060 static int isStudyLocked(_PTR(Study) theStudy){
1061 return theStudy->GetProperties()->IsLocked();
1064 static bool checkLock(_PTR(Study) theStudy) {
1065 if (isStudyLocked(theStudy)) {
1066 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1067 QObject::tr("WRN_WARNING"),
1068 QObject::tr("WRN_STUDY_LOCKED"),
1069 QObject::tr("BUT_OK") );
1075 //=======================================================================
1076 //function : CheckActiveStudyLocked
1078 //=======================================================================
1080 bool SMESHGUI::isActiveStudyLocked()
1082 _PTR(Study) aStudy = activeStudy()->studyDS();
1083 return checkLock( aStudy );
1086 //=============================================================================
1090 //=============================================================================
1091 bool SMESHGUI::OnGUIEvent( int theCommandID )
1093 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1097 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1098 SUIT_ResourceMgr* mgr = resourceMgr();
1102 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1103 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1105 QAction* act = action( theCommandID );
1107 switch (theCommandID) {
1109 if(checkLock(aStudy)) break;
1117 if(checkLock(aStudy)) break;
1118 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1122 case 122: // EXPORT MED
1129 ::ExportMeshToFile(theCommandID);
1133 case 200: // SCALAR BAR
1135 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1136 SALOME_ListIO selected;
1138 aSel->selectedObjects( selected );
1140 if( selected.Extent() ) {
1141 Handle(SALOME_InteractiveObject) anIO = selected.First();
1142 if( anIO->hasEntry() ) {
1143 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1144 anActor->SetControlMode( SMESH_Actor::eNone );
1152 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1156 case 1134: // Clipping
1157 case 1133: // Tranparency
1158 case 1132: // Colors / Size
1165 ::SetDisplayMode(theCommandID);
1171 case 219: // Volumes
1172 case 220: // All Entity
1173 ::SetDisplayEntity(theCommandID);
1178 if(checkLock(aStudy)) break;
1179 SMESH::UpdateView();
1182 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1183 aSel->setSelectedObjects( l );
1188 case 301: // DISPLAY
1189 case 302: // DISPLAY ONLY
1191 SMESH::EDisplaing anAction;
1192 switch(theCommandID){
1193 case 300: anAction = SMESH::eErase; break;
1194 case 301: anAction = SMESH::eDisplay; break;
1195 case 302: anAction = SMESH::eDisplayOnly; break;
1198 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1199 SALOME_ListIO selected;
1201 aSel->selectedObjects( selected );
1204 SALOME_ListIteratorOfListIO It(selected);
1205 for (; It.More(); It.Next()) {
1206 Handle(SALOME_InteractiveObject) IOS = It.Value();
1207 if (IOS->hasEntry()) {
1208 SMESH::UpdateView(anAction,IOS->getEntry());
1213 aSel->setSelectedObjects( l1 );
1219 if(checkLock(aStudy)) break;
1222 EmitSignalDeactivateDialog();
1224 new SMESHGUI_NodesDlg(this);
1227 SUIT_MessageBox::warn1(desktop(),
1228 tr("SMESH_WRN_WARNING"),
1229 tr("SMESH_WRN_VIEWER_VTK"),
1230 tr("SMESH_BUT_OK"));
1235 case 2151: // FILTER
1239 EmitSignalDeactivateDialog();
1240 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1245 case 406: // MOVE NODE
1249 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1250 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1254 if(checkLock(aStudy)) break;
1255 new SMESHGUI_MoveNodesDlg(this);
1259 case 701: // COMPUTE MESH
1261 if(checkLock(aStudy)) break;
1263 SalomeApp_SelectionMgr *Sel = selectionMgr();
1264 SALOME_ListIO selected; Sel->selectedObjects( selected );
1266 int nbSel = selected.Extent();
1271 SMESH::SMESH_Mesh_var aMesh;
1272 SMESH::SMESH_subMesh_var aSubMesh;
1273 Handle(SALOME_InteractiveObject) IObject = selected.First();
1274 if (IObject->hasEntry()){
1275 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1276 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1277 if ( aShapeObject->_is_nil() ) {
1282 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1283 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1285 if (!aMesh->_is_nil()){
1286 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1287 if (!refShapeObject->_is_nil()) {
1288 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1289 SUIT_MessageBox::warn1(desktop(),
1290 tr("SMESH_WRN_WARNING"),
1291 tr("SMESH_WRN_MISSING_PARAMETERS"),
1292 tr("SMESH_BUT_OK"));
1296 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1297 SMESH::ModifiedMesh(aMeshSObj,true);
1298 // TO Do : change icon of all submeshes
1300 SUIT_MessageBox::warn1(desktop(),
1301 tr("SMESH_WRN_WARNING"),
1302 tr("SMESH_WRN_COMPUTE_FAILED"),
1303 tr("SMESH_BUT_OK"));
1305 catch(const SALOME::SALOME_Exception & S_ex){
1306 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1309 }else if(!aSubMesh->_is_nil()){
1310 aMesh = aSubMesh->GetFather();
1311 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1312 if(!refShapeObject->_is_nil()){
1313 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1315 SUIT_MessageBox::warn1(desktop(),
1316 tr("SMESH_WRN_WARNING"),
1317 tr("SMESH_WRN_MISSING_PARAMETERS"),
1318 tr("SMESH_BUT_OK"));
1322 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1323 SMESH::ModifiedMesh(aMeshSObj,true);
1324 // TO Do : change icon of all submeshes
1326 SUIT_MessageBox::warn1(desktop(),
1327 tr("SMESH_WRN_WARNING"),
1328 tr("SMESH_WRN_COMPUTE_FAILED"),
1329 tr("SMESH_BUT_OK"));
1330 }catch(const SALOME::SALOME_Exception & S_ex){
1331 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1337 CORBA::Long anId = aStudy->StudyId();
1338 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1339 if ( automaticUpdate() && aVisualObj){
1340 aVisualObj->Update();
1341 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1343 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1345 SMESH::DisplayActor(view,anActor); //apo
1351 SUIT_MessageBox::warn1(desktop(),
1352 tr("SMESH_WRN_WARNING"),
1353 tr("SMESH_WRN_VIEWER_VTK"),
1354 tr("SMESH_BUT_OK"));
1360 case 702: // ADD SUB MESH
1362 if(checkLock(aStudy)) break;
1364 EmitSignalDeactivateDialog();
1365 new SMESHGUI_AddSubMeshDlg( this );
1368 SUIT_MessageBox::warn1(desktop(),
1369 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1370 tr("SMESH_BUT_OK"));
1375 case 703: // INIT MESH
1377 if(checkLock(aStudy)) break;
1378 EmitSignalDeactivateDialog();
1379 new SMESHGUI_InitMeshDlg( this );
1383 case 704: // EDIT Hypothesis
1385 if(checkLock(aStudy)) break;
1386 EmitSignalDeactivateDialog();
1387 new SMESHGUI_EditHypothesesDlg( this );
1391 case 705: // EDIT Global Hypothesis
1393 if(checkLock(aStudy)) break;
1394 EmitSignalDeactivateDialog();
1395 new SMESHGUI_EditHypothesesDlg( this );
1399 case 706: // EDIT Local Hypothesis
1401 if(checkLock(aStudy)) break;
1402 EmitSignalDeactivateDialog();
1403 new SMESHGUI_EditHypothesesDlg( this );
1407 case 407: // DIAGONAL INVERSION
1408 case 408: // Delete diagonal
1412 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1413 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1417 if ( checkLock( aStudy ) )
1420 /*Standard_Boolean aRes;
1421 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1422 if ( aMesh->_is_nil() )
1424 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1425 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1429 EmitSignalDeactivateDialog();
1430 if ( theCommandID == 407 )
1431 new SMESHGUI_TrianglesInversionDlg(this);
1433 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1436 case 409: // Change orientation
1437 case 410: // Union of triangles
1438 case 411: // Cutting of quadrangles
1442 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1443 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1447 if ( checkLock( aStudy ) )
1450 EmitSignalDeactivateDialog();
1451 SMESHGUI_MultiEditDlg* aDlg = NULL;
1452 if ( theCommandID == 409 )
1453 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1454 else if ( theCommandID == 410 )
1455 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1457 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1460 DefineDlgPosition( aDlg, x, y );
1465 case 412: // Smoothing
1467 if(checkLock(aStudy)) break;
1469 EmitSignalDeactivateDialog();
1470 new SMESHGUI_SmoothingDlg( this );
1473 SUIT_MessageBox::warn1(desktop(),
1474 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1475 tr("SMESH_BUT_OK"));
1479 case 413: // Extrusion
1481 if (checkLock(aStudy)) break;
1483 EmitSignalDeactivateDialog();
1484 new SMESHGUI_ExtrusionDlg ( this );
1486 SUIT_MessageBox::warn1(desktop(),
1487 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1488 tr("SMESH_BUT_OK"));
1492 case 414: // Revolution
1494 if(checkLock(aStudy)) break;
1496 EmitSignalDeactivateDialog();
1497 new SMESHGUI_RevolutionDlg( this );
1500 SUIT_MessageBox::warn1(desktop(),
1501 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1502 tr("SMESH_BUT_OK"));
1506 case 415: // Pattern mapping
1508 if ( checkLock( aStudy ) )
1512 EmitSignalDeactivateDialog();
1513 new SMESHGUI_MeshPatternDlg( this );
1516 SUIT_MessageBox::warn1(desktop(),
1517 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1518 tr("SMESH_BUT_OK"));
1522 case 416: // Extrusion along a path
1524 if (checkLock(aStudy)) break;
1526 EmitSignalDeactivateDialog();
1527 new SMESHGUI_ExtrusionAlongPathDlg( this );
1529 SUIT_MessageBox::warn1(desktop(),
1530 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1531 tr("SMESH_BUT_OK"));
1535 case 801: // CREATE GROUP
1539 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1540 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1544 if(checkLock(aStudy)) break;
1545 EmitSignalDeactivateDialog();
1546 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1548 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1549 SALOME_ListIO selected;
1551 aSel->selectedObjects( selected );
1553 int nbSel = selected.Extent();
1555 // check if mesh is selected
1556 aMesh = SMESH::GetMeshByIO( selected.First() );
1558 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1563 case 802: // CONSTRUCT GROUP
1567 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1568 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1572 if(checkLock(aStudy)) break;
1573 EmitSignalDeactivateDialog();
1575 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1576 SALOME_ListIO selected;
1578 aSel->selectedObjects( selected );
1580 int nbSel = selected.Extent();
1582 // check if submesh is selected
1583 Handle(SALOME_InteractiveObject) IObject = selected.First();
1584 if (IObject->hasEntry()) {
1585 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1587 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1588 if (!aSubMesh->_is_nil()) {
1590 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1591 // get submesh elements list by types
1592 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1593 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1594 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1595 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1596 // create group for each type o elements
1597 QString aName = IObject->getName();
1598 if (aNodes->length() > 0) {
1599 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1600 aGroup->Add(aNodes.inout());
1602 if (aEdges->length() > 0) {
1603 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1604 aGroup->Add(aEdges.inout());
1606 if (aFaces->length() > 0) {
1607 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1608 aGroup->Add(aFaces.inout());
1610 if (aVolumes->length() > 0) {
1611 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1612 aGroup->Add(aVolumes.inout());
1616 }catch(const SALOME::SALOME_Exception & S_ex){
1617 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1626 case 803: // EDIT GROUP
1630 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1631 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1635 if(checkLock(aStudy)) break;
1636 EmitSignalDeactivateDialog();
1638 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1639 SALOME_ListIO selected;
1641 aSel->selectedObjects( selected );
1643 SALOME_ListIteratorOfListIO It (selected);
1644 int nbSelectedGroups = 0;
1645 for ( ; It.More(); It.Next() )
1647 SMESH::SMESH_Group_var aGroup =
1648 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1649 if (!aGroup->_is_nil()) {
1651 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1655 if (nbSelectedGroups == 0)
1657 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1663 case 804: // Add elements to group
1665 if(checkLock(aStudy)) break;
1666 if (myState == 800) {
1667 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1668 if (aDlg) aDlg->onAdd();
1673 case 805: // Remove elements from group
1675 if(checkLock(aStudy)) break;
1676 if (myState == 800) {
1677 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1678 if (aDlg) aDlg->onRemove();
1683 case 810: // Union Groups
1684 case 811: // Intersect groups
1685 case 812: // Cut groups
1689 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1690 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1694 if ( checkLock( aStudy ) )
1697 EmitSignalDeactivateDialog();
1700 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1701 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1702 else aMode = SMESHGUI_GroupOpDlg::CUT;
1704 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1708 case 813: // Delete groups with their contents
1712 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1713 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1717 if ( checkLock( aStudy ) )
1720 EmitSignalDeactivateDialog();
1722 new SMESHGUI_DeleteGroupDlg( this );
1726 case 900: // MESH INFOS
1728 EmitSignalDeactivateDialog();
1729 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1730 SALOME_ListIO selected;
1732 aSel->selectedObjects( selected );
1734 if ( selected.Extent() > 1 ) { // a dlg for each IO
1736 SALOME_ListIteratorOfListIO It (selected);
1737 for ( ; It.More(); It.Next() ) {
1738 IOs.Clear(); IOs.Append( It.Value() );
1739 aSel->setSelectedObjects( IOs );
1740 new SMESHGUI_MeshInfosDlg(this, "", false);
1742 // restore selection
1743 aSel->setSelectedObjects( selected );
1746 new SMESHGUI_MeshInfosDlg(this, "", false);
1750 case 902: // STANDARD MESH INFOS
1752 EmitSignalDeactivateDialog();
1753 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1754 SALOME_ListIO selected;
1756 aSel->selectedObjects( selected );
1758 if ( selected.Extent() > 1 ) { // a dlg for each IO
1760 SALOME_ListIteratorOfListIO It (selected);
1761 for ( ; It.More(); It.Next() ) {
1763 IOs.Append( It.Value() );
1764 aSel->setSelectedObjects( IOs );
1765 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1767 // restore selection
1768 aSel->setSelectedObjects( selected );
1771 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1775 case 1001: // AUTOMATIC UPDATE PREFERENCES
1777 // if (act->isOn()) {
1778 // mgr->setValue( "SMESH", "AutomaticUpdate", true );
1779 // myAutomaticUpdate = true;
1782 // mgr->setValue( "SMESH", "AutomaticUpdate", false );
1783 // myAutomaticUpdate = false;
1788 case 1003: // MESH PREFERENCES
1790 ::SetDisplaySettings();
1796 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( this );
1802 ( new SMESHGUI_PrecisionDlg( this ) )->exec();
1809 mgr->setValue( "SMESH", "DispayEntity", true );
1812 mgr->setValue( "SMESH", "DispayEntity", false );
1818 SMESHGUI_Preferences_SelectionDlg* aDlg =
1819 new SMESHGUI_Preferences_SelectionDlg( this );
1821 QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
1822 aDlg->SetColor(1, aColor);
1824 aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow );
1825 aDlg->SetColor(2, aColor);
1827 aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white );
1828 aDlg->SetColor(3, aColor);
1830 aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) );
1831 aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) );
1832 aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) );
1833 aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) );
1836 QColor aPreColor = aDlg->GetColor(1),
1837 aSelColor = aDlg->GetColor(2),
1838 aHiColor = aDlg->GetColor(3);
1839 int aPreWidth = aDlg->GetWidth(1),
1840 aSelWidth = aDlg->GetWidth(2);
1841 double aTolNodes = aDlg->GetPrecision(1),
1842 aTolItems = aDlg->GetPrecision(2);
1844 mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor );
1845 mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor );
1846 mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor );
1848 mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth );
1849 mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth );
1850 mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes );
1851 mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems );
1853 // update current study settings
1854 SMESH::UpdateSelectionProp( this );
1857 // update VTK viewer properties
1858 SVTK_RenderWindowInteractor* anInteractor =
1859 dynamic_cast<SVTK_RenderWindowInteractor*>( vtkwnd->getRWInteractor() );
1861 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1862 aSelColor.blue()/255., aSelWidth);
1863 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1864 SVTK_InteractorStyle* aStyle =
1865 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
1868 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1869 aPreColor.blue()/255., aPreWidth);
1872 vtkRenderer* aRenderer = vtkwnd->getRenderer();
1873 vtkActorCollection *aCollection = aRenderer->GetActors();
1874 aCollection->InitTraversal();
1875 while(vtkActor *anAct = aCollection->GetNextActor()){
1876 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1877 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1878 aHiColor.blue()/255.);
1879 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1880 aPreColor.blue()/255.);
1889 case 1100: // EDIT HYPOTHESIS
1891 if(checkLock(aStudy)) break;
1893 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1894 SALOME_ListIO selected;
1896 aSel->selectedObjects( selected );
1898 int nbSel = selected.Extent();
1901 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1903 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1904 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1905 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1906 if ( !Hyp->_is_nil() )
1908 char* sName = Hyp->GetName();
1909 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1912 aCreator->EditHypothesis(Hyp);
1920 updateObjBrowser( true );
1924 case 1101: // RENAME
1926 if ( checkLock( aStudy ) )
1929 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1930 SALOME_ListIO selected;
1932 aSel->selectedObjects( selected );
1934 SALOME_ListIteratorOfListIO It( selected );
1935 for ( ; It.More(); It.Next() )
1937 Handle(SALOME_InteractiveObject) IObject = It.Value();
1938 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1939 _PTR(GenericAttribute) anAttr;
1940 _PTR(AttributeName) aName;
1943 if ( obj->FindAttribute(anAttr, "AttributeName") )
1946 QString newName = QString(aName->Value().c_str());
1947 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1948 if ( !newName.isEmpty() )
1950 //old source: aStudy->renameIObject( IObject, newName );
1951 aName->SetValue( newName.latin1() );
1953 // if current object is group update group's name
1954 SMESH::SMESH_GroupBase_var aGroup =
1955 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1956 if (!aGroup->_is_nil() )
1957 aGroup->SetName( newName.latin1() );
1967 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1969 if(checkLock(aStudy)) break;
1970 SUIT_OverrideCursor wc;
1972 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1973 SALOME_ListIO selected;
1975 aSel->selectedObjects( selected );
1977 SALOME_ListIteratorOfListIO It(selected);
1978 for (int i = 0; It.More(); It.Next(), i++) {
1979 Handle(SALOME_InteractiveObject) IObject = It.Value();
1980 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1983 aSel->setSelectedObjects( l1 );
1988 case 401: // GEOM::EDGE
1989 case 4021: // TRIANGLE
1991 case 4023: // POLYGON
1995 if(checkLock(aStudy)) break;
1997 EmitSignalDeactivateDialog();
1998 SMDSAbs_ElementType type = SMDSAbs_Edge;
2000 switch (theCommandID) {
2001 case 4021: // TRIANGLE
2002 type = SMDSAbs_Face; nbNodes = 3; break;
2004 type = SMDSAbs_Face; nbNodes = 4; break;
2006 type = SMDSAbs_Volume; nbNodes = 4; break;
2007 case 4023: // POLYGON
2008 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2010 type = SMDSAbs_Volume; nbNodes = 8; break;
2011 case 4033: // POLYHEDRE
2012 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2015 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2018 SUIT_MessageBox::warn1(desktop(),
2019 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2020 tr("SMESH_BUT_OK"));
2024 case 4033: // POLYHEDRON
2026 if(checkLock(aStudy)) break;
2028 EmitSignalDeactivateDialog();
2029 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2032 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2033 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2034 tr("SMESH_BUT_OK"));
2038 case 4041: // REMOVES NODES
2040 if(checkLock(aStudy)) break;
2042 EmitSignalDeactivateDialog();
2043 new SMESHGUI_RemoveNodesDlg(this);
2046 SUIT_MessageBox::warn1(desktop(),
2047 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2048 tr("SMESH_BUT_OK"));
2052 case 4042: // REMOVES ELEMENTS
2054 if(checkLock(aStudy)) break;
2056 EmitSignalDeactivateDialog();
2057 new SMESHGUI_RemoveElementsDlg(this);
2061 SUIT_MessageBox::warn1(desktop(),
2062 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2063 tr("SMESH_BUT_OK"));
2067 case 4051: // RENUMBERING NODES
2069 if(checkLock(aStudy)) break;
2071 EmitSignalDeactivateDialog();
2072 new SMESHGUI_RenumberingDlg( this, "", 0);
2076 SUIT_MessageBox::warn1(desktop(),
2077 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2078 tr("SMESH_BUT_OK"));
2082 case 4052: // RENUMBERING ELEMENTS
2084 if(checkLock(aStudy)) break;
2086 EmitSignalDeactivateDialog();
2087 new SMESHGUI_RenumberingDlg( this, "", 1);
2091 SUIT_MessageBox::warn1(desktop(),
2092 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2093 tr("SMESH_BUT_OK"));
2097 case 4061: // TRANSLATION
2099 if(checkLock(aStudy)) break;
2101 EmitSignalDeactivateDialog();
2102 new SMESHGUI_TranslationDlg( this );
2105 SUIT_MessageBox::warn1(desktop(),
2106 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2107 tr("SMESH_BUT_OK"));
2111 case 4062: // ROTATION
2113 if(checkLock(aStudy)) break;
2115 EmitSignalDeactivateDialog();
2116 new SMESHGUI_RotationDlg( this );
2119 SUIT_MessageBox::warn1(desktop(),
2120 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2121 tr("SMESH_BUT_OK"));
2125 case 4063: // SYMMETRY
2127 if(checkLock(aStudy)) break;
2129 EmitSignalDeactivateDialog();
2130 new SMESHGUI_SymmetryDlg( this );
2133 SUIT_MessageBox::warn1(desktop(),
2134 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2135 tr("SMESH_BUT_OK"));
2139 case 4064: // SEWING
2141 if(checkLock(aStudy)) break;
2143 EmitSignalDeactivateDialog();
2144 new SMESHGUI_SewingDlg( this );
2147 SUIT_MessageBox::warn1(desktop(),
2148 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2149 tr("SMESH_BUT_OK"));
2153 case 4065: // MERGE NODES
2155 if(checkLock(aStudy)) break;
2157 EmitSignalDeactivateDialog();
2158 new SMESHGUI_MergeNodesDlg( this );
2161 SUIT_MessageBox::warn1(desktop(),
2162 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2163 tr("SMESH_BUT_OK"));
2169 case 5000: // HYPOTHESIS
2171 if(checkLock(aStudy)) break;
2172 EmitSignalDeactivateDialog();
2173 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2178 if(checkLock(aStudy)) break;
2179 EmitSignalDeactivateDialog();
2180 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2184 case 5105: // Library of selection filters
2186 static QValueList<int> aTypes;
2187 if ( aTypes.isEmpty() )
2189 aTypes.append( SMESH::NODE );
2190 aTypes.append( SMESH::EDGE );
2191 aTypes.append( SMESH::FACE );
2192 aTypes.append( SMESH::VOLUME );
2194 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2198 case 6017: // CONTROLS
2213 SalomeApp_SelectionMgr* mgr = selectionMgr();
2214 SALOME_ListIO selected; mgr->selectedObjects( selected );
2216 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2217 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2219 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2220 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2221 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2222 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2223 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2224 ::Control( theCommandID );
2229 SUIT_MessageBox::warn1(desktop(),
2230 tr( "SMESH_WRN_WARNING" ),
2231 tr( "SMESH_BAD_SELECTION" ),
2232 tr( "SMESH_BUT_OK" ) );
2236 SUIT_MessageBox::warn1(desktop(),
2237 tr( "SMESH_WRN_WARNING" ),
2238 tr( "NOT_A_VTK_VIEWER" ),
2239 tr( "SMESH_BUT_OK" ) );
2244 SalomeApp_SelectionMgr* mgr = selectionMgr();
2245 SALOME_ListIO selected; mgr->selectedObjects( selected );
2247 if (selected.Extent() == 1) {
2248 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2249 if(anIObject->hasEntry())
2250 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2251 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2258 SalomeApp_SelectionMgr* mgr = selectionMgr();
2259 SALOME_ListIO selected; mgr->selectedObjects( selected );
2261 if (selected.Extent() == 1) {
2262 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2263 if(anIObject->hasEntry())
2264 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2265 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2270 case 10001: // DISPLAY MODE PREFERENCE
2274 action( 10002 )->setOn( false );
2275 action( 10004 )->setOn( false );
2276 action( 10003 )->setOn( true );
2277 mgr->setValue( "SMESH", "DisplayMode", "Wireframe");
2283 action( 10001 )->setOn( false );
2284 action( 10004 )->setOn( false );
2285 action( 10003 )->setOn( true );
2286 mgr->setValue( "SMESH", "DisplayMode", "Shading");
2291 mgr->setValue( "SMESH", "Shrink", act->isOn() );
2297 action( 10001 )->setOn( false );
2298 action( 10002 )->setOn( false );
2299 action( 10003 )->setOn( false );
2300 mgr->setValue( "SMESH", "DisplayMode", "Nodes" );
2306 //updateObjBrowser();
2310 //=============================================================================
2314 //=============================================================================
2315 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2320 //=============================================================================
2324 //=============================================================================
2325 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2330 //=============================================================================
2334 //=============================================================================
2335 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2340 //=============================================================================
2344 //=============================================================================
2345 bool SMESHGUI::SetSettings(SUIT_Desktop* parent)
2347 SMESHGUI::GetSMESHGUI();
2349 SUIT_ResourceMgr* mgr = resourceMgr();
2354 QString DisplayMode = "Shading";
2355 if ( mgr->hasValue("SMESH","DisplayMode") )
2356 DisplayMode = mgr->stringValue("SMESH","DisplayMode");
2358 mgr->setValue("SMESH","DisplayMode", "Shading");
2360 bool Shrink = false;
2361 if ( mgr->hasValue("SMESH","Shrink") )
2362 Shrink = mgr->stringValue("SMESH","Shrink") == "yes";
2364 if (DisplayMode == "Wireframe") {
2366 action( 10004 )->setOn( false );
2367 action( 10002 )->setOn( false );
2368 action( 10001 )->setOn( true );
2369 action( 10003 )->setOn( true );
2371 else if (DisplayMode == "Nodes") {
2373 action( 10004 )->setOn( true );
2374 action( 10002 )->setOn( false );
2375 action( 10001 )->setOn( false );
2376 action( 10003 )->setOn( false );
2379 // default is shading
2380 action( 10004 )->setOn( false );
2381 action( 10002 )->setOn( true );
2382 action( 10001 )->setOn( false );
2383 action( 10003 )->setOn( true );
2386 action( 10003 )->setOn( Shrink );
2389 // if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) {
2390 // action( 1001 )->setOn( true );
2391 // myAutomaticUpdate = true;
2394 // action( 1001 )->setOn( false );
2395 // myAutomaticUpdate = false;
2398 if ( mgr->booleanValue( "SMESH","DispayEntity", false ) )
2399 action( 10071 )->setOn( true );
2401 action( 10071 )->setOn( false );
2404 SMESH::UpdateSelectionProp( this );
2407 action( 111 )->setEnabled( false ); // IMPORT DAT
2409 //action( 112 )->setEnabled( false );
2410 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2415 //=============================================================================
2416 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2417 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2419 //=============================================================================
2420 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2421 SUIT_ViewWindow* wnd )
2423 if(theIO->hasEntry()){
2424 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2425 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2429 //=======================================================================
2430 // function : createSMESHAction
2432 //=======================================================================
2433 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2436 QWidget* parent = application()->desktop();
2437 SUIT_ResourceMgr* resMgr = resourceMgr();
2439 if ( icon_id.length() )
2440 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2442 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2443 if ( !pix.isNull() )
2444 icon = QIconSet( pix );
2446 QString tooltip = tr( QString( "TOP_" )+po_id ),
2447 menu = tr( QString( "MEN_" )+po_id ),
2448 status_bar = tr( QString( "STB_" )+po_id );
2450 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2453 //=======================================================================
2454 // function : createPopupItem
2456 //=======================================================================
2457 void SMESHGUI::createPopupItem( const int id,
2458 const QString& clients,
2459 const QString& types,
2460 const QString& theRule,
2465 parentId = popupMgr()->actionId( action( pId ) );
2467 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2468 popupMgr()->insert( action( id ), parentId, 0 );
2470 QChar lc = QtxPopupMgr::Selection::defEquality();
2471 QString rule = "(%1) and (%2) and (%3)";
2472 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2473 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2474 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2477 bool cont = myRules.contains( id );
2479 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2481 popupMgr()->setRule( action( id ), rule, true );
2482 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2485 //=======================================================================
2486 // function : initialize
2488 //=======================================================================
2489 void SMESHGUI::initialize( CAM_Application* app )
2491 SalomeApp_Module::initialize( app );
2493 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2495 /* Automatic Update flag */
2496 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2498 // ----- create actions --------------
2500 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2501 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2502 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2503 createSMESHAction( 114, "NUM" );
2504 createSMESHAction( 121, "DAT" );
2505 createSMESHAction( 122, "MED" );
2506 createSMESHAction( 123, "UNV" );
2507 createSMESHAction( 124, "EXPORT_DAT" );
2508 createSMESHAction( 125, "EXPORT_MED" );
2509 createSMESHAction( 126, "EXPORT_UNV" );
2510 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2511 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2512 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2513 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2514 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2515 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2516 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2517 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2518 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2519 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2520 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2521 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2522 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2523 createSMESHAction( 804, "ADD" );
2524 createSMESHAction( 805, "REMOVE" );
2525 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2526 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2527 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2528 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2529 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2530 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2531 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2532 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2533 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2534 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2535 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2536 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2537 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2538 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2539 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2540 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2541 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2542 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2543 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2544 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2545 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2546 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2547 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2548 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2549 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2550 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2551 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2552 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2553 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2554 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2555 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2556 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2557 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2558 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2559 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2560 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2561 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2562 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2563 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2564 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2565 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2566 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2567 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2568 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2569 createSMESHAction( 415, "MAP", "ICON_MAP" );
2570 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2571 createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true );
2572 createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true );
2573 createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true );
2574 createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true );
2575 createSMESHAction( 1001, "AUTO_UPD", "", 0, true );
2576 createSMESHAction( 1003, "COLORS" );
2577 createSMESHAction( 1005, "SCALAR_BAR" );
2578 createSMESHAction( 1006, "SELECTION" );
2579 createSMESHAction( 10070, "PRECISION", "", 0, true );
2580 createSMESHAction( 10071, "DISP_ENT", "", 0, true );
2581 createSMESHAction( 200, "RESET" );
2582 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2583 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2584 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2585 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2586 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2587 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2588 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2589 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2590 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2591 createSMESHAction( 220, "ALL" );
2592 createSMESHAction( 1100, "EDIT_HYPO" );
2593 createSMESHAction( 1101, "RENAME" );
2594 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2595 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2596 createSMESHAction( 1131, "DISPMODE" );
2597 createSMESHAction( 1132, "COLORS" );
2598 createSMESHAction( 1133, "TRANSP" );
2599 createSMESHAction( 1134, "CLIP" );
2600 createSMESHAction( 1135, "DISP_ENT" );
2601 createSMESHAction( 2000, "CTRL" );
2603 createSMESHAction( 300, "ERASE" );
2604 createSMESHAction( 301, "DISPLAY" );
2605 createSMESHAction( 302, "DISPLAY_ONLY" );
2606 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2608 // ----- create menu --------------
2609 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2610 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2611 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2612 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2613 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2614 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2615 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2616 prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ),
2617 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2619 createMenu( separator(), fileId );
2621 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2622 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2624 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2625 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2626 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2627 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
2629 meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ),
2631 dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ),
2632 qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 );
2634 createMenu( 111, importId, -1 );
2635 createMenu( 112, importId, -1 );
2636 createMenu( 113, importId, -1 );
2638 createMenu( 121, exportId, -1 );
2639 createMenu( 122, exportId, -1 );
2640 createMenu( 123, exportId, -1 );
2642 createMenu( separator(), fileId, 10 );
2644 createMenu( 33, editId, -1 );
2646 createMenu( 5105, toolsId, -1 );
2648 createMenu( 5000, hypoId, -1 );
2649 createMenu( 5010, hypoId, -1 );
2651 createMenu( 703, meshId, -1 );
2652 createMenu( 702, meshId, -1 );
2653 createMenu( 704, meshId, -1 );
2654 createMenu( separator(), meshId, -1 );
2655 createMenu( 701, meshId, -1 );
2656 createMenu( separator(), meshId, -1 );
2657 createMenu( 801, meshId, -1 );
2658 createMenu( 802, meshId, -1 );
2659 createMenu( 803, meshId, -1 );
2660 createMenu( separator(), meshId, -1 );
2661 createMenu( 810, meshId, -1 );
2662 createMenu( 811, meshId, -1 );
2663 createMenu( 812, meshId, -1 );
2664 createMenu( separator(), meshId, -1 );
2665 createMenu( 813, meshId, -1 );
2666 createMenu( separator(), meshId, -1 );
2667 createMenu( 900, meshId, -1 );
2668 createMenu( 902, meshId, -1 );
2669 createMenu( separator(), meshId, -1 );
2671 createMenu( 6003, ctrlId, -1 );
2672 createMenu( 6001, ctrlId, -1 );
2673 createMenu( 6004, ctrlId, -1 );
2674 createMenu( separator(), ctrlId, -1 );
2675 createMenu( 6002, ctrlId, -1 );
2676 createMenu( 6018, ctrlId, -1 );
2677 createMenu( 6019, ctrlId, -1 );
2678 createMenu( 6011, ctrlId, -1 );
2679 createMenu( 6012, ctrlId, -1 );
2680 createMenu( 6013, ctrlId, -1 );
2681 createMenu( 6014, ctrlId, -1 );
2682 createMenu( 6015, ctrlId, -1 );
2683 createMenu( 6016, ctrlId, -1 );
2684 createMenu( separator(), ctrlId, -1 );
2685 createMenu( 6017, ctrlId, -1 );
2686 createMenu( separator(), ctrlId, -1 );
2688 createMenu( 400, addId, -1 );
2689 createMenu( 401, addId, -1 );
2690 createMenu( 4021, addId, -1 );
2691 createMenu( 4022, addId, -1 );
2692 createMenu( 4023, addId, -1 );
2693 createMenu( 4031, addId, -1 );
2694 createMenu( 4032, addId, -1 );
2695 createMenu( 4033, addId, -1 );
2697 createMenu( 4041, removeId, -1 );
2698 createMenu( 4042, removeId, -1 );
2700 createMenu( 4051, renumId, -1 );
2701 createMenu( 4052, renumId, -1 );
2703 createMenu( 4061, transfId, -1 );
2704 createMenu( 4062, transfId, -1 );
2705 createMenu( 4063, transfId, -1 );
2706 createMenu( 4064, transfId, -1 );
2707 createMenu( 4065, transfId, -1 );
2709 createMenu( 406, modifyId, -1 );
2710 createMenu( 407, modifyId, -1 );
2711 createMenu( 408, modifyId, -1 );
2712 createMenu( 409, modifyId, -1 );
2713 createMenu( 410, modifyId, -1 );
2714 createMenu( 411, modifyId, -1 );
2715 createMenu( 412, modifyId, -1 );
2716 createMenu( 413, modifyId, -1 );
2717 createMenu( 416, modifyId, -1 );
2718 createMenu( 414, modifyId, -1 );
2719 createMenu( 415, modifyId, -1 );
2721 createMenu( 10001, dispModeId, -1 );
2722 createMenu( 10002, dispModeId, -1 );
2723 createMenu( 10004, dispModeId, -1 );
2724 createMenu( 10003, dispModeId, -1 );
2726 createMenu( 1001, prefId, -1 );
2727 createMenu( separator(), prefId, -1 );
2728 createMenu( 1003, prefId, -1 );
2729 createMenu( separator(), prefId, -1 );
2730 createMenu( 1005, prefId, -1 );
2731 createMenu( separator(), prefId, -1 );
2732 createMenu( 1006, prefId, -1 );
2733 createMenu( separator(), prefId, -1 );
2735 createMenu( 10070, qualityId, -1 );
2736 createMenu( 10071, qualityId, -1 );
2738 createMenu( separator(), prefId, -1 );
2740 createMenu( 214, viewId, -1 );
2742 // ----- create toolbars --------------
2743 int meshTb = createTool( tr( "TB_MESH" ) ),
2744 hypoTb = createTool( tr( "TB_HYPO" ) ),
2745 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2746 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2747 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2748 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2750 createTool( 703, meshTb );
2751 createTool( 702, meshTb );
2752 createTool( 704, meshTb );
2753 createTool( separator(), meshTb );
2754 createTool( 701, meshTb );
2755 createTool( separator(), meshTb );
2756 createTool( 801, meshTb );
2757 createTool( 802, meshTb );
2758 createTool( 803, meshTb );
2759 createTool( separator(), meshTb );
2760 createTool( 900, meshTb );
2761 createTool( 902, meshTb );
2762 createTool( separator(), meshTb );
2764 createTool( 5000, hypoTb );
2765 createTool( 5010, hypoTb );
2767 createTool( 6001, ctrlTb );
2768 createTool( 6003, ctrlTb );
2769 createTool( 6004, ctrlTb );
2770 createTool( separator(), ctrlTb );
2771 createTool( 6002, ctrlTb );
2772 createTool( 6018, ctrlTb );
2773 createTool( 6019, ctrlTb );
2774 createTool( 6011, ctrlTb );
2775 createTool( 6012, ctrlTb );
2776 createTool( 6013, ctrlTb );
2777 createTool( 6014, ctrlTb );
2778 createTool( 6015, ctrlTb );
2779 createTool( 6016, ctrlTb );
2780 createTool( separator(), ctrlTb );
2781 createTool( 6017, ctrlTb );
2782 createTool( separator(), ctrlTb );
2784 createTool( 400, addRemTb );
2785 createTool( 401, addRemTb );
2786 createTool( 4021, addRemTb );
2787 createTool( 4022, addRemTb );
2788 createTool( 4023, addRemTb );
2789 createTool( 4031, addRemTb );
2790 createTool( 4032, addRemTb );
2791 createTool( 4033, addRemTb );
2792 createTool( separator(), addRemTb );
2793 createTool( 4041, addRemTb );
2794 createTool( 4042, addRemTb );
2795 createTool( separator(), addRemTb );
2796 createTool( 4051, addRemTb );
2797 createTool( 4052, addRemTb );
2798 createTool( separator(), addRemTb );
2799 createTool( 4061, addRemTb );
2800 createTool( 4062, addRemTb );
2801 createTool( 4063, addRemTb );
2802 createTool( 4064, addRemTb );
2803 createTool( 4065, addRemTb );
2804 createTool( separator(), addRemTb );
2806 createTool( 406, modifyTb );
2807 createTool( 407, modifyTb );
2808 createTool( 408, modifyTb );
2809 createTool( 409, modifyTb );
2810 createTool( 410, modifyTb );
2811 createTool( 411, modifyTb );
2812 createTool( 412, modifyTb );
2813 createTool( 413, modifyTb );
2814 createTool( 416, modifyTb );
2815 createTool( 414, modifyTb );
2816 createTool( 415, modifyTb );
2818 createTool( 214, dispModeTb );
2822 QString OB = "'ObjectBrowser'",
2823 View = "'" + SVTK_Viewer::Type() + "'",
2825 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2826 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2827 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2828 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2829 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2830 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2831 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2832 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2833 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2834 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2836 mesh_group = mesh + " " + subMesh + " " + group,
2837 hyp_alg = hypo + " " + algo;
2839 // popup for object browser
2841 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2842 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2843 createPopupItem( 803, OB, group ); // EDIT_GROUP
2844 popupMgr()->insert( separator(), -1, 0 );
2845 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2846 createPopupItem( 214, OB, mesh_group ); // UPDATE
2847 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2848 createPopupItem( 902, OB, mesh ); // STD_INFO
2849 popupMgr()->insert( separator(), -1, 0 );
2850 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2851 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2852 popupMgr()->insert( separator(), -1, 0 );
2853 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2854 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2855 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2856 popupMgr()->insert( separator(), -1, 0 );
2857 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2858 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2859 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2860 popupMgr()->insert( separator(), -1, 0 );
2863 createPopupItem( 803, View, group ); // EDIT_GROUP
2864 createPopupItem( 804, View, elems ); // ADD
2865 createPopupItem( 805, View, elems ); // REMOVE
2866 popupMgr()->insert( separator(), -1, 0 );
2867 createPopupItem( 214, View, mesh_group ); // UPDATE
2868 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2869 createPopupItem( 902, View, mesh ); // STD_INFO
2870 popupMgr()->insert( separator(), -1, 0 );
2874 isInvisible("not( isVisible )"),
2875 isEmpty("numberOfNodes = 0"),
2876 isNotEmpty("numberOfNodes <> 0"),
2878 // has nodes, edges, etc in VISIBLE! actor
2879 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2880 hasElems("(count( elemTypes ) > 0)"),
2881 hasDifferentElems("(count( elemTypes ) > 1)"),
2882 hasEdges("({'Edge'} in elemTypes)"),
2883 hasFaces("({'Face'} in elemTypes)"),
2884 hasVolumes("({'Volume'} in elemTypes)");
2886 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2887 QString lc = QtxPopupMgr::Selection::defEquality();
2888 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2889 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2890 QString aMeshInVTK = aClient + "&&" + aType;// + "&&" + aSelCount;
2892 //-------------------------------------------------
2894 //-------------------------------------------------
2895 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2897 popupMgr()->insert( action( 9010 ), anId, -1 );
2898 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true );
2899 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2901 popupMgr()->insert( action( 9011 ), anId, -1 );
2902 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true );
2903 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2905 popupMgr()->insert( separator(), -1, -1 );
2907 //-------------------------------------------------
2909 //-------------------------------------------------
2910 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2912 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2913 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2914 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2916 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2917 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2918 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2920 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2921 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2922 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2924 popupMgr()->insert( separator(), anId, -1 );
2926 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2927 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2928 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2930 //-------------------------------------------------
2932 //-------------------------------------------------
2933 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2935 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2937 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2938 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true );
2939 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2941 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2942 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true );
2943 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2945 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2946 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true );
2947 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2949 popupMgr()->insert( separator(), anId, -1 );
2951 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2952 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true );
2954 //-------------------------------------------------
2956 //-------------------------------------------------
2957 popupMgr()->insert( action( 1132 ), -1, -1 );
2958 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2960 //-------------------------------------------------
2962 //-------------------------------------------------
2963 popupMgr()->insert( action( 1133 ), -1, -1 );
2964 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2966 //-------------------------------------------------
2968 //-------------------------------------------------
2969 popupMgr()->insert( action( 1134 ), -1, -1 );
2970 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2972 popupMgr()->insert( separator(), -1, -1 );
2974 //-------------------------------------------------
2976 //-------------------------------------------------
2978 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2979 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2980 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2982 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2984 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2985 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2987 popupMgr()->insert( separator(), anId, -1 );
2989 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2990 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2991 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2993 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2994 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2995 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2997 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2998 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2999 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
3001 popupMgr()->insert( separator(), anId, -1 );
3003 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3004 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
3005 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
3007 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3008 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
3009 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
3011 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3012 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
3013 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
3015 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3016 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
3017 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
3019 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3020 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
3021 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
3023 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3024 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
3025 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
3027 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3028 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3029 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3031 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3032 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3033 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3035 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3036 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3037 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3039 popupMgr()->insert( separator(), anId, -1 );
3041 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3042 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3043 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3045 popupMgr()->insert( separator(), anId, -1 );
3047 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3048 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3050 popupMgr()->insert( separator(), -1, -1 );
3052 //-------------------------------------------------
3054 //-------------------------------------------------
3055 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3056 QString aRule = aClient + " and " + aType + " and " + aSelCount;
3057 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3058 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
3060 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3061 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
3063 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3064 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
3066 popupMgr()->insert( separator(), -1, -1 );
3068 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
3069 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
3072 bool SMESHGUI::activateModule( SUIT_Study* study )
3074 bool res = SalomeApp_Module::activateModule( study );
3076 setMenuShown( true );
3077 setToolShown( true );
3078 SetSettings( desktop() );
3083 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3085 setMenuShown( false );
3086 setToolShown( false );
3088 EmitSignalCloseAllDialogs();
3090 return SalomeApp_Module::deactivateModule( study );
3093 void SMESHGUI::OnGUIEvent()
3095 const QObject* obj = sender();
3096 if ( !obj || !obj->inherits( "QAction" ) )
3098 int id = actionId((QAction*)obj);
3103 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3105 if ( CORBA::is_nil( myComponentSMESH ) )
3107 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3108 return aGUI.myComponentSMESH;
3110 return myComponentSMESH;
3113 QString SMESHGUI::engineIOR() const
3115 CORBA::ORB_var anORB = getApp()->orb();
3116 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3120 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3122 SMESHGUI_Selection sel;
3123 sel.init( client, selectionMgr() );
3124 popupMgr()->updatePopup( menu, &sel );
3127 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3129 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3130 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3133 void SMESHGUI::viewManagers( QStringList& list ) const
3135 list.append( SVTK_Viewer::Type() );
3138 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
3140 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
3141 SMESH::UpdateSelectionProp( this );
3144 void SMESHGUI::createPreferences()
3146 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3148 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3149 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "display_entity" );
3150 addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "auto_update" );
3152 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3153 setPreferenceProperty( precGroup, "columns", 1 );
3155 addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool );
3156 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3158 setPreferenceProperty( prec, "min", 0 );
3159 setPreferenceProperty( prec, "max", 16 );
3161 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3162 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3164 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
3165 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
3167 setPreferenceProperty( nodeSz, "min", 1 );
3168 setPreferenceProperty( nodeSz, "max", 5 );
3170 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3172 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
3173 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
3174 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
3175 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
3177 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
3178 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3180 setPreferenceProperty( elemW, "min", 1 );
3181 setPreferenceProperty( elemW, "max", 5 );
3183 setPreferenceProperty( shrink, "min", 0 );
3184 setPreferenceProperty( shrink, "max", 100 );
3186 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3188 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3190 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
3191 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
3192 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
3194 setPreferenceProperty( selW, "min", 1 );
3195 setPreferenceProperty( selW, "max", 5 );
3197 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3199 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
3200 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3202 setPreferenceProperty( preW, "min", 1 );
3203 setPreferenceProperty( preW, "max", 5 );
3205 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3207 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
3208 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
3211 void SMESHGUI::preferencesChanged( const QString&, const QString& )