1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESHGUI_NodesDlg.h"
30 #include "SMESHGUI_TransparencyDlg.h"
31 #include "SMESHGUI_ClippingDlg.h"
32 #include "SMESHGUI_GroupDlg.h"
33 #include "SMESHGUI_RemoveNodesDlg.h"
34 #include "SMESHGUI_RemoveElementsDlg.h"
35 #include "SMESHGUI_MeshInfosDlg.h"
36 #include "SMESHGUI_StandardMeshInfosDlg.h"
37 #include "SMESHGUI_Preferences_ColorDlg.h"
38 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
39 #include "SMESHGUI_Preferences_SelectionDlg.h"
40 #include "SMESHGUI_Hypotheses.h"
41 #include "SMESHGUI_MoveNodesDlg.h"
42 #include "SMESHGUI_AddMeshElementDlg.h"
43 #include "SMESHGUI_EditHypothesesDlg.h"
44 #include "SMESHGUI_CreateHypothesesDlg.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_PrecisionDlg.h"
64 #include "SMESHGUI_Selection.h"
65 #include "SMESHGUI_CreatePolyhedralVolumeDlg.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 "LightApp_DataOwner.h"
87 #include "LightApp_Preferences.h"
88 #include "LightApp_VTKSelector.h"
89 #include "LightApp_Operation.h"
90 #include "LightApp_UpdateFlags.h"
92 #include "SalomeApp_ImportOperation.h"
94 #include <SVTK_ViewWindow.h>
95 #include <SVTK_ViewModel.h>
96 #include <SVTK_InteractorStyle.h>
97 #include <SVTK_RenderWindowInteractor.h>
98 #include <SVTK_ViewManager.h>
100 #include "OB_Browser.h"
102 #include "SUIT_Tools.h"
103 #include "SUIT_MessageBox.h"
104 #include "SUIT_ResourceMgr.h"
105 #include "SUIT_FileDlg.h"
106 #include "SUIT_Desktop.h"
107 #include "SUIT_OverrideCursor.h"
108 #include "SUIT_Study.h"
109 #include "SUIT_Session.h"
111 #include "QtxPopupMgr.h"
113 #include "SALOME_ListIO.hxx"
114 #include "SALOME_ListIteratorOfListIO.hxx"
115 #include "SALOME_InteractiveObject.hxx"
116 #include "SALOME_NamingService.hxx"
117 #include "SALOME_LifeCycleCORBA.hxx"
119 #include "SALOMEconfig.h"
120 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
123 #define INCLUDE_MENUITEM_DEF
124 #include <qpopupmenu.h>
128 #include <qinputdialog.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 ) {
263 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
264 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
268 aFilter = QObject::tr("DAT files (*.dat)");
272 if(aMesh->NbPyramids()){
273 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
274 QObject::tr("SMESH_WRN_WARNING"),
275 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
276 QObject::tr("SMESH_BUT_YES"),
277 QObject::tr("SMESH_BUT_NO"),
282 aFilter = QObject::tr("IDEAS files (*.unv)");
289 SMESH::MED_VERSION aFormat;
290 // Init the parameter with the default value
291 bool toCreateGroups = false;
292 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
294 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
296 if ( theCommandID != 122 && theCommandID != 125 )
297 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
301 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
302 filters.push_back( it.key() );
304 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
305 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
306 fd->setCaption( aTitle );
307 fd->setFilters( filters );
308 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
309 fd->SetChecked(toCreateGroups);
313 aFilename = fd->selectedFile();
314 aFormat = aFilterMap[fd->selectedFilter()];
316 if( !aFilename.isEmpty()
317 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
318 && aFormat==SMESH::MED_V2_1){
319 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
320 QObject::tr("SMESH_WRN_WARNING"),
321 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
322 QObject::tr("SMESH_BUT_YES"),
323 QObject::tr("SMESH_BUT_NO"),
330 toCreateGroups = fd->IsChecked();
333 if ( !aFilename.isEmpty() ) {
334 // Check whether the file already exists and delete it if yes
335 QFile aFile( aFilename );
336 if ( aFile.exists() )
338 SUIT_OverrideCursor wc;
339 switch ( theCommandID ) {
342 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
346 aMesh->ExportDAT( aFilename.latin1() );
350 aMesh->ExportUNV( aFilename.latin1() );
360 inline void InverseEntityMode(unsigned int& theOutputMode,
361 unsigned int theMode)
363 bool anIsNotPresent = ~theOutputMode & theMode;
365 theOutputMode |= theMode;
367 theOutputMode &= ~theMode;
370 void SetDisplayEntity(int theCommandID){
371 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
372 SALOME_ListIO selected;
374 aSel->selectedObjects( selected );
376 if(selected.Extent() >= 1){
377 SALOME_ListIteratorOfListIO It( selected );
378 for(; It.More(); It.Next()){
379 Handle(SALOME_InteractiveObject) IObject = It.Value();
380 if(IObject->hasEntry()){
381 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
382 unsigned int aMode = anActor->GetEntityMode();
383 switch(theCommandID){
385 InverseEntityMode(aMode,SMESH_Actor::eEdges);
388 InverseEntityMode(aMode,SMESH_Actor::eFaces);
391 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
394 aMode = SMESH_Actor::eAllEntity;
398 anActor->SetEntityMode(aMode);
405 void SetDisplayMode(int theCommandID){
406 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
407 SALOME_ListIO selected;
409 aSel->selectedObjects( selected );
411 if(selected.Extent() >= 1){
412 switch(theCommandID){
414 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
415 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
419 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
420 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
423 SALOME_ListIteratorOfListIO It( selected );
424 for(; It.More(); It.Next()){
425 Handle(SALOME_InteractiveObject) IObject = It.Value();
426 if(IObject->hasEntry()){
427 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
428 switch(theCommandID){
430 anActor->SetRepresentation(SMESH_Actor::eEdge);
433 anActor->SetRepresentation(SMESH_Actor::eSurface);
436 if(anActor->IsShrunk())
439 anActor->SetShrink();
442 anActor->SetRepresentation(SMESH_Actor::ePoint);
446 anActor->GetSufaceColor(color[0], color[1], color[2]);
447 int c0 = int (color[0] * 255);
448 int c1 = int (color[1] * 255);
449 int c2 = int (color[2] * 255);
450 QColor c(c0, c1, c2);
453 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
454 c0 = int (edgecolor[0] * 255);
455 c1 = int (edgecolor[1] * 255);
456 c2 = int (edgecolor[2] * 255);
457 QColor e(c0, c1, c2);
459 float backfacecolor[3];
460 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
461 c0 = int (backfacecolor[0] * 255);
462 c1 = int (backfacecolor[1] * 255);
463 c2 = int (backfacecolor[2] * 255);
464 QColor b(c0, c1, c2);
467 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
468 c0 = int (nodecolor[0] * 255);
469 c1 = int (nodecolor[1] * 255);
470 c2 = int (nodecolor[2] * 255);
471 QColor n(c0, c1, c2);
473 int Edgewidth = (int)anActor->GetLineWidth();
476 int intValue = int(anActor->GetNodeSize());
477 float Shrink = anActor->GetShrinkFactor();
479 SMESHGUI_Preferences_ColorDlg *aDlg =
480 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
481 aDlg->SetColor(1, c);
482 aDlg->SetColor(2, e);
483 aDlg->SetColor(3, n);
484 aDlg->SetColor(4, b);
485 aDlg->SetIntValue(1, Edgewidth);
486 aDlg->SetIntValue(2, intValue);
487 aDlg->SetIntValue(3, int(Shrink*100.));
489 QColor color = aDlg->GetColor(1);
490 QColor edgecolor = aDlg->GetColor(2);
491 QColor nodecolor = aDlg->GetColor(3);
492 QColor backfacecolor = aDlg->GetColor(4);
493 /* actor color and backface color */
494 anActor->SetSufaceColor(float (color.red()) / 255.,
495 float (color.green()) / 255.,
496 float (color.blue()) / 255.);
497 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
498 float (backfacecolor.green()) / 255.,
499 float (backfacecolor.blue()) / 255.);
502 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
503 float (edgecolor.green()) / 255.,
504 float (edgecolor.blue()) / 255.);
506 /* Shrink factor and size edges */
507 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
508 anActor->SetLineWidth(aDlg->GetIntValue(1));
510 /* Nodes color and size */
511 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
512 float (nodecolor.green()) / 255.,
513 float (nodecolor.blue()) / 255.);
514 anActor->SetNodeSize(aDlg->GetIntValue(2));
523 SMESH::RepaintCurrentView();
527 void Control( int theCommandID )
529 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
530 SALOME_ListIO selected;
532 aSel->selectedObjects( selected );
534 if( !selected.IsEmpty() ){
535 Handle(SALOME_InteractiveObject) anIO = selected.First();
538 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
539 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
540 switch ( theCommandID ){
542 aTitle = QObject::tr( "LENGTH_EDGES" );
543 aControl = SMESH_Actor::eLength;
546 aTitle = QObject::tr( "LENGTH2D_EDGES" );
547 aControl = SMESH_Actor::eLength2D;
550 aTitle = QObject::tr( "FREE_EDGES" );
551 aControl = SMESH_Actor::eFreeEdges;
554 aTitle = QObject::tr( "FREE_BORDERS" );
555 aControl = SMESH_Actor::eFreeBorders;
558 aTitle = QObject::tr( "MULTI_BORDERS" );
559 aControl = SMESH_Actor::eMultiConnection;
562 aTitle = QObject::tr( "MULTI2D_BORDERS" );
563 aControl = SMESH_Actor::eMultiConnection2D;
566 aTitle = QObject::tr( "AREA_ELEMENTS" );
567 aControl = SMESH_Actor::eArea;
570 aTitle = QObject::tr( "TAPER_ELEMENTS" );
571 aControl = SMESH_Actor::eTaper;
574 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
575 aControl = SMESH_Actor::eAspectRatio;
578 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
579 aControl = SMESH_Actor::eAspectRatio3D;
582 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
583 aControl = SMESH_Actor::eMinimumAngle;
586 aTitle = QObject::tr( "WARP_ELEMENTS" );
587 aControl = SMESH_Actor::eWarping;
590 aTitle = QObject::tr( "SKEW_ELEMENTS" );
591 aControl = SMESH_Actor::eSkew;
594 aTitle = QObject::tr( "SMESH_VOLUME" );
595 aControl = SMESH_Actor::eVolume3D;
598 anActor->SetControlMode(aControl);
599 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
600 SMESH::RepaintCurrentView();
607 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
608 MeshObjectType theType,
609 const QString theInTypeName,
610 QString & theOutTypeName)
612 SMESH_TypeFilter aTypeFilter( theType );
614 if( !theIO.IsNull() )
616 entry = theIO->getEntry();
617 LightApp_DataOwner owner( entry );
618 if ( aTypeFilter.isOk( &owner )) {
619 theOutTypeName = theInTypeName;
627 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
629 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
630 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
632 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
633 CORBA::String_var anID = aSComp->GetID().c_str();
634 if (!strcmp(anID.in(),theIO->getEntry()))
640 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
641 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
642 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
643 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
644 CheckOIType ( theIO, GROUP, "Group", aTypeName )
652 QString CheckHomogeneousSelection()
654 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
655 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
656 SALOME_ListIO selected;
658 aSel->selectedObjects( selected );
660 QString RefType = CheckTypeObject(selected.First());
661 SALOME_ListIteratorOfListIO It(selected);
662 for (; It.More(); It.Next())
664 Handle(SALOME_InteractiveObject) IObject = It.Value();
665 QString Type = CheckTypeObject(IObject);
666 if (Type.compare(RefType) != 0)
667 return "Heterogeneous Selection";
675 Standard_EXPORT CAM_Module* createModule()
677 return new SMESHGUI();
681 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
683 //=============================================================================
687 //=============================================================================
688 SMESHGUI::SMESHGUI() :
689 SalomeApp_Module( "SMESH" )
691 if ( CORBA::is_nil( myComponentSMESH ) )
693 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
694 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
695 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
698 myActiveDialogBox = 0;
702 SMESH::GetFilterManager();
705 /* load resources for all available meshers */
706 SMESH::InitAvailableHypotheses();
709 //=============================================================================
713 //=============================================================================
714 SMESHGUI::~SMESHGUI()
716 SMESH::GetFilterManager()->Destroy();
717 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
720 //=============================================================================
724 //=============================================================================
725 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
727 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
729 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
734 bool SMESHGUI::automaticUpdate()
736 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
740 return resMgr->booleanValue( "SMESH", "auto_update", false );
743 //=============================================================================
747 //=============================================================================
748 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
750 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
753 //=============================================================================
757 //=============================================================================
758 SMESHGUI* SMESHGUI::GetSMESHGUI()
760 SMESHGUI* smeshMod = 0;
761 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
764 CAM_Module* module = app->module( "Mesh" );
765 smeshMod = dynamic_cast<SMESHGUI*>( module );
768 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
770 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
773 _PTR(Study) aStudy = study->studyDS();
775 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
784 Standard_EXPORT SMESHGUI* GetComponentGUI()
786 return SMESHGUI::GetSMESHGUI();
790 //=============================================================================
794 //=============================================================================
795 void SMESHGUI::SetState(int aState)
800 //=============================================================================
804 //=============================================================================
805 void SMESHGUI::ResetState()
810 //=============================================================================
814 //=============================================================================
815 void SMESHGUI::EmitSignalDeactivateDialog()
817 emit SignalDeactivateActiveDialog();
820 //=============================================================================
824 //=============================================================================
825 void SMESHGUI::EmitSignalStudyFrameChanged()
827 emit SignalStudyFrameChanged();
830 //=============================================================================
834 //=============================================================================
835 void SMESHGUI::EmitSignalCloseAllDialogs()
837 emit SignalCloseAllDialogs();
840 //=============================================================================
844 //=============================================================================
845 QDialog *SMESHGUI::GetActiveDialogBox()
847 return myActiveDialogBox;
850 //=============================================================================
854 //=============================================================================
855 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
857 myActiveDialogBox = (QDialog *) aDlg;
861 //=============================================================================
865 //=============================================================================
866 SUIT_Desktop* SMESHGUI::desktop()
868 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
870 return app->desktop();
875 //=============================================================================
879 //=============================================================================
880 SalomeApp_Study* SMESHGUI::activeStudy()
882 SUIT_Application* app = SUIT_Session::session()->activeApplication();
884 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
889 //=============================================================================
893 //=============================================================================
894 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
896 /* Here the position is on the bottom right corner - 10 */
897 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
899 SUIT_Desktop *PP = desktop();
900 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
901 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
905 //=============================================================================
909 //=============================================================================
910 static int isStudyLocked(_PTR(Study) theStudy){
911 return theStudy->GetProperties()->IsLocked();
914 static bool checkLock(_PTR(Study) theStudy) {
915 if (isStudyLocked(theStudy)) {
916 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
917 QObject::tr("WRN_WARNING"),
918 QObject::tr("WRN_STUDY_LOCKED"),
919 QObject::tr("BUT_OK") );
925 //=======================================================================
926 //function : CheckActiveStudyLocked
928 //=======================================================================
930 bool SMESHGUI::isActiveStudyLocked()
932 _PTR(Study) aStudy = activeStudy()->studyDS();
933 return checkLock( aStudy );
936 //=============================================================================
940 //=============================================================================
941 bool SMESHGUI::OnGUIEvent( int theCommandID )
943 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
947 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
948 SUIT_ResourceMgr* mgr = resourceMgr();
952 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
953 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
956 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
957 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
959 //QAction* act = action( theCommandID );
961 switch (theCommandID) {
963 if(checkLock(aStudy)) break;
971 if(checkLock(aStudy)) break;
972 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
976 case 122: // EXPORT MED
983 ::ExportMeshToFile(theCommandID);
987 case 200: // SCALAR BAR
989 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
990 SALOME_ListIO selected;
992 aSel->selectedObjects( selected );
994 if( selected.Extent() ) {
995 Handle(SALOME_InteractiveObject) anIO = selected.First();
996 if( anIO->hasEntry() ) {
997 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
998 anActor->SetControlMode( SMESH_Actor::eNone );
1006 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1010 case 1134: // Clipping
1011 case 1133: // Tranparency
1012 case 1132: // Colors / Size
1019 ::SetDisplayMode(theCommandID);
1025 case 219: // Volumes
1026 case 220: // All Entity
1027 ::SetDisplayEntity(theCommandID);
1032 if(checkLock(aStudy)) break;
1033 SMESH::UpdateView();
1036 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1037 aSel->selectedObjects( l );
1038 aSel->setSelectedObjects( l );
1043 case 301: // DISPLAY
1044 case 302: // DISPLAY ONLY
1046 SMESH::EDisplaing anAction;
1047 switch (theCommandID) {
1048 case 300: anAction = SMESH::eErase; break;
1049 case 301: anAction = SMESH::eDisplay; break;
1050 case 302: anAction = SMESH::eDisplayOnly; break;
1053 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1054 SALOME_ListIO sel_objects, to_process;
1056 aSel->selectedObjects( sel_objects );
1058 if( theCommandID==302 )
1059 startOperation( myEraseAll );
1061 extractContainers( sel_objects, to_process );
1064 SALOME_ListIteratorOfListIO It( to_process );
1065 for (; It.More(); It.Next()) {
1066 Handle(SALOME_InteractiveObject) IOS = It.Value();
1067 if (IOS->hasEntry()) {
1068 SMESH::UpdateView(anAction, IOS->getEntry());
1069 if (anAction == SMESH::eDisplayOnly)
1070 anAction = SMESH::eDisplay;
1075 if (anAction == SMESH::eErase) {
1077 aSel->setSelectedObjects( l1 );
1080 aSel->setSelectedObjects( to_process );
1086 if(checkLock(aStudy)) break;
1089 EmitSignalDeactivateDialog();
1091 new SMESHGUI_NodesDlg(this);
1094 SUIT_MessageBox::warn1(desktop(),
1095 tr("SMESH_WRN_WARNING"),
1096 tr("SMESH_WRN_VIEWER_VTK"),
1097 tr("SMESH_BUT_OK"));
1102 case 2151: // FILTER
1106 EmitSignalDeactivateDialog();
1107 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1112 case 406: // MOVE NODE
1116 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1117 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1121 if(checkLock(aStudy)) break;
1122 new SMESHGUI_MoveNodesDlg(this);
1126 case 701: // COMPUTE MESH
1128 if(checkLock(aStudy)) break;
1130 LightApp_SelectionMgr *Sel = selectionMgr();
1131 SALOME_ListIO selected; Sel->selectedObjects( selected );
1134 int nbSel = selected.Extent();
1139 SMESH::SMESH_Mesh_var aMesh;
1140 SMESH::SMESH_subMesh_var aSubMesh;
1141 Handle(SALOME_InteractiveObject) IObject = selected.First();
1142 if (IObject->hasEntry()) {
1143 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1144 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1145 if ( aShapeObject->_is_nil() ) {
1150 aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1151 aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1152 if ( !aSubMesh->_is_nil() )
1153 aMesh = aSubMesh->GetFather();
1155 if (!aMesh->_is_nil()) {
1156 // if(!GetSMESHGen()->IsReadyToCompute(aMesh,aShapeObject)) {
1157 // SUIT_MessageBox::warn1(desktop(),
1158 // tr("SMESH_WRN_WARNING"),
1159 // tr("SMESH_WRN_MISSING_PARAMETERS"),
1160 // tr("SMESH_BUT_OK"));
1163 SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1164 if ( errors->length() > 0 ) {
1165 SUIT_MessageBox::warn1(desktop(),
1166 tr("SMESH_WRN_WARNING"),
1167 SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1168 tr("SMESH_BUT_OK"));
1172 if (GetSMESHGen()->Compute(aMesh,aShapeObject))
1173 SMESH::ModifiedMesh(aMeshSObj,true);
1175 SUIT_MessageBox::warn1(desktop(),
1176 tr("SMESH_WRN_WARNING"),
1177 tr("SMESH_WRN_COMPUTE_FAILED"),
1178 tr("SMESH_BUT_OK"));
1180 catch(const SALOME::SALOME_Exception & S_ex){
1181 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1186 CORBA::Long anId = aStudy->StudyId();
1187 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1188 if ( automaticUpdate() && aVisualObj){
1189 aVisualObj->Update();
1190 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1192 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1194 SMESH::DisplayActor(view,anActor); //apo
1198 SMESH::RepaintCurrentView();
1201 SUIT_MessageBox::warn1(desktop(),
1202 tr("SMESH_WRN_WARNING"),
1203 tr("SMESH_WRN_VIEWER_VTK"),
1204 tr("SMESH_BUT_OK"));
1207 Sel->setSelectedObjects( selected );
1211 case 702: // Create mesh
1212 startOperation( 702 );
1214 case 703: // Create sub-mesh
1215 startOperation( 703 );
1217 case 704: // Edit mesh/sub-mesh
1218 startOperation( 704 );
1220 case 407: // DIAGONAL INVERSION
1221 case 408: // Delete diagonal
1225 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1226 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1230 if ( checkLock( aStudy ) )
1233 /*Standard_Boolean aRes;
1234 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1235 if ( aMesh->_is_nil() )
1237 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1238 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1242 EmitSignalDeactivateDialog();
1243 if ( theCommandID == 407 )
1244 new SMESHGUI_TrianglesInversionDlg(this);
1246 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1249 case 409: // Change orientation
1250 case 410: // Union of triangles
1251 case 411: // Cutting of quadrangles
1255 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1256 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1260 if ( checkLock( aStudy ) )
1263 EmitSignalDeactivateDialog();
1264 SMESHGUI_MultiEditDlg* aDlg = NULL;
1265 if ( theCommandID == 409 )
1266 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1267 else if ( theCommandID == 410 )
1268 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1270 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1273 DefineDlgPosition( aDlg, x, y );
1278 case 412: // Smoothing
1280 if(checkLock(aStudy)) break;
1282 EmitSignalDeactivateDialog();
1283 new SMESHGUI_SmoothingDlg( this );
1286 SUIT_MessageBox::warn1(desktop(),
1287 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1288 tr("SMESH_BUT_OK"));
1292 case 413: // Extrusion
1294 if (checkLock(aStudy)) break;
1296 EmitSignalDeactivateDialog();
1297 new SMESHGUI_ExtrusionDlg ( this );
1299 SUIT_MessageBox::warn1(desktop(),
1300 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1301 tr("SMESH_BUT_OK"));
1305 case 414: // Revolution
1307 if(checkLock(aStudy)) break;
1309 EmitSignalDeactivateDialog();
1310 new SMESHGUI_RevolutionDlg( this );
1313 SUIT_MessageBox::warn1(desktop(),
1314 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1315 tr("SMESH_BUT_OK"));
1319 case 415: // Pattern mapping
1321 if ( checkLock( aStudy ) )
1325 EmitSignalDeactivateDialog();
1326 new SMESHGUI_MeshPatternDlg( this );
1329 SUIT_MessageBox::warn1(desktop(),
1330 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1331 tr("SMESH_BUT_OK"));
1335 case 416: // Extrusion along a path
1337 if (checkLock(aStudy)) break;
1339 EmitSignalDeactivateDialog();
1340 new SMESHGUI_ExtrusionAlongPathDlg( this );
1342 SUIT_MessageBox::warn1(desktop(),
1343 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1344 tr("SMESH_BUT_OK"));
1348 case 801: // CREATE GROUP
1352 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1353 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1357 if(checkLock(aStudy)) break;
1358 EmitSignalDeactivateDialog();
1359 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1361 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1362 SALOME_ListIO selected;
1364 aSel->selectedObjects( selected );
1366 int nbSel = selected.Extent();
1368 // check if mesh is selected
1369 aMesh = SMESH::GetMeshByIO( selected.First() );
1371 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1376 case 802: // CONSTRUCT GROUP
1380 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1381 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1385 if(checkLock(aStudy)) break;
1386 EmitSignalDeactivateDialog();
1388 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1389 SALOME_ListIO selected;
1391 aSel->selectedObjects( selected );
1393 int nbSel = selected.Extent();
1395 // check if submesh is selected
1396 Handle(SALOME_InteractiveObject) IObject = selected.First();
1397 if (IObject->hasEntry()) {
1398 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1400 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1401 if (!aSubMesh->_is_nil()) {
1403 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1404 // get submesh elements list by types
1405 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1406 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1407 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1408 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1409 // create group for each type o elements
1410 QString aName = IObject->getName();
1411 if (aNodes->length() > 0) {
1412 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1413 aGroup->Add(aNodes.inout());
1415 if (aEdges->length() > 0) {
1416 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1417 aGroup->Add(aEdges.inout());
1419 if (aFaces->length() > 0) {
1420 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1421 aGroup->Add(aFaces.inout());
1423 if (aVolumes->length() > 0) {
1424 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1425 aGroup->Add(aVolumes.inout());
1429 }catch(const SALOME::SALOME_Exception & S_ex){
1430 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1439 case 803: // EDIT GROUP
1443 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1444 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1448 if(checkLock(aStudy)) break;
1449 EmitSignalDeactivateDialog();
1451 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1452 SALOME_ListIO selected;
1454 aSel->selectedObjects( selected );
1456 SALOME_ListIteratorOfListIO It (selected);
1457 int nbSelectedGroups = 0;
1458 for ( ; It.More(); It.Next() )
1460 SMESH::SMESH_Group_var aGroup =
1461 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1462 if (!aGroup->_is_nil()) {
1464 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1468 if (nbSelectedGroups == 0)
1470 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1476 case 804: // Add elements to group
1478 if(checkLock(aStudy)) break;
1479 if (myState == 800) {
1480 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1481 if (aDlg) aDlg->onAdd();
1486 case 805: // Remove elements from group
1488 if(checkLock(aStudy)) break;
1489 if (myState == 800) {
1490 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1491 if (aDlg) aDlg->onRemove();
1496 case 810: // Union Groups
1497 case 811: // Intersect groups
1498 case 812: // Cut groups
1502 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1503 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1507 if ( checkLock( aStudy ) )
1510 EmitSignalDeactivateDialog();
1513 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1514 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1515 else aMode = SMESHGUI_GroupOpDlg::CUT;
1517 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1521 case 813: // Delete groups with their contents
1525 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1526 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1530 if ( checkLock( aStudy ) )
1533 EmitSignalDeactivateDialog();
1535 new SMESHGUI_DeleteGroupDlg( this );
1539 case 900: // MESH INFOS
1541 EmitSignalDeactivateDialog();
1542 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1543 SALOME_ListIO selected;
1545 aSel->selectedObjects( selected );
1547 if ( selected.Extent() > 1 ) { // a dlg for each IO
1549 SALOME_ListIteratorOfListIO It (selected);
1550 for ( ; It.More(); It.Next() ) {
1551 IOs.Clear(); IOs.Append( It.Value() );
1552 aSel->setSelectedObjects( IOs );
1553 new SMESHGUI_MeshInfosDlg(this, "", false);
1555 // restore selection
1556 aSel->setSelectedObjects( selected );
1559 new SMESHGUI_MeshInfosDlg(this, "", false);
1563 case 902: // STANDARD MESH INFOS
1565 EmitSignalDeactivateDialog();
1566 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1567 SALOME_ListIO selected;
1569 aSel->selectedObjects( selected );
1571 if ( selected.Extent() > 1 ) { // a dlg for each IO
1573 SALOME_ListIteratorOfListIO It (selected);
1574 for ( ; It.More(); It.Next() ) {
1576 IOs.Append( It.Value() );
1577 aSel->setSelectedObjects( IOs );
1578 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1580 // restore selection
1581 aSel->setSelectedObjects( selected );
1584 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1588 case 1100: // EDIT HYPOTHESIS
1590 if(checkLock(aStudy)) break;
1592 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1593 SALOME_ListIO selected;
1595 aSel->selectedObjects( selected );
1597 int nbSel = selected.Extent();
1600 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1602 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1603 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1604 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1605 if ( !Hyp->_is_nil() )
1607 char* sName = Hyp->GetName();
1608 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1610 aCreator->edit( Hyp.in(), desktop() );
1617 updateObjBrowser( true );
1621 case 1101: // RENAME
1623 if ( checkLock( aStudy ) )
1626 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1627 SALOME_ListIO selected;
1629 aSel->selectedObjects( selected );
1631 SALOME_ListIteratorOfListIO It( selected );
1632 for ( ; It.More(); It.Next() )
1634 Handle(SALOME_InteractiveObject) IObject = It.Value();
1635 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1636 _PTR(GenericAttribute) anAttr;
1637 _PTR(AttributeName) aName;
1640 if ( obj->FindAttribute(anAttr, "AttributeName") )
1643 QString newName = QString(aName->Value().c_str());
1645 newName = QInputDialog::getText( tr( "Rename" ), tr( "Enter new name:" ), QLineEdit::Normal,
1646 newName, &ok, desktop() );
1647 if ( ok && !newName.isEmpty() )
1649 //old source: aStudy->renameIObject( IObject, newName );
1650 aName->SetValue( newName.latin1() );
1652 // if current object is group update group's name
1653 SMESH::SMESH_GroupBase_var aGroup =
1654 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1655 if (!aGroup->_is_nil() )
1656 aGroup->SetName( newName.latin1() );
1666 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1668 if(checkLock(aStudy)) break;
1669 SUIT_OverrideCursor wc;
1671 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1672 SALOME_ListIO selected;
1674 aSel->selectedObjects( selected, QString::null, false );
1676 SALOME_ListIteratorOfListIO It(selected);
1677 for (int i = 0; It.More(); It.Next(), i++) {
1678 Handle(SALOME_InteractiveObject) IObject = It.Value();
1679 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1682 aSel->setSelectedObjects( l1 );
1687 case 401: // GEOM::EDGE
1688 case 4021: // TRIANGLE
1690 case 4023: // POLYGON
1694 if(checkLock(aStudy)) break;
1696 EmitSignalDeactivateDialog();
1697 SMDSAbs_ElementType type = SMDSAbs_Edge;
1699 switch (theCommandID) {
1700 case 4021: // TRIANGLE
1701 type = SMDSAbs_Face; nbNodes = 3; break;
1703 type = SMDSAbs_Face; nbNodes = 4; break;
1705 type = SMDSAbs_Volume; nbNodes = 4; break;
1706 case 4023: // POLYGON
1707 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1709 type = SMDSAbs_Volume; nbNodes = 8; break;
1710 case 4033: // POLYHEDRE
1711 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1714 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1717 SUIT_MessageBox::warn1(desktop(),
1718 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1719 tr("SMESH_BUT_OK"));
1723 case 4033: // POLYHEDRON
1725 if(checkLock(aStudy)) break;
1727 EmitSignalDeactivateDialog();
1728 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1731 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1732 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1733 tr("SMESH_BUT_OK"));
1737 case 4041: // REMOVES NODES
1739 if(checkLock(aStudy)) break;
1741 EmitSignalDeactivateDialog();
1742 new SMESHGUI_RemoveNodesDlg(this);
1745 SUIT_MessageBox::warn1(desktop(),
1746 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1747 tr("SMESH_BUT_OK"));
1751 case 4042: // REMOVES ELEMENTS
1753 if(checkLock(aStudy)) break;
1755 EmitSignalDeactivateDialog();
1756 new SMESHGUI_RemoveElementsDlg(this);
1760 SUIT_MessageBox::warn1(desktop(),
1761 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1762 tr("SMESH_BUT_OK"));
1766 case 4051: // RENUMBERING NODES
1768 if(checkLock(aStudy)) break;
1770 EmitSignalDeactivateDialog();
1771 new SMESHGUI_RenumberingDlg( this, "", 0);
1775 SUIT_MessageBox::warn1(desktop(),
1776 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1777 tr("SMESH_BUT_OK"));
1781 case 4052: // RENUMBERING ELEMENTS
1783 if(checkLock(aStudy)) break;
1785 EmitSignalDeactivateDialog();
1786 new SMESHGUI_RenumberingDlg( this, "", 1);
1790 SUIT_MessageBox::warn1(desktop(),
1791 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1792 tr("SMESH_BUT_OK"));
1796 case 4061: // TRANSLATION
1798 if(checkLock(aStudy)) break;
1800 EmitSignalDeactivateDialog();
1801 new SMESHGUI_TranslationDlg( this );
1804 SUIT_MessageBox::warn1(desktop(),
1805 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1806 tr("SMESH_BUT_OK"));
1810 case 4062: // ROTATION
1812 if(checkLock(aStudy)) break;
1814 EmitSignalDeactivateDialog();
1815 new SMESHGUI_RotationDlg( this );
1818 SUIT_MessageBox::warn1(desktop(),
1819 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1820 tr("SMESH_BUT_OK"));
1824 case 4063: // SYMMETRY
1826 if(checkLock(aStudy)) break;
1828 EmitSignalDeactivateDialog();
1829 new SMESHGUI_SymmetryDlg( this );
1832 SUIT_MessageBox::warn1(desktop(),
1833 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1834 tr("SMESH_BUT_OK"));
1838 case 4064: // SEWING
1840 if(checkLock(aStudy)) break;
1842 EmitSignalDeactivateDialog();
1843 new SMESHGUI_SewingDlg( this );
1846 SUIT_MessageBox::warn1(desktop(),
1847 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1848 tr("SMESH_BUT_OK"));
1852 case 4065: // MERGE NODES
1854 if(checkLock(aStudy)) break;
1856 EmitSignalDeactivateDialog();
1857 new SMESHGUI_MergeNodesDlg( this );
1860 SUIT_MessageBox::warn1(desktop(),
1861 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1862 tr("SMESH_BUT_OK"));
1866 case 4066: // MERGE EQUAL ELEMENTS
1868 if (checkLock(aStudy)) break;
1870 EmitSignalDeactivateDialog();
1871 new SMESHGUI_EditMeshDlg(this,
1872 "SMESH_MERGE_ELEMENTS_TITLE",
1873 "ICON_DLG_MERGE_ELEMENTS",
1874 1); // MergeEqualElemets
1876 SUIT_MessageBox::warn1(desktop(),
1877 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1878 tr("SMESH_BUT_OK"));
1883 case 5105: // Library of selection filters
1885 static QValueList<int> aTypes;
1886 if ( aTypes.isEmpty() )
1888 aTypes.append( SMESH::NODE );
1889 aTypes.append( SMESH::EDGE );
1890 aTypes.append( SMESH::FACE );
1891 aTypes.append( SMESH::VOLUME );
1893 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
1897 case 6017: // CONTROLS
1913 LightApp_SelectionMgr* mgr = selectionMgr();
1914 SALOME_ListIO selected; mgr->selectedObjects( selected );
1916 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
1917 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
1919 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1920 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
1921 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
1922 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
1923 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
1924 ::Control( theCommandID );
1929 SUIT_MessageBox::warn1(desktop(),
1930 tr( "SMESH_WRN_WARNING" ),
1931 tr( "SMESH_BAD_SELECTION" ),
1932 tr( "SMESH_BUT_OK" ) );
1936 SUIT_MessageBox::warn1(desktop(),
1937 tr( "SMESH_WRN_WARNING" ),
1938 tr( "NOT_A_VTK_VIEWER" ),
1939 tr( "SMESH_BUT_OK" ) );
1944 LightApp_SelectionMgr* mgr = selectionMgr();
1945 SALOME_ListIO selected; mgr->selectedObjects( selected );
1947 if (selected.Extent() == 1) {
1948 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1949 if(anIObject->hasEntry())
1950 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1951 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
1958 LightApp_SelectionMgr* mgr = selectionMgr();
1959 SALOME_ListIO selected; mgr->selectedObjects( selected );
1961 if (selected.Extent() == 1) {
1962 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1963 if(anIObject->hasEntry())
1964 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1965 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
1972 anApp->updateActions(); //SRN: To update a Save button in the toolbar
1973 //updateObjBrowser();
1977 //=============================================================================
1981 //=============================================================================
1982 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
1987 //=============================================================================
1991 //=============================================================================
1992 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
1997 //=============================================================================
2001 //=============================================================================
2002 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2007 //=============================================================================
2008 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2009 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2011 //=============================================================================
2012 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2013 SUIT_ViewWindow* wnd )
2015 if(theIO->hasEntry()){
2016 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2017 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2021 //=======================================================================
2022 // function : createSMESHAction
2024 //=======================================================================
2025 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2028 QWidget* parent = application()->desktop();
2029 SUIT_ResourceMgr* resMgr = resourceMgr();
2031 if ( icon_id.length() )
2032 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2034 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2035 if ( !pix.isNull() )
2036 icon = QIconSet( pix );
2038 QString tooltip = tr( QString( "TOP_" )+po_id ),
2039 menu = tr( QString( "MEN_" )+po_id ),
2040 status_bar = tr( QString( "STB_" )+po_id );
2042 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2045 //=======================================================================
2046 // function : createPopupItem
2048 //=======================================================================
2049 void SMESHGUI::createPopupItem( const int id,
2050 const QString& clients,
2051 const QString& types,
2052 const QString& theRule,
2057 parentId = popupMgr()->actionId( action( pId ) );
2059 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2060 popupMgr()->insert( action( id ), parentId, 0 );
2062 QChar lc = QtxPopupMgr::Selection::defEquality();
2063 QString rule = "(%1) and (%2) and (%3)";
2064 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2065 if( clients.isEmpty() )
2066 rule = rule.arg( QString( "true" ) );
2068 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2069 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2072 bool cont = myRules.contains( id );
2074 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2076 popupMgr()->setRule( action( id ), rule, true );
2077 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2080 //=======================================================================
2081 // function : initialize
2083 //=======================================================================
2084 void SMESHGUI::initialize( CAM_Application* app )
2086 SalomeApp_Module::initialize( app );
2088 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2090 /* Automatic Update flag */
2091 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2093 // ----- create actions --------------
2095 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2096 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2097 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2098 createSMESHAction( 114, "NUM" );
2099 createSMESHAction( 121, "DAT" );
2100 createSMESHAction( 122, "MED" );
2101 createSMESHAction( 123, "UNV" );
2102 createSMESHAction( 124, "EXPORT_DAT" );
2103 createSMESHAction( 125, "EXPORT_MED" );
2104 createSMESHAction( 126, "EXPORT_UNV" );
2105 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2106 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2107 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2108 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2109 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2110 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2111 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2112 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2113 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2114 createSMESHAction( 804, "ADD" );
2115 createSMESHAction( 805, "REMOVE" );
2116 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2117 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2118 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2119 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2120 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2121 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2122 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2123 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2124 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2125 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2126 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2127 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2128 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2129 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2130 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2131 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2132 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2133 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2134 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2135 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2136 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2137 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2138 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2139 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2140 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2141 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2142 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2143 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2144 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2145 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2146 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2147 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2148 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2149 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2150 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2151 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2152 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2153 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2154 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2155 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2156 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2157 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2158 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2159 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2160 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2161 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2162 createSMESHAction( 415, "MAP", "ICON_MAP" );
2163 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2164 createSMESHAction( 200, "RESET" );
2165 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2166 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2167 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2168 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2169 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2170 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2171 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2172 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2173 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2174 createSMESHAction( 220, "ALL" );
2175 createSMESHAction( 1100, "EDIT_HYPO" );
2176 createSMESHAction( 1101, "RENAME" );
2177 createSMESHAction( 1102, "UNASSIGN" );
2178 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2179 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2180 createSMESHAction( 1131, "DISPMODE" );
2181 createSMESHAction( 1132, "COLORS" );
2182 createSMESHAction( 1133, "TRANSP" );
2183 createSMESHAction( 1134, "CLIP" );
2184 createSMESHAction( 1135, "DISP_ENT" );
2185 createSMESHAction( 2000, "CTRL" );
2187 createSMESHAction( 300, "ERASE" );
2188 createSMESHAction( 301, "DISPLAY" );
2189 createSMESHAction( 302, "DISPLAY_ONLY" );
2190 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2192 // ----- create menu --------------
2193 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2194 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2195 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2196 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2197 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2198 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2199 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2201 createMenu( separator(), fileId );
2203 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2204 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2205 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2206 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2207 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2208 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2210 createMenu( 111, importId, -1 );
2211 createMenu( 112, importId, -1 );
2212 createMenu( 113, importId, -1 );
2214 createMenu( 121, exportId, -1 );
2215 createMenu( 122, exportId, -1 );
2216 createMenu( 123, exportId, -1 );
2218 createMenu( separator(), fileId, 10 );
2220 createMenu( 33, editId, -1 );
2222 createMenu( 5105, toolsId, -1 );
2224 createMenu( 702, meshId, -1 );
2225 createMenu( 703, meshId, -1 );
2226 createMenu( 704, meshId, -1 );
2227 createMenu( separator(), meshId, -1 );
2228 createMenu( 701, meshId, -1 );
2229 createMenu( separator(), meshId, -1 );
2230 createMenu( 801, meshId, -1 );
2231 createMenu( 802, meshId, -1 );
2232 createMenu( 803, meshId, -1 );
2233 createMenu( separator(), meshId, -1 );
2234 createMenu( 810, meshId, -1 );
2235 createMenu( 811, meshId, -1 );
2236 createMenu( 812, meshId, -1 );
2237 createMenu( separator(), meshId, -1 );
2238 createMenu( 813, meshId, -1 );
2239 createMenu( separator(), meshId, -1 );
2240 createMenu( 900, meshId, -1 );
2241 createMenu( 902, meshId, -1 );
2242 createMenu( separator(), meshId, -1 );
2244 createMenu( 6003, ctrlId, -1 );
2245 createMenu( 6001, ctrlId, -1 );
2246 createMenu( 6004, ctrlId, -1 );
2247 createMenu( separator(), ctrlId, -1 );
2248 createMenu( 6002, ctrlId, -1 );
2249 createMenu( 6018, ctrlId, -1 );
2250 createMenu( 6019, ctrlId, -1 );
2251 createMenu( 6011, ctrlId, -1 );
2252 createMenu( 6012, ctrlId, -1 );
2253 createMenu( 6013, ctrlId, -1 );
2254 createMenu( 6014, ctrlId, -1 );
2255 createMenu( 6015, ctrlId, -1 );
2256 createMenu( 6016, ctrlId, -1 );
2257 createMenu( separator(), ctrlId, -1 );
2258 createMenu( 6017, ctrlId, -1 );
2259 createMenu( 6009, ctrlId, -1 );
2260 createMenu( separator(), ctrlId, -1 );
2262 createMenu( 400, addId, -1 );
2263 createMenu( 401, addId, -1 );
2264 createMenu( 4021, addId, -1 );
2265 createMenu( 4022, addId, -1 );
2266 createMenu( 4023, addId, -1 );
2267 createMenu( 4031, addId, -1 );
2268 createMenu( 4032, addId, -1 );
2269 createMenu( 4033, addId, -1 );
2271 createMenu( 4041, removeId, -1 );
2272 createMenu( 4042, removeId, -1 );
2274 createMenu( 4051, renumId, -1 );
2275 createMenu( 4052, renumId, -1 );
2277 createMenu( 4061, transfId, -1 );
2278 createMenu( 4062, transfId, -1 );
2279 createMenu( 4063, transfId, -1 );
2280 createMenu( 4064, transfId, -1 );
2281 createMenu( 4065, transfId, -1 );
2282 createMenu( 4066, transfId, -1 );
2284 createMenu( 406, modifyId, -1 );
2285 createMenu( 407, modifyId, -1 );
2286 createMenu( 408, modifyId, -1 );
2287 createMenu( 409, modifyId, -1 );
2288 createMenu( 410, modifyId, -1 );
2289 createMenu( 411, modifyId, -1 );
2290 createMenu( 412, modifyId, -1 );
2291 createMenu( 413, modifyId, -1 );
2292 createMenu( 416, modifyId, -1 );
2293 createMenu( 414, modifyId, -1 );
2294 createMenu( 415, modifyId, -1 );
2296 createMenu( 214, viewId, -1 );
2298 // ----- create toolbars --------------
2299 int meshTb = createTool( tr( "TB_MESH" ) ),
2300 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2301 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2302 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2303 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2305 createTool( 702, meshTb );
2306 createTool( 703, meshTb );
2307 createTool( 704, meshTb );
2308 createTool( separator(), meshTb );
2309 createTool( 701, meshTb );
2310 createTool( separator(), meshTb );
2311 createTool( 801, meshTb );
2312 createTool( 802, meshTb );
2313 createTool( 803, meshTb );
2314 createTool( separator(), meshTb );
2315 createTool( 900, meshTb );
2316 createTool( 902, meshTb );
2317 createTool( separator(), meshTb );
2319 createTool( 6001, ctrlTb );
2320 createTool( 6003, ctrlTb );
2321 createTool( 6004, ctrlTb );
2322 createTool( separator(), ctrlTb );
2323 createTool( 6002, ctrlTb );
2324 createTool( 6018, ctrlTb );
2325 createTool( 6019, ctrlTb );
2326 createTool( 6011, ctrlTb );
2327 createTool( 6012, ctrlTb );
2328 createTool( 6013, ctrlTb );
2329 createTool( 6014, ctrlTb );
2330 createTool( 6015, ctrlTb );
2331 createTool( 6016, ctrlTb );
2332 createTool( separator(), ctrlTb );
2333 createTool( 6017, ctrlTb );
2334 createTool( 6009, ctrlTb );
2335 createTool( separator(), ctrlTb );
2337 createTool( 400, addRemTb );
2338 createTool( 401, addRemTb );
2339 createTool( 4021, addRemTb );
2340 createTool( 4022, addRemTb );
2341 createTool( 4023, addRemTb );
2342 createTool( 4031, addRemTb );
2343 createTool( 4032, addRemTb );
2344 createTool( 4033, addRemTb );
2345 createTool( separator(), addRemTb );
2346 createTool( 4041, addRemTb );
2347 createTool( 4042, addRemTb );
2348 createTool( separator(), addRemTb );
2349 createTool( 4051, addRemTb );
2350 createTool( 4052, addRemTb );
2351 createTool( separator(), addRemTb );
2352 createTool( 4061, addRemTb );
2353 createTool( 4062, addRemTb );
2354 createTool( 4063, addRemTb );
2355 createTool( 4064, addRemTb );
2356 createTool( 4065, addRemTb );
2357 createTool( 4066, addRemTb );
2358 createTool( separator(), addRemTb );
2360 createTool( 406, modifyTb );
2361 createTool( 407, modifyTb );
2362 createTool( 408, modifyTb );
2363 createTool( 409, modifyTb );
2364 createTool( 410, modifyTb );
2365 createTool( 411, modifyTb );
2366 createTool( 412, modifyTb );
2367 createTool( 413, modifyTb );
2368 createTool( 416, modifyTb );
2369 createTool( 414, modifyTb );
2370 createTool( 415, modifyTb );
2372 createTool( 214, dispModeTb );
2376 QString OB = "'ObjectBrowser'",
2377 View = "'" + SVTK_Viewer::Type() + "'",
2379 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2380 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2381 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2382 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2383 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2384 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2385 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2386 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2387 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2388 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2390 mesh_group = mesh + " " + subMesh + " " + group,
2391 hyp_alg = hypo + " " + algo;
2393 // popup for object browser
2395 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2396 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2397 createPopupItem( 803, OB, group ); // EDIT_GROUP
2398 popupMgr()->insert( separator(), -1, 0 );
2399 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2400 createPopupItem( 214, OB, mesh_group ); // UPDATE
2401 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2402 createPopupItem( 902, OB, mesh ); // STD_INFO
2403 popupMgr()->insert( separator(), -1, 0 );
2404 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2405 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2406 popupMgr()->insert( separator(), -1, 0 );
2407 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2408 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2409 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2410 popupMgr()->insert( separator(), -1, 0 );
2412 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2413 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2414 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2415 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2416 popupMgr()->insert( separator(), -1, 0 );
2419 createPopupItem( 803, View, group ); // EDIT_GROUP
2420 createPopupItem( 804, View, elems ); // ADD
2421 createPopupItem( 805, View, elems ); // REMOVE
2422 popupMgr()->insert( separator(), -1, 0 );
2423 createPopupItem( 214, View, mesh_group ); // UPDATE
2424 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2425 createPopupItem( 902, View, mesh ); // STD_INFO
2426 popupMgr()->insert( separator(), -1, 0 );
2430 isInvisible("not( isVisible )"),
2431 isEmpty("numberOfNodes = 0"),
2432 isNotEmpty("numberOfNodes <> 0"),
2434 // has nodes, edges, etc in VISIBLE! actor
2435 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2436 hasElems("(count( elemTypes ) > 0)"),
2437 hasDifferentElems("(count( elemTypes ) > 1)"),
2438 hasEdges("({'Edge'} in elemTypes)"),
2439 hasFaces("({'Face'} in elemTypes)"),
2440 hasVolumes("({'Volume'} in elemTypes)");
2442 QString lc = QtxPopupMgr::Selection::defEquality();
2443 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2444 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2445 aType = aType.arg( mesh_group );
2446 QString aMeshInVTK = aClient + "&&" + aType;
2448 //-------------------------------------------------
2450 //-------------------------------------------------
2451 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2453 popupMgr()->insert( action( 9010 ), anId, -1 );
2454 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2455 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2457 popupMgr()->insert( action( 9011 ), anId, -1 );
2458 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2459 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2461 popupMgr()->insert( separator(), -1, -1 );
2463 //-------------------------------------------------
2465 //-------------------------------------------------
2466 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2468 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2469 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2470 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2472 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2473 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2474 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2476 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2477 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2478 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2480 popupMgr()->insert( separator(), anId, -1 );
2482 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2483 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2484 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2486 //-------------------------------------------------
2488 //-------------------------------------------------
2489 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2491 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2493 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2494 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2495 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2497 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2498 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2499 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2501 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2502 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2503 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2505 popupMgr()->insert( separator(), anId, -1 );
2507 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2508 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2510 //-------------------------------------------------
2512 //-------------------------------------------------
2513 popupMgr()->insert( action( 1132 ), -1, -1 );
2514 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2516 //-------------------------------------------------
2518 //-------------------------------------------------
2519 popupMgr()->insert( action( 1133 ), -1, -1 );
2520 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2522 //-------------------------------------------------
2524 //-------------------------------------------------
2525 popupMgr()->insert( action( 1134 ), -1, -1 );
2526 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2528 popupMgr()->insert( separator(), -1, -1 );
2530 //-------------------------------------------------
2532 //-------------------------------------------------
2534 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2535 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2536 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2538 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2540 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2541 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2543 popupMgr()->insert( separator(), anId, -1 );
2545 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2546 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2547 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2549 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2550 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2551 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2553 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2554 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2555 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2557 popupMgr()->insert( separator(), anId, -1 );
2559 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2560 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2561 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2563 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2564 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2565 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2567 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2568 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2569 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2571 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2572 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2573 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2575 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2576 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2577 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2579 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2580 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2581 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2583 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2584 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2585 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2587 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2588 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2589 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2591 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2592 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2593 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2595 popupMgr()->insert( separator(), anId, -1 );
2597 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2598 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2599 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2601 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2602 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2603 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2605 popupMgr()->insert( separator(), anId, -1 );
2607 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2608 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2610 popupMgr()->insert( separator(), -1, -1 );
2612 //-------------------------------------------------
2614 //-------------------------------------------------
2615 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2616 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2617 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2619 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2620 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2621 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2622 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2624 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2625 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2627 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2628 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2630 popupMgr()->insert( separator(), -1, -1 );
2632 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2633 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2636 bool SMESHGUI::activateModule( SUIT_Study* study )
2638 bool res = SalomeApp_Module::activateModule( study );
2640 setMenuShown( true );
2641 setToolShown( true );
2646 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2648 setMenuShown( false );
2649 setToolShown( false );
2651 EmitSignalCloseAllDialogs();
2653 return SalomeApp_Module::deactivateModule( study );
2656 void SMESHGUI::OnGUIEvent()
2658 const QObject* obj = sender();
2659 if ( !obj || !obj->inherits( "QAction" ) )
2661 int id = actionId((QAction*)obj);
2666 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2668 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2669 if ( CORBA::is_nil( myComponentSMESH ) )
2671 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2673 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2674 return aGUI.myComponentSMESH;
2677 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2678 return myComponentSMESH;
2681 QString SMESHGUI::engineIOR() const
2683 CORBA::ORB_var anORB = getApp()->orb();
2684 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2688 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2690 SMESHGUI_Selection sel;
2691 sel.init( client, selectionMgr() );
2692 popupMgr()->updatePopup( menu, &sel );
2695 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2697 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2698 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2701 void SMESHGUI::viewManagers( QStringList& list ) const
2703 list.append( SVTK_Viewer::Type() );
2706 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
2708 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
2709 SMESH::UpdateSelectionProp( this );
2712 void SMESHGUI::createPreferences()
2714 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2716 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2717 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
2719 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2720 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
2721 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
2723 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2724 setPreferenceProperty( precGroup, "columns", 1 );
2726 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2728 setPreferenceProperty( prec, "min", 0 );
2729 setPreferenceProperty( prec, "max", 16 );
2731 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2732 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
2734 modes.append( "Wireframe" );
2735 modes.append( "Shading" );
2736 modes.append( "Nodes" );
2737 modes.append( "Shrink" );
2738 QValueList<QVariant> indices;
2739 indices.append( 0 );
2740 indices.append( 1 );
2741 indices.append( 2 );
2742 indices.append( 3 );
2743 setPreferenceProperty( dispmode, "strings", modes );
2744 setPreferenceProperty( dispmode, "indexes", indices );
2746 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
2747 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
2749 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2750 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2752 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
2753 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
2755 setPreferenceProperty( nodeSz, "min", 1 );
2756 setPreferenceProperty( nodeSz, "max", 5 );
2758 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2760 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
2761 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
2762 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
2763 addPreference( "", elemGroup, LightApp_Preferences::Space );
2765 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
2766 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2768 setPreferenceProperty( elemW, "min", 1 );
2769 setPreferenceProperty( elemW, "max", 5 );
2771 setPreferenceProperty( shrink, "min", 0 );
2772 setPreferenceProperty( shrink, "max", 100 );
2774 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2776 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2778 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
2779 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
2780 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
2782 setPreferenceProperty( selW, "min", 1 );
2783 setPreferenceProperty( selW, "max", 5 );
2785 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2787 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
2788 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2790 setPreferenceProperty( preW, "min", 1 );
2791 setPreferenceProperty( preW, "max", 5 );
2793 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2795 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
2796 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
2798 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2799 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2801 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2802 addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2803 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2804 addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
2807 fam.append( tr( "SMESH_FONT_ARIAL" ) );
2808 fam.append( tr( "SMESH_FONT_COURIER" ) );
2809 fam.append( tr( "SMESH_FONT_TIMES" ) );
2810 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2812 setPreferenceProperty( tfont, "families", fam );
2813 setPreferenceProperty( tfont, "system", false );
2814 setPreferenceProperty( tfont, "widget_flags", wflag );
2815 setPreferenceProperty( lfont, "families", fam );
2816 setPreferenceProperty( lfont, "system", false );
2817 setPreferenceProperty( lfont, "widget_flags", wflag );
2819 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
2821 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
2822 setPreferenceProperty( numcol, "min", 2 );
2823 setPreferenceProperty( numcol, "max", 256 );
2825 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
2826 setPreferenceProperty( numlab, "min", 2 );
2827 setPreferenceProperty( numlab, "max", 65 );
2829 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
2830 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2831 QStringList orients;
2832 orients.append( tr( "SMESH_VERTICAL" ) );
2833 orients.append( tr( "SMESH_HORIZONTAL" ) );
2834 indices.clear(); indices.append( 0 ); indices.append( 1 );
2835 setPreferenceProperty( orient, "strings", orients );
2836 setPreferenceProperty( orient, "indexes", indices );
2838 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
2839 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2840 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2841 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2842 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
2843 setPreferenceProperty( xv, "step", 0.1 );
2844 setPreferenceProperty( xv, "min", 0.0 );
2845 setPreferenceProperty( xv, "max", 1.0 );
2846 setPreferenceProperty( yv, "step", 0.1 );
2847 setPreferenceProperty( yv, "min", 0.0 );
2848 setPreferenceProperty( yv, "max", 1.0 );
2849 setPreferenceProperty( wv, "step", 0.1 );
2850 setPreferenceProperty( wv, "min", 0.0 );
2851 setPreferenceProperty( wv, "max", 1.0 );
2852 setPreferenceProperty( hv, "min", 0.0 );
2853 setPreferenceProperty( hv, "max", 1.0 );
2854 setPreferenceProperty( hv, "step", 0.1 );
2856 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
2857 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
2858 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
2859 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
2860 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
2861 setPreferenceProperty( xv, "min", 0.0 );
2862 setPreferenceProperty( xv, "max", 1.0 );
2863 setPreferenceProperty( xv, "step", 0.1 );
2864 setPreferenceProperty( xh, "min", 0.0 );
2865 setPreferenceProperty( xh, "max", 1.0 );
2866 setPreferenceProperty( xh, "step", 0.1 );
2867 setPreferenceProperty( yh, "min", 0.0 );
2868 setPreferenceProperty( yh, "max", 1.0 );
2869 setPreferenceProperty( yh, "step", 0.1 );
2870 setPreferenceProperty( wh, "min", 0.0 );
2871 setPreferenceProperty( wh, "max", 1.0 );
2872 setPreferenceProperty( wh, "step", 0.1 );
2873 setPreferenceProperty( hh, "min", 0.0 );
2874 setPreferenceProperty( hh, "max", 1.0 );
2875 setPreferenceProperty( hh, "step", 0.1 );
2878 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
2880 if( sect=="SMESH" ){
2881 float sbX1,sbY1,sbW,sbH;
2882 std::string aWarning;
2883 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2884 if( name=="selection_object_color" || name=="selection_element_color" ||
2885 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
2886 name=="selection_precision_node" || name=="selection_precision_element" )
2887 SMESH::UpdateSelectionProp( this );
2888 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
2889 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
2890 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
2892 aWarning = "Origin and Size Vertical: X+Width > 1\n";
2895 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
2896 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
2899 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
2900 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
2901 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
2903 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
2906 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
2907 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
2910 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
2911 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
2912 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
2914 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
2917 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
2918 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
2921 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
2922 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
2923 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
2925 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
2928 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
2929 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
2933 if(aWarning.size() != 0){
2934 aWarning += "The default values are applied instead.";
2935 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2936 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
2937 QObject::tr(aWarning.c_str()),
2938 QObject::tr("SMESH_BUT_OK"));
2943 //================================================================================
2945 * \brief Update something in accordance with update flags
2946 * \param theFlags - update flags
2948 * Update viewer or/and object browser etc. in accordance with update flags ( see
2949 * LightApp_UpdateFlags enumeration ).
2951 //================================================================================
2952 void SMESHGUI::update( const int flags )
2954 if ( flags & UF_Viewer | flags & UF_Forced )
2955 SMESH::UpdateView();
2957 SalomeApp_Module::update( flags );
2960 //================================================================================
2962 * \brief Set default selection mode
2964 * SLOT called when operation commited. Sets default selection mode
2966 //================================================================================
2967 void SMESHGUI::onOperationCommited( SUIT_Operation* )
2969 SVTK_ViewWindow* vtkWnd =
2970 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
2972 vtkWnd->SetSelectionMode( ActorSelection );
2975 //================================================================================
2977 * \brief Set default selection mode
2979 * SLOT called when operation aborted. Sets default selection mode
2981 //================================================================================
2982 void SMESHGUI::onOperationAborted( SUIT_Operation* )
2984 SVTK_ViewWindow* vtkWnd =
2985 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
2987 vtkWnd->SetSelectionMode( ActorSelection );
2990 //================================================================================
2992 * \brief Creates operation with given identifier
2993 * \param id - identifier of operation to be started
2994 * \return Pointer on created operation or NULL if operation is not created
2996 * Virtual method redefined from the base class creates operation with given id.
2997 * It is called called automatically from startOperation method of base class.
2999 //================================================================================
3000 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3002 LightApp_Operation* op = 0;
3003 // to do : create operation here
3006 case 702: // Create mesh
3007 op = new SMESHGUI_MeshOp( true, true );
3009 case 703: // Create sub-mesh
3010 op = new SMESHGUI_MeshOp( true, false );
3012 case 704: // Edit mesh/sub-mesh
3013 op = new SMESHGUI_MeshOp( false );
3020 op = SalomeApp_Module::createOperation( id );
3024 //================================================================================
3026 * \brief Stops current operations and starts a given one
3027 * \param id - The id of the operation to start
3029 //================================================================================
3031 void SMESHGUI::switchToOperation(int id)
3033 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3034 activeStudy()->abortAllOperations();
3035 startOperation( id );
3038 LightApp_Displayer* SMESHGUI::displayer()
3041 myDisplayer = new SMESHGUI_Displayer( getApp() );
3045 void SMESHGUI::OnEditDelete()
3047 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
3048 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
3049 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
3051 QString aParentComponent = QString::null;
3052 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
3054 QString cur = anIt.Value()->getComponentDataType();
3055 if( aParentComponent.isNull() )
3056 aParentComponent = cur;
3057 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
3058 aParentComponent = "";
3061 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
3062 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
3063 QObject::tr("ERR_ERROR"),
3064 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
3065 QObject::tr("BUT_OK") );
3068 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
3069 if (SUIT_MessageBox::warn2
3070 (SMESHGUI::desktop(),
3071 QObject::tr("SMESH_WRN_WARNING"),
3072 QObject::tr("SMESH_REALLY_DELETE"),
3073 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
3076 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3077 SUIT_ViewManager* vm = anApp->activeViewManager();
3078 int nbSf = vm->getViewsCount();
3080 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
3081 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
3082 _PTR(GenericAttribute) anAttr;
3083 _PTR(AttributeIOR) anIOR;
3085 SALOME_ListIteratorOfListIO It(selected);
3087 aStudyBuilder->NewCommand(); // There is a transaction
3088 for(; It.More(); It.Next()){
3089 Handle(SALOME_InteractiveObject) IObject = It.Value();
3090 if(IObject->hasEntry()){
3091 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
3093 // disable removal of "SMESH" component object
3094 if(SO->FindAttribute(anAttr, "AttributeIOR")){
3096 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
3100 /* Erase child graphical objects */
3101 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
3102 for(it->InitEx(true); it->More(); it->Next()){
3103 _PTR(SObject) CSO = it->Value();
3104 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
3107 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
3108 for(int i = 0; i < nbSf; i++){
3109 SUIT_ViewWindow *sf = aViews[i];
3110 CORBA::String_var anEntry = CSO->GetID().c_str();
3111 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
3112 SMESH::RemoveActor(sf,anActor);
3118 /* Erase main graphical object */
3119 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
3120 for(int i = 0; i < nbSf; i++){
3121 SUIT_ViewWindow *sf = aViews[i];
3122 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
3123 SMESH::RemoveActor(sf,anActor);
3127 // Remove object(s) from data structures
3128 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
3130 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
3131 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
3132 QString objType = CheckTypeObject(IObject);
3133 if ( !aGroup->_is_nil() ) { // DELETE GROUP
3134 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
3135 aMesh->RemoveGroup( aGroup );
3137 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
3138 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
3139 aMesh->RemoveSubMesh( aSubMesh );
3141 else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
3142 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3143 aStudyBuilder->RemoveObjectWithChildren( obj );
3145 else {// default action: remove SObject from the study
3146 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
3147 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
3149 aStudyBuilder->RemoveObjectWithChildren( obj );
3154 } /* IObject->hasEntry() */
3156 aStudyBuilder->CommitCommand();
3158 /* Clear any previous selection */
3160 aSel->setSelectedObjects( l1 );
3162 SMESHGUI::GetSMESHGUI()->updateObjBrowser();