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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESH_Client.hxx"
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_MoveNodesDlg.h"
43 #include "SMESHGUI_AddMeshElementDlg.h"
44 #include "SMESHGUI_AddQuadraticElementDlg.h"
45 #include "SMESHGUI_FilterDlg.h"
46 #include "SMESHGUI_FilterLibraryDlg.h"
47 #include "SMESHGUI_SingleEditDlg.h"
48 #include "SMESHGUI_MultiEditDlg.h"
49 #include "SMESHGUI_GroupOpDlg.h"
50 #include "SMESHGUI_DeleteGroupDlg.h"
51 #include "SMESHGUI_SmoothingDlg.h"
52 #include "SMESHGUI_RenumberingDlg.h"
53 #include "SMESHGUI_ExtrusionDlg.h"
54 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
55 #include "SMESHGUI_RevolutionDlg.h"
56 #include "SMESHGUI_TranslationDlg.h"
57 #include "SMESHGUI_RotationDlg.h"
58 #include "SMESHGUI_SymmetryDlg.h"
59 #include "SMESHGUI_SewingDlg.h"
60 #include "SMESHGUI_MergeNodesDlg.h"
61 #include "SMESHGUI_EditMeshDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_Selection.h"
64 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
65 #include "SMESHGUI_ConvToQuadOp.h"
66 #include "SMESHGUI_MeshOp.h"
67 #include "SMESHGUI_Displayer.h"
69 #include "SMESHGUI_Utils.h"
70 #include "SMESHGUI_GEOMGenUtils.h"
71 #include "SMESHGUI_MeshUtils.h"
72 #include "SMESHGUI_GroupUtils.h"
73 #include "SMESHGUI_FilterUtils.h"
74 #include "SMESHGUI_PatternUtils.h"
75 #include "SMESHGUI_VTKUtils.h"
76 #include "SMESHGUI_HypothesesUtils.h"
78 #include "SMESH_Actor.h"
79 #include "SMESH_Object.h"
80 #include "SMESH_TypeFilter.hxx"
82 #include "SalomeApp_Tools.h"
83 #include "SalomeApp_Study.h"
84 #include "SalomeApp_Application.h"
85 #include "SalomeApp_CheckFileDlg.h"
86 #include "SalomeApp_ImportOperation.h"
88 #include "LightApp_DataOwner.h"
89 #include "LightApp_Preferences.h"
90 #include "LightApp_VTKSelector.h"
91 #include "LightApp_Operation.h"
92 #include "LightApp_UpdateFlags.h"
93 #include "LightApp_NameDlg.h"
95 #include <SVTK_ViewWindow.h>
96 #include <SVTK_ViewModel.h>
97 #include <SVTK_InteractorStyle.h>
98 #include <SVTK_RenderWindowInteractor.h>
99 #include <SVTK_ViewManager.h>
101 #include "OB_Browser.h"
103 #include "SUIT_Tools.h"
104 #include "SUIT_MessageBox.h"
105 #include "SUIT_ResourceMgr.h"
106 #include "SUIT_FileDlg.h"
107 #include "SUIT_Desktop.h"
108 #include "SUIT_OverrideCursor.h"
109 #include "SUIT_Study.h"
110 #include "SUIT_Session.h"
112 #include "QtxPopupMgr.h"
114 #include "SALOME_ListIO.hxx"
115 #include "SALOME_ListIteratorOfListIO.hxx"
116 #include "SALOME_InteractiveObject.hxx"
117 #include "SALOME_NamingService.hxx"
118 #include "SALOME_LifeCycleCORBA.hxx"
120 #include "SALOMEconfig.h"
121 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
124 #define INCLUDE_MENUITEM_DEF
125 #include <qpopupmenu.h>
131 #include <boost/shared_ptr.hpp>
134 #include <vtkRenderer.h>
135 #include <vtkRenderWindow.h>
136 #include <vtkActorCollection.h>
137 #include <vtkScalarBarActor.h>
138 #include <vtkUnstructuredGrid.h>
140 #include "utilities.h"
142 #include "SALOMEDS_Study.hxx"
143 #include "SALOMEDSClient_StudyBuilder.hxx"
144 #include "SALOMEDSClient_SComponent.hxx"
150 //=============================================================
151 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
154 void ExportMeshToFile(int theCommandID);
156 void SetDisplayMode(int theCommandID);
158 void SetDisplayEntity(int theCommandID);
160 void Control( int theCommandID );
164 //=============================================================
165 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
171 if(theCommandID == 113){
172 filter.append(QObject::tr("MED files (*.med)"));
173 filter.append(QObject::tr("All files (*)"));
174 }else if (theCommandID == 112){
175 filter.append(QObject::tr("IDEAS files (*.unv)"));
176 }else if (theCommandID == 111){
177 filter.append(QObject::tr("DAT files (*.dat)"));
179 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
182 QObject::tr("Import mesh"),
184 if(!filename.isEmpty()) {
185 SUIT_OverrideCursor wc;
186 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
189 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
190 switch ( theCommandID ) {
193 aMeshes->length( 1 );
194 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
199 SMESH::DriverMED_ReadStatus res;
200 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
201 if ( res != SMESH::DRS_OK ) {
203 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
204 QObject::tr("SMESH_WRN_WARNING"),
205 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
206 QObject::tr("SMESH_BUT_OK"));
207 aMeshes->length( 0 );
214 bool isEmpty = false;
215 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
216 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
218 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
219 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
220 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
221 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
222 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
229 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
230 QObject::tr("SMESH_WRN_WARNING"),
231 QObject::tr("SMESH_DRS_EMPTY"),
232 QObject::tr("SMESH_BUT_OK"));
236 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
238 catch (const SALOME::SALOME_Exception& S_ex){
240 SalomeApp_Tools::QtCatchCorbaException(S_ex);
247 void ExportMeshToFile( int theCommandID )
249 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
250 SALOME_ListIO selected;
252 aSel->selectedObjects( selected );
254 if(selected.Extent()){
255 Handle(SALOME_InteractiveObject) anIObject = selected.First();
256 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
257 if ( !aMesh->_is_nil() ) {
258 QString aFilter, aTitle = QObject::tr("Export mesh");
259 QMap<QString, SMESH::MED_VERSION> aFilterMap;
260 switch ( theCommandID ) {
264 if (aMesh->HasDuplicatedGroupNamesMED()) {
265 int aRet = SUIT_MessageBox::warn2
266 (SMESHGUI::desktop(),
267 QObject::tr("SMESH_WRN_WARNING"),
268 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
269 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
275 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
276 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
281 aFilter = QObject::tr("DAT files (*.dat)");
286 if (aMesh->NbPyramids()) {
287 int aRet = SUIT_MessageBox::warn2
288 (SMESHGUI::desktop(),
289 QObject::tr("SMESH_WRN_WARNING"),
290 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
291 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
296 aFilter = QObject::tr("IDEAS files (*.unv)");
304 SMESH::MED_VERSION aFormat;
305 // Init the parameter with the default value
306 bool toCreateGroups = false;
307 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
309 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
311 if ( theCommandID != 122 && theCommandID != 125 )
312 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
315 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
316 for ( ; it != aFilterMap.end(); ++it )
317 filters.push_back( it.key() );
319 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
320 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
321 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
322 fd->setCaption( aTitle );
323 fd->setFilters( filters );
324 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
325 fd->SetChecked(toCreateGroups);
329 aFilename = fd->selectedFile();
330 aFormat = aFilterMap[fd->selectedFilter()];
332 if ( !aFilename.isEmpty()
333 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
334 && aFormat==SMESH::MED_V2_1) {
335 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
336 QObject::tr("SMESH_WRN_WARNING"),
337 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
338 QObject::tr("SMESH_BUT_YES"),
339 QObject::tr("SMESH_BUT_NO"),
346 toCreateGroups = fd->IsChecked();
349 if ( !aFilename.isEmpty() ) {
350 // Check whether the file already exists and delete it if yes
351 QFile aFile( aFilename );
352 if ( aFile.exists() )
354 SUIT_OverrideCursor wc;
355 switch ( theCommandID ) {
358 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
362 aMesh->ExportDAT( aFilename.latin1() );
366 aMesh->ExportUNV( aFilename.latin1() );
376 inline void InverseEntityMode(unsigned int& theOutputMode,
377 unsigned int theMode)
379 bool anIsNotPresent = ~theOutputMode & theMode;
381 theOutputMode |= theMode;
383 theOutputMode &= ~theMode;
386 void SetDisplayEntity(int theCommandID){
387 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
388 SALOME_ListIO selected;
390 aSel->selectedObjects( selected );
392 if(selected.Extent() >= 1){
393 SALOME_ListIteratorOfListIO It( selected );
394 for(; It.More(); It.Next()){
395 Handle(SALOME_InteractiveObject) IObject = It.Value();
396 if(IObject->hasEntry()){
397 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
398 unsigned int aMode = anActor->GetEntityMode();
399 switch(theCommandID){
401 InverseEntityMode(aMode,SMESH_Actor::eEdges);
404 InverseEntityMode(aMode,SMESH_Actor::eFaces);
407 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
410 aMode = SMESH_Actor::eAllEntity;
414 anActor->SetEntityMode(aMode);
421 void SetDisplayMode(int theCommandID){
422 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
423 SALOME_ListIO selected;
425 aSel->selectedObjects( selected );
427 if(selected.Extent() >= 1){
428 switch(theCommandID){
430 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
431 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
435 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
436 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
439 SALOME_ListIteratorOfListIO It( selected );
440 for(; It.More(); It.Next()){
441 Handle(SALOME_InteractiveObject) IObject = It.Value();
442 if(IObject->hasEntry()){
443 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
444 switch(theCommandID){
446 anActor->SetRepresentation(SMESH_Actor::eEdge);
449 anActor->SetRepresentation(SMESH_Actor::eSurface);
452 if(anActor->IsShrunk())
455 anActor->SetShrink();
458 anActor->SetRepresentation(SMESH_Actor::ePoint);
461 vtkFloatingPointType color[3];
462 anActor->GetSufaceColor(color[0], color[1], color[2]);
463 int c0 = int (color[0] * 255);
464 int c1 = int (color[1] * 255);
465 int c2 = int (color[2] * 255);
466 QColor c(c0, c1, c2);
468 vtkFloatingPointType edgecolor[3];
469 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
470 c0 = int (edgecolor[0] * 255);
471 c1 = int (edgecolor[1] * 255);
472 c2 = int (edgecolor[2] * 255);
473 QColor e(c0, c1, c2);
475 vtkFloatingPointType backfacecolor[3];
476 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
477 c0 = int (backfacecolor[0] * 255);
478 c1 = int (backfacecolor[1] * 255);
479 c2 = int (backfacecolor[2] * 255);
480 QColor b(c0, c1, c2);
482 vtkFloatingPointType nodecolor[3];
483 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
484 c0 = int (nodecolor[0] * 255);
485 c1 = int (nodecolor[1] * 255);
486 c2 = int (nodecolor[2] * 255);
487 QColor n(c0, c1, c2);
489 int Edgewidth = (int)anActor->GetLineWidth();
492 int intValue = int(anActor->GetNodeSize());
493 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
495 SMESHGUI_Preferences_ColorDlg *aDlg =
496 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
497 aDlg->SetColor(1, c);
498 aDlg->SetColor(2, e);
499 aDlg->SetColor(3, n);
500 aDlg->SetColor(4, b);
501 aDlg->SetIntValue(1, Edgewidth);
502 aDlg->SetIntValue(2, intValue);
503 aDlg->SetIntValue(3, int(Shrink*100.));
505 QColor color = aDlg->GetColor(1);
506 QColor edgecolor = aDlg->GetColor(2);
507 QColor nodecolor = aDlg->GetColor(3);
508 QColor backfacecolor = aDlg->GetColor(4);
509 /* actor color and backface color */
510 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
511 vtkFloatingPointType (color.green()) / 255.,
512 vtkFloatingPointType (color.blue()) / 255.);
513 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
514 vtkFloatingPointType (backfacecolor.green()) / 255.,
515 vtkFloatingPointType (backfacecolor.blue()) / 255.);
518 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
519 vtkFloatingPointType (edgecolor.green()) / 255.,
520 vtkFloatingPointType (edgecolor.blue()) / 255.);
522 /* Shrink factor and size edges */
523 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
524 anActor->SetLineWidth(aDlg->GetIntValue(1));
526 /* Nodes color and size */
527 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
528 vtkFloatingPointType (nodecolor.green()) / 255.,
529 vtkFloatingPointType (nodecolor.blue()) / 255.);
530 anActor->SetNodeSize(aDlg->GetIntValue(2));
539 SMESH::RepaintCurrentView();
543 void Control( int theCommandID )
545 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
546 SALOME_ListIO selected;
548 aSel->selectedObjects( selected );
550 if( !selected.IsEmpty() ){
551 Handle(SALOME_InteractiveObject) anIO = selected.First();
554 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
555 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
556 switch ( theCommandID ){
558 aTitle = QObject::tr( "LENGTH_EDGES" );
559 aControl = SMESH_Actor::eLength;
562 aTitle = QObject::tr( "LENGTH2D_EDGES" );
563 aControl = SMESH_Actor::eLength2D;
566 aTitle = QObject::tr( "FREE_EDGES" );
567 aControl = SMESH_Actor::eFreeEdges;
570 aTitle = QObject::tr( "FREE_BORDERS" );
571 aControl = SMESH_Actor::eFreeBorders;
574 aTitle = QObject::tr( "MULTI_BORDERS" );
575 aControl = SMESH_Actor::eMultiConnection;
578 aTitle = QObject::tr( "MULTI2D_BORDERS" );
579 aControl = SMESH_Actor::eMultiConnection2D;
582 aTitle = QObject::tr( "AREA_ELEMENTS" );
583 aControl = SMESH_Actor::eArea;
586 aTitle = QObject::tr( "TAPER_ELEMENTS" );
587 aControl = SMESH_Actor::eTaper;
590 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
591 aControl = SMESH_Actor::eAspectRatio;
594 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
595 aControl = SMESH_Actor::eAspectRatio3D;
598 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
599 aControl = SMESH_Actor::eMinimumAngle;
602 aTitle = QObject::tr( "WARP_ELEMENTS" );
603 aControl = SMESH_Actor::eWarping;
606 aTitle = QObject::tr( "SKEW_ELEMENTS" );
607 aControl = SMESH_Actor::eSkew;
610 aTitle = QObject::tr( "SMESH_VOLUME" );
611 aControl = SMESH_Actor::eVolume3D;
614 anActor->SetControlMode(aControl);
615 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
616 SMESH::RepaintCurrentView();
623 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
624 MeshObjectType theType,
625 const QString theInTypeName,
626 QString & theOutTypeName)
628 SMESH_TypeFilter aTypeFilter( theType );
630 if( !theIO.IsNull() )
632 entry = theIO->getEntry();
633 LightApp_DataOwner owner( entry );
634 if ( aTypeFilter.isOk( &owner )) {
635 theOutTypeName = theInTypeName;
643 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
645 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
646 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
648 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
649 CORBA::String_var anID = aSComp->GetID().c_str();
650 if (!strcmp(anID.in(),theIO->getEntry()))
656 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
657 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
658 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
659 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
660 CheckOIType ( theIO, GROUP, "Group", aTypeName )
668 QString CheckHomogeneousSelection()
670 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
671 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
672 SALOME_ListIO selected;
674 aSel->selectedObjects( selected );
676 QString RefType = CheckTypeObject(selected.First());
677 SALOME_ListIteratorOfListIO It(selected);
678 for (; It.More(); It.Next())
680 Handle(SALOME_InteractiveObject) IObject = It.Value();
681 QString Type = CheckTypeObject(IObject);
682 if (Type.compare(RefType) != 0)
683 return "Heterogeneous Selection";
691 SMESHGUI_EXPORT CAM_Module* createModule()
693 return new SMESHGUI();
697 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
699 //=============================================================================
703 //=============================================================================
704 SMESHGUI::SMESHGUI() :
705 SalomeApp_Module( "SMESH" )
707 if ( CORBA::is_nil( myComponentSMESH ) )
709 CORBA::Boolean anIsEmbeddedMode;
710 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
713 myActiveDialogBox = 0;
714 myFilterLibraryDlg = 0;
718 SMESH::GetFilterManager();
721 /* load resources for all available meshers */
722 SMESH::InitAvailableHypotheses();
725 //=============================================================================
729 //=============================================================================
730 SMESHGUI::~SMESHGUI()
732 SMESH::GetFilterManager()->Destroy();
733 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
736 //=============================================================================
740 //=============================================================================
741 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
743 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
745 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
750 bool SMESHGUI::automaticUpdate()
752 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
756 return resMgr->booleanValue( "SMESH", "auto_update", false );
759 //=============================================================================
763 //=============================================================================
764 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
766 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
769 //=============================================================================
773 //=============================================================================
774 SMESHGUI* SMESHGUI::GetSMESHGUI()
776 SMESHGUI* smeshMod = 0;
777 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
780 CAM_Module* module = app->module( "Mesh" );
781 smeshMod = dynamic_cast<SMESHGUI*>( module );
784 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
786 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
789 _PTR(Study) aStudy = study->studyDS();
791 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
800 Standard_EXPORT SMESHGUI* GetComponentGUI()
802 return SMESHGUI::GetSMESHGUI();
806 //=============================================================================
810 //=============================================================================
811 void SMESHGUI::SetState(int aState)
816 //=============================================================================
820 //=============================================================================
821 void SMESHGUI::ResetState()
826 //=============================================================================
830 //=============================================================================
831 void SMESHGUI::EmitSignalDeactivateDialog()
833 emit SignalDeactivateActiveDialog();
836 //=============================================================================
840 //=============================================================================
841 void SMESHGUI::EmitSignalStudyFrameChanged()
843 emit SignalStudyFrameChanged();
846 //=============================================================================
850 //=============================================================================
851 void SMESHGUI::EmitSignalCloseAllDialogs()
853 emit SignalCloseAllDialogs();
856 //=============================================================================
860 //=============================================================================
861 QDialog *SMESHGUI::GetActiveDialogBox()
863 return myActiveDialogBox;
866 //=============================================================================
870 //=============================================================================
871 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
873 myActiveDialogBox = (QDialog *) aDlg;
877 //=============================================================================
881 //=============================================================================
882 SUIT_Desktop* SMESHGUI::desktop()
884 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
886 return app->desktop();
891 //=============================================================================
895 //=============================================================================
896 SalomeApp_Study* SMESHGUI::activeStudy()
898 SUIT_Application* app = SUIT_Session::session()->activeApplication();
900 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
905 //=============================================================================
909 //=============================================================================
910 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
912 /* Here the position is on the bottom right corner - 10 */
913 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
915 SUIT_Desktop *PP = desktop();
916 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
917 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
921 //=============================================================================
925 //=============================================================================
926 static int isStudyLocked(_PTR(Study) theStudy){
927 return theStudy->GetProperties()->IsLocked();
930 static bool checkLock(_PTR(Study) theStudy) {
931 if (isStudyLocked(theStudy)) {
932 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
933 QObject::tr("WRN_WARNING"),
934 QObject::tr("WRN_STUDY_LOCKED"),
935 QObject::tr("BUT_OK") );
941 //=======================================================================
942 //function : CheckActiveStudyLocked
944 //=======================================================================
946 bool SMESHGUI::isActiveStudyLocked()
948 _PTR(Study) aStudy = activeStudy()->studyDS();
949 return checkLock( aStudy );
952 //=============================================================================
956 //=============================================================================
957 bool SMESHGUI::OnGUIEvent( int theCommandID )
959 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
963 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
964 SUIT_ResourceMgr* mgr = resourceMgr();
968 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
969 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
972 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
973 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
975 //QAction* act = action( theCommandID );
977 switch (theCommandID) {
979 if(checkLock(aStudy)) break;
987 if(checkLock(aStudy)) break;
988 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
992 case 122: // EXPORT MED
999 ::ExportMeshToFile(theCommandID);
1003 case 200: // SCALAR BAR
1005 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1006 SALOME_ListIO selected;
1008 aSel->selectedObjects( selected );
1010 if( selected.Extent() ) {
1011 Handle(SALOME_InteractiveObject) anIO = selected.First();
1012 if( anIO->hasEntry() ) {
1013 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1014 anActor->SetControlMode( SMESH_Actor::eNone );
1022 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1026 case 1134: // Clipping
1027 case 1133: // Tranparency
1028 case 1132: // Colors / Size
1035 ::SetDisplayMode(theCommandID);
1041 case 219: // Volumes
1042 case 220: // All Entity
1043 ::SetDisplayEntity(theCommandID);
1048 if(checkLock(aStudy)) break;
1049 SMESH::UpdateView();
1052 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1053 aSel->selectedObjects( l );
1054 aSel->setSelectedObjects( l );
1059 case 301: // DISPLAY
1060 case 302: // DISPLAY ONLY
1062 SMESH::EDisplaing anAction;
1063 switch (theCommandID) {
1064 case 300: anAction = SMESH::eErase; break;
1065 case 301: anAction = SMESH::eDisplay; break;
1066 case 302: anAction = SMESH::eDisplayOnly; break;
1069 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1070 SALOME_ListIO sel_objects, to_process;
1072 aSel->selectedObjects( sel_objects );
1074 if( theCommandID==302 )
1075 startOperation( myEraseAll );
1077 extractContainers( sel_objects, to_process );
1080 SALOME_ListIteratorOfListIO It( to_process );
1081 for (; It.More(); It.Next()) {
1082 Handle(SALOME_InteractiveObject) IOS = It.Value();
1083 if (IOS->hasEntry()) {
1084 SMESH::UpdateView(anAction, IOS->getEntry());
1085 if (anAction == SMESH::eDisplayOnly)
1086 anAction = SMESH::eDisplay;
1091 if (anAction == SMESH::eErase) {
1093 aSel->setSelectedObjects( l1 );
1096 aSel->setSelectedObjects( to_process );
1102 if(checkLock(aStudy)) break;
1105 EmitSignalDeactivateDialog();
1107 new SMESHGUI_NodesDlg(this);
1110 SUIT_MessageBox::warn1(desktop(),
1111 tr("SMESH_WRN_WARNING"),
1112 tr("SMESH_WRN_VIEWER_VTK"),
1113 tr("SMESH_BUT_OK"));
1118 case 2151: // FILTER
1122 EmitSignalDeactivateDialog();
1123 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1128 case 406: // MOVE NODE
1132 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1133 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1137 if(checkLock(aStudy)) break;
1138 new SMESHGUI_MoveNodesDlg(this);
1142 case 701: // COMPUTE MESH
1144 if(checkLock(aStudy)) break;
1146 LightApp_SelectionMgr *Sel = selectionMgr();
1147 SALOME_ListIO selected; Sel->selectedObjects( selected );
1150 int nbSel = selected.Extent();
1155 SMESH::SMESH_Mesh_var aMesh;
1156 SMESH::SMESH_subMesh_var aSubMesh;
1157 Handle(SALOME_InteractiveObject) IObject = selected.First();
1158 if (IObject->hasEntry()) {
1159 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1160 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1161 if ( aShapeObject->_is_nil() ) {
1166 aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1167 aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1168 if ( !aSubMesh->_is_nil() )
1169 aMesh = aSubMesh->GetFather();
1171 if (!aMesh->_is_nil()) {
1172 // if(!GetSMESHGen()->IsReadyToCompute(aMesh,aShapeObject)) {
1173 // SUIT_MessageBox::warn1(desktop(),
1174 // tr("SMESH_WRN_WARNING"),
1175 // tr("SMESH_WRN_MISSING_PARAMETERS"),
1176 // tr("SMESH_BUT_OK"));
1179 SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1180 if ( errors->length() > 0 ) {
1181 SUIT_MessageBox::warn1(desktop(),
1182 tr("SMESH_WRN_WARNING"),
1183 SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1184 tr("SMESH_BUT_OK"));
1188 if (GetSMESHGen()->Compute(aMesh,aShapeObject))
1189 SMESH::ModifiedMesh(aMeshSObj,true);
1191 SUIT_MessageBox::warn1(desktop(),
1192 tr("SMESH_WRN_WARNING"),
1193 tr("SMESH_WRN_COMPUTE_FAILED"),
1194 tr("SMESH_BUT_OK"));
1196 catch(const SALOME::SALOME_Exception & S_ex){
1197 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1202 CORBA::Long anId = aStudy->StudyId();
1203 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1204 if ( automaticUpdate() && aVisualObj){
1205 aVisualObj->Update();
1206 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1208 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1210 SMESH::DisplayActor(view,anActor); //apo
1214 SMESH::RepaintCurrentView();
1217 SUIT_MessageBox::warn1(desktop(),
1218 tr("SMESH_WRN_WARNING"),
1219 tr("SMESH_WRN_VIEWER_VTK"),
1220 tr("SMESH_BUT_OK"));
1223 Sel->setSelectedObjects( selected );
1227 case 702: // Create mesh
1228 startOperation( 702 );
1230 case 703: // Create sub-mesh
1231 startOperation( 703 );
1233 case 704: // Edit mesh/sub-mesh
1234 startOperation( 704 );
1236 case 407: // DIAGONAL INVERSION
1237 case 408: // Delete diagonal
1241 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1242 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1246 if ( checkLock( aStudy ) )
1249 /*Standard_Boolean aRes;
1250 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1251 if ( aMesh->_is_nil() )
1253 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1254 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1258 EmitSignalDeactivateDialog();
1259 if ( theCommandID == 407 )
1260 new SMESHGUI_TrianglesInversionDlg(this);
1262 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1265 case 409: // Change orientation
1266 case 410: // Union of triangles
1267 case 411: // Cutting of quadrangles
1271 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1272 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1276 if ( checkLock( aStudy ) )
1279 EmitSignalDeactivateDialog();
1280 SMESHGUI_MultiEditDlg* aDlg = NULL;
1281 if ( theCommandID == 409 )
1282 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1283 else if ( theCommandID == 410 )
1284 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1286 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1291 case 412: // Smoothing
1293 if(checkLock(aStudy)) break;
1295 EmitSignalDeactivateDialog();
1296 new SMESHGUI_SmoothingDlg( this );
1299 SUIT_MessageBox::warn1(desktop(),
1300 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1301 tr("SMESH_BUT_OK"));
1305 case 413: // Extrusion
1307 if (checkLock(aStudy)) break;
1309 EmitSignalDeactivateDialog();
1310 new SMESHGUI_ExtrusionDlg ( this );
1312 SUIT_MessageBox::warn1(desktop(),
1313 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1314 tr("SMESH_BUT_OK"));
1318 case 414: // Revolution
1320 if(checkLock(aStudy)) break;
1322 EmitSignalDeactivateDialog();
1323 new SMESHGUI_RevolutionDlg( this );
1326 SUIT_MessageBox::warn1(desktop(),
1327 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1328 tr("SMESH_BUT_OK"));
1332 case 415: // Pattern mapping
1334 if ( checkLock( aStudy ) )
1338 EmitSignalDeactivateDialog();
1339 new SMESHGUI_MeshPatternDlg( this );
1342 SUIT_MessageBox::warn1(desktop(),
1343 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1344 tr("SMESH_BUT_OK"));
1348 case 416: // Extrusion along a path
1350 if (checkLock(aStudy)) break;
1352 EmitSignalDeactivateDialog();
1353 new SMESHGUI_ExtrusionAlongPathDlg( this );
1355 SUIT_MessageBox::warn1(desktop(),
1356 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1357 tr("SMESH_BUT_OK"));
1361 case 417: // Convert mesh to quadratic
1363 startOperation( 417 );
1364 /* if (checkLock(aStudy)) break;
1366 EmitSignalDeactivateDialog();
1367 new SMESHGUI_ConvToQuadDlg();
1369 SUIT_MessageBox::warn1(desktop(),
1370 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1371 tr("SMESH_BUT_OK"));
1375 case 801: // CREATE GROUP
1379 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1380 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1384 if(checkLock(aStudy)) break;
1385 EmitSignalDeactivateDialog();
1386 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1388 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1389 SALOME_ListIO selected;
1391 aSel->selectedObjects( selected );
1393 int nbSel = selected.Extent();
1395 // check if mesh is selected
1396 aMesh = SMESH::GetMeshByIO( selected.First() );
1398 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1403 case 802: // CONSTRUCT GROUP
1407 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1408 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1412 if(checkLock(aStudy)) break;
1413 EmitSignalDeactivateDialog();
1415 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1416 SALOME_ListIO selected;
1418 aSel->selectedObjects( selected );
1420 int nbSel = selected.Extent();
1422 // check if submesh is selected
1423 Handle(SALOME_InteractiveObject) IObject = selected.First();
1424 if (IObject->hasEntry()) {
1425 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1427 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1428 if (!aSubMesh->_is_nil()) {
1430 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1431 // get submesh elements list by types
1432 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1433 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1434 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1435 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1436 // create group for each type o elements
1437 QString aName = IObject->getName();
1438 if (aNodes->length() > 0) {
1439 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1440 aGroup->Add(aNodes.inout());
1442 if (aEdges->length() > 0) {
1443 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1444 aGroup->Add(aEdges.inout());
1446 if (aFaces->length() > 0) {
1447 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1448 aGroup->Add(aFaces.inout());
1450 if (aVolumes->length() > 0) {
1451 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1452 aGroup->Add(aVolumes.inout());
1456 }catch(const SALOME::SALOME_Exception & S_ex){
1457 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1466 case 803: // EDIT GROUP
1470 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1471 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1475 if(checkLock(aStudy)) break;
1476 EmitSignalDeactivateDialog();
1478 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1479 SALOME_ListIO selected;
1481 aSel->selectedObjects( selected );
1483 SALOME_ListIteratorOfListIO It (selected);
1484 int nbSelectedGroups = 0;
1485 for ( ; It.More(); It.Next() )
1487 SMESH::SMESH_GroupBase_var aGroup =
1488 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1489 if (!aGroup->_is_nil()) {
1491 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1495 if (nbSelectedGroups == 0)
1497 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1503 case 804: // Add elements to group
1505 if(checkLock(aStudy)) break;
1506 if (myState == 800) {
1507 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1508 if (aDlg) aDlg->onAdd();
1513 case 805: // Remove elements from group
1515 if(checkLock(aStudy)) break;
1516 if (myState == 800) {
1517 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1518 if (aDlg) aDlg->onRemove();
1523 case 810: // Union Groups
1524 case 811: // Intersect groups
1525 case 812: // Cut groups
1529 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1530 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1534 if ( checkLock( aStudy ) )
1537 EmitSignalDeactivateDialog();
1540 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1541 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1542 else aMode = SMESHGUI_GroupOpDlg::CUT;
1544 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1548 case 813: // Delete groups with their contents
1552 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1553 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1557 if ( checkLock( aStudy ) )
1560 EmitSignalDeactivateDialog();
1562 new SMESHGUI_DeleteGroupDlg( this );
1566 case 900: // MESH INFOS
1568 EmitSignalDeactivateDialog();
1569 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1570 SALOME_ListIO selected;
1572 aSel->selectedObjects( selected );
1574 if ( selected.Extent() > 1 ) { // a dlg for each IO
1576 SALOME_ListIteratorOfListIO It (selected);
1577 for ( ; It.More(); It.Next() ) {
1578 IOs.Clear(); IOs.Append( It.Value() );
1579 aSel->setSelectedObjects( IOs );
1580 new SMESHGUI_MeshInfosDlg(this, "", false);
1582 // restore selection
1583 aSel->setSelectedObjects( selected );
1586 new SMESHGUI_MeshInfosDlg(this, "", false);
1590 case 902: // STANDARD MESH INFOS
1592 EmitSignalDeactivateDialog();
1593 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1594 SALOME_ListIO selected;
1596 aSel->selectedObjects( selected );
1598 if ( selected.Extent() > 1 ) { // a dlg for each IO
1600 SALOME_ListIteratorOfListIO It (selected);
1601 for ( ; It.More(); It.Next() ) {
1603 IOs.Append( It.Value() );
1604 aSel->setSelectedObjects( IOs );
1605 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1607 // restore selection
1608 aSel->setSelectedObjects( selected );
1611 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1615 case 1100: // EDIT HYPOTHESIS
1617 if(checkLock(aStudy)) break;
1619 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1620 SALOME_ListIO selected;
1622 aSel->selectedObjects( selected );
1624 int nbSel = selected.Extent();
1627 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1629 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1630 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1631 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1632 if ( !Hyp->_is_nil() )
1634 char* sName = Hyp->GetName();
1635 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1637 aCreator->edit( Hyp.in(), desktop() );
1644 updateObjBrowser( true );
1648 case 1101: // RENAME
1650 if ( checkLock( aStudy ) )
1653 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1654 SALOME_ListIO selected;
1656 aSel->selectedObjects( selected );
1658 SALOME_ListIteratorOfListIO It( selected );
1659 for ( ; It.More(); It.Next() )
1661 Handle(SALOME_InteractiveObject) IObject = It.Value();
1662 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1663 _PTR(GenericAttribute) anAttr;
1664 _PTR(AttributeName) aName;
1667 if ( obj->FindAttribute(anAttr, "AttributeName") )
1670 QString newName = QString(aName->Value().c_str());
1671 newName = LightApp_NameDlg::getName(desktop(), newName);
1672 if ( !newName.isEmpty() )
1674 //old source: aStudy->renameIObject( IObject, newName );
1675 aName->SetValue( newName.latin1() );
1677 // if current object is group update group's name
1678 SMESH::SMESH_GroupBase_var aGroup =
1679 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1680 if (!aGroup->_is_nil() )
1681 aGroup->SetName( newName.latin1() );
1691 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1693 if(checkLock(aStudy)) break;
1694 SUIT_OverrideCursor wc;
1696 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1697 SALOME_ListIO selected;
1699 aSel->selectedObjects( selected, QString::null, false );
1701 SALOME_ListIteratorOfListIO It(selected);
1702 for (int i = 0; It.More(); It.Next(), i++) {
1703 Handle(SALOME_InteractiveObject) IObject = It.Value();
1704 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1707 aSel->setSelectedObjects( l1 );
1712 case 401: // GEOM::EDGE
1713 case 4021: // TRIANGLE
1715 case 4023: // POLYGON
1719 if(checkLock(aStudy)) break;
1721 EmitSignalDeactivateDialog();
1722 SMDSAbs_ElementType type = SMDSAbs_Edge;
1724 switch (theCommandID) {
1725 case 4021: // TRIANGLE
1726 type = SMDSAbs_Face; nbNodes = 3; break;
1728 type = SMDSAbs_Face; nbNodes = 4; break;
1730 type = SMDSAbs_Volume; nbNodes = 4; break;
1731 case 4023: // POLYGON
1732 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1734 type = SMDSAbs_Volume; nbNodes = 8; break;
1735 case 4033: // POLYHEDRE
1736 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1739 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1742 SUIT_MessageBox::warn1(desktop(),
1743 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1744 tr("SMESH_BUT_OK"));
1748 case 4033: // POLYHEDRON
1750 if(checkLock(aStudy)) break;
1752 EmitSignalDeactivateDialog();
1753 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1756 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1757 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1758 tr("SMESH_BUT_OK"));
1762 case 4034: // QUADRATIC EDGE
1763 case 4035: // QUADRATIC TRIANGLE
1764 case 4036: // QUADRATIC QUADRANGLE
1765 case 4037: // QUADRATIC TETRAHEDRON
1766 case 4038: // QUADRATIC PYRAMID
1767 case 4039: // QUADRATIC PENTAHEDRON
1768 case 4040: // QUADRATIC HEXAHEDRON
1770 if(checkLock(aStudy)) break;
1772 EmitSignalDeactivateDialog();
1775 switch (theCommandID) {
1777 type = QUAD_EDGE; break;
1779 type = QUAD_TRIANGLE; break;
1781 type = QUAD_QUADRANGLE; break;
1783 type = QUAD_TETRAHEDRON; break;
1785 type = QUAD_PYRAMID; break;
1787 type = QUAD_PENTAHEDRON; break;
1789 type = QUAD_HEXAHEDRON;
1793 new SMESHGUI_AddQuadraticElementDlg( this, type );
1796 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1797 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1798 tr("SMESH_BUT_OK"));
1802 case 4041: // REMOVES NODES
1804 if(checkLock(aStudy)) break;
1806 EmitSignalDeactivateDialog();
1807 new SMESHGUI_RemoveNodesDlg(this);
1810 SUIT_MessageBox::warn1(desktop(),
1811 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1812 tr("SMESH_BUT_OK"));
1816 case 4042: // REMOVES ELEMENTS
1818 if(checkLock(aStudy)) break;
1820 EmitSignalDeactivateDialog();
1821 new SMESHGUI_RemoveElementsDlg(this);
1825 SUIT_MessageBox::warn1(desktop(),
1826 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1827 tr("SMESH_BUT_OK"));
1831 case 4051: // RENUMBERING NODES
1833 if(checkLock(aStudy)) break;
1835 EmitSignalDeactivateDialog();
1836 new SMESHGUI_RenumberingDlg( this, "", 0);
1840 SUIT_MessageBox::warn1(desktop(),
1841 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1842 tr("SMESH_BUT_OK"));
1846 case 4052: // RENUMBERING ELEMENTS
1848 if(checkLock(aStudy)) break;
1850 EmitSignalDeactivateDialog();
1851 new SMESHGUI_RenumberingDlg( this, "", 1);
1855 SUIT_MessageBox::warn1(desktop(),
1856 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1857 tr("SMESH_BUT_OK"));
1861 case 4061: // TRANSLATION
1863 if(checkLock(aStudy)) break;
1865 EmitSignalDeactivateDialog();
1866 new SMESHGUI_TranslationDlg( this );
1869 SUIT_MessageBox::warn1(desktop(),
1870 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1871 tr("SMESH_BUT_OK"));
1875 case 4062: // ROTATION
1877 if(checkLock(aStudy)) break;
1879 EmitSignalDeactivateDialog();
1880 new SMESHGUI_RotationDlg( this );
1883 SUIT_MessageBox::warn1(desktop(),
1884 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1885 tr("SMESH_BUT_OK"));
1889 case 4063: // SYMMETRY
1891 if(checkLock(aStudy)) break;
1893 EmitSignalDeactivateDialog();
1894 new SMESHGUI_SymmetryDlg( this );
1897 SUIT_MessageBox::warn1(desktop(),
1898 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1899 tr("SMESH_BUT_OK"));
1903 case 4064: // SEWING
1905 if(checkLock(aStudy)) break;
1907 EmitSignalDeactivateDialog();
1908 new SMESHGUI_SewingDlg( this );
1911 SUIT_MessageBox::warn1(desktop(),
1912 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1913 tr("SMESH_BUT_OK"));
1917 case 4065: // MERGE NODES
1919 if(checkLock(aStudy)) break;
1921 EmitSignalDeactivateDialog();
1922 new SMESHGUI_MergeNodesDlg( this );
1925 SUIT_MessageBox::warn1(desktop(),
1926 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1927 tr("SMESH_BUT_OK"));
1931 case 4066: // MERGE EQUAL ELEMENTS
1933 if (checkLock(aStudy)) break;
1935 EmitSignalDeactivateDialog();
1936 new SMESHGUI_EditMeshDlg(this,
1937 "SMESH_MERGE_ELEMENTS_TITLE",
1938 "ICON_DLG_MERGE_ELEMENTS",
1939 1); // MergeEqualElemets
1941 SUIT_MessageBox::warn1(desktop(),
1942 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1943 tr("SMESH_BUT_OK"));
1948 case 5105: // Library of selection filters
1950 static QValueList<int> aTypes;
1951 if ( aTypes.isEmpty() )
1953 aTypes.append( SMESH::NODE );
1954 aTypes.append( SMESH::EDGE );
1955 aTypes.append( SMESH::FACE );
1956 aTypes.append( SMESH::VOLUME );
1958 if (!myFilterLibraryDlg)
1959 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
1960 else if (myFilterLibraryDlg->isHidden())
1961 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
1962 myFilterLibraryDlg->raise();
1966 case 6017: // CONTROLS
1982 LightApp_SelectionMgr* mgr = selectionMgr();
1983 SALOME_ListIO selected; mgr->selectedObjects( selected );
1985 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
1986 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
1988 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1989 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
1990 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
1991 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
1992 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
1993 ::Control( theCommandID );
1998 SUIT_MessageBox::warn1(desktop(),
1999 tr( "SMESH_WRN_WARNING" ),
2000 tr( "SMESH_BAD_SELECTION" ),
2001 tr( "SMESH_BUT_OK" ) );
2005 SUIT_MessageBox::warn1(desktop(),
2006 tr( "SMESH_WRN_WARNING" ),
2007 tr( "NOT_A_VTK_VIEWER" ),
2008 tr( "SMESH_BUT_OK" ) );
2013 LightApp_SelectionMgr* mgr = selectionMgr();
2014 SALOME_ListIO selected; mgr->selectedObjects( selected );
2016 if (selected.Extent() == 1) {
2017 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2018 if(anIObject->hasEntry())
2019 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2020 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2027 LightApp_SelectionMgr* mgr = selectionMgr();
2028 SALOME_ListIO selected; mgr->selectedObjects( selected );
2030 if (selected.Extent() == 1) {
2031 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2032 if(anIObject->hasEntry())
2033 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2034 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2041 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2042 //updateObjBrowser();
2046 //=============================================================================
2050 //=============================================================================
2051 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2056 //=============================================================================
2060 //=============================================================================
2061 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2066 //=============================================================================
2070 //=============================================================================
2071 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2076 //=============================================================================
2077 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2078 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2080 //=============================================================================
2081 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2082 SUIT_ViewWindow* wnd )
2084 if(theIO->hasEntry()){
2085 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2086 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2090 //=======================================================================
2091 // function : createSMESHAction
2093 //=======================================================================
2094 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2097 QWidget* parent = application()->desktop();
2098 SUIT_ResourceMgr* resMgr = resourceMgr();
2100 if ( icon_id.length() )
2101 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2103 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2104 if ( !pix.isNull() )
2105 icon = QIconSet( pix );
2107 QString tooltip = tr( QString( "TOP_" )+po_id ),
2108 menu = tr( QString( "MEN_" )+po_id ),
2109 status_bar = tr( QString( "STB_" )+po_id );
2111 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2114 //=======================================================================
2115 // function : createPopupItem
2117 //=======================================================================
2118 void SMESHGUI::createPopupItem( const int id,
2119 const QString& clients,
2120 const QString& types,
2121 const QString& theRule,
2126 parentId = popupMgr()->actionId( action( pId ) );
2128 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2129 popupMgr()->insert( action( id ), parentId, 0 );
2131 QChar lc = QtxPopupMgr::Selection::defEquality();
2132 QString rule = "(%1) and (%2) and (%3)";
2133 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2134 if( clients.isEmpty() )
2135 rule = rule.arg( QString( "true" ) );
2137 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2138 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2141 bool cont = myRules.contains( id );
2143 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2145 popupMgr()->setRule( action( id ), rule, true );
2146 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2149 //=======================================================================
2150 // function : initialize
2152 //=======================================================================
2153 void SMESHGUI::initialize( CAM_Application* app )
2155 SalomeApp_Module::initialize( app );
2157 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2159 /* Automatic Update flag */
2160 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2162 // ----- create actions --------------
2164 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2165 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2166 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2167 createSMESHAction( 114, "NUM" );
2168 createSMESHAction( 121, "DAT" );
2169 createSMESHAction( 122, "MED" );
2170 createSMESHAction( 123, "UNV" );
2171 createSMESHAction( 124, "EXPORT_DAT" );
2172 createSMESHAction( 125, "EXPORT_MED" );
2173 createSMESHAction( 126, "EXPORT_UNV" );
2174 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2175 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2176 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2177 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2178 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2179 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2180 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2181 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2182 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2183 createSMESHAction( 804, "ADD" );
2184 createSMESHAction( 805, "REMOVE" );
2185 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2186 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2187 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2188 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2189 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2190 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2191 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2192 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2193 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2194 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2195 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2196 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2197 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2198 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2199 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2200 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2201 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2202 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2203 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2204 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2205 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2206 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2207 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2208 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2209 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2210 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2211 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2212 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2213 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2214 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2215 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2216 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2217 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2218 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2219 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2220 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2221 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2222 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2223 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2224 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2225 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2226 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2227 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2228 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2229 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2230 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2231 createSMESHAction( 415, "MAP", "ICON_MAP" );
2232 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2233 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2234 createSMESHAction( 200, "RESET" );
2235 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2236 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2237 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2238 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2239 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2240 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2241 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2242 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2243 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2244 createSMESHAction( 220, "ALL" );
2245 createSMESHAction( 1100, "EDIT_HYPO" );
2246 createSMESHAction( 1101, "RENAME" );
2247 createSMESHAction( 1102, "UNASSIGN" );
2248 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2249 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2250 createSMESHAction( 1131, "DISPMODE" );
2251 createSMESHAction( 1132, "COLORS" );
2252 createSMESHAction( 1133, "TRANSP" );
2253 createSMESHAction( 1134, "CLIP" );
2254 createSMESHAction( 1135, "DISP_ENT" );
2255 createSMESHAction( 2000, "CTRL" );
2257 createSMESHAction( 300, "ERASE" );
2258 createSMESHAction( 301, "DISPLAY" );
2259 createSMESHAction( 302, "DISPLAY_ONLY" );
2260 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2261 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2262 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2263 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2264 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2265 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2266 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2267 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2269 // ----- create menu --------------
2270 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2271 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2272 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2273 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2274 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2275 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2276 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2278 createMenu( separator(), fileId );
2280 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2281 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2282 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2283 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2284 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2285 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2287 createMenu( 111, importId, -1 );
2288 createMenu( 112, importId, -1 );
2289 createMenu( 113, importId, -1 );
2291 createMenu( 121, exportId, -1 );
2292 createMenu( 122, exportId, -1 );
2293 createMenu( 123, exportId, -1 );
2295 createMenu( separator(), fileId, 10 );
2297 createMenu( 33, editId, -1 );
2299 createMenu( 5105, toolsId, -1 );
2301 createMenu( 702, meshId, -1 );
2302 createMenu( 703, meshId, -1 );
2303 createMenu( 704, meshId, -1 );
2304 createMenu( separator(), meshId, -1 );
2305 createMenu( 701, meshId, -1 );
2306 createMenu( separator(), meshId, -1 );
2307 createMenu( 801, meshId, -1 );
2308 createMenu( 802, meshId, -1 );
2309 createMenu( 803, meshId, -1 );
2310 createMenu( separator(), meshId, -1 );
2311 createMenu( 810, meshId, -1 );
2312 createMenu( 811, meshId, -1 );
2313 createMenu( 812, meshId, -1 );
2314 createMenu( separator(), meshId, -1 );
2315 createMenu( 813, meshId, -1 );
2316 createMenu( separator(), meshId, -1 );
2317 createMenu( 900, meshId, -1 );
2318 createMenu( 902, meshId, -1 );
2319 createMenu( separator(), meshId, -1 );
2321 createMenu( 6003, ctrlId, -1 );
2322 createMenu( 6001, ctrlId, -1 );
2323 createMenu( 6004, ctrlId, -1 );
2324 createMenu( separator(), ctrlId, -1 );
2325 createMenu( 6002, ctrlId, -1 );
2326 createMenu( 6018, ctrlId, -1 );
2327 createMenu( 6019, ctrlId, -1 );
2328 createMenu( 6011, ctrlId, -1 );
2329 createMenu( 6012, ctrlId, -1 );
2330 createMenu( 6013, ctrlId, -1 );
2331 createMenu( 6014, ctrlId, -1 );
2332 createMenu( 6015, ctrlId, -1 );
2333 createMenu( 6016, ctrlId, -1 );
2334 createMenu( separator(), ctrlId, -1 );
2335 createMenu( 6017, ctrlId, -1 );
2336 createMenu( 6009, ctrlId, -1 );
2337 createMenu( separator(), ctrlId, -1 );
2339 createMenu( 400, addId, -1 );
2340 createMenu( 401, addId, -1 );
2341 createMenu( 4021, addId, -1 );
2342 createMenu( 4022, addId, -1 );
2343 createMenu( 4023, addId, -1 );
2344 createMenu( 4031, addId, -1 );
2345 createMenu( 4032, addId, -1 );
2346 createMenu( 4033, addId, -1 );
2347 createMenu( separator(), addId, -1 );
2348 createMenu( 4034, addId, -1 );
2349 createMenu( 4035, addId, -1 );
2350 createMenu( 4036, addId, -1 );
2351 createMenu( 4037, addId, -1 );
2352 createMenu( 4038, addId, -1 );
2353 createMenu( 4039, addId, -1 );
2354 createMenu( 4040, addId, -1 );
2356 createMenu( 4041, removeId, -1 );
2357 createMenu( 4042, removeId, -1 );
2359 createMenu( 4051, renumId, -1 );
2360 createMenu( 4052, renumId, -1 );
2362 createMenu( 4061, transfId, -1 );
2363 createMenu( 4062, transfId, -1 );
2364 createMenu( 4063, transfId, -1 );
2365 createMenu( 4064, transfId, -1 );
2366 createMenu( 4065, transfId, -1 );
2367 createMenu( 4066, transfId, -1 );
2369 createMenu( 406, modifyId, -1 );
2370 createMenu( 407, modifyId, -1 );
2371 createMenu( 408, modifyId, -1 );
2372 createMenu( 409, modifyId, -1 );
2373 createMenu( 410, modifyId, -1 );
2374 createMenu( 411, modifyId, -1 );
2375 createMenu( 412, modifyId, -1 );
2376 createMenu( 413, modifyId, -1 );
2377 createMenu( 416, modifyId, -1 );
2378 createMenu( 414, modifyId, -1 );
2379 createMenu( 415, modifyId, -1 );
2380 createMenu( 417, modifyId, -1 );
2382 createMenu( 214, viewId, -1 );
2384 // ----- create toolbars --------------
2385 int meshTb = createTool( tr( "TB_MESH" ) ),
2386 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2387 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2388 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2389 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2391 createTool( 702, meshTb );
2392 createTool( 703, meshTb );
2393 createTool( 704, meshTb );
2394 createTool( separator(), meshTb );
2395 createTool( 701, meshTb );
2396 createTool( separator(), meshTb );
2397 createTool( 801, meshTb );
2398 createTool( 802, meshTb );
2399 createTool( 803, meshTb );
2400 createTool( separator(), meshTb );
2401 createTool( 900, meshTb );
2402 createTool( 902, meshTb );
2403 createTool( separator(), meshTb );
2405 createTool( 6001, ctrlTb );
2406 createTool( 6003, ctrlTb );
2407 createTool( 6004, ctrlTb );
2408 createTool( separator(), ctrlTb );
2409 createTool( 6002, ctrlTb );
2410 createTool( 6018, ctrlTb );
2411 createTool( 6019, ctrlTb );
2412 createTool( 6011, ctrlTb );
2413 createTool( 6012, ctrlTb );
2414 createTool( 6013, ctrlTb );
2415 createTool( 6014, ctrlTb );
2416 createTool( 6015, ctrlTb );
2417 createTool( 6016, ctrlTb );
2418 createTool( separator(), ctrlTb );
2419 createTool( 6017, ctrlTb );
2420 createTool( 6009, ctrlTb );
2421 createTool( separator(), ctrlTb );
2423 createTool( 400, addRemTb );
2424 createTool( 401, addRemTb );
2425 createTool( 4021, addRemTb );
2426 createTool( 4022, addRemTb );
2427 createTool( 4023, addRemTb );
2428 createTool( 4031, addRemTb );
2429 createTool( 4032, addRemTb );
2430 createTool( 4033, addRemTb );
2431 createTool( separator(), addRemTb );
2432 createTool( 4034, addRemTb );
2433 createTool( 4035, addRemTb );
2434 createTool( 4036, addRemTb );
2435 createTool( 4037, addRemTb );
2436 createTool( 4038, addRemTb );
2437 createTool( 4039, addRemTb );
2438 createTool( 4040, addRemTb );
2439 createTool( separator(), addRemTb );
2440 createTool( 4041, addRemTb );
2441 createTool( 4042, addRemTb );
2442 createTool( separator(), addRemTb );
2443 createTool( 4051, addRemTb );
2444 createTool( 4052, addRemTb );
2445 createTool( separator(), addRemTb );
2446 createTool( 4061, addRemTb );
2447 createTool( 4062, addRemTb );
2448 createTool( 4063, addRemTb );
2449 createTool( 4064, addRemTb );
2450 createTool( 4065, addRemTb );
2451 createTool( 4066, addRemTb );
2452 createTool( separator(), addRemTb );
2454 createTool( 406, modifyTb );
2455 createTool( 407, modifyTb );
2456 createTool( 408, modifyTb );
2457 createTool( 409, modifyTb );
2458 createTool( 410, modifyTb );
2459 createTool( 411, modifyTb );
2460 createTool( 412, modifyTb );
2461 createTool( 413, modifyTb );
2462 createTool( 416, modifyTb );
2463 createTool( 414, modifyTb );
2464 createTool( 415, modifyTb );
2465 createTool( 417, modifyTb );
2467 createTool( 214, dispModeTb );
2471 QString OB = "'ObjectBrowser'",
2472 View = "'" + SVTK_Viewer::Type() + "'",
2474 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2475 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2476 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2477 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2478 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2479 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2480 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2481 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2482 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2483 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2484 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2486 mesh_group = mesh + " " + subMesh + " " + group,
2487 hyp_alg = hypo + " " + algo;
2489 // popup for object browser
2491 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2492 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2493 createPopupItem( 803, OB, group ); // EDIT_GROUP
2494 popupMgr()->insert( separator(), -1, 0 );
2495 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2496 createPopupItem( 214, OB, mesh_group ); // UPDATE
2497 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2498 createPopupItem( 902, OB, mesh ); // STD_INFO
2499 popupMgr()->insert( separator(), -1, 0 );
2500 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2501 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2502 popupMgr()->insert( separator(), -1, 0 );
2503 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2504 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2505 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2506 popupMgr()->insert( separator(), -1, 0 );
2508 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2509 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2510 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2511 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2512 popupMgr()->insert( separator(), -1, 0 );
2515 createPopupItem( 803, View, group ); // EDIT_GROUP
2516 createPopupItem( 804, View, elems ); // ADD
2517 createPopupItem( 805, View, elems ); // REMOVE
2518 popupMgr()->insert( separator(), -1, 0 );
2519 createPopupItem( 214, View, mesh_group ); // UPDATE
2520 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2521 createPopupItem( 902, View, mesh ); // STD_INFO
2522 popupMgr()->insert( separator(), -1, 0 );
2526 isInvisible("not( isVisible )"),
2527 isEmpty("numberOfNodes = 0"),
2528 isNotEmpty("numberOfNodes <> 0"),
2530 // has nodes, edges, etc in VISIBLE! actor
2531 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2532 hasElems("(count( elemTypes ) > 0)"),
2533 hasDifferentElems("(count( elemTypes ) > 1)"),
2534 hasEdges("({'Edge'} in elemTypes)"),
2535 hasFaces("({'Face'} in elemTypes)"),
2536 hasVolumes("({'Volume'} in elemTypes)");
2538 QString lc = QtxPopupMgr::Selection::defEquality();
2539 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2540 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2541 aType = aType.arg( mesh_group );
2542 QString aMeshInVTK = aClient + "&&" + aType;
2544 //-------------------------------------------------
2546 //-------------------------------------------------
2547 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2549 popupMgr()->insert( action( 9010 ), anId, -1 );
2550 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2551 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2553 popupMgr()->insert( action( 9011 ), anId, -1 );
2554 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2555 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2557 popupMgr()->insert( separator(), -1, -1 );
2559 //-------------------------------------------------
2561 //-------------------------------------------------
2562 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2564 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2565 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2566 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2568 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2569 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2570 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2572 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2573 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2574 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2576 popupMgr()->insert( separator(), anId, -1 );
2578 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2579 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2580 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2582 //-------------------------------------------------
2584 //-------------------------------------------------
2585 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2587 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2589 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2590 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2591 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2593 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2594 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2595 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2597 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2598 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2599 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2601 popupMgr()->insert( separator(), anId, -1 );
2603 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2604 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2606 //-------------------------------------------------
2608 //-------------------------------------------------
2609 popupMgr()->insert( action( 1132 ), -1, -1 );
2610 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2612 //-------------------------------------------------
2614 //-------------------------------------------------
2615 popupMgr()->insert( action( 1133 ), -1, -1 );
2616 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2618 //-------------------------------------------------
2620 //-------------------------------------------------
2621 popupMgr()->insert( action( 1134 ), -1, -1 );
2622 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2624 popupMgr()->insert( separator(), -1, -1 );
2626 //-------------------------------------------------
2628 //-------------------------------------------------
2630 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2631 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2632 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2634 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2636 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2637 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2639 popupMgr()->insert( separator(), anId, -1 );
2641 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2642 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2643 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2645 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2646 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2647 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2649 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2650 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2651 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2653 popupMgr()->insert( separator(), anId, -1 );
2655 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2656 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2657 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2659 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2660 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2661 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2663 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2664 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2665 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2667 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2668 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2669 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2671 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2672 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2673 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2675 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2676 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2677 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2679 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2680 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2681 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2683 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2684 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2685 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2687 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2688 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2689 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2691 popupMgr()->insert( separator(), anId, -1 );
2693 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2694 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2695 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2697 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2698 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2699 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2701 popupMgr()->insert( separator(), anId, -1 );
2703 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2704 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2706 popupMgr()->insert( separator(), -1, -1 );
2708 //-------------------------------------------------
2710 //-------------------------------------------------
2711 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2712 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2713 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2715 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2716 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2717 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2718 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2720 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2721 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2723 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2724 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2726 popupMgr()->insert( separator(), -1, -1 );
2728 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2729 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2732 bool SMESHGUI::activateModule( SUIT_Study* study )
2734 bool res = SalomeApp_Module::activateModule( study );
2736 setMenuShown( true );
2737 setToolShown( true );
2739 // Reset actions accelerator keys
2740 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
2741 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
2742 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
2747 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2749 setMenuShown( false );
2750 setToolShown( false );
2752 EmitSignalCloseAllDialogs();
2754 // Unset actions accelerator keys
2755 action(111)->setAccel(QKeySequence()); // Import DAT
2756 action(112)->setAccel(QKeySequence()); // Import UNV
2757 action(113)->setAccel(QKeySequence()); // Import MED
2759 return SalomeApp_Module::deactivateModule( study );
2762 void SMESHGUI::OnGUIEvent()
2764 const QObject* obj = sender();
2765 if ( !obj || !obj->inherits( "QAction" ) )
2767 int id = actionId((QAction*)obj);
2772 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2774 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2775 if ( CORBA::is_nil( myComponentSMESH ) )
2777 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2779 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2780 return aGUI.myComponentSMESH;
2783 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2784 return myComponentSMESH;
2787 QString SMESHGUI::engineIOR() const
2789 CORBA::ORB_var anORB = getApp()->orb();
2790 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2791 return QString( anIOR.in() );
2794 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2796 SMESHGUI_Selection sel;
2797 sel.init( client, selectionMgr() );
2798 popupMgr()->updatePopup( menu, &sel );
2801 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2803 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2804 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2807 void SMESHGUI::viewManagers( QStringList& list ) const
2809 list.append( SVTK_Viewer::Type() );
2812 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
2814 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
2815 SMESH::UpdateSelectionProp( this );
2818 void SMESHGUI::createPreferences()
2820 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2822 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2823 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
2825 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2826 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
2827 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
2829 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2830 setPreferenceProperty( precGroup, "columns", 1 );
2832 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2834 setPreferenceProperty( prec, "min", 0 );
2835 setPreferenceProperty( prec, "max", 16 );
2837 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2838 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
2840 modes.append( "Wireframe" );
2841 modes.append( "Shading" );
2842 modes.append( "Nodes" );
2843 modes.append( "Shrink" );
2844 QValueList<QVariant> indices;
2845 indices.append( 0 );
2846 indices.append( 1 );
2847 indices.append( 2 );
2848 indices.append( 3 );
2849 setPreferenceProperty( dispmode, "strings", modes );
2850 setPreferenceProperty( dispmode, "indexes", indices );
2852 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
2853 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
2855 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2856 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2858 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
2859 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
2861 setPreferenceProperty( nodeSz, "min", 1 );
2862 setPreferenceProperty( nodeSz, "max", 5 );
2864 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2866 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
2867 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
2868 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
2869 addPreference( "", elemGroup, LightApp_Preferences::Space );
2871 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
2872 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2874 setPreferenceProperty( elemW, "min", 1 );
2875 setPreferenceProperty( elemW, "max", 5 );
2877 setPreferenceProperty( shrink, "min", 0 );
2878 setPreferenceProperty( shrink, "max", 100 );
2880 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2882 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2884 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
2885 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
2886 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
2888 setPreferenceProperty( selW, "min", 1 );
2889 setPreferenceProperty( selW, "max", 5 );
2891 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2893 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
2894 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2896 setPreferenceProperty( preW, "min", 1 );
2897 setPreferenceProperty( preW, "max", 5 );
2899 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2901 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
2902 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
2904 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2905 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2907 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2908 addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2909 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2910 addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
2913 fam.append( tr( "SMESH_FONT_ARIAL" ) );
2914 fam.append( tr( "SMESH_FONT_COURIER" ) );
2915 fam.append( tr( "SMESH_FONT_TIMES" ) );
2916 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2918 setPreferenceProperty( tfont, "families", fam );
2919 setPreferenceProperty( tfont, "system", false );
2920 setPreferenceProperty( tfont, "widget_flags", wflag );
2921 setPreferenceProperty( lfont, "families", fam );
2922 setPreferenceProperty( lfont, "system", false );
2923 setPreferenceProperty( lfont, "widget_flags", wflag );
2925 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
2927 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
2928 setPreferenceProperty( numcol, "min", 2 );
2929 setPreferenceProperty( numcol, "max", 256 );
2931 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
2932 setPreferenceProperty( numlab, "min", 2 );
2933 setPreferenceProperty( numlab, "max", 65 );
2935 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
2936 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2937 QStringList orients;
2938 orients.append( tr( "SMESH_VERTICAL" ) );
2939 orients.append( tr( "SMESH_HORIZONTAL" ) );
2940 indices.clear(); indices.append( 0 ); indices.append( 1 );
2941 setPreferenceProperty( orient, "strings", orients );
2942 setPreferenceProperty( orient, "indexes", indices );
2944 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
2945 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2946 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2947 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2948 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
2949 setPreferenceProperty( xv, "step", 0.1 );
2950 setPreferenceProperty( xv, "min", 0.0 );
2951 setPreferenceProperty( xv, "max", 1.0 );
2952 setPreferenceProperty( yv, "step", 0.1 );
2953 setPreferenceProperty( yv, "min", 0.0 );
2954 setPreferenceProperty( yv, "max", 1.0 );
2955 setPreferenceProperty( wv, "step", 0.1 );
2956 setPreferenceProperty( wv, "min", 0.0 );
2957 setPreferenceProperty( wv, "max", 1.0 );
2958 setPreferenceProperty( hv, "min", 0.0 );
2959 setPreferenceProperty( hv, "max", 1.0 );
2960 setPreferenceProperty( hv, "step", 0.1 );
2962 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
2963 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
2964 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
2965 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
2966 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
2967 setPreferenceProperty( xv, "min", 0.0 );
2968 setPreferenceProperty( xv, "max", 1.0 );
2969 setPreferenceProperty( xv, "step", 0.1 );
2970 setPreferenceProperty( xh, "min", 0.0 );
2971 setPreferenceProperty( xh, "max", 1.0 );
2972 setPreferenceProperty( xh, "step", 0.1 );
2973 setPreferenceProperty( yh, "min", 0.0 );
2974 setPreferenceProperty( yh, "max", 1.0 );
2975 setPreferenceProperty( yh, "step", 0.1 );
2976 setPreferenceProperty( wh, "min", 0.0 );
2977 setPreferenceProperty( wh, "max", 1.0 );
2978 setPreferenceProperty( wh, "step", 0.1 );
2979 setPreferenceProperty( hh, "min", 0.0 );
2980 setPreferenceProperty( hh, "max", 1.0 );
2981 setPreferenceProperty( hh, "step", 0.1 );
2984 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
2986 if( sect=="SMESH" ){
2987 float sbX1,sbY1,sbW,sbH;
2988 float aTol = 1.00000009999999;
2989 std::string aWarning;
2990 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2991 if( name=="selection_object_color" || name=="selection_element_color" ||
2992 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
2993 name=="selection_precision_node" || name=="selection_precision_element" )
2994 SMESH::UpdateSelectionProp( this );
2995 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
2996 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
2997 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
2998 if(sbX1+sbW > aTol){
2999 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3000 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3001 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3004 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3005 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3006 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3007 if(sbY1+sbH > aTol){
3008 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3009 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3010 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3013 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3014 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3015 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3016 if(sbX1+sbW > aTol){
3017 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3020 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3021 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3024 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3025 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3026 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3027 if(sbY1+sbH > aTol){
3028 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3031 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3032 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3036 if(aWarning.size() != 0){
3037 aWarning += "The default values are applied instead.";
3038 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3039 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3040 QObject::tr(aWarning.c_str()),
3041 QObject::tr("SMESH_BUT_OK"));
3046 //================================================================================
3048 * \brief Update something in accordance with update flags
3049 * \param theFlags - update flags
3051 * Update viewer or/and object browser etc. in accordance with update flags ( see
3052 * LightApp_UpdateFlags enumeration ).
3054 //================================================================================
3055 void SMESHGUI::update( const int flags )
3057 if ( flags & UF_Viewer | flags & UF_Forced )
3058 SMESH::UpdateView();
3060 SalomeApp_Module::update( flags );
3063 //================================================================================
3065 * \brief Set default selection mode
3067 * SLOT called when operation commited. Sets default selection mode
3069 //================================================================================
3070 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3072 SVTK_ViewWindow* vtkWnd =
3073 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3075 vtkWnd->SetSelectionMode( ActorSelection );
3078 //================================================================================
3080 * \brief Set default selection mode
3082 * SLOT called when operation aborted. Sets default selection mode
3084 //================================================================================
3085 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3087 SVTK_ViewWindow* vtkWnd =
3088 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3090 vtkWnd->SetSelectionMode( ActorSelection );
3093 //================================================================================
3095 * \brief Creates operation with given identifier
3096 * \param id - identifier of operation to be started
3097 * \return Pointer on created operation or NULL if operation is not created
3099 * Virtual method redefined from the base class creates operation with given id.
3100 * It is called called automatically from startOperation method of base class.
3102 //================================================================================
3103 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3105 LightApp_Operation* op = 0;
3106 // to do : create operation here
3109 case 702: // Create mesh
3110 op = new SMESHGUI_MeshOp( true, true );
3112 case 703: // Create sub-mesh
3113 op = new SMESHGUI_MeshOp( true, false );
3115 case 704: // Edit mesh/sub-mesh
3116 op = new SMESHGUI_MeshOp( false );
3118 case 417: //convert to quadratic
3119 op = new SMESHGUI_ConvToQuadOp();
3126 op = SalomeApp_Module::createOperation( id );
3130 //================================================================================
3132 * \brief Stops current operations and starts a given one
3133 * \param id - The id of the operation to start
3135 //================================================================================
3137 void SMESHGUI::switchToOperation(int id)
3139 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3140 activeStudy()->abortAllOperations();
3141 startOperation( id );
3144 LightApp_Displayer* SMESHGUI::displayer()
3147 myDisplayer = new SMESHGUI_Displayer( getApp() );
3151 void SMESHGUI::OnEditDelete()
3153 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
3154 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
3155 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
3157 QString aParentComponent = QString::null;
3158 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
3160 QString cur = anIt.Value()->getComponentDataType();
3161 if( aParentComponent.isNull() )
3162 aParentComponent = cur;
3163 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
3164 aParentComponent = "";
3167 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
3168 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
3169 QObject::tr("ERR_ERROR"),
3170 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
3171 QObject::tr("BUT_OK") );
3174 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
3175 if (SUIT_MessageBox::warn2
3176 (SMESHGUI::desktop(),
3177 QObject::tr("SMESH_WRN_WARNING"),
3178 QObject::tr("SMESH_REALLY_DELETE"),
3179 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
3182 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3183 SUIT_ViewManager* vm = anApp->activeViewManager();
3184 int nbSf = vm->getViewsCount();
3186 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
3187 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
3188 _PTR(GenericAttribute) anAttr;
3189 _PTR(AttributeIOR) anIOR;
3191 SALOME_ListIteratorOfListIO It(selected);
3193 aStudyBuilder->NewCommand(); // There is a transaction
3194 for(; It.More(); It.Next()){ // loop on selected IO's
3195 Handle(SALOME_InteractiveObject) IObject = It.Value();
3196 if(IObject->hasEntry()) {
3197 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
3199 // disable removal of "SMESH" component object
3200 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
3202 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
3206 // put the whole hierarchy of sub-objects of the selected SO into a list and
3207 // then treat them all starting from the deepest objects (at list back)
3209 list< _PTR(SObject) > listSO;
3210 listSO.push_back( aSO );
3211 list< _PTR(SObject) >::iterator itSO = listSO.begin();
3212 for ( ; itSO != listSO.end(); ++itSO ) {
3213 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
3214 for (it->InitEx(false); it->More(); it->Next())
3215 listSO.push_back( it->Value() );
3218 // treat SO's in the list starting from the back
3220 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
3221 for ( ; ritSO != listSO.rend(); ++ritSO ) {
3222 _PTR(SObject) SO = *ritSO;
3223 if ( !SO ) continue;
3224 string anEntry = SO->GetID();
3226 /** Erase graphical object **/
3227 if(SO->FindAttribute(anAttr, "AttributeIOR")){
3228 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
3229 for(int i = 0; i < nbSf; i++){
3230 SUIT_ViewWindow *sf = aViews[i];
3231 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
3232 SMESH::RemoveActor(sf,anActor);
3237 /** Remove an object from data structures **/
3238 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
3239 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
3240 if ( !aGroup->_is_nil() ) { // DELETE GROUP
3241 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
3242 aMesh->RemoveGroup( aGroup );
3244 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
3245 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
3246 aMesh->RemoveSubMesh( aSubMesh );
3248 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
3250 SMESH::ModifiedMesh(aMeshSO, false);
3253 IObject = new SALOME_InteractiveObject
3254 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
3255 QString objType = CheckTypeObject(IObject);
3256 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
3257 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3258 aStudyBuilder->RemoveObjectWithChildren( SO );
3260 else {// default action: remove SObject from the study
3261 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
3262 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
3264 aStudyBuilder->RemoveObjectWithChildren( SO );
3268 } /* listSO back loop */
3269 } /* IObject->hasEntry() */
3271 aStudyBuilder->CommitCommand();
3273 /* Clear any previous selection */
3275 aSel->setSelectedObjects( l1 );
3277 SMESHGUI::GetSMESHGUI()->updateObjBrowser();