1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
28 #include "SMESHGUI_InitMeshDlg.h"
29 #include "SMESHGUI_AddSubMeshDlg.h"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_HypothesesUtils.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_EditHypothesesDlg.h"
46 #include "SMESHGUI_CreateHypothesesDlg.h"
47 #include "SMESHGUI_FilterDlg.h"
48 #include "SMESHGUI_FilterLibraryDlg.h"
49 #include "SMESHGUI_SingleEditDlg.h"
50 #include "SMESHGUI_MultiEditDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_DeleteGroupDlg.h"
53 #include "SMESHGUI_SmoothingDlg.h"
54 #include "SMESHGUI_RenumberingDlg.h"
55 #include "SMESHGUI_ExtrusionDlg.h"
56 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
57 #include "SMESHGUI_RevolutionDlg.h"
58 #include "SMESHGUI_TranslationDlg.h"
59 #include "SMESHGUI_RotationDlg.h"
60 #include "SMESHGUI_SymmetryDlg.h"
61 #include "SMESHGUI_SewingDlg.h"
62 #include "SMESHGUI_MergeNodesDlg.h"
63 #include "SMESHGUI_MeshPatternDlg.h"
64 #include "SMESHGUI_PrecisionDlg.h"
65 #include "SMESHGUI_Selection.h"
66 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
68 #include <SVTK_InteractorStyle.h>
69 #include <SVTK_RenderWindowInteractor.h>
71 #include "SMESH_Actor.h"
72 #include "SMESH_Object.h"
73 #include "SMESH_TypeFilter.hxx"
75 #include "SUIT_Tools.h"
76 #include "SUIT_MessageBox.h"
77 #include "SUIT_ResourceMgr.h"
78 #include "SUIT_FileDlg.h"
79 #include "SUIT_Desktop.h"
80 #include "SUIT_ResourceMgr.h"
81 #include "SUIT_OverrideCursor.h"
82 #include "SUIT_Study.h"
83 #include "SUIT_Session.h"
85 #include "SALOME_NamingService.hxx"
86 #include "SALOME_ListIteratorOfListIO.hxx"
87 #include "SALOME_InteractiveObject.hxx"
88 #include "SALOME_ListIO.hxx"
89 #include <SALOME_LifeCycleCORBA.hxx>
91 #include "OB_Browser.h"
93 #include "QtxPopupMgr.h"
95 #include "SalomeApp_Application.h"
96 #include "SalomeApp_NameDlg.h"
97 #include "SalomeApp_DataOwner.h"
98 #include "SalomeApp_ImportOperation.h"
99 #include "SalomeApp_Tools.h"
100 #include "SalomeApp_Study.h"
101 #include "SalomeApp_VTKSelector.h"
103 #include <SVTK_ViewWindow.h>
104 #include <SVTK_ViewModel.h>
106 #include <VTKViewer_ViewManager.h>
108 #include "SMESHGUI_Utils.h"
109 #include "SMESHGUI_GEOMGenUtils.h"
110 #include "SMESHGUI_MeshUtils.h"
111 #include "SMESHGUI_GroupUtils.h"
112 #include "SMESHGUI_FilterUtils.h"
113 #include "SMESHGUI_PatternUtils.h"
114 #include "SMESHGUI_VTKUtils.h"
116 #include "SALOMEconfig.h"
117 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
120 #define INCLUDE_MENUITEM_DEF
121 #include <qapplication.h>
122 #include <qlineedit.h>
123 #include <qmenudata.h>
124 #include <qmenubar.h>
125 #include <qpopupmenu.h>
128 #include <qpainter.h>
129 #include <qcheckbox.h>
130 #include <qcolordialog.h>
131 #include <qspinbox.h>
136 #include <qradiobutton.h>
138 #include <boost/shared_ptr.hpp>
140 #include <vtkRenderer.h>
141 #include <vtkRenderWindow.h>
142 #include <vtkActorCollection.h>
143 #include <vtkScalarBarActor.h>
144 #include <vtkUnstructuredGrid.h>
146 #include "utilities.h"
148 #include "SALOMEDS_Study.hxx"
149 #include "SALOMEDSClient_StudyBuilder.hxx"
150 #include "SALOMEDSClient_SComponent.hxx"
156 //=============================================================
157 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
160 void ExportMeshToFile(int theCommandID);
162 void SetDisplayMode(int theCommandID);
164 void SetDisplayEntity(int theCommandID);
166 void Control( int theCommandID );
168 void SetDisplaySettings();
172 //=============================================================
173 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
179 if(theCommandID == 113){
180 filter.append(QObject::tr("MED files (*.med)"));
181 filter.append(QObject::tr("All files (*)"));
182 }else if (theCommandID == 112){
183 filter.append(QObject::tr("IDEAS files (*.unv)"));
184 }else if (theCommandID == 111){
185 filter.append(QObject::tr("DAT files (*.dat)"));
187 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
190 QObject::tr("Import mesh"),
192 if(!filename.isEmpty()) {
193 SUIT_OverrideCursor wc;
194 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
197 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
198 switch ( theCommandID ) {
201 aMeshes->length( 1 );
202 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
207 SMESH::DriverMED_ReadStatus res;
208 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
209 if ( res != SMESH::DRS_OK ) {
211 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
212 QObject::tr("SMESH_WRN_WARNING"),
213 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
214 QObject::tr("SMESH_BUT_OK"));
215 aMeshes->length( 0 );
222 bool isEmpty = false;
223 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
224 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
226 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
227 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
228 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
229 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
230 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
237 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
238 QObject::tr("SMESH_WRN_WARNING"),
239 QObject::tr("SMESH_DRS_EMPTY"),
240 QObject::tr("SMESH_BUT_OK"));
244 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
246 catch (const SALOME::SALOME_Exception& S_ex){
248 SalomeApp_Tools::QtCatchCorbaException(S_ex);
255 void ExportMeshToFile( int theCommandID )
257 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
258 SALOME_ListIO selected;
260 aSel->selectedObjects( selected );
262 if(selected.Extent()){
263 Handle(SALOME_InteractiveObject) anIObject = selected.First();
264 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
265 if ( !aMesh->_is_nil() ) {
266 QString aFilter, aTitle = QObject::tr("Export mesh");
267 QMap<QString, SMESH::MED_VERSION> aFilterMap;
268 switch ( theCommandID ) {
271 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
272 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
276 aFilter = QObject::tr("DAT files (*.dat)");
280 if(aMesh->NbPyramids()){
281 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
282 QObject::tr("SMESH_WRN_WARNING"),
283 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
284 QObject::tr("SMESH_BUT_YES"),
285 QObject::tr("SMESH_BUT_NO"),
290 aFilter = QObject::tr("IDEAS files (*.unv)");
297 SMESH::MED_VERSION aFormat;
299 if ( theCommandID != 122 && theCommandID != 125 )
300 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
304 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
305 filters.push_back( it.key() );
307 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
308 fd->setCaption( aTitle );
309 fd->setFilters( filters );
311 aFilename = fd->selectedFile();
312 aFormat = aFilterMap[fd->selectedFilter()];
315 if ( !aFilename.isEmpty() ) {
316 // Check whether the file already exists and delete it if yes
317 QFile aFile( aFilename );
318 if ( aFile.exists() )
320 SUIT_OverrideCursor wc;
321 switch ( theCommandID ) {
324 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
328 aMesh->ExportDAT( aFilename.latin1() );
332 aMesh->ExportUNV( aFilename.latin1() );
342 inline void InverseEntityMode(unsigned int& theOutputMode,
343 unsigned int theMode)
345 bool anIsNotPresent = ~theOutputMode & theMode;
347 theOutputMode |= theMode;
349 theOutputMode &= ~theMode;
352 void SetDisplayEntity(int theCommandID){
353 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
354 SALOME_ListIO selected;
356 aSel->selectedObjects( selected );
358 if(selected.Extent() >= 1){
359 SALOME_ListIteratorOfListIO It( selected );
360 for(; It.More(); It.Next()){
361 Handle(SALOME_InteractiveObject) IObject = It.Value();
362 if(IObject->hasEntry()){
363 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
364 unsigned int aMode = anActor->GetEntityMode();
365 switch(theCommandID){
367 InverseEntityMode(aMode,SMESH_Actor::eEdges);
370 InverseEntityMode(aMode,SMESH_Actor::eFaces);
373 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
376 aMode = SMESH_Actor::eAllEntity;
380 anActor->SetEntityMode(aMode);
387 void SetDisplayMode(int theCommandID){
388 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
389 SALOME_ListIO selected;
391 aSel->selectedObjects( selected );
393 if(selected.Extent() >= 1){
394 switch(theCommandID){
396 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
397 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
401 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
402 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
405 SALOME_ListIteratorOfListIO It( selected );
406 for(; It.More(); It.Next()){
407 Handle(SALOME_InteractiveObject) IObject = It.Value();
408 if(IObject->hasEntry()){
409 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
410 switch(theCommandID){
412 anActor->SetRepresentation(SMESH_Actor::eEdge);
415 anActor->SetRepresentation(SMESH_Actor::eSurface);
418 if(anActor->IsShrunk())
421 anActor->SetShrink();
424 anActor->SetRepresentation(SMESH_Actor::ePoint);
428 anActor->GetSufaceColor(color[0], color[1], color[2]);
429 int c0 = int (color[0] * 255);
430 int c1 = int (color[1] * 255);
431 int c2 = int (color[2] * 255);
432 QColor c(c0, c1, c2);
435 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
436 c0 = int (edgecolor[0] * 255);
437 c1 = int (edgecolor[1] * 255);
438 c2 = int (edgecolor[2] * 255);
439 QColor e(c0, c1, c2);
441 float backfacecolor[3];
442 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
443 c0 = int (backfacecolor[0] * 255);
444 c1 = int (backfacecolor[1] * 255);
445 c2 = int (backfacecolor[2] * 255);
446 QColor b(c0, c1, c2);
449 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
450 c0 = int (nodecolor[0] * 255);
451 c1 = int (nodecolor[1] * 255);
452 c2 = int (nodecolor[2] * 255);
453 QColor n(c0, c1, c2);
455 int Edgewidth = (int)anActor->GetLineWidth();
458 int intValue = int(anActor->GetNodeSize());
459 float Shrink = anActor->GetShrinkFactor();
461 SMESHGUI_Preferences_ColorDlg *aDlg =
462 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
463 aDlg->SetColor(1, c);
464 aDlg->SetColor(2, e);
465 aDlg->SetColor(3, n);
466 aDlg->SetColor(4, b);
467 aDlg->SetIntValue(1, Edgewidth);
468 aDlg->SetIntValue(2, intValue);
469 aDlg->SetIntValue(3, int(Shrink*100.));
471 QColor color = aDlg->GetColor(1);
472 QColor edgecolor = aDlg->GetColor(2);
473 QColor nodecolor = aDlg->GetColor(3);
474 QColor backfacecolor = aDlg->GetColor(4);
475 /* actor color and backface color */
476 anActor->SetSufaceColor(float (color.red()) / 255.,
477 float (color.green()) / 255.,
478 float (color.blue()) / 255.);
479 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
480 float (backfacecolor.green()) / 255.,
481 float (backfacecolor.blue()) / 255.);
484 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
485 float (edgecolor.green()) / 255.,
486 float (edgecolor.blue()) / 255.);
488 /* Shrink factor and size edges */
489 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
490 anActor->SetLineWidth(aDlg->GetIntValue(1));
492 /* Nodes color and size */
493 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
494 float (nodecolor.green()) / 255.,
495 float (nodecolor.blue()) / 255.);
496 anActor->SetNodeSize(aDlg->GetIntValue(2));
505 SMESH::RepaintCurrentView();
510 void SetDisplaySettings()
512 SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
516 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
517 SMESHGUI_Preferences_ColorDlg *aDlg =
518 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
520 QColor color = mgr->colorValue( "SMESH", "SettingsFillColor", QColor(0, 170, 255) );
521 aDlg->SetColor(1, color);
523 color = mgr->colorValue( "SMESH", "SettingsOutlineColor", QColor(0, 170, 255) );
524 aDlg->SetColor(2, color);
526 color = mgr->colorValue( "SMESH", "SettingsNodeColor", Qt::red );
527 aDlg->SetColor(3, color);
529 color = mgr->colorValue( "SMESH", "SettingsBackFaceColor", Qt::blue );
530 aDlg->SetColor(4, color);
532 int iVal = mgr->integerValue( "SMESH", "SettingsWidth", 1 );
533 aDlg->SetIntValue(1, iVal);
535 iVal = mgr->integerValue( "SMESH", "SettingsNodesSize", 3 );
536 aDlg->SetIntValue(2, iVal);
538 iVal = mgr->integerValue( "SMESH", "SettingsShrinkCoeff", 75 );
539 aDlg->SetIntValue(3, iVal);
542 mgr->setValue( "SMESH", "SettingsFillColor", aDlg->GetColor(1) );
543 mgr->setValue( "SMESH", "SettingsOutlineColor", aDlg->GetColor(2) );
544 mgr->setValue( "SMESH", "SettingsNodeColor", aDlg->GetColor(3) );
545 mgr->setValue( "SMESH", "SettingsBackFaceColor", aDlg->GetColor(4) );
547 mgr->setValue( "SMESH", "SettingsWidth", aDlg->GetIntValue(1) );
548 mgr->setValue( "SMESH", "SettingsNodesSize", aDlg->GetIntValue(2) );
549 mgr->setValue( "SMESH", "SettingsShrinkCoeff", aDlg->GetIntValue(3) );
556 void Control( int theCommandID )
558 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
559 SALOME_ListIO selected;
561 aSel->selectedObjects( selected );
563 if( !selected.IsEmpty() ){
564 Handle(SALOME_InteractiveObject) anIO = selected.First();
567 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
568 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
569 switch ( theCommandID ){
571 aTitle = QObject::tr( "LENGTH_EDGES" );
572 aControl = SMESH_Actor::eLength;
575 aTitle = QObject::tr( "LENGTH2D_EDGES" );
576 aControl = SMESH_Actor::eLength2D;
579 aTitle = QObject::tr( "FREE_EDGES" );
580 aControl = SMESH_Actor::eFreeEdges;
583 aTitle = QObject::tr( "FREE_BORDERS" );
584 aControl = SMESH_Actor::eFreeBorders;
587 aTitle = QObject::tr( "MULTI_BORDERS" );
588 aControl = SMESH_Actor::eMultiConnection;
591 aTitle = QObject::tr( "MULTI2D_BORDERS" );
592 aControl = SMESH_Actor::eMultiConnection2D;
595 aTitle = QObject::tr( "AREA_ELEMENTS" );
596 aControl = SMESH_Actor::eArea;
599 aTitle = QObject::tr( "TAPER_ELEMENTS" );
600 aControl = SMESH_Actor::eTaper;
603 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
604 aControl = SMESH_Actor::eAspectRatio;
607 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
608 aControl = SMESH_Actor::eAspectRatio3D;
611 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
612 aControl = SMESH_Actor::eMinimumAngle;
615 aTitle = QObject::tr( "WARP_ELEMENTS" );
616 aControl = SMESH_Actor::eWarping;
619 aTitle = QObject::tr( "SKEW_ELEMENTS" );
620 aControl = SMESH_Actor::eSkew;
623 anActor->SetControlMode(aControl);
624 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
631 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
632 MeshObjectType theType,
633 const QString theInTypeName,
634 QString & theOutTypeName)
636 SMESH_TypeFilter aTypeFilter( theType );
638 if( !theIO.IsNull() )
640 entry = theIO->getEntry();
641 SalomeApp_DataOwner owner( entry );
642 if ( aTypeFilter.isOk( &owner )) {
643 theOutTypeName = theInTypeName;
651 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
653 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
654 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
656 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
657 CORBA::String_var anID = aSComp->GetID().c_str();
658 if (!strcmp(anID.in(),theIO->getEntry()))
664 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
665 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
666 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
667 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
668 CheckOIType ( theIO, GROUP, "Group", aTypeName )
676 QString CheckHomogeneousSelection()
678 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
679 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
680 SALOME_ListIO selected;
682 aSel->selectedObjects( selected );
684 QString RefType = CheckTypeObject(selected.First());
685 SALOME_ListIteratorOfListIO It(selected);
686 for (; It.More(); It.Next())
688 Handle(SALOME_InteractiveObject) IObject = It.Value();
689 QString Type = CheckTypeObject(IObject);
690 if (Type.compare(RefType) != 0)
691 return "Heterogeneous Selection";
699 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
700 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
701 SALOME_ListIO selected; aSel->selectedObjects( selected );
703 QString aParentComponent = QString::null;
704 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
706 QString cur = anIt.Value()->getComponentDataType();
707 if( aParentComponent.isNull() )
708 aParentComponent = cur;
709 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
710 aParentComponent = "";
713 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
714 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
715 QObject::tr("ERR_ERROR"),
716 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
717 QObject::tr("BUT_OK") );
720 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
721 if (SUIT_MessageBox::warn2
722 (SMESHGUI::desktop(),
723 QObject::tr("SMESH_WRN_WARNING"),
724 QObject::tr("SMESH_REALLY_DELETE"),
725 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
728 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
729 SUIT_ViewManager* vm = anApp->activeViewManager();
730 int nbSf = vm->getViewsCount();
732 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
733 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
734 _PTR(GenericAttribute) anAttr;
735 _PTR(AttributeIOR) anIOR;
737 SALOME_ListIteratorOfListIO It(selected);
739 aStudyBuilder->NewCommand(); // There is a transaction
740 for(; It.More(); It.Next()){
741 Handle(SALOME_InteractiveObject) IObject = It.Value();
742 if(IObject->hasEntry()){
743 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
745 /* Erase child graphical objects */
746 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
747 for(it->InitEx(true); it->More(); it->Next()){
748 _PTR(SObject) CSO = it->Value();
749 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
752 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
753 for(int i = 0; i < nbSf; i++){
754 SUIT_ViewWindow *sf = aViews[i];
755 CORBA::String_var anEntry = CSO->GetID().c_str();
756 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
757 SMESH::RemoveActor(sf,anActor);
763 /* Erase main graphical object */
764 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
765 for(int i = 0; i < nbSf; i++){
766 SUIT_ViewWindow *sf = aViews[i];
767 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
768 SMESH::RemoveActor(sf,anActor);
772 // Remove object(s) from data structures
773 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
775 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
776 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
778 if ( !aGroup->_is_nil() ) { // DELETE GROUP
779 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
780 aMesh->RemoveGroup( aGroup );
782 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
783 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
784 aMesh->RemoveSubMesh( aSubMesh );
786 else {// default action: remove SObject from the study
787 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
788 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
790 aStudyBuilder->RemoveObjectWithChildren( obj );
795 } /* IObject->hasEntry() */
797 aStudyBuilder->CommitCommand();
799 /* Clear any previous selection */
801 aSel->setSelectedObjects( l1 );
803 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
808 Standard_EXPORT CAM_Module* createModule()
810 return new SMESHGUI();
814 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
816 //=============================================================================
820 //=============================================================================
821 SMESHGUI::SMESHGUI() :
822 SalomeApp_Module( "SMESH" )
824 if ( CORBA::is_nil( myComponentSMESH ) )
826 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
827 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
828 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
831 myAutomaticUpdate = false;
832 myActiveDialogBox = 0 ;
835 SMESH::GetFilterManager();
838 /* load resources for all available meshers */
839 SMESH::InitAvailableHypotheses();
842 //=============================================================================
846 //=============================================================================
847 SMESHGUI::~SMESHGUI()
849 SMESH::GetFilterManager()->Destroy();
852 //=============================================================================
856 //=============================================================================
857 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
859 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
861 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
866 //=============================================================================
870 //=============================================================================
871 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
873 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
876 //=============================================================================
880 //=============================================================================
881 SMESHGUI* SMESHGUI::GetSMESHGUI()
883 SMESHGUI* smeshMod = 0;
884 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
887 CAM_Module* module = app->module( "Mesh" );
888 smeshMod = dynamic_cast<SMESHGUI*>( module );
891 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
893 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
896 _PTR(Study) aStudy = study->studyDS();
898 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
907 Standard_EXPORT SMESHGUI* GetComponentGUI()
909 return SMESHGUI::GetSMESHGUI();
913 //=============================================================================
917 //=============================================================================
918 void SMESHGUI::SetState(int aState)
923 //=============================================================================
927 //=============================================================================
928 void SMESHGUI::ResetState()
933 //=============================================================================
937 //=============================================================================
938 void SMESHGUI::EmitSignalDeactivateDialog()
940 emit SignalDeactivateActiveDialog();
943 //=============================================================================
947 //=============================================================================
948 void SMESHGUI::EmitSignalStudyFrameChanged()
950 emit SignalStudyFrameChanged();
953 //=============================================================================
957 //=============================================================================
958 void SMESHGUI::EmitSignalCloseAllDialogs()
960 emit SignalCloseAllDialogs();
963 //=============================================================================
967 //=============================================================================
968 QDialog *SMESHGUI::GetActiveDialogBox()
970 return myActiveDialogBox;
973 //=============================================================================
977 //=============================================================================
978 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
980 myActiveDialogBox = (QDialog *) aDlg;
984 //=============================================================================
988 //=============================================================================
989 SUIT_Desktop* SMESHGUI::desktop()
991 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
993 return app->desktop();
998 //=============================================================================
1002 //=============================================================================
1003 SalomeApp_Study* SMESHGUI::activeStudy()
1005 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1007 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1012 //=============================================================================
1016 //=============================================================================
1017 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1019 /* Here the position is on the bottom right corner - 10 */
1020 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1022 SUIT_Desktop *PP = desktop();
1023 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1024 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1028 //=============================================================================
1032 //=============================================================================
1033 static int isStudyLocked(_PTR(Study) theStudy){
1034 return theStudy->GetProperties()->IsLocked();
1037 static bool checkLock(_PTR(Study) theStudy) {
1038 if (isStudyLocked(theStudy)) {
1039 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1040 QObject::tr("WRN_WARNING"),
1041 QObject::tr("WRN_STUDY_LOCKED"),
1042 QObject::tr("BUT_OK") );
1048 //=======================================================================
1049 //function : CheckActiveStudyLocked
1051 //=======================================================================
1053 bool SMESHGUI::isActiveStudyLocked()
1055 _PTR(Study) aStudy = activeStudy()->studyDS();
1056 return checkLock( aStudy );
1059 //=============================================================================
1063 //=============================================================================
1064 bool SMESHGUI::OnGUIEvent( int theCommandID )
1066 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1070 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1071 SUIT_ResourceMgr* mgr = resourceMgr();
1075 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1076 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1078 QAction* act = action( theCommandID );
1080 switch (theCommandID) {
1082 if(checkLock(aStudy)) break;
1090 if(checkLock(aStudy)) break;
1091 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1095 case 122: // EXPORT MED
1102 ::ExportMeshToFile(theCommandID);
1106 case 200: // SCALAR BAR
1108 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1109 SALOME_ListIO selected;
1111 aSel->selectedObjects( selected );
1113 if( selected.Extent() ) {
1114 Handle(SALOME_InteractiveObject) anIO = selected.First();
1115 if( anIO->hasEntry() ) {
1116 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1117 anActor->SetControlMode( SMESH_Actor::eNone );
1125 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1129 case 1134: // Clipping
1130 case 1133: // Tranparency
1131 case 1132: // Colors / Size
1138 ::SetDisplayMode(theCommandID);
1144 case 219: // Volumes
1145 case 220: // All Entity
1146 ::SetDisplayEntity(theCommandID);
1151 if(checkLock(aStudy)) break;
1152 SMESH::UpdateView();
1155 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1156 aSel->setSelectedObjects( l );
1161 case 301: // DISPLAY
1162 case 302: // DISPLAY ONLY
1164 SMESH::EDisplaing anAction;
1165 switch(theCommandID){
1166 case 300: anAction = SMESH::eErase; break;
1167 case 301: anAction = SMESH::eDisplay; break;
1168 case 302: anAction = SMESH::eDisplayOnly; break;
1171 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1172 SALOME_ListIO selected;
1174 aSel->selectedObjects( selected );
1177 SALOME_ListIteratorOfListIO It(selected);
1178 for (; It.More(); It.Next()) {
1179 Handle(SALOME_InteractiveObject) IOS = It.Value();
1180 if (IOS->hasEntry()) {
1181 SMESH::UpdateView(anAction,IOS->getEntry());
1186 aSel->setSelectedObjects( l1 );
1192 if(checkLock(aStudy)) break;
1195 EmitSignalDeactivateDialog();
1197 new SMESHGUI_NodesDlg(this);
1200 SUIT_MessageBox::warn1(desktop(),
1201 tr("SMESH_WRN_WARNING"),
1202 tr("SMESH_WRN_VIEWER_VTK"),
1203 tr("SMESH_BUT_OK"));
1208 case 2151: // FILTER
1212 EmitSignalDeactivateDialog();
1213 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1218 case 406: // MOVE NODE
1222 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1223 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1227 if(checkLock(aStudy)) break;
1228 new SMESHGUI_MoveNodesDlg(this);
1232 case 701: // COMPUTE MESH
1234 if(checkLock(aStudy)) break;
1236 SalomeApp_SelectionMgr *Sel = selectionMgr();
1237 SALOME_ListIO selected; Sel->selectedObjects( selected );
1239 int nbSel = selected.Extent();
1244 SMESH::SMESH_Mesh_var aMesh;
1245 SMESH::SMESH_subMesh_var aSubMesh;
1246 Handle(SALOME_InteractiveObject) IObject = selected.First();
1247 if (IObject->hasEntry()){
1248 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1249 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1250 if ( aShapeObject->_is_nil() ) {
1255 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1256 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1258 if (!aMesh->_is_nil()){
1259 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1260 if (!refShapeObject->_is_nil()) {
1261 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1262 SUIT_MessageBox::warn1(desktop(),
1263 tr("SMESH_WRN_WARNING"),
1264 tr("SMESH_WRN_MISSING_PARAMETERS"),
1265 tr("SMESH_BUT_OK"));
1269 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1270 SMESH::ModifiedMesh(aMeshSObj,true);
1271 // TO Do : change icon of all submeshes
1273 SUIT_MessageBox::warn1(desktop(),
1274 tr("SMESH_WRN_WARNING"),
1275 tr("SMESH_WRN_COMPUTE_FAILED"),
1276 tr("SMESH_BUT_OK"));
1278 catch(const SALOME::SALOME_Exception & S_ex){
1279 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1282 }else if(!aSubMesh->_is_nil()){
1283 aMesh = aSubMesh->GetFather();
1284 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1285 if(!refShapeObject->_is_nil()){
1286 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1288 SUIT_MessageBox::warn1(desktop(),
1289 tr("SMESH_WRN_WARNING"),
1290 tr("SMESH_WRN_MISSING_PARAMETERS"),
1291 tr("SMESH_BUT_OK"));
1295 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1296 SMESH::ModifiedMesh(aMeshSObj,true);
1297 // TO Do : change icon of all submeshes
1299 SUIT_MessageBox::warn1(desktop(),
1300 tr("SMESH_WRN_WARNING"),
1301 tr("SMESH_WRN_COMPUTE_FAILED"),
1302 tr("SMESH_BUT_OK"));
1303 }catch(const SALOME::SALOME_Exception & S_ex){
1304 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1310 CORBA::Long anId = aStudy->StudyId();
1311 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1312 cout<<"myAutomaticUpdate - "<<myAutomaticUpdate<<endl;
1313 if(myAutomaticUpdate && aVisualObj){
1314 aVisualObj->Update();
1315 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1317 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1319 SMESH::DisplayActor(view,anActor); //apo
1325 SUIT_MessageBox::warn1(desktop(),
1326 tr("SMESH_WRN_WARNING"),
1327 tr("SMESH_WRN_VIEWER_VTK"),
1328 tr("SMESH_BUT_OK"));
1334 case 702: // ADD SUB MESH
1336 if(checkLock(aStudy)) break;
1338 EmitSignalDeactivateDialog();
1339 new SMESHGUI_AddSubMeshDlg( this );
1342 SUIT_MessageBox::warn1(desktop(),
1343 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1344 tr("SMESH_BUT_OK"));
1349 case 703: // INIT MESH
1351 if(checkLock(aStudy)) break;
1352 EmitSignalDeactivateDialog();
1353 new SMESHGUI_InitMeshDlg( this );
1357 case 704: // EDIT Hypothesis
1359 if(checkLock(aStudy)) break;
1360 EmitSignalDeactivateDialog();
1361 new SMESHGUI_EditHypothesesDlg( this );
1365 case 705: // EDIT Global Hypothesis
1367 if(checkLock(aStudy)) break;
1368 EmitSignalDeactivateDialog();
1369 new SMESHGUI_EditHypothesesDlg( this );
1373 case 706: // EDIT Local Hypothesis
1375 if(checkLock(aStudy)) break;
1376 EmitSignalDeactivateDialog();
1377 new SMESHGUI_EditHypothesesDlg( this );
1381 case 407: // DIAGONAL INVERSION
1382 case 408: // Delete diagonal
1386 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1387 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1391 if ( checkLock( aStudy ) )
1394 /*Standard_Boolean aRes;
1395 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1396 if ( aMesh->_is_nil() )
1398 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1399 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1403 EmitSignalDeactivateDialog();
1404 if ( theCommandID == 407 )
1405 new SMESHGUI_TrianglesInversionDlg(this);
1407 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1410 case 409: // Change orientation
1411 case 410: // Union of triangles
1412 case 411: // Cutting of quadrangles
1416 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1417 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1421 if ( checkLock( aStudy ) )
1424 EmitSignalDeactivateDialog();
1425 SMESHGUI_MultiEditDlg* aDlg = NULL;
1426 if ( theCommandID == 409 )
1427 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1428 else if ( theCommandID == 410 )
1429 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1431 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1434 DefineDlgPosition( aDlg, x, y );
1439 case 412: // Smoothing
1441 if(checkLock(aStudy)) break;
1443 EmitSignalDeactivateDialog();
1444 new SMESHGUI_SmoothingDlg( this );
1447 SUIT_MessageBox::warn1(desktop(),
1448 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1449 tr("SMESH_BUT_OK"));
1453 case 413: // Extrusion
1455 if (checkLock(aStudy)) break;
1457 EmitSignalDeactivateDialog();
1458 new SMESHGUI_ExtrusionDlg ( this );
1460 SUIT_MessageBox::warn1(desktop(),
1461 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1462 tr("SMESH_BUT_OK"));
1466 case 414: // Revolution
1468 if(checkLock(aStudy)) break;
1470 EmitSignalDeactivateDialog();
1471 new SMESHGUI_RevolutionDlg( this );
1474 SUIT_MessageBox::warn1(desktop(),
1475 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1476 tr("SMESH_BUT_OK"));
1480 case 415: // Pattern mapping
1482 if ( checkLock( aStudy ) )
1486 EmitSignalDeactivateDialog();
1487 new SMESHGUI_MeshPatternDlg( this );
1490 SUIT_MessageBox::warn1(desktop(),
1491 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1492 tr("SMESH_BUT_OK"));
1496 case 416: // Extrusion along a path
1498 if (checkLock(aStudy)) break;
1500 EmitSignalDeactivateDialog();
1501 new SMESHGUI_ExtrusionAlongPathDlg( this );
1503 SUIT_MessageBox::warn1(desktop(),
1504 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1505 tr("SMESH_BUT_OK"));
1509 case 801: // CREATE GROUP
1513 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1514 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1518 if(checkLock(aStudy)) break;
1519 EmitSignalDeactivateDialog();
1520 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1522 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1523 SALOME_ListIO selected;
1525 aSel->selectedObjects( selected );
1527 int nbSel = selected.Extent();
1529 // check if mesh is selected
1530 aMesh = SMESH::GetMeshByIO( selected.First() );
1532 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1537 case 802: // CONSTRUCT GROUP
1541 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1542 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1546 if(checkLock(aStudy)) break;
1547 EmitSignalDeactivateDialog();
1549 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1550 SALOME_ListIO selected;
1552 aSel->selectedObjects( selected );
1554 int nbSel = selected.Extent();
1556 // check if submesh is selected
1557 Handle(SALOME_InteractiveObject) IObject = selected.First();
1558 if (IObject->hasEntry()) {
1559 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1561 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1562 if (!aSubMesh->_is_nil()) {
1564 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1565 // get submesh elements list by types
1566 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1567 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1568 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1569 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1570 // create group for each type o elements
1571 QString aName = IObject->getName();
1572 if (aNodes->length() > 0) {
1573 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1574 aGroup->Add(aNodes.inout());
1576 if (aEdges->length() > 0) {
1577 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1578 aGroup->Add(aEdges.inout());
1580 if (aFaces->length() > 0) {
1581 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1582 aGroup->Add(aFaces.inout());
1584 if (aVolumes->length() > 0) {
1585 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1586 aGroup->Add(aVolumes.inout());
1590 }catch(const SALOME::SALOME_Exception & S_ex){
1591 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1600 case 803: // EDIT GROUP
1602 if(checkLock(aStudy)) break;
1603 EmitSignalDeactivateDialog();
1605 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1606 SALOME_ListIO selected;
1608 aSel->selectedObjects( selected );
1610 SALOME_ListIteratorOfListIO It (selected);
1611 int nbSelectedGroups = 0;
1612 for ( ; It.More(); It.Next() )
1614 SMESH::SMESH_Group_var aGroup =
1615 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1616 if (!aGroup->_is_nil()) {
1618 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1622 if (nbSelectedGroups == 0)
1624 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1630 case 804: // Add elements to group
1632 if(checkLock(aStudy)) break;
1633 if (myState == 800) {
1634 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1635 if (aDlg) aDlg->onAdd();
1640 case 805: // Remove elements from group
1642 if(checkLock(aStudy)) break;
1643 if (myState == 800) {
1644 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1645 if (aDlg) aDlg->onRemove();
1650 case 810: // Union Groups
1651 case 811: // Intersect groups
1652 case 812: // Cut groups
1654 if ( checkLock( aStudy ) )
1657 EmitSignalDeactivateDialog();
1660 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1661 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1662 else aMode = SMESHGUI_GroupOpDlg::CUT;
1664 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1668 case 813: // Delete groups with their contents
1670 if ( checkLock( aStudy ) )
1673 EmitSignalDeactivateDialog();
1675 new SMESHGUI_DeleteGroupDlg( this );
1679 case 900: // MESH INFOS
1681 EmitSignalDeactivateDialog();
1682 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1683 SALOME_ListIO selected;
1685 aSel->selectedObjects( selected );
1687 if ( selected.Extent() > 1 ) { // a dlg for each IO
1689 SALOME_ListIteratorOfListIO It (selected);
1690 for ( ; It.More(); It.Next() ) {
1691 IOs.Clear(); IOs.Append( It.Value() );
1692 aSel->setSelectedObjects( IOs );
1693 new SMESHGUI_MeshInfosDlg(this, "", false);
1695 // restore selection
1696 aSel->setSelectedObjects( selected );
1699 new SMESHGUI_MeshInfosDlg(this, "", false);
1703 case 902: // STANDARD MESH INFOS
1705 EmitSignalDeactivateDialog();
1706 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1707 SALOME_ListIO selected;
1709 aSel->selectedObjects( selected );
1711 if ( selected.Extent() > 1 ) { // a dlg for each IO
1713 SALOME_ListIteratorOfListIO It (selected);
1714 for ( ; It.More(); It.Next() ) {
1716 IOs.Append( It.Value() );
1717 aSel->setSelectedObjects( IOs );
1718 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1720 // restore selection
1721 aSel->setSelectedObjects( selected );
1724 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1728 case 1001: // AUTOMATIC UPDATE PREFERENCES
1731 mgr->setValue( "SMESH", "AutomaticUpdate", true );
1732 myAutomaticUpdate = true;
1735 mgr->setValue( "SMESH", "AutomaticUpdate", false );
1736 myAutomaticUpdate = false;
1741 case 1003: // MESH PREFERENCES
1743 ::SetDisplaySettings();
1749 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( this );
1755 ( new SMESHGUI_PrecisionDlg( this ) )->exec();
1762 mgr->setValue( "SMESH", "DispayEntity", true );
1765 mgr->setValue( "SMESH", "DispayEntity", false );
1771 SMESHGUI_Preferences_SelectionDlg* aDlg =
1772 new SMESHGUI_Preferences_SelectionDlg( this );
1774 QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
1775 aDlg->SetColor(1, aColor);
1777 aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow );
1778 aDlg->SetColor(2, aColor);
1780 aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white );
1781 aDlg->SetColor(3, aColor);
1783 aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) );
1784 aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) );
1785 aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) );
1786 aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) );
1789 QColor aPreColor = aDlg->GetColor(1),
1790 aSelColor = aDlg->GetColor(2),
1791 aHiColor = aDlg->GetColor(3);
1792 int aPreWidth = aDlg->GetWidth(1),
1793 aSelWidth = aDlg->GetWidth(2);
1794 double aTolNodes = aDlg->GetPrecision(1),
1795 aTolItems = aDlg->GetPrecision(2);
1797 mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor );
1798 mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor );
1799 mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor );
1801 mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth );
1802 mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth );
1803 mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes );
1804 mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems );
1806 // update current study settings
1807 SMESH::UpdateSelectionProp( this );
1810 // update VTK viewer properties
1811 SVTK_RenderWindowInteractor* anInteractor =
1812 dynamic_cast<SVTK_RenderWindowInteractor*>( vtkwnd->getRWInteractor() );
1814 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1815 aSelColor.blue()/255., aSelWidth);
1816 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1817 SVTK_InteractorStyle* aStyle =
1818 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
1821 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1822 aPreColor.blue()/255., aPreWidth);
1825 vtkRenderer* aRenderer = vtkwnd->getRenderer();
1826 vtkActorCollection *aCollection = aRenderer->GetActors();
1827 aCollection->InitTraversal();
1828 while(vtkActor *anAct = aCollection->GetNextActor()){
1829 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1830 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1831 aHiColor.blue()/255.);
1832 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1833 aPreColor.blue()/255.);
1842 case 1100: // EDIT HYPOTHESIS
1844 if(checkLock(aStudy)) break;
1846 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1847 SALOME_ListIO selected;
1849 aSel->selectedObjects( selected );
1851 int nbSel = selected.Extent();
1854 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1856 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1857 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1858 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1859 if ( !Hyp->_is_nil() )
1861 char* sName = Hyp->GetName();
1862 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1865 aCreator->EditHypothesis(Hyp);
1873 updateObjBrowser( true );
1877 case 1101: // RENAME
1879 if ( checkLock( aStudy ) )
1882 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1883 SALOME_ListIO selected;
1885 aSel->selectedObjects( selected );
1887 SALOME_ListIteratorOfListIO It( selected );
1888 for ( ; It.More(); It.Next() )
1890 Handle(SALOME_InteractiveObject) IObject = It.Value();
1891 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1892 _PTR(GenericAttribute) anAttr;
1893 _PTR(AttributeName) aName;
1896 if ( obj->FindAttribute(anAttr, "AttributeName") )
1899 QString newName = QString(aName->Value().c_str());
1900 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1901 if ( !newName.isEmpty() )
1903 //old source: aStudy->renameIObject( IObject, newName );
1904 aName->SetValue( newName.latin1() );
1906 // if current object is group update group's name
1907 SMESH::SMESH_GroupBase_var aGroup =
1908 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1909 if (!aGroup->_is_nil() )
1910 aGroup->SetName( newName.latin1() );
1920 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1922 if(checkLock(aStudy)) break;
1923 SUIT_OverrideCursor wc;
1925 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1926 SALOME_ListIO selected;
1928 aSel->selectedObjects( selected );
1930 SALOME_ListIteratorOfListIO It(selected);
1931 for (int i = 0; It.More(); It.Next(), i++) {
1932 Handle(SALOME_InteractiveObject) IObject = It.Value();
1933 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1936 aSel->setSelectedObjects( l1 );
1941 case 401: // GEOM::EDGE
1942 case 4021: // TRIANGLE
1944 case 4023: // POLYGON
1948 if(checkLock(aStudy)) break;
1950 EmitSignalDeactivateDialog();
1951 SMDSAbs_ElementType type = SMDSAbs_Edge;
1953 switch (theCommandID) {
1954 case 4021: // TRIANGLE
1955 type = SMDSAbs_Face; nbNodes = 3; break;
1957 type = SMDSAbs_Face; nbNodes = 4; break;
1959 type = SMDSAbs_Volume; nbNodes = 4; break;
1960 case 4023: // POLYGON
1961 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1963 type = SMDSAbs_Volume; nbNodes = 8; break;
1964 case 4033: // POLYHEDRE
1965 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1968 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1971 SUIT_MessageBox::warn1(desktop(),
1972 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1973 tr("SMESH_BUT_OK"));
1977 case 4033: // POLYHEDRON
1979 if(checkLock(aStudy)) break;
1981 EmitSignalDeactivateDialog();
1982 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1985 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1986 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1987 tr("SMESH_BUT_OK"));
1991 case 4041: // REMOVES NODES
1993 if(checkLock(aStudy)) break;
1995 EmitSignalDeactivateDialog();
1996 new SMESHGUI_RemoveNodesDlg(this);
1999 SUIT_MessageBox::warn1(desktop(),
2000 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2001 tr("SMESH_BUT_OK"));
2005 case 4042: // REMOVES ELEMENTS
2007 if(checkLock(aStudy)) break;
2009 EmitSignalDeactivateDialog();
2010 new SMESHGUI_RemoveElementsDlg(this);
2014 SUIT_MessageBox::warn1(desktop(),
2015 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2016 tr("SMESH_BUT_OK"));
2020 case 4051: // RENUMBERING NODES
2022 if(checkLock(aStudy)) break;
2024 EmitSignalDeactivateDialog();
2025 new SMESHGUI_RenumberingDlg( this, "", 0);
2029 SUIT_MessageBox::warn1(desktop(),
2030 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2031 tr("SMESH_BUT_OK"));
2035 case 4052: // RENUMBERING ELEMENTS
2037 if(checkLock(aStudy)) break;
2039 EmitSignalDeactivateDialog();
2040 new SMESHGUI_RenumberingDlg( this, "", 1);
2044 SUIT_MessageBox::warn1(desktop(),
2045 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2046 tr("SMESH_BUT_OK"));
2050 case 4061: // TRANSLATION
2052 if(checkLock(aStudy)) break;
2054 EmitSignalDeactivateDialog();
2055 new SMESHGUI_TranslationDlg( this );
2058 SUIT_MessageBox::warn1(desktop(),
2059 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2060 tr("SMESH_BUT_OK"));
2064 case 4062: // ROTATION
2066 if(checkLock(aStudy)) break;
2068 EmitSignalDeactivateDialog();
2069 new SMESHGUI_RotationDlg( this );
2072 SUIT_MessageBox::warn1(desktop(),
2073 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2074 tr("SMESH_BUT_OK"));
2078 case 4063: // SYMMETRY
2080 if(checkLock(aStudy)) break;
2082 EmitSignalDeactivateDialog();
2083 new SMESHGUI_SymmetryDlg( this );
2086 SUIT_MessageBox::warn1(desktop(),
2087 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2088 tr("SMESH_BUT_OK"));
2092 case 4064: // SEWING
2094 if(checkLock(aStudy)) break;
2096 EmitSignalDeactivateDialog();
2097 new SMESHGUI_SewingDlg( this );
2100 SUIT_MessageBox::warn1(desktop(),
2101 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2102 tr("SMESH_BUT_OK"));
2106 case 4065: // MERGE NODES
2108 if(checkLock(aStudy)) break;
2110 EmitSignalDeactivateDialog();
2111 new SMESHGUI_MergeNodesDlg( this );
2114 SUIT_MessageBox::warn1(desktop(),
2115 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2116 tr("SMESH_BUT_OK"));
2122 case 5000: // HYPOTHESIS
2124 if(checkLock(aStudy)) break;
2125 EmitSignalDeactivateDialog();
2126 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2131 if(checkLock(aStudy)) break;
2132 EmitSignalDeactivateDialog();
2133 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2137 case 5105: // Library of selection filters
2139 static QValueList<int> aTypes;
2140 if ( aTypes.isEmpty() )
2142 aTypes.append( SMESH::NODE );
2143 aTypes.append( SMESH::EDGE );
2144 aTypes.append( SMESH::FACE );
2145 aTypes.append( SMESH::VOLUME );
2147 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2151 case 6017: // CONTROLS
2166 SalomeApp_SelectionMgr* mgr = selectionMgr();
2167 SALOME_ListIO selected; mgr->selectedObjects( selected );
2169 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2170 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2172 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2173 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2174 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2175 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2176 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2177 ::Control( theCommandID );
2182 SUIT_MessageBox::warn1(desktop(),
2183 tr( "SMESH_WRN_WARNING" ),
2184 tr( "SMESH_BAD_SELECTION" ),
2185 tr( "SMESH_BUT_OK" ) );
2189 SUIT_MessageBox::warn1(desktop(),
2190 tr( "SMESH_WRN_WARNING" ),
2191 tr( "NOT_A_VTK_VIEWER" ),
2192 tr( "SMESH_BUT_OK" ) );
2197 SalomeApp_SelectionMgr* mgr = selectionMgr();
2198 SALOME_ListIO selected; mgr->selectedObjects( selected );
2200 if (selected.Extent() == 1) {
2201 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2202 if(anIObject->hasEntry())
2203 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2204 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2211 SalomeApp_SelectionMgr* mgr = selectionMgr();
2212 SALOME_ListIO selected; mgr->selectedObjects( selected );
2214 if (selected.Extent() == 1) {
2215 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2216 if(anIObject->hasEntry())
2217 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2218 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2223 case 10001: // DISPLAY MODE PREFERENCE
2227 action( 10002 )->setOn( false );
2228 action( 10004 )->setOn( false );
2229 action( 10003 )->setOn( true );
2230 mgr->setValue( "SMESH", "DisplayMode", "Wireframe");
2236 action( 10001 )->setOn( false );
2237 action( 10004 )->setOn( false );
2238 action( 10003 )->setOn( true );
2239 mgr->setValue( "SMESH", "DisplayMode", "Shading");
2244 mgr->setValue( "SMESH", "Shrink", act->isOn() );
2250 action( 10001 )->setOn( false );
2251 action( 10002 )->setOn( false );
2252 action( 10003 )->setOn( false );
2253 mgr->setValue( "SMESH", "DisplayMode", "Nodes" );
2259 //updateObjBrowser();
2263 //=============================================================================
2267 //=============================================================================
2268 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2273 //=============================================================================
2277 //=============================================================================
2278 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2283 //=============================================================================
2287 //=============================================================================
2288 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2293 //=============================================================================
2297 //=============================================================================
2298 bool SMESHGUI::SetSettings(SUIT_Desktop* parent)
2300 SMESHGUI::GetSMESHGUI();
2302 SUIT_ResourceMgr* mgr = resourceMgr();
2307 QString DisplayMode = "Shading";
2308 if ( mgr->hasValue("SMESH","DisplayMode") )
2309 DisplayMode = mgr->stringValue("SMESH","DisplayMode");
2311 mgr->setValue("SMESH","DisplayMode", "Shading");
2313 bool Shrink = false;
2314 if ( mgr->hasValue("SMESH","Shrink") )
2315 Shrink = mgr->stringValue("SMESH","Shrink") == "yes";
2317 if (DisplayMode == "Wireframe") {
2319 action( 10004 )->setOn( false );
2320 action( 10002 )->setOn( false );
2321 action( 10001 )->setOn( true );
2322 action( 10003 )->setOn( true );
2324 else if (DisplayMode == "Nodes") {
2326 action( 10004 )->setOn( true );
2327 action( 10002 )->setOn( false );
2328 action( 10001 )->setOn( false );
2329 action( 10003 )->setOn( false );
2332 // default is shading
2333 action( 10004 )->setOn( false );
2334 action( 10002 )->setOn( true );
2335 action( 10001 )->setOn( false );
2336 action( 10003 )->setOn( true );
2339 action( 10003 )->setOn( Shrink );
2342 if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) {
2343 action( 1001 )->setOn( true );
2344 myAutomaticUpdate = true;
2347 action( 1001 )->setOn( false );
2348 myAutomaticUpdate = false;
2351 if ( mgr->booleanValue( "SMESH","DispayEntity", false ) )
2352 action( 10071 )->setOn( true );
2354 action( 10071 )->setOn( false );
2357 SMESH::UpdateSelectionProp( this );
2360 action( 111 )->setEnabled( false ); // IMPORT DAT
2362 //action( 112 )->setEnabled( false );
2363 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2368 //=============================================================================
2369 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2370 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2372 //=============================================================================
2373 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2374 SUIT_ViewWindow* wnd )
2376 if(theIO->hasEntry()){
2377 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2378 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2382 //=======================================================================
2383 // function : createSMESHAction
2385 //=======================================================================
2386 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2389 QWidget* parent = application()->desktop();
2390 SUIT_ResourceMgr* resMgr = resourceMgr();
2392 if ( icon_id.length() )
2393 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2395 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ) );
2396 if ( !pix.isNull() )
2397 icon = QIconSet( pix );
2399 QString tooltip = tr( QString( "TOP_" )+po_id ),
2400 menu = tr( QString( "MEN_" )+po_id ),
2401 status_bar = tr( QString( "STB_" )+po_id );
2403 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2406 //=======================================================================
2407 // function : createPopupItem
2409 //=======================================================================
2410 void SMESHGUI::createPopupItem( const int id,
2411 const QString& clients,
2412 const QString& types,
2413 const QString& theRule,
2418 parentId = popupMgr()->actionId( action( pId ) );
2420 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2421 popupMgr()->insert( action( id ), parentId, 0 );
2423 QChar lc = QtxPopupMgr::Selection::defEquality();
2424 QString rule = "(%1) and (%2) and (%3)";
2425 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2426 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2427 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2430 bool cont = myRules.contains( id );
2432 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2434 popupMgr()->setRule( action( id ), rule, true );
2435 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2438 //=======================================================================
2439 // function : initialize
2441 //=======================================================================
2442 void SMESHGUI::initialize( CAM_Application* app )
2444 SalomeApp_Module::initialize( app );
2446 SUIT_ResourceMgr* mgr = app->resourceMgr();
2448 /* Automatic Update flag */
2449 myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2451 // ----- create actions --------------
2453 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2454 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2455 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2456 createSMESHAction( 114, "NUM" );
2457 createSMESHAction( 121, "DAT" );
2458 createSMESHAction( 122, "MED" );
2459 createSMESHAction( 123, "UNV" );
2460 createSMESHAction( 124, "EXPORT_DAT" );
2461 createSMESHAction( 125, "EXPORT_MED" );
2462 createSMESHAction( 126, "EXPORT_UNV" );
2463 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2464 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2465 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2466 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2467 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2468 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2469 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2470 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2471 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2472 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2473 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2474 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2475 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2476 createSMESHAction( 804, "ADD" );
2477 createSMESHAction( 805, "REMOVE" );
2478 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2479 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2480 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2481 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2482 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2483 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2484 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2485 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2486 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2487 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2488 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2489 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2490 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2491 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2492 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2493 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2494 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2495 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2496 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2497 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2498 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2499 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2500 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2501 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2502 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2503 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2504 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2505 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2506 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2507 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2508 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2509 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2510 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2511 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2512 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2513 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2514 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2515 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2516 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2517 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2518 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2519 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2520 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2521 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2522 createSMESHAction( 415, "MAP", "ICON_MAP" );
2523 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2524 createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true );
2525 createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true );
2526 createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true );
2527 createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true );
2528 createSMESHAction( 1001, "AUTO_UPD", "", 0, true );
2529 createSMESHAction( 1003, "COLORS" );
2530 createSMESHAction( 1005, "SCALAR_BAR" );
2531 createSMESHAction( 1006, "SELECTION" );
2532 createSMESHAction( 10070, "PRECISION", "", 0, true );
2533 createSMESHAction( 10071, "DISP_ENT", "", 0, true );
2534 createSMESHAction( 200, "RESET" );
2535 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2536 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2537 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2538 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2539 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2540 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2541 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2542 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2543 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2544 createSMESHAction( 220, "ALL" );
2545 createSMESHAction( 1100, "EDIT_HYPO" );
2546 createSMESHAction( 1101, "RENAME" );
2547 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2548 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2549 createSMESHAction( 1131, "DISPMODE" );
2550 createSMESHAction( 1132, "COLORS" );
2551 createSMESHAction( 1133, "TRANSP" );
2552 createSMESHAction( 1134, "CLIP" );
2553 createSMESHAction( 1135, "DISP_ENT" );
2554 createSMESHAction( 2000, "CTRL" );
2556 createSMESHAction( 300, "ERASE" );
2557 createSMESHAction( 301, "DISPLAY" );
2558 createSMESHAction( 302, "DISPLAY_ONLY" );
2559 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2561 // ----- create menu --------------
2562 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2563 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2564 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2565 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2566 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2567 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2568 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2569 prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ),
2570 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2572 createMenu( separator(), fileId );
2574 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2575 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2577 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2578 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2579 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2580 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
2582 meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ),
2584 dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ),
2585 qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 );
2587 createMenu( 111, importId, -1 );
2588 createMenu( 112, importId, -1 );
2589 createMenu( 113, importId, -1 );
2591 createMenu( 121, exportId, -1 );
2592 createMenu( 122, exportId, -1 );
2593 createMenu( 123, exportId, -1 );
2595 createMenu( separator(), fileId, 10 );
2597 createMenu( 33, editId, -1 );
2599 createMenu( 5105, toolsId, -1 );
2601 createMenu( 5000, hypoId, -1 );
2602 createMenu( 5010, hypoId, -1 );
2604 createMenu( 703, meshId, -1 );
2605 createMenu( 702, meshId, -1 );
2606 createMenu( 704, meshId, -1 );
2607 createMenu( separator(), meshId, -1 );
2608 createMenu( 701, meshId, -1 );
2609 createMenu( separator(), meshId, -1 );
2610 createMenu( 801, meshId, -1 );
2611 createMenu( 802, meshId, -1 );
2612 createMenu( 803, meshId, -1 );
2613 createMenu( separator(), meshId, -1 );
2614 createMenu( 810, meshId, -1 );
2615 createMenu( 811, meshId, -1 );
2616 createMenu( 812, meshId, -1 );
2617 createMenu( separator(), meshId, -1 );
2618 createMenu( 813, meshId, -1 );
2619 createMenu( separator(), meshId, -1 );
2620 createMenu( 900, meshId, -1 );
2621 createMenu( 902, meshId, -1 );
2622 createMenu( separator(), meshId, -1 );
2624 createMenu( 6003, ctrlId, -1 );
2625 createMenu( 6001, ctrlId, -1 );
2626 createMenu( 6004, ctrlId, -1 );
2627 createMenu( separator(), ctrlId, -1 );
2628 createMenu( 6002, ctrlId, -1 );
2629 createMenu( 6018, ctrlId, -1 );
2630 createMenu( 6019, ctrlId, -1 );
2631 createMenu( 6011, ctrlId, -1 );
2632 createMenu( 6012, ctrlId, -1 );
2633 createMenu( 6013, ctrlId, -1 );
2634 createMenu( 6014, ctrlId, -1 );
2635 createMenu( 6015, ctrlId, -1 );
2636 createMenu( 6016, ctrlId, -1 );
2637 createMenu( separator(), ctrlId, -1 );
2638 createMenu( 6017, ctrlId, -1 );
2639 createMenu( separator(), ctrlId, -1 );
2641 createMenu( 400, addId, -1 );
2642 createMenu( 401, addId, -1 );
2643 createMenu( 4021, addId, -1 );
2644 createMenu( 4022, addId, -1 );
2645 createMenu( 4023, addId, -1 );
2646 createMenu( 4031, addId, -1 );
2647 createMenu( 4032, addId, -1 );
2648 createMenu( 4033, addId, -1 );
2650 createMenu( 4041, removeId, -1 );
2651 createMenu( 4042, removeId, -1 );
2653 createMenu( 4051, renumId, -1 );
2654 createMenu( 4052, renumId, -1 );
2656 createMenu( 4061, transfId, -1 );
2657 createMenu( 4062, transfId, -1 );
2658 createMenu( 4063, transfId, -1 );
2659 createMenu( 4064, transfId, -1 );
2660 createMenu( 4065, transfId, -1 );
2662 createMenu( 406, modifyId, -1 );
2663 createMenu( 407, modifyId, -1 );
2664 createMenu( 408, modifyId, -1 );
2665 createMenu( 409, modifyId, -1 );
2666 createMenu( 410, modifyId, -1 );
2667 createMenu( 411, modifyId, -1 );
2668 createMenu( 412, modifyId, -1 );
2669 createMenu( 413, modifyId, -1 );
2670 createMenu( 416, modifyId, -1 );
2671 createMenu( 414, modifyId, -1 );
2672 createMenu( 415, modifyId, -1 );
2674 createMenu( 10001, dispModeId, -1 );
2675 createMenu( 10002, dispModeId, -1 );
2676 createMenu( 10004, dispModeId, -1 );
2677 createMenu( 10003, dispModeId, -1 );
2679 createMenu( 1001, prefId, -1 );
2680 createMenu( separator(), prefId, -1 );
2681 createMenu( 1003, prefId, -1 );
2682 createMenu( separator(), prefId, -1 );
2683 createMenu( 1005, prefId, -1 );
2684 createMenu( separator(), prefId, -1 );
2685 createMenu( 1006, prefId, -1 );
2686 createMenu( separator(), prefId, -1 );
2688 createMenu( 10070, qualityId, -1 );
2689 createMenu( 10071, qualityId, -1 );
2691 createMenu( separator(), prefId, -1 );
2693 createMenu( 214, viewId, -1 );
2695 // ----- create toolbars --------------
2696 int meshTb = createTool( tr( "TB_MESH" ) ),
2697 hypoTb = createTool( tr( "TB_HYPO" ) ),
2698 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2699 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2700 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2701 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2703 createTool( 703, meshTb );
2704 createTool( 702, meshTb );
2705 createTool( 704, meshTb );
2706 createTool( separator(), meshTb );
2707 createTool( 701, meshTb );
2708 createTool( separator(), meshTb );
2709 createTool( 801, meshTb );
2710 createTool( 802, meshTb );
2711 createTool( 803, meshTb );
2712 createTool( separator(), meshTb );
2713 createTool( 900, meshTb );
2714 createTool( 902, meshTb );
2715 createTool( separator(), meshTb );
2717 createTool( 5000, hypoTb );
2718 createTool( 5010, hypoTb );
2720 createTool( 6001, ctrlTb );
2721 createTool( 6003, ctrlTb );
2722 createTool( 6004, ctrlTb );
2723 createTool( separator(), ctrlTb );
2724 createTool( 6002, ctrlTb );
2725 createTool( 6018, ctrlTb );
2726 createTool( 6019, ctrlTb );
2727 createTool( 6011, ctrlTb );
2728 createTool( 6012, ctrlTb );
2729 createTool( 6013, ctrlTb );
2730 createTool( 6014, ctrlTb );
2731 createTool( 6015, ctrlTb );
2732 createTool( 6016, ctrlTb );
2733 createTool( separator(), ctrlTb );
2734 createTool( 6017, ctrlTb );
2735 createTool( separator(), ctrlTb );
2737 createTool( 400, addRemTb );
2738 createTool( 401, addRemTb );
2739 createTool( 4021, addRemTb );
2740 createTool( 4022, addRemTb );
2741 createTool( 4023, addRemTb );
2742 createTool( 4031, addRemTb );
2743 createTool( 4032, addRemTb );
2744 createTool( 4033, addRemTb );
2745 createTool( separator(), addRemTb );
2746 createTool( 4041, addRemTb );
2747 createTool( 4042, addRemTb );
2748 createTool( separator(), addRemTb );
2749 createTool( 4051, addRemTb );
2750 createTool( 4052, addRemTb );
2751 createTool( separator(), addRemTb );
2752 createTool( 4061, addRemTb );
2753 createTool( 4062, addRemTb );
2754 createTool( 4063, addRemTb );
2755 createTool( 4064, addRemTb );
2756 createTool( 4065, addRemTb );
2757 createTool( separator(), addRemTb );
2759 createTool( 406, modifyTb );
2760 createTool( 407, modifyTb );
2761 createTool( 408, modifyTb );
2762 createTool( 409, modifyTb );
2763 createTool( 410, modifyTb );
2764 createTool( 411, modifyTb );
2765 createTool( 412, modifyTb );
2766 createTool( 413, modifyTb );
2767 createTool( 416, modifyTb );
2768 createTool( 414, modifyTb );
2769 createTool( 415, modifyTb );
2771 createTool( 214, dispModeTb );
2775 QString OB = "'ObjectBrowser'",
2776 View = "'" + SVTK_Viewer::Type() + "'",
2778 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2779 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2780 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2781 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2782 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2783 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2784 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2785 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2786 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2787 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2789 mesh_group = mesh + " " + subMesh + " " + group,
2790 hyp_alg = hypo + " " + algo;
2792 // popup for object browser
2794 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2795 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2796 createPopupItem( 803, OB, group ); // EDIT_GROUP
2797 popupMgr()->insert( separator(), -1, 0 );
2798 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2799 createPopupItem( 214, OB, mesh_group ); // UPDATE
2800 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2801 createPopupItem( 902, OB, mesh ); // STD_INFO
2802 popupMgr()->insert( separator(), -1, 0 );
2803 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2804 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2805 popupMgr()->insert( separator(), -1, 0 );
2806 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2807 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2808 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2809 popupMgr()->insert( separator(), -1, 0 );
2810 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2811 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2812 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2813 popupMgr()->insert( separator(), -1, 0 );
2816 createPopupItem( 803, View, group ); // EDIT_GROUP
2817 createPopupItem( 804, View, elems ); // ADD
2818 createPopupItem( 805, View, elems ); // REMOVE
2819 popupMgr()->insert( separator(), -1, 0 );
2820 createPopupItem( 214, View, mesh_group ); // UPDATE
2821 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2822 createPopupItem( 902, View, mesh ); // STD_INFO
2823 popupMgr()->insert( separator(), -1, 0 );
2827 isInvisible("not( isVisible )"),
2828 isEmpty("numberOfNodes = 0"),
2829 isNotEmpty("numberOfNodes <> 0"),
2831 // has nodes, edges, etc in VISIBLE! actor
2832 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2833 hasElems("(count( elemTypes ) > 0)"),
2834 hasDifferentElems("(count( elemTypes ) > 1)"),
2835 hasEdges("({'Edge'} in elemTypes)"),
2836 hasFaces("({'Face'} in elemTypes)"),
2837 hasVolumes("({'Volume'} in elemTypes)");
2839 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2840 QString lc = QtxPopupMgr::Selection::defEquality();
2841 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2842 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2843 QString aMeshInVTK = aClient + "&&" + aType;// + "&&" + aSelCount;
2845 //-------------------------------------------------
2847 //-------------------------------------------------
2848 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2850 popupMgr()->insert( action( 9010 ), anId, -1 );
2851 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true );
2852 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2854 popupMgr()->insert( action( 9011 ), anId, -1 );
2855 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true );
2856 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2858 popupMgr()->insert( separator(), -1, -1 );
2860 //-------------------------------------------------
2862 //-------------------------------------------------
2863 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2865 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2866 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2867 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2869 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2870 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2871 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2873 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2874 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2875 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2877 popupMgr()->insert( separator(), anId, -1 );
2879 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2880 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2881 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2883 //-------------------------------------------------
2885 //-------------------------------------------------
2886 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2888 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2890 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2891 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true );
2892 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2894 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2895 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true );
2896 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2898 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2899 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true );
2900 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2902 popupMgr()->insert( separator(), anId, -1 );
2904 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2905 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true );
2907 //-------------------------------------------------
2909 //-------------------------------------------------
2910 popupMgr()->insert( action( 1132 ), -1, -1 );
2911 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2913 //-------------------------------------------------
2915 //-------------------------------------------------
2916 popupMgr()->insert( action( 1133 ), -1, -1 );
2917 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2919 //-------------------------------------------------
2921 //-------------------------------------------------
2922 popupMgr()->insert( action( 1134 ), -1, -1 );
2923 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2925 popupMgr()->insert( separator(), -1, -1 );
2927 //-------------------------------------------------
2929 //-------------------------------------------------
2931 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2932 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2933 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2935 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2937 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2938 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2940 popupMgr()->insert( separator(), anId, -1 );
2942 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2943 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2944 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2946 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2947 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2948 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2950 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2951 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2952 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2954 popupMgr()->insert( separator(), anId, -1 );
2956 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2957 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2958 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2960 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2961 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2962 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2964 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2965 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2966 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2968 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2969 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2970 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2972 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2973 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2974 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2976 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2977 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2978 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2980 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2981 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2982 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2984 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2985 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2986 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2988 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2989 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2990 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2992 popupMgr()->insert( separator(), anId, -1 );
2994 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2995 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2996 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2998 popupMgr()->insert( separator(), anId, -1 );
3000 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3001 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3003 popupMgr()->insert( separator(), -1, -1 );
3005 //-------------------------------------------------
3007 //-------------------------------------------------
3008 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3009 QString aRule = aClient + " and " + aType + " and " + aSelCount;
3010 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3011 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
3013 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3014 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
3016 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3017 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
3019 popupMgr()->insert( separator(), -1, -1 );
3021 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
3022 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
3025 bool SMESHGUI::activateModule( SUIT_Study* study )
3027 bool res = SalomeApp_Module::activateModule( study );
3029 setMenuShown( true );
3030 setToolShown( true );
3031 SetSettings( desktop() );
3036 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3038 setMenuShown( false );
3039 setToolShown( false );
3041 EmitSignalCloseAllDialogs();
3043 return SalomeApp_Module::deactivateModule( study );
3046 void SMESHGUI::OnGUIEvent()
3048 const QObject* obj = sender();
3049 if ( !obj || !obj->inherits( "QAction" ) )
3051 int id = actionId((QAction*)obj);
3056 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3058 if ( CORBA::is_nil( myComponentSMESH ) )
3060 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3061 return aGUI.myComponentSMESH;
3063 return myComponentSMESH;
3066 QString SMESHGUI::engineIOR() const
3068 CORBA::ORB_var anORB = getApp()->orb();
3069 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3073 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3075 SMESHGUI_Selection sel;
3076 sel.init( 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() );
3091 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
3093 if( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
3094 SMESH::UpdateSelectionProp( this );