1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
28 #include "SMESHGUI_InitMeshDlg.h"
29 #include "SMESHGUI_AddSubMeshDlg.h"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_HypothesesUtils.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_EditHypothesesDlg.h"
46 #include "SMESHGUI_CreateHypothesesDlg.h"
47 #include "SMESHGUI_FilterDlg.h"
48 #include "SMESHGUI_FilterLibraryDlg.h"
49 #include "SMESHGUI_SingleEditDlg.h"
50 #include "SMESHGUI_MultiEditDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_DeleteGroupDlg.h"
53 #include "SMESHGUI_SmoothingDlg.h"
54 #include "SMESHGUI_RenumberingDlg.h"
55 #include "SMESHGUI_ExtrusionDlg.h"
56 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
57 #include "SMESHGUI_RevolutionDlg.h"
58 #include "SMESHGUI_TranslationDlg.h"
59 #include "SMESHGUI_RotationDlg.h"
60 #include "SMESHGUI_SymmetryDlg.h"
61 #include "SMESHGUI_SewingDlg.h"
62 #include "SMESHGUI_MergeNodesDlg.h"
63 #include "SMESHGUI_MeshPatternDlg.h"
64 #include "SMESHGUI_PrecisionDlg.h"
65 #include "SMESHGUI_Selection.h"
66 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
68 #include <SVTK_InteractorStyle.h>
69 #include <SVTK_RenderWindowInteractor.h>
71 #include "SMESH_Actor.h"
72 #include "SMESH_Object.h"
73 #include "SMESH_TypeFilter.hxx"
75 #include "SUIT_Tools.h"
76 #include "SUIT_MessageBox.h"
77 #include "SUIT_ResourceMgr.h"
78 #include "SUIT_FileDlg.h"
79 #include "SUIT_Desktop.h"
80 #include "SUIT_ResourceMgr.h"
81 #include "SUIT_OverrideCursor.h"
82 #include "SUIT_Study.h"
83 #include "SUIT_Session.h"
85 #include "SALOME_NamingService.hxx"
86 #include "SALOME_ListIteratorOfListIO.hxx"
87 #include "SALOME_InteractiveObject.hxx"
88 #include "SALOME_ListIO.hxx"
89 #include <SALOME_LifeCycleCORBA.hxx>
91 #include "OB_Browser.h"
93 #include "QtxPopupMgr.h"
95 #include "SalomeApp_Application.h"
96 #include "SalomeApp_NameDlg.h"
97 #include "SalomeApp_DataOwner.h"
98 #include "SalomeApp_ImportOperation.h"
99 #include "SalomeApp_Tools.h"
100 #include "SalomeApp_Study.h"
101 #include "SalomeApp_VTKSelector.h"
103 #include <SVTK_ViewWindow.h>
104 #include <SVTK_ViewModel.h>
106 #include "SMESHGUI_Utils.h"
107 #include "SMESHGUI_GEOMGenUtils.h"
108 #include "SMESHGUI_MeshUtils.h"
109 #include "SMESHGUI_GroupUtils.h"
110 #include "SMESHGUI_FilterUtils.h"
111 #include "SMESHGUI_PatternUtils.h"
112 #include "SMESHGUI_VTKUtils.h"
114 #include "SALOMEconfig.h"
115 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
118 #define INCLUDE_MENUITEM_DEF
119 #include <qapplication.h>
120 #include <qlineedit.h>
121 #include <qmenudata.h>
122 #include <qmenubar.h>
123 #include <qpopupmenu.h>
126 #include <qpainter.h>
127 #include <qcheckbox.h>
128 #include <qcolordialog.h>
129 #include <qspinbox.h>
134 #include <qradiobutton.h>
136 #include <boost/shared_ptr.hpp>
138 #include <vtkRenderer.h>
139 #include <vtkRenderWindow.h>
140 #include <vtkActorCollection.h>
141 #include <vtkScalarBarActor.h>
142 #include <vtkUnstructuredGrid.h>
144 #include "utilities.h"
146 #include "SALOMEDS_Study.hxx"
147 #include "SALOMEDSClient_StudyBuilder.hxx"
148 #include "SALOMEDSClient_SComponent.hxx"
154 //=============================================================
155 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
158 void ExportMeshToFile(int theCommandID);
160 void SetDisplayMode(int theCommandID);
162 void SetDisplayEntity(int theCommandID);
164 void Control( int theCommandID );
166 void SetDisplaySettings();
170 //=============================================================
171 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
177 if(theCommandID == 113){
178 filter.append(QObject::tr("MED files (*.med)"));
179 filter.append(QObject::tr("All files (*)"));
180 }else if (theCommandID == 112){
181 filter.append(QObject::tr("IDEAS files (*.unv)"));
182 }else if (theCommandID == 111){
183 filter.append(QObject::tr("DAT files (*.dat)"));
185 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
188 QObject::tr("Import mesh"),
190 if(!filename.isEmpty()) {
191 SUIT_OverrideCursor wc;
192 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
195 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
196 switch ( theCommandID ) {
199 aMeshes->length( 1 );
200 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
205 SMESH::DriverMED_ReadStatus res;
206 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
207 if ( res != SMESH::DRS_OK ) {
209 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
210 QObject::tr("SMESH_WRN_WARNING"),
211 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
212 QObject::tr("SMESH_BUT_OK"));
213 aMeshes->length( 0 );
220 bool isEmpty = false;
221 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
222 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
224 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
225 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
226 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
227 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
228 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
235 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
236 QObject::tr("SMESH_WRN_WARNING"),
237 QObject::tr("SMESH_DRS_EMPTY"),
238 QObject::tr("SMESH_BUT_OK"));
242 catch (const SALOME::SALOME_Exception& S_ex){
244 SalomeApp_Tools::QtCatchCorbaException(S_ex);
251 void ExportMeshToFile( int theCommandID )
253 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
254 SALOME_ListIO selected;
256 aSel->selectedObjects( selected );
258 if(selected.Extent()){
259 Handle(SALOME_InteractiveObject) anIObject = selected.First();
260 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
261 if ( !aMesh->_is_nil() ) {
262 QString aFilter, aTitle = QObject::tr("Export mesh");
263 QMap<QString, SMESH::MED_VERSION> aFilterMap;
264 switch ( theCommandID ) {
267 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
268 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
272 aFilter = QObject::tr("DAT files (*.dat)");
276 if(aMesh->NbPyramids()){
277 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
278 QObject::tr("SMESH_WRN_WARNING"),
279 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
280 QObject::tr("SMESH_BUT_YES"),
281 QObject::tr("SMESH_BUT_NO"),
286 aFilter = QObject::tr("IDEAS files (*.unv)");
293 SMESH::MED_VERSION aFormat;
295 if ( theCommandID != 122 && theCommandID != 125 )
296 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
300 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
301 filters.push_back( it.key() );
303 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
304 fd->setCaption( aTitle );
305 fd->setFilters( filters );
307 aFilename = fd->selectedFile();
308 aFormat = aFilterMap[fd->selectedFilter()];
310 if( !aFilename.isEmpty()
311 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
312 && aFormat==SMESH::MED_V2_1){
313 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
314 QObject::tr("SMESH_WRN_WARNING"),
315 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
316 QObject::tr("SMESH_BUT_YES"),
317 QObject::tr("SMESH_BUT_NO"),
324 if ( !aFilename.isEmpty() ) {
325 // Check whether the file already exists and delete it if yes
326 QFile aFile( aFilename );
327 if ( aFile.exists() )
329 SUIT_OverrideCursor wc;
330 switch ( theCommandID ) {
333 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
337 aMesh->ExportDAT( aFilename.latin1() );
341 aMesh->ExportUNV( aFilename.latin1() );
351 inline void InverseEntityMode(unsigned int& theOutputMode,
352 unsigned int theMode)
354 bool anIsNotPresent = ~theOutputMode & theMode;
356 theOutputMode |= theMode;
358 theOutputMode &= ~theMode;
361 void SetDisplayEntity(int theCommandID){
362 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
363 SALOME_ListIO selected;
365 aSel->selectedObjects( selected );
367 if(selected.Extent() >= 1){
368 SALOME_ListIteratorOfListIO It( selected );
369 for(; It.More(); It.Next()){
370 Handle(SALOME_InteractiveObject) IObject = It.Value();
371 if(IObject->hasEntry()){
372 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
373 unsigned int aMode = anActor->GetEntityMode();
374 switch(theCommandID){
376 InverseEntityMode(aMode,SMESH_Actor::eEdges);
379 InverseEntityMode(aMode,SMESH_Actor::eFaces);
382 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
385 aMode = SMESH_Actor::eAllEntity;
389 anActor->SetEntityMode(aMode);
396 void SetDisplayMode(int theCommandID){
397 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
398 SALOME_ListIO selected;
400 aSel->selectedObjects( selected );
402 if(selected.Extent() >= 1){
403 switch(theCommandID){
405 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
406 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
410 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
411 new SMESHGUI_TransparencyDlg( SMESHGUI::desktop(), "", false );
414 SALOME_ListIteratorOfListIO It( selected );
415 for(; It.More(); It.Next()){
416 Handle(SALOME_InteractiveObject) IObject = It.Value();
417 if(IObject->hasEntry()){
418 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
419 switch(theCommandID){
421 anActor->SetRepresentation(SMESH_Actor::eEdge);
424 anActor->SetRepresentation(SMESH_Actor::eSurface);
427 if(anActor->IsShrunk())
430 anActor->SetShrink();
433 anActor->SetRepresentation(SMESH_Actor::ePoint);
437 anActor->GetSufaceColor(color[0], color[1], color[2]);
438 int c0 = int (color[0] * 255);
439 int c1 = int (color[1] * 255);
440 int c2 = int (color[2] * 255);
441 QColor c(c0, c1, c2);
444 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
445 c0 = int (edgecolor[0] * 255);
446 c1 = int (edgecolor[1] * 255);
447 c2 = int (edgecolor[2] * 255);
448 QColor e(c0, c1, c2);
450 float backfacecolor[3];
451 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
452 c0 = int (backfacecolor[0] * 255);
453 c1 = int (backfacecolor[1] * 255);
454 c2 = int (backfacecolor[2] * 255);
455 QColor b(c0, c1, c2);
458 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
459 c0 = int (nodecolor[0] * 255);
460 c1 = int (nodecolor[1] * 255);
461 c2 = int (nodecolor[2] * 255);
462 QColor n(c0, c1, c2);
464 int Edgewidth = (int)anActor->GetLineWidth();
467 int intValue = int(anActor->GetNodeSize());
468 float Shrink = anActor->GetShrinkFactor();
470 SMESHGUI_Preferences_ColorDlg *aDlg =
471 new SMESHGUI_Preferences_ColorDlg(SMESHGUI::desktop(),"");
472 aDlg->SetColor(1, c);
473 aDlg->SetColor(2, e);
474 aDlg->SetColor(3, n);
475 aDlg->SetColor(4, b);
476 aDlg->SetIntValue(1, Edgewidth);
477 aDlg->SetIntValue(2, intValue);
478 aDlg->SetIntValue(3, int(Shrink*100.));
480 QColor color = aDlg->GetColor(1);
481 QColor edgecolor = aDlg->GetColor(2);
482 QColor nodecolor = aDlg->GetColor(3);
483 QColor backfacecolor = aDlg->GetColor(4);
484 /* actor color and backface color */
485 anActor->SetSufaceColor(float (color.red()) / 255.,
486 float (color.green()) / 255.,
487 float (color.blue()) / 255.);
488 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
489 float (backfacecolor.green()) / 255.,
490 float (backfacecolor.blue()) / 255.);
493 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
494 float (edgecolor.green()) / 255.,
495 float (edgecolor.blue()) / 255.);
497 /* Shrink factor and size edges */
498 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
499 anActor->SetLineWidth(aDlg->GetIntValue(1));
501 /* Nodes color and size */
502 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
503 float (nodecolor.green()) / 255.,
504 float (nodecolor.blue()) / 255.);
505 anActor->SetNodeSize(aDlg->GetIntValue(2));
514 SMESH::RepaintCurrentView();
519 void SetDisplaySettings()
521 SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
525 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
526 SMESHGUI_Preferences_ColorDlg *aDlg =
527 new SMESHGUI_Preferences_ColorDlg(SMESHGUI::desktop(), "");
529 QColor color = mgr->colorValue( "SMESH", "SettingsFillColor", QColor(0, 170, 255) );
530 aDlg->SetColor(1, color);
532 color = mgr->colorValue( "SMESH", "SettingsOutlineColor", QColor(0, 170, 255) );
533 aDlg->SetColor(2, color);
535 color = mgr->colorValue( "SMESH", "SettingsNodeColor", Qt::red );
536 aDlg->SetColor(3, color);
538 color = mgr->colorValue( "SMESH", "SettingsBackFaceColor", Qt::blue );
539 aDlg->SetColor(4, color);
541 int iVal = mgr->integerValue( "SMESH", "SettingsWidth", 1 );
542 aDlg->SetIntValue(1, iVal);
544 iVal = mgr->integerValue( "SMESH", "SettingsNodesSize", 3 );
545 aDlg->SetIntValue(2, iVal);
547 iVal = mgr->integerValue( "SMESH", "SettingsShrinkCoeff", 75 );
548 aDlg->SetIntValue(3, iVal);
551 mgr->setValue( "SMESH", "SettingsFillColor", aDlg->GetColor(1) );
552 mgr->setValue( "SMESH", "SettingsOutlineColor", aDlg->GetColor(2) );
553 mgr->setValue( "SMESH", "SettingsNodeColor", aDlg->GetColor(3) );
554 mgr->setValue( "SMESH", "SettingsBackFaceColor", aDlg->GetColor(4) );
556 mgr->setValue( "SMESH", "SettingsWidth", aDlg->GetIntValue(1) );
557 mgr->setValue( "SMESH", "SettingsNodesSize", aDlg->GetIntValue(2) );
558 mgr->setValue( "SMESH", "SettingsShrinkCoeff", aDlg->GetIntValue(3) );
565 void Control( int theCommandID )
567 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
568 SALOME_ListIO selected;
570 aSel->selectedObjects( selected );
572 if( !selected.IsEmpty() ){
573 Handle(SALOME_InteractiveObject) anIO = selected.First();
576 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
577 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
578 switch ( theCommandID ){
580 aTitle = QObject::tr( "LENGTH_EDGES" );
581 aControl = SMESH_Actor::eLength;
584 aTitle = QObject::tr( "LENGTH2D_EDGES" );
585 aControl = SMESH_Actor::eLength2D;
588 aTitle = QObject::tr( "FREE_EDGES" );
589 aControl = SMESH_Actor::eFreeEdges;
592 aTitle = QObject::tr( "FREE_BORDERS" );
593 aControl = SMESH_Actor::eFreeBorders;
596 aTitle = QObject::tr( "MULTI_BORDERS" );
597 aControl = SMESH_Actor::eMultiConnection;
600 aTitle = QObject::tr( "MULTI2D_BORDERS" );
601 aControl = SMESH_Actor::eMultiConnection2D;
604 aTitle = QObject::tr( "AREA_ELEMENTS" );
605 aControl = SMESH_Actor::eArea;
608 aTitle = QObject::tr( "TAPER_ELEMENTS" );
609 aControl = SMESH_Actor::eTaper;
612 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
613 aControl = SMESH_Actor::eAspectRatio;
616 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
617 aControl = SMESH_Actor::eAspectRatio3D;
620 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
621 aControl = SMESH_Actor::eMinimumAngle;
624 aTitle = QObject::tr( "WARP_ELEMENTS" );
625 aControl = SMESH_Actor::eWarping;
628 aTitle = QObject::tr( "SKEW_ELEMENTS" );
629 aControl = SMESH_Actor::eSkew;
632 anActor->SetControlMode(aControl);
633 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
640 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
641 MeshObjectType theType,
642 const QString theInTypeName,
643 QString & theOutTypeName)
645 SMESH_TypeFilter aTypeFilter( theType );
647 if( !theIO.IsNull() )
649 entry = theIO->getEntry();
650 SalomeApp_DataOwner owner( entry );
651 if ( aTypeFilter.isOk( &owner )) {
652 theOutTypeName = theInTypeName;
660 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
662 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
663 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
665 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
666 CORBA::String_var anID = aSComp->GetID().c_str();
667 if (!strcmp(anID.in(),theIO->getEntry()))
673 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
674 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
675 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
676 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
677 CheckOIType ( theIO, GROUP, "Group", aTypeName )
685 QString CheckHomogeneousSelection()
687 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
688 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
689 SALOME_ListIO selected;
691 aSel->selectedObjects( selected );
693 QString RefType = CheckTypeObject(selected.First());
694 SALOME_ListIteratorOfListIO It(selected);
695 for (; It.More(); It.Next())
697 Handle(SALOME_InteractiveObject) IObject = It.Value();
698 QString Type = CheckTypeObject(IObject);
699 if (Type.compare(RefType) != 0)
700 return "Heterogeneous Selection";
708 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
709 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
710 SALOME_ListIO selected; aSel->selectedObjects( selected );
712 QString aParentComponent = QString::null;
713 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
715 QString cur = anIt.Value()->getComponentDataType();
716 if( aParentComponent.isNull() )
717 aParentComponent = cur;
718 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
719 aParentComponent = "";
722 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
723 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
724 QObject::tr("ERR_ERROR"),
725 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
726 QObject::tr("BUT_OK") );
729 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
730 if (SUIT_MessageBox::warn2
731 (SMESHGUI::desktop(),
732 QObject::tr("SMESH_WRN_WARNING"),
733 QObject::tr("SMESH_REALLY_DELETE"),
734 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
737 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
738 SUIT_ViewManager* vm = anApp->activeViewManager();
739 int nbSf = vm->getViewsCount();
741 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
742 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
743 _PTR(GenericAttribute) anAttr;
744 _PTR(AttributeIOR) anIOR;
746 SALOME_ListIteratorOfListIO It(selected);
748 aStudyBuilder->NewCommand(); // There is a transaction
749 for(; It.More(); It.Next()){
750 Handle(SALOME_InteractiveObject) IObject = It.Value();
751 if(IObject->hasEntry()){
752 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
754 /* Erase child graphical objects */
755 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
756 for(it->InitEx(true); it->More(); it->Next()){
757 _PTR(SObject) CSO = it->Value();
758 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
761 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
762 for(int i = 0; i < nbSf; i++){
763 SUIT_ViewWindow *sf = aViews[i];
764 CORBA::String_var anEntry = CSO->GetID().c_str();
765 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
766 SMESH::RemoveActor(sf,anActor);
772 /* Erase main graphical object */
773 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
774 for(int i = 0; i < nbSf; i++){
775 SUIT_ViewWindow *sf = aViews[i];
776 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
777 SMESH::RemoveActor(sf,anActor);
781 // Remove object(s) from data structures
782 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
784 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
785 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
787 if ( !aGroup->_is_nil() ) { // DELETE GROUP
788 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
789 aMesh->RemoveGroup( aGroup );
791 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
792 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
793 aMesh->RemoveSubMesh( aSubMesh );
795 else {// default action: remove SObject from the study
796 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
797 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
799 aStudyBuilder->RemoveObjectWithChildren( obj );
804 } /* IObject->hasEntry() */
806 aStudyBuilder->CommitCommand();
808 /* Clear any previous selection */
809 SALOME_ListIO selected1;
810 aSel->setSelectedObjects( selected1 );
812 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
816 //=============================================================================
820 //=============================================================================
821 class CustomItem : public QCustomMenuItem
824 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
827 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
830 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
831 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
832 p->setFont( myFont );
833 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
839 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
842 bool fullSpan() const
853 Standard_EXPORT CAM_Module* createModule()
855 return SMESHGUI::GetSMESHGUI();
859 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
861 //=============================================================================
865 //=============================================================================
866 SMESHGUI::SMESHGUI() :
867 SalomeApp_Module( "SMESH" )
869 if ( CORBA::is_nil( myComponentSMESH ) )
871 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
872 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
873 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
876 myActiveDialogBox = 0 ;
879 SMESH::GetFilterManager();
882 /* load resources for all available meshers */
883 SMESH::InitAvailableHypotheses();
886 //=============================================================================
890 //=============================================================================
891 SMESHGUI::~SMESHGUI()
893 SMESH::GetFilterManager()->Destroy();
896 //=============================================================================
900 //=============================================================================
901 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
903 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
905 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
910 //=============================================================================
914 //=============================================================================
915 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
917 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
920 //=============================================================================
924 //=============================================================================
925 SMESHGUI* SMESHGUI::GetSMESHGUI()
927 static SMESHGUI* aSMESHGUI = NULL;
929 aSMESHGUI = new SMESHGUI();
931 if(_PTR(Study) aStudy = SMESH::GetActiveStudyDocument())
932 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
934 SUIT_ResourceMgr* mgr = resourceMgr();
936 /* Automatic Update flag */
937 aSMESHGUI->myAutomaticUpdate = ( mgr->stringValue( "SMESH", "AutomaticUpdate" ).compare( "true" ) == 0 );
944 Standard_EXPORT SMESHGUI* GetComponentGUI() {
945 return SMESHGUI::GetSMESHGUI();
949 //=============================================================================
953 //=============================================================================
954 void SMESHGUI::SetState(int aState)
959 //=============================================================================
963 //=============================================================================
964 void SMESHGUI::ResetState()
969 //=============================================================================
973 //=============================================================================
974 void SMESHGUI::EmitSignalDeactivateDialog()
976 emit SignalDeactivateActiveDialog();
979 //=============================================================================
983 //=============================================================================
984 void SMESHGUI::EmitSignalStudyFrameChanged()
986 emit SignalStudyFrameChanged();
989 //=============================================================================
993 //=============================================================================
994 void SMESHGUI::EmitSignalCloseAllDialogs()
996 emit SignalCloseAllDialogs();
999 //=============================================================================
1003 //=============================================================================
1004 QDialog *SMESHGUI::GetActiveDialogBox()
1006 return myActiveDialogBox;
1009 //=============================================================================
1013 //=============================================================================
1014 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1016 myActiveDialogBox = (QDialog *) aDlg;
1020 //=============================================================================
1024 //=============================================================================
1025 SUIT_Desktop* SMESHGUI::desktop()
1027 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1029 return app->desktop();
1034 //=============================================================================
1038 //=============================================================================
1039 SalomeApp_Study* SMESHGUI::activeStudy()
1041 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1043 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1048 //=============================================================================
1052 //=============================================================================
1053 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1055 /* Here the position is on the bottom right corner - 10 */
1056 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1058 SUIT_Desktop *PP = desktop();
1059 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1060 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1064 //=============================================================================
1068 //=============================================================================
1069 static int isStudyLocked(_PTR(Study) theStudy){
1070 return theStudy->GetProperties()->IsLocked();
1073 static bool checkLock(_PTR(Study) theStudy) {
1074 if (isStudyLocked(theStudy)) {
1075 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1076 QObject::tr("WRN_WARNING"),
1077 QObject::tr("WRN_STUDY_LOCKED"),
1078 QObject::tr("BUT_OK") );
1084 //=======================================================================
1085 //function : CheckActiveStudyLocked
1087 //=======================================================================
1089 bool SMESHGUI::isActiveStudyLocked()
1091 _PTR(Study) aStudy = activeStudy()->studyDS();
1092 return checkLock( aStudy );
1095 //=============================================================================
1099 //=============================================================================
1100 bool SMESHGUI::OnGUIEvent( int theCommandID )
1102 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1106 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1107 SUIT_ResourceMgr* mgr = resourceMgr();
1111 SUIT_ViewManager* vm = application()->activeViewManager();
1115 SUIT_ViewWindow* view =vm->getActiveView();
1116 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1118 QAction* act = action( theCommandID );
1120 switch (theCommandID) {
1122 if(checkLock(aStudy)) break;
1130 if(checkLock(aStudy)) break;
1131 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1135 case 122: // EXPORT MED
1142 ::ExportMeshToFile(theCommandID);
1146 case 200: // SCALAR BAR
1148 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1149 SALOME_ListIO selected;
1151 aSel->selectedObjects( selected );
1153 if( selected.Extent() ) {
1154 Handle(SALOME_InteractiveObject) anIO = selected.First();
1155 if( anIO->hasEntry() ) {
1156 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1157 anActor->SetControlMode( SMESH_Actor::eNone );
1165 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1166 SALOME_ListIO selected;
1168 aSel->selectedObjects( selected );
1170 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( desktop(), aSel );
1174 case 1134: // Clipping
1175 case 1133: // Tranparency
1176 case 1132: // Colors / Size
1183 ::SetDisplayMode(theCommandID);
1189 case 219: // Volumes
1190 case 220: // All Entity
1191 ::SetDisplayEntity(theCommandID);
1196 if(checkLock(aStudy)) break;
1197 SMESH::UpdateView();
1202 case 301: // DISPLAY
1203 case 302: // DISPLAY ONLY
1205 SMESH::EDisplaing anAction;
1206 switch(theCommandID){
1207 case 300: anAction = SMESH::eErase; break;
1208 case 301: anAction = SMESH::eDisplay; break;
1209 case 302: anAction = SMESH::eDisplayOnly; break;
1212 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1213 SALOME_ListIO selected;
1215 aSel->selectedObjects( selected );
1218 SALOME_ListIteratorOfListIO It(selected);
1219 for (; It.More(); It.Next()) {
1220 Handle(SALOME_InteractiveObject) IOS = It.Value();
1221 if (IOS->hasEntry()) {
1222 SMESH::UpdateView(anAction,IOS->getEntry());
1226 SALOME_ListIO selected1;
1227 aSel->setSelectedObjects( selected1 );
1233 if(checkLock(aStudy)) break;
1236 EmitSignalDeactivateDialog();
1238 new SMESHGUI_NodesDlg( desktop(), "", SMESHGUI::selectionMgr() );
1241 SUIT_MessageBox::warn1(desktop(),
1242 tr("SMESH_WRN_WARNING"),
1243 tr("SMESH_WRN_VIEWER_VTK"),
1244 tr("SMESH_BUT_OK"));
1249 case 2151: // FILTER
1253 EmitSignalDeactivateDialog();
1254 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1259 case 406: // MOVE NODE
1263 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1264 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1268 if(checkLock(aStudy)) break;
1269 new SMESHGUI_MoveNodesDlg(this);
1273 case 701: // COMPUTE MESH
1275 if(checkLock(aStudy)) break;
1277 SalomeApp_SelectionMgr *Sel = selectionMgr();
1278 SALOME_ListIO selected; Sel->selectedObjects( selected );
1280 int nbSel = selected.Extent();
1285 SMESH::SMESH_Mesh_var aMesh;
1286 SMESH::SMESH_subMesh_var aSubMesh;
1287 Handle(SALOME_InteractiveObject) IObject = selected.First();
1288 if (IObject->hasEntry()){
1289 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1290 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1291 if ( aShapeObject->_is_nil() ) {
1296 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1297 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1299 if (!aMesh->_is_nil()){
1300 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1301 if (!refShapeObject->_is_nil()) {
1302 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1303 SUIT_MessageBox::warn1(desktop(),
1304 tr("SMESH_WRN_WARNING"),
1305 tr("SMESH_WRN_MISSING_PARAMETERS"),
1306 tr("SMESH_BUT_OK"));
1310 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1311 SMESH::ModifiedMesh(aMeshSObj,true);
1312 // TO Do : change icon of all submeshes
1314 SUIT_MessageBox::warn1(desktop(),
1315 tr("SMESH_WRN_WARNING"),
1316 tr("SMESH_WRN_COMPUTE_FAILED"),
1317 tr("SMESH_BUT_OK"));
1319 catch(const SALOME::SALOME_Exception & S_ex){
1320 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1323 }else if(!aSubMesh->_is_nil()){
1324 aMesh = aSubMesh->GetFather();
1325 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1326 if(!refShapeObject->_is_nil()){
1327 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1329 SUIT_MessageBox::warn1(desktop(),
1330 tr("SMESH_WRN_WARNING"),
1331 tr("SMESH_WRN_MISSING_PARAMETERS"),
1332 tr("SMESH_BUT_OK"));
1336 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1337 SMESH::ModifiedMesh(aMeshSObj,true);
1338 // TO Do : change icon of all submeshes
1340 SUIT_MessageBox::warn1(desktop(),
1341 tr("SMESH_WRN_WARNING"),
1342 tr("SMESH_WRN_COMPUTE_FAILED"),
1343 tr("SMESH_BUT_OK"));
1344 }catch(const SALOME::SALOME_Exception & S_ex){
1345 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1351 CORBA::Long anId = aStudy->StudyId();
1352 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1353 cout<<"myAutomaticUpdate - "<<myAutomaticUpdate<<endl;
1354 if(myAutomaticUpdate && aVisualObj){
1355 aVisualObj->Update();
1356 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1358 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1360 SMESH::DisplayActor(view,anActor); //apo
1366 SUIT_MessageBox::warn1(desktop(),
1367 tr("SMESH_WRN_WARNING"),
1368 tr("SMESH_WRN_VIEWER_VTK"),
1369 tr("SMESH_BUT_OK"));
1374 case 702: // ADD SUB MESH
1376 if(checkLock(aStudy)) break;
1378 EmitSignalDeactivateDialog();
1379 new SMESHGUI_AddSubMeshDlg( this );
1382 SUIT_MessageBox::warn1(desktop(),
1383 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1384 tr("SMESH_BUT_OK"));
1389 case 703: // INIT MESH
1391 if(checkLock(aStudy)) break;
1392 EmitSignalDeactivateDialog();
1393 new SMESHGUI_InitMeshDlg( this );
1397 case 704: // EDIT Hypothesis
1399 if(checkLock(aStudy)) break;
1400 EmitSignalDeactivateDialog();
1401 new SMESHGUI_EditHypothesesDlg( this );
1405 case 705: // EDIT Global Hypothesis
1407 if(checkLock(aStudy)) break;
1408 EmitSignalDeactivateDialog();
1409 new SMESHGUI_EditHypothesesDlg( this );
1413 case 706: // EDIT Local Hypothesis
1415 if(checkLock(aStudy)) break;
1416 EmitSignalDeactivateDialog();
1417 new SMESHGUI_EditHypothesesDlg( this );
1421 case 407: // DIAGONAL INVERSION
1422 case 408: // Delete diagonal
1426 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1427 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1431 if ( checkLock( aStudy ) )
1434 /*Standard_Boolean aRes;
1435 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1436 if ( aMesh->_is_nil() )
1438 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1439 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1443 EmitSignalDeactivateDialog();
1444 if ( theCommandID == 407 )
1445 new SMESHGUI_TrianglesInversionDlg(this);
1447 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1450 case 409: // Change orientation
1451 case 410: // Union of triangles
1452 case 411: // Cutting of quadrangles
1456 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1457 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1461 if ( checkLock( aStudy ) )
1464 EmitSignalDeactivateDialog();
1465 SMESHGUI_MultiEditDlg* aDlg = NULL;
1466 if ( theCommandID == 409 )
1467 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1468 else if ( theCommandID == 410 )
1469 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1471 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1474 DefineDlgPosition( aDlg, x, y );
1479 case 412: // Smoothing
1481 if(checkLock(aStudy)) break;
1483 EmitSignalDeactivateDialog();
1484 new SMESHGUI_SmoothingDlg( this );
1487 SUIT_MessageBox::warn1(desktop(),
1488 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1489 tr("SMESH_BUT_OK"));
1493 case 413: // Extrusion
1495 if (checkLock(aStudy)) break;
1497 EmitSignalDeactivateDialog();
1498 new SMESHGUI_ExtrusionDlg ( this );
1500 SUIT_MessageBox::warn1(desktop(),
1501 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1502 tr("SMESH_BUT_OK"));
1506 case 414: // Revolution
1508 if(checkLock(aStudy)) break;
1510 EmitSignalDeactivateDialog();
1511 new SMESHGUI_RevolutionDlg( this );
1514 SUIT_MessageBox::warn1(desktop(),
1515 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1516 tr("SMESH_BUT_OK"));
1520 case 415: // Pattern mapping
1522 if ( checkLock( aStudy ) )
1526 EmitSignalDeactivateDialog();
1527 new SMESHGUI_MeshPatternDlg( this );
1530 SUIT_MessageBox::warn1(desktop(),
1531 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1532 tr("SMESH_BUT_OK"));
1536 case 416: // Extrusion along a path
1538 if (checkLock(aStudy)) break;
1540 EmitSignalDeactivateDialog();
1541 new SMESHGUI_ExtrusionAlongPathDlg( this );
1543 SUIT_MessageBox::warn1(desktop(),
1544 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1545 tr("SMESH_BUT_OK"));
1549 case 801: // CREATE GROUP
1551 if(checkLock(aStudy)) break;
1552 EmitSignalDeactivateDialog();
1553 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1555 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1556 SALOME_ListIO selected;
1558 aSel->selectedObjects( selected );
1560 int nbSel = selected.Extent();
1562 // check if mesh is selected
1563 aMesh = SMESH::GetMeshByIO( selected.First() );
1565 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1570 case 802: // CONSTRUCT GROUP
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
1628 if(checkLock(aStudy)) break;
1629 EmitSignalDeactivateDialog();
1631 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1632 SALOME_ListIO selected;
1634 aSel->selectedObjects( selected );
1636 SALOME_ListIteratorOfListIO It (selected);
1637 int nbSelectedGroups = 0;
1638 for ( ; It.More(); It.Next() )
1640 SMESH::SMESH_Group_var aGroup =
1641 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1642 if (!aGroup->_is_nil()) {
1644 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1648 if (nbSelectedGroups == 0)
1650 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1656 case 804: // Add elements to group
1658 if(checkLock(aStudy)) break;
1659 if (myState == 800) {
1660 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1661 if (aDlg) aDlg->onAdd();
1666 case 805: // Remove elements from group
1668 if(checkLock(aStudy)) break;
1669 if (myState == 800) {
1670 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1671 if (aDlg) aDlg->onRemove();
1676 case 810: // Union Groups
1677 case 811: // Intersect groups
1678 case 812: // Cut groups
1680 if ( checkLock( aStudy ) )
1683 EmitSignalDeactivateDialog();
1686 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1687 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1688 else aMode = SMESHGUI_GroupOpDlg::CUT;
1690 ( new SMESHGUI_GroupOpDlg( desktop(), SMESHGUI::selectionMgr(), aMode ) )->show();
1694 case 813: // Delete groups with their contents
1696 if ( checkLock( aStudy ) )
1699 EmitSignalDeactivateDialog();
1701 new SMESHGUI_DeleteGroupDlg( desktop(), SMESHGUI::selectionMgr() );
1705 case 900: // MESH INFOS
1707 EmitSignalDeactivateDialog();
1708 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1709 SALOME_ListIO selected;
1711 aSel->selectedObjects( selected );
1713 if ( selected.Extent() > 1 ) { // a dlg for each IO
1715 SALOME_ListIteratorOfListIO It (selected);
1716 for ( ; It.More(); It.Next() ) {
1717 IOs.Clear(); IOs.Append( It.Value() );
1718 aSel->setSelectedObjects( IOs );
1719 new SMESHGUI_MeshInfosDlg(this, "", false);
1721 // restore selection
1722 aSel->setSelectedObjects( selected );
1725 new SMESHGUI_MeshInfosDlg(this, "", false);
1729 case 902: // STANDARD MESH INFOS
1731 EmitSignalDeactivateDialog();
1732 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1733 SALOME_ListIO selected;
1735 aSel->selectedObjects( selected );
1737 if ( selected.Extent() > 1 ) { // a dlg for each IO
1739 SALOME_ListIteratorOfListIO It (selected);
1740 for ( ; It.More(); It.Next() ) {
1742 IOs.Append( It.Value() );
1743 aSel->setSelectedObjects( IOs );
1744 new SMESHGUI_StandardMeshInfosDlg(desktop(), "", false);
1746 // restore selection
1747 aSel->setSelectedObjects( selected );
1750 new SMESHGUI_StandardMeshInfosDlg(desktop(), "", false);
1754 case 1001: // AUTOMATIC UPDATE PREFERENCES
1757 mgr->setValue( "SMESH", "AutomaticUpdate", true );
1758 myAutomaticUpdate = true;
1761 mgr->setValue( "SMESH", "AutomaticUpdate", false );
1762 myAutomaticUpdate = false;
1767 case 1003: // MESH PREFERENCES
1769 ::SetDisplaySettings();
1775 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( desktop() );
1781 ( new SMESHGUI_PrecisionDlg( desktop() ) )->exec();
1788 mgr->setValue( "SMESH", "DispayEntity", true );
1791 mgr->setValue( "SMESH", "DispayEntity", false );
1797 SMESHGUI_Preferences_SelectionDlg* aDlg =
1798 new SMESHGUI_Preferences_SelectionDlg(desktop());
1800 QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
1801 aDlg->SetColor(1, aColor);
1803 aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow );
1804 aDlg->SetColor(2, aColor);
1806 aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white );
1807 aDlg->SetColor(3, aColor);
1809 aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) );
1810 aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) );
1811 aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) );
1812 aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) );
1815 QColor aPreColor = aDlg->GetColor(1),
1816 aSelColor = aDlg->GetColor(2),
1817 aHiColor = aDlg->GetColor(3);
1818 int aPreWidth = aDlg->GetWidth(1),
1819 aSelWidth = aDlg->GetWidth(2);
1820 double aTolNodes = aDlg->GetPrecision(1),
1821 aTolItems = aDlg->GetPrecision(2);
1823 mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor );
1824 mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor );
1825 mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor );
1827 mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth );
1828 mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth );
1829 mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes );
1830 mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems );
1832 // update current study settings
1833 SMESH::UpdateSelectionProp();
1836 // update VTK viewer properties
1837 SVTK_RenderWindowInteractor* anInteractor =
1838 dynamic_cast<SVTK_RenderWindowInteractor*>( vtkwnd->getRWInteractor() );
1840 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1841 aSelColor.blue()/255., aSelWidth);
1842 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1843 SVTK_InteractorStyle* aStyle =
1844 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
1847 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1848 aPreColor.blue()/255., aPreWidth);
1851 vtkRenderer* aRenderer = vtkwnd->getRenderer();
1852 vtkActorCollection *aCollection = aRenderer->GetActors();
1853 aCollection->InitTraversal();
1854 while(vtkActor *anAct = aCollection->GetNextActor()){
1855 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1856 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1857 aHiColor.blue()/255.);
1858 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1859 aPreColor.blue()/255.);
1868 case 1100: // EDIT HYPOTHESIS
1870 if(checkLock(aStudy)) break;
1872 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1873 SALOME_ListIO selected;
1875 aSel->selectedObjects( selected );
1877 int nbSel = selected.Extent();
1880 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1882 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1883 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1884 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1885 if ( !Hyp->_is_nil() )
1887 char* sName = Hyp->GetName();
1888 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1891 aCreator->EditHypothesis(Hyp);
1902 case 1101: // RENAME
1904 if ( checkLock( aStudy ) )
1907 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1908 SALOME_ListIO selected;
1910 aSel->selectedObjects( selected );
1912 SALOME_ListIteratorOfListIO It( selected );
1913 for ( ; It.More(); It.Next() )
1915 Handle(SALOME_InteractiveObject) IObject = It.Value();
1916 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1917 _PTR(GenericAttribute) anAttr;
1918 _PTR(AttributeName) aName;
1921 if ( obj->FindAttribute(anAttr, "AttributeName") )
1924 QString newName = QString(aName->Value().c_str());
1925 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1926 if ( !newName.isEmpty() )
1928 //old source: aStudy->renameIObject( IObject, newName );
1929 aName->SetValue( newName.latin1() );
1931 // if current object is group update group's name
1932 SMESH::SMESH_GroupBase_var aGroup =
1933 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1934 if (!aGroup->_is_nil() )
1935 aGroup->SetName( newName.latin1() );
1945 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1947 if(checkLock(aStudy)) break;
1948 SUIT_OverrideCursor wc;
1950 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1951 SALOME_ListIO selected;
1953 aSel->selectedObjects( selected );
1955 SALOME_ListIteratorOfListIO It(selected);
1956 for (int i = 0; It.More(); It.Next(), i++) {
1957 Handle(SALOME_InteractiveObject) IObject = It.Value();
1958 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1960 SALOME_ListIO selected1;
1961 aSel->setSelectedObjects( selected1 );
1966 case 401: // GEOM::EDGE
1967 case 4021: // TRIANGLE
1969 case 4023: // POLYGON
1973 if(checkLock(aStudy)) break;
1975 EmitSignalDeactivateDialog();
1976 SMDSAbs_ElementType type = SMDSAbs_Edge;
1978 switch (theCommandID) {
1979 case 4021: // TRIANGLE
1980 type = SMDSAbs_Face; nbNodes = 3; break;
1982 type = SMDSAbs_Face; nbNodes = 4; break;
1984 type = SMDSAbs_Volume; nbNodes = 4; break;
1985 case 4023: // POLYGON
1986 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1988 type = SMDSAbs_Volume; nbNodes = 8; break;
1989 case 4033: // POLYHEDRE
1990 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1993 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1996 SUIT_MessageBox::warn1(desktop(),
1997 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1998 tr("SMESH_BUT_OK"));
2002 case 4033: // POLYHEDRON
2004 if(checkLock(aStudy)) break;
2006 EmitSignalDeactivateDialog();
2007 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2010 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2011 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2012 tr("SMESH_BUT_OK"));
2016 case 4041: // REMOVES NODES
2018 if(checkLock(aStudy)) break;
2020 EmitSignalDeactivateDialog();
2021 new SMESHGUI_RemoveNodesDlg(this);
2024 SUIT_MessageBox::warn1(desktop(),
2025 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2026 tr("SMESH_BUT_OK"));
2030 case 4042: // REMOVES ELEMENTS
2032 if(checkLock(aStudy)) break;
2034 EmitSignalDeactivateDialog();
2035 new SMESHGUI_RemoveElementsDlg(this);
2039 SUIT_MessageBox::warn1(desktop(),
2040 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2041 tr("SMESH_BUT_OK"));
2045 case 4051: // RENUMBERING NODES
2047 if(checkLock(aStudy)) break;
2049 EmitSignalDeactivateDialog();
2050 new SMESHGUI_RenumberingDlg(desktop(), "", selectionMgr(), 0);
2054 SUIT_MessageBox::warn1(desktop(),
2055 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2056 tr("SMESH_BUT_OK"));
2060 case 4052: // RENUMBERING ELEMENTS
2062 if(checkLock(aStudy)) break;
2064 EmitSignalDeactivateDialog();
2065 new SMESHGUI_RenumberingDlg(desktop(), "", selectionMgr(), 1);
2069 SUIT_MessageBox::warn1(desktop(),
2070 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2071 tr("SMESH_BUT_OK"));
2075 case 4061: // TRANSLATION
2077 if(checkLock(aStudy)) break;
2079 EmitSignalDeactivateDialog();
2080 new SMESHGUI_TranslationDlg( this );
2083 SUIT_MessageBox::warn1(desktop(),
2084 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2085 tr("SMESH_BUT_OK"));
2089 case 4062: // ROTATION
2091 if(checkLock(aStudy)) break;
2093 EmitSignalDeactivateDialog();
2094 new SMESHGUI_RotationDlg( this );
2097 SUIT_MessageBox::warn1(desktop(),
2098 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2099 tr("SMESH_BUT_OK"));
2103 case 4063: // SYMMETRY
2105 if(checkLock(aStudy)) break;
2107 EmitSignalDeactivateDialog();
2108 new SMESHGUI_SymmetryDlg( this );
2111 SUIT_MessageBox::warn1(desktop(),
2112 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2113 tr("SMESH_BUT_OK"));
2117 case 4064: // SEWING
2119 if(checkLock(aStudy)) break;
2121 EmitSignalDeactivateDialog();
2122 new SMESHGUI_SewingDlg( this );
2125 SUIT_MessageBox::warn1(desktop(),
2126 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2127 tr("SMESH_BUT_OK"));
2131 case 4065: // MERGE NODES
2133 if(checkLock(aStudy)) break;
2135 EmitSignalDeactivateDialog();
2136 new SMESHGUI_MergeNodesDlg( this );
2139 SUIT_MessageBox::warn1(desktop(),
2140 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2141 tr("SMESH_BUT_OK"));
2147 case 5000: // HYPOTHESIS
2149 if(checkLock(aStudy)) break;
2150 EmitSignalDeactivateDialog();
2151 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2156 if(checkLock(aStudy)) break;
2157 EmitSignalDeactivateDialog();
2158 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2162 case 5105: // Library of selection filters
2164 static QValueList<int> aTypes;
2165 if ( aTypes.isEmpty() )
2167 aTypes.append( SMESH::NODE );
2168 aTypes.append( SMESH::EDGE );
2169 aTypes.append( SMESH::FACE );
2170 aTypes.append( SMESH::VOLUME );
2172 new SMESHGUI_FilterLibraryDlg( desktop(), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2176 case 6017: // CONTROLS
2191 SalomeApp_SelectionMgr* mgr = selectionMgr();
2192 SALOME_ListIO selected; mgr->selectedObjects( selected );
2194 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2195 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2197 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2198 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2199 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2200 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2201 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2202 ::Control( theCommandID );
2207 SUIT_MessageBox::warn1(desktop(),
2208 tr( "SMESH_WRN_WARNING" ),
2209 tr( "SMESH_BAD_SELECTION" ),
2210 tr( "SMESH_BUT_OK" ) );
2214 SUIT_MessageBox::warn1(desktop(),
2215 tr( "SMESH_WRN_WARNING" ),
2216 tr( "NOT_A_VTK_VIEWER" ),
2217 tr( "SMESH_BUT_OK" ) );
2222 SalomeApp_SelectionMgr* mgr = selectionMgr();
2223 SALOME_ListIO selected; mgr->selectedObjects( selected );
2225 if (selected.Extent() == 1) {
2226 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2227 if(anIObject->hasEntry())
2228 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2229 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2236 SalomeApp_SelectionMgr* mgr = selectionMgr();
2237 SALOME_ListIO selected; mgr->selectedObjects( selected );
2239 if (selected.Extent() == 1) {
2240 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2241 if(anIObject->hasEntry())
2242 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2243 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2248 case 10001: // DISPLAY MODE PREFERENCE
2252 action( 10002 )->setOn( false );
2253 action( 10004 )->setOn( false );
2254 action( 10003 )->setOn( true );
2255 mgr->setValue( "SMESH", "DisplayMode", "Wireframe");
2261 action( 10001 )->setOn( false );
2262 action( 10004 )->setOn( false );
2263 action( 10003 )->setOn( true );
2264 mgr->setValue( "SMESH", "DisplayMode", "Shading");
2269 mgr->setValue( "SMESH", "Shrink", act->isOn() );
2275 action( 10001 )->setOn( false );
2276 action( 10002 )->setOn( false );
2277 action( 10003 )->setOn( false );
2278 mgr->setValue( "SMESH", "DisplayMode", "Nodes" );
2288 //=============================================================================
2292 //=============================================================================
2293 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2298 //=============================================================================
2302 //=============================================================================
2303 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2308 //=============================================================================
2312 //=============================================================================
2313 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2318 //=============================================================================
2322 //=============================================================================
2323 bool SMESHGUI::SetSettings(SUIT_Desktop* parent)
2325 MESSAGE("SMESHGUI::SetSettings.");
2326 SMESHGUI::GetSMESHGUI();
2328 SUIT_ResourceMgr* mgr = resourceMgr();
2333 QString DisplayMode = "Shading";
2334 if ( mgr->hasValue("SMESH","DisplayMode") )
2335 DisplayMode = mgr->stringValue("SMESH","DisplayMode");
2337 mgr->setValue("SMESH","DisplayMode", "Shading");
2339 bool Shrink = false;
2340 if ( mgr->hasValue("SMESH","Shrink") )
2341 Shrink = mgr->stringValue("SMESH","Shrink") == "yes";
2343 if (DisplayMode == "Wireframe") {
2345 action( 10004 )->setOn( false );
2346 action( 10002 )->setOn( false );
2347 action( 10001 )->setOn( true );
2348 action( 10003 )->setOn( true );
2350 else if (DisplayMode == "Nodes") {
2352 action( 10004 )->setOn( true );
2353 action( 10002 )->setOn( false );
2354 action( 10001 )->setOn( false );
2355 action( 10003 )->setOn( false );
2358 // default is shading
2359 action( 10004 )->setOn( false );
2360 action( 10002 )->setOn( true );
2361 action( 10001 )->setOn( false );
2362 action( 10003 )->setOn( true );
2364 action( 10003 )->setOn( Shrink );
2367 if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) {
2368 action( 1001 )->setOn( true );
2369 myAutomaticUpdate = true;
2372 action( 1001 )->setOn( false );
2373 myAutomaticUpdate = false;
2376 if ( mgr->booleanValue( "SMESH","DispayEntity", false ) )
2377 action( 10071 )->setOn( true );
2379 action( 10071 )->setOn( false );
2382 SMESH::UpdateSelectionProp();
2385 //action( 111 )->setEnabled( false ); // IMPORT DAT
2386 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2391 //=============================================================================
2392 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2393 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2395 //=============================================================================
2396 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2397 SUIT_ViewWindow* wnd )
2399 if(theIO->hasEntry()){
2400 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2401 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2405 //=======================================================================
2406 // function : createSMESHAction
2408 //=======================================================================
2409 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2412 QWidget* parent = application()->desktop();
2413 SUIT_ResourceMgr* resMgr = resourceMgr();
2415 if ( icon_id.length() )
2416 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2418 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ) );
2419 if ( !pix.isNull() )
2420 icon = QIconSet( pix );
2422 QString tooltip = tr( QString( "TOP_" )+po_id ),
2423 menu = tr( QString( "MEN_" )+po_id ),
2424 status_bar = tr( QString( "STB_" )+po_id );
2426 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2429 //=======================================================================
2430 // function : createPopupItem
2432 //=======================================================================
2433 void SMESHGUI::createPopupItem( const int id,
2434 const QString& clients,
2435 const QString& types,
2436 const QString& theRule,
2441 parentId = popupMgr()->actionId( action( pId ) );
2443 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2444 popupMgr()->insert( action( id ), parentId, 0 );
2446 QChar lc = popupMgr()->equality();
2447 QString rule = "(%1) and (%2) and (%3)";
2448 rule = rule.arg( QString( "%1>0" ).arg( popupMgr()->selCountParam() ) );
2449 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2450 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2453 bool cont = myRules.contains( id );
2455 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2457 popupMgr()->setRule( action( id ), rule, true );
2458 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2461 //=======================================================================
2462 // function : initialize
2464 //=======================================================================
2465 void SMESHGUI::initialize( CAM_Application* app )
2467 SalomeApp_Module::initialize( app );
2469 // ----- create actions --------------
2471 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2472 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2473 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2474 createSMESHAction( 114, "NUM" );
2475 createSMESHAction( 121, "DAT" );
2476 createSMESHAction( 122, "MED" );
2477 createSMESHAction( 123, "UNV" );
2478 createSMESHAction( 124, "EXPORT_DAT" );
2479 createSMESHAction( 125, "EXPORT_MED" );
2480 createSMESHAction( 126, "EXPORT_UNV" );
2481 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2482 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2483 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2484 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2485 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2486 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2487 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2488 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2489 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2490 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2491 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2492 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2493 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2494 createSMESHAction( 804, "ADD" );
2495 createSMESHAction( 805, "REMOVE" );
2496 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2497 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2498 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2499 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2500 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2501 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2502 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" );
2503 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" );
2504 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" );
2505 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" );
2506 createSMESHAction( 6011, "AREA", "ICON_AREA" );
2507 createSMESHAction( 6012, "TAPER", "ICON_TAPER" );
2508 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" );
2509 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" );
2510 createSMESHAction( 6015, "WRAP", "ICON_WRAP" );
2511 createSMESHAction( 6016, "SKEW", "ICON_SKEW" );
2512 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D" );
2513 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D" );
2514 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D" );
2515 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2516 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2517 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2518 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2519 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2520 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2521 createSMESHAction( 4041, "NODES", "ICON_DLG_REM_NODE" );
2522 createSMESHAction( 4042, "ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2523 createSMESHAction( 4051, "NODES", "ICON_DLG_RENUMBERING_NODES" );
2524 createSMESHAction( 4052, "ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2525 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2526 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2527 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2528 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2529 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2530 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2531 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2532 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2533 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2534 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2535 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2536 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2537 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2538 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2539 createSMESHAction( 415, "MAP", "ICON_MAP" );
2540 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2541 createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true );
2542 createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true );
2543 createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true );
2544 createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true );
2545 createSMESHAction( 1001, "AUTO_UPD", "", 0, true );
2546 createSMESHAction( 1003, "COLORS" );
2547 createSMESHAction( 1005, "SCALAR_BAR" );
2548 createSMESHAction( 1006, "SELECTION" );
2549 createSMESHAction( 10070, "PRECISION", "", 0, true );
2550 createSMESHAction( 10071, "DISP_ENT", "", 0, true );
2551 createSMESHAction( 200, "RESET" );
2552 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2553 createSMESHAction( 211, "WIRE", "ICON_WIRE" );
2554 createSMESHAction( 212, "SHADE", "ICON_SHADE" );
2555 createSMESHAction( 213, "SHRINK", "ICON_SHRINK" );
2556 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2557 createSMESHAction( 215, "NODES", "ICON_POINTS" );
2558 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE" );
2559 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE" );
2560 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS" );
2561 createSMESHAction( 220, "ALL" );
2562 createSMESHAction( 1101, "RENAME" );
2563 createSMESHAction( 9010, "NUM_NODES" );
2564 createSMESHAction( 9011, "NUM_ELEMENTS" );
2565 createSMESHAction( 1131, "DISPMODE" );
2566 createSMESHAction( 1132, "COLORS" );
2567 createSMESHAction( 1133, "TRANSP" );
2568 createSMESHAction( 1134, "CLIP" );
2569 createSMESHAction( 1135, "DISP_ENT" );
2570 createSMESHAction( 2000, "CTRL" );
2572 createSMESHAction( 300, "ERASE" );
2573 createSMESHAction( 301, "DISPLAY" );
2574 createSMESHAction( 302, "DISPLAY_ONLY" );
2576 // ----- create menu --------------
2577 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2578 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2579 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2580 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2581 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2582 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2583 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2584 prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ),
2585 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2587 createMenu( separator(), fileId );
2589 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2590 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2592 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2593 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2594 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2595 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
2597 meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ),
2599 dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ),
2600 qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 );
2602 createMenu( 111, importId, -1 );
2603 createMenu( 112, importId, -1 );
2604 createMenu( 113, importId, -1 );
2606 createMenu( 121, exportId, -1 );
2607 createMenu( 122, exportId, -1 );
2608 createMenu( 123, exportId, -1 );
2610 createMenu( separator(), fileId, 10 );
2612 createMenu( 33, editId, -1 );
2614 createMenu( 5105, toolsId, -1 );
2616 createMenu( 5000, hypoId, -1 );
2617 createMenu( 5010, hypoId, -1 );
2619 createMenu( 703, meshId, -1 );
2620 createMenu( 702, meshId, -1 );
2621 createMenu( 704, meshId, -1 );
2622 createMenu( separator(), meshId, -1 );
2623 createMenu( 701, meshId, -1 );
2624 createMenu( separator(), meshId, -1 );
2625 createMenu( 801, meshId, -1 );
2626 createMenu( 802, meshId, -1 );
2627 createMenu( 803, meshId, -1 );
2628 createMenu( separator(), meshId, -1 );
2629 createMenu( 810, meshId, -1 );
2630 createMenu( 811, meshId, -1 );
2631 createMenu( 812, meshId, -1 );
2632 createMenu( separator(), meshId, -1 );
2633 createMenu( 813, meshId, -1 );
2634 createMenu( separator(), meshId, -1 );
2635 createMenu( 900, meshId, -1 );
2636 createMenu( 902, meshId, -1 );
2637 createMenu( separator(), meshId, -1 );
2639 createMenu( 6003, ctrlId, -1 );
2640 createMenu( 6001, ctrlId, -1 );
2641 createMenu( 6004, ctrlId, -1 );
2642 createMenu( separator(), ctrlId, -1 );
2643 createMenu( 6002, ctrlId, -1 );
2644 createMenu( 6018, ctrlId, -1 );
2645 createMenu( 6019, ctrlId, -1 );
2646 createMenu( 6011, ctrlId, -1 );
2647 createMenu( 6012, ctrlId, -1 );
2648 createMenu( 6013, ctrlId, -1 );
2649 createMenu( 6014, ctrlId, -1 );
2650 createMenu( 6015, ctrlId, -1 );
2651 createMenu( 6016, ctrlId, -1 );
2652 createMenu( separator(), ctrlId, -1 );
2653 createMenu( 6017, ctrlId, -1 );
2654 createMenu( separator(), ctrlId, -1 );
2656 createMenu( 400, addId, -1 );
2657 createMenu( 401, addId, -1 );
2658 createMenu( 4021, addId, -1 );
2659 createMenu( 4022, addId, -1 );
2660 createMenu( 4031, addId, -1 );
2661 createMenu( 4032, addId, -1 );
2663 createMenu( 4041, removeId, -1 );
2664 createMenu( 4042, removeId, -1 );
2666 createMenu( 4051, renumId, -1 );
2667 createMenu( 4052, renumId, -1 );
2669 createMenu( 4061, transfId, -1 );
2670 createMenu( 4062, transfId, -1 );
2671 createMenu( 4063, transfId, -1 );
2672 createMenu( 4064, transfId, -1 );
2673 createMenu( 4065, transfId, -1 );
2675 createMenu( 406, modifyId, -1 );
2676 createMenu( 407, modifyId, -1 );
2677 createMenu( 408, modifyId, -1 );
2678 createMenu( 409, modifyId, -1 );
2679 createMenu( 410, modifyId, -1 );
2680 createMenu( 411, modifyId, -1 );
2681 createMenu( 412, modifyId, -1 );
2682 createMenu( 413, modifyId, -1 );
2683 createMenu( 416, modifyId, -1 );
2684 createMenu( 414, modifyId, -1 );
2685 createMenu( 415, modifyId, -1 );
2687 createMenu( 10001, dispModeId, -1 );
2688 createMenu( 10002, dispModeId, -1 );
2689 createMenu( 10004, dispModeId, -1 );
2690 createMenu( 10003, dispModeId, -1 );
2692 createMenu( 1001, prefId, -1 );
2693 createMenu( separator(), prefId, -1 );
2694 createMenu( 1003, prefId, -1 );
2695 createMenu( separator(), prefId, -1 );
2696 createMenu( 1005, prefId, -1 );
2697 createMenu( separator(), prefId, -1 );
2698 createMenu( 1006, prefId, -1 );
2699 createMenu( separator(), prefId, -1 );
2701 createMenu( 10070, qualityId, -1 );
2702 createMenu( 10071, qualityId, -1 );
2704 createMenu( separator(), prefId, -1 );
2706 createMenu( 214, viewId, -1 );
2708 // ----- create toolbars --------------
2709 int meshTb = createTool( tr( "TB_MESH" ) ),
2710 hypoTb = createTool( tr( "TB_HYPO" ) ),
2711 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2712 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2713 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2714 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2716 createTool( 703, meshTb );
2717 createTool( 702, meshTb );
2718 createTool( 704, meshTb );
2719 createTool( separator(), meshTb );
2720 createTool( 701, meshTb );
2721 createTool( separator(), meshTb );
2722 createTool( 801, meshTb );
2723 createTool( 802, meshTb );
2724 createTool( 803, meshTb );
2725 createTool( separator(), meshTb );
2726 createTool( 900, meshTb );
2727 createTool( 902, meshTb );
2728 createTool( separator(), meshTb );
2730 createTool( 5000, hypoTb );
2731 createTool( 5010, hypoTb );
2733 createTool( 6001, ctrlTb );
2734 createTool( 6003, ctrlTb );
2735 createTool( 6004, ctrlTb );
2736 createTool( separator(), ctrlTb );
2737 createTool( 6002, ctrlTb );
2738 createTool( 6018, ctrlTb );
2739 createTool( 6019, ctrlTb );
2740 createTool( 6011, ctrlTb );
2741 createTool( 6012, ctrlTb );
2742 createTool( 6013, ctrlTb );
2743 createTool( 6014, ctrlTb );
2744 createTool( 6015, ctrlTb );
2745 createTool( 6016, ctrlTb );
2746 createTool( separator(), ctrlTb );
2747 createTool( 6017, ctrlTb );
2748 createTool( separator(), ctrlTb );
2750 createTool( 400, addRemTb );
2751 createTool( 401, addRemTb );
2752 createTool( 4021, addRemTb );
2753 createTool( 4022, addRemTb );
2754 createTool( 4031, addRemTb );
2755 createTool( 4032, addRemTb );
2756 createTool( separator(), addRemTb );
2757 createTool( 4041, addRemTb );
2758 createTool( 4042, addRemTb );
2759 createTool( separator(), addRemTb );
2760 createTool( 4051, addRemTb );
2761 createTool( 4052, addRemTb );
2762 createTool( separator(), addRemTb );
2763 createTool( 4061, addRemTb );
2764 createTool( 4062, addRemTb );
2765 createTool( 4063, addRemTb );
2766 createTool( 4064, addRemTb );
2767 createTool( 4065, addRemTb );
2768 createTool( separator(), addRemTb );
2770 createTool( 406, modifyTb );
2771 createTool( 407, modifyTb );
2772 createTool( 408, modifyTb );
2773 createTool( 409, modifyTb );
2774 createTool( 410, modifyTb );
2775 createTool( 411, modifyTb );
2776 createTool( 412, modifyTb );
2777 createTool( 413, modifyTb );
2778 createTool( 416, modifyTb );
2779 createTool( 414, modifyTb );
2780 createTool( 415, modifyTb );
2782 createTool( 214, dispModeTb );
2786 QString OB = "'ObjectBrowser'",
2787 View = "'" + SVTK_Viewer::Type() + "'",
2789 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2790 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2791 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2792 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2793 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2794 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2795 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2796 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2797 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2798 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2800 mesh_group = mesh + " " + subMesh + " " + group,
2801 hyp_alg = hypo + " " + algo;
2803 // popup for object browser
2805 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2806 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2807 createPopupItem( 803, OB, group ); // EDIT_GROUP
2808 popupMgr()->insert( separator(), -1, 0 );
2809 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2810 createPopupItem( 214, OB, mesh_group ); // UPDATE
2811 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2812 createPopupItem( 902, OB, mesh ); // STD_INFO
2813 popupMgr()->insert( separator(), -1, 0 );
2814 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2815 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2816 popupMgr()->insert( separator(), -1, 0 );
2817 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2818 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2819 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2820 popupMgr()->insert( separator(), -1, 0 );
2821 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2822 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2823 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2824 popupMgr()->insert( separator(), -1, 0 );
2827 createPopupItem( 803, View, group ); // EDIT_GROUP
2828 createPopupItem( 804, View, elems ); // ADD
2829 createPopupItem( 805, View, elems ); // REMOVE
2830 popupMgr()->insert( separator(), -1, 0 );
2831 createPopupItem( 214, View, mesh_group ); // UPDATE
2832 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2833 createPopupItem( 902, View, mesh ); // STD_INFO
2834 popupMgr()->insert( separator(), -1, 0 );
2838 isInvisible("not( isVisible )"),
2839 isEmpty("numberOfNodes = 0"),
2840 isNotEmpty("numberOfNodes <> 0"),
2842 // has nodes, edges, etc in VISIBLE! actor
2843 hasNodes("(numberOfNodes > 0 && isVisible)"),
2844 hasElems("count( elemTypes ) > 0"),
2845 hasDifferentElems("count( elemTypes ) > 1"),
2846 hasEdges("{'Edge'} in elemTypes"),
2847 hasFaces("{'Face'} in elemTypes"),
2848 hasVolumes("{'Volume'} in elemTypes");
2850 QString aSelCount = popupMgr()->selCountParam() + "= 1";
2851 QString aClient = QString( popupMgr()->equality() )+ "client in {" + View + "}";
2852 QString aType = QString( popupMgr()->equality() ) + "type in {" + mesh_group + "}";
2853 QString aMeshInVTK = aClient + "&&" + aType + "&&" + aSelCount;
2855 //-------------------------------------------------
2857 //-------------------------------------------------
2858 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2860 popupMgr()->insert( action( 9010 ), anId, -1 );
2861 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true );
2862 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2864 popupMgr()->insert( action( 9011 ), anId, -1 );
2865 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true );
2866 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2868 popupMgr()->insert( separator(), -1, -1 );
2870 //-------------------------------------------------
2872 //-------------------------------------------------
2873 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2875 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2876 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2877 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2879 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2880 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2881 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2883 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2884 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2885 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2887 popupMgr()->insert( separator(), anId, -1 );
2889 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2890 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2891 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2893 //-------------------------------------------------
2895 //-------------------------------------------------
2896 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2898 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2900 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2901 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true );
2902 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2904 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2905 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true );
2906 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2908 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2909 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true );
2910 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2912 popupMgr()->insert( separator(), anId, -1 );
2914 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2915 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true );
2917 //-------------------------------------------------
2919 //-------------------------------------------------
2920 popupMgr()->insert( action( 1132 ), -1, -1 );
2921 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2923 //-------------------------------------------------
2925 //-------------------------------------------------
2926 popupMgr()->insert( action( 1133 ), -1, -1 );
2927 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2929 //-------------------------------------------------
2931 //-------------------------------------------------
2932 popupMgr()->insert( action( 1134 ), -1, -1 );
2933 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2935 popupMgr()->insert( separator(), -1, -1 );
2937 //-------------------------------------------------
2939 //-------------------------------------------------
2941 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2942 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2943 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2945 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2947 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2948 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2950 popupMgr()->insert( separator(), anId, -1 );
2952 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2953 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2954 popupMgr()->setRule( action( 6003 ), "&& controlMode = 'eFreeEdges'", true );
2956 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2957 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2958 popupMgr()->setRule( action( 6001 ), "&& controlMode = 'eLength'", true );
2960 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2961 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2962 popupMgr()->setRule( action( 6004 ), "&& controlMode = 'eMultiConnection'", true );
2964 popupMgr()->insert( separator(), anId, -1 );
2966 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2967 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2968 popupMgr()->setRule( action( 6002 ), "&& controlMode = 'eFreeBorders'", true );
2970 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2971 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2972 popupMgr()->setRule( action( 6018 ), "&& controlMode = 'eLength2D'", true );
2974 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2975 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2976 popupMgr()->setRule( action( 6019 ), "&& controlMode = 'eMultiConnection2D'", true );
2978 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2979 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2980 popupMgr()->setRule( action( 6011 ), "&& controlMode = 'eArea'", true );
2982 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2983 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2984 popupMgr()->setRule( action( 6012 ), "&& controlMode = 'eTaper'", true );
2986 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2987 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2988 popupMgr()->setRule( action( 6013 ), "&& controlMode = 'eAspectRatio'", true );
2990 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2991 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2992 popupMgr()->setRule( action( 6014 ), "&& controlMode = 'eMinimumAngle'", true );
2994 popupMgr()->insert( action( 6015 ), anId, -1 ); // WRAP
2995 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2996 popupMgr()->setRule( action( 6015 ), "&& controlMode = 'eWarping'", true );
2998 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2999 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3000 popupMgr()->setRule( action( 6016 ), "&& controlMode = 'eSkew'", true );
3002 popupMgr()->insert( separator(), anId, -1 );
3004 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3005 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3006 popupMgr()->setRule( action( 6017 ), "&& controlMode = 'eAspectRatio3D'", true );
3008 popupMgr()->insert( separator(), anId, -1 );
3010 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3011 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3013 popupMgr()->insert( separator(), -1, -1 );
3015 //-------------------------------------------------
3017 //-------------------------------------------------
3018 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3019 QString aRule = aClient + " and " + aType + " and " + aSelCount;
3020 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3021 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
3023 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3024 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
3026 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3027 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
3029 popupMgr()->insert( separator(), -1, -1 );
3032 void SMESHGUI::activateModule( SUIT_Study* study )
3034 SalomeApp_Module::activateModule( study );
3036 setMenuShown( true );
3037 setToolShown( true );
3039 //SetSettings( desktop() );
3042 void SMESHGUI::deactivateModule( SUIT_Study* study )
3044 setMenuShown( false );
3045 setToolShown( false );
3047 EmitSignalCloseAllDialogs();
3049 SalomeApp_Module::deactivateModule( study );
3052 void SMESHGUI::OnGUIEvent()
3054 const QObject* obj = sender();
3055 if ( !obj || !obj->inherits( "QAction" ) )
3057 int id = actionId((QAction*)obj);
3062 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3064 return myComponentSMESH;
3067 QString SMESHGUI::engineIOR() const
3069 CORBA::ORB_var anORB = getApp()->orb();
3070 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3074 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3076 SMESHGUI_Selection sel( client, selectionMgr() );
3077 popupMgr()->updatePopup( menu, &sel );
3080 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3082 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3083 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3086 void SMESHGUI::viewManagers( QStringList& list ) const
3088 list.append( SVTK_Viewer::Type() );