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_ResourceMgr.h"
108 #include "SUIT_OverrideCursor.h"
109 #include "SUIT_Study.h"
110 #include "SUIT_Session.h"
112 #include "QtxPopupMgr.h"
114 #include "SALOME_ListIO.hxx"
115 #include "SALOME_ListIteratorOfListIO.hxx"
116 #include "SALOME_InteractiveObject.hxx"
117 #include "SALOME_NamingService.hxx"
118 #include "SALOME_LifeCycleCORBA.hxx"
120 #include "SALOMEconfig.h"
121 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
124 #define INCLUDE_MENUITEM_DEF
125 #include <qpopupmenu.h>
129 #include <qinputdialog.h>
132 #include <boost/shared_ptr.hpp>
135 #include <vtkRenderer.h>
136 #include <vtkRenderWindow.h>
137 #include <vtkActorCollection.h>
138 #include <vtkScalarBarActor.h>
139 #include <vtkUnstructuredGrid.h>
141 #include "utilities.h"
143 #include "SALOMEDS_Study.hxx"
144 #include "SALOMEDSClient_StudyBuilder.hxx"
145 #include "SALOMEDSClient_SComponent.hxx"
151 //=============================================================
152 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
155 void ExportMeshToFile(int theCommandID);
157 void SetDisplayMode(int theCommandID);
159 void SetDisplayEntity(int theCommandID);
161 void Control( int theCommandID );
165 //=============================================================
166 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
172 if(theCommandID == 113){
173 filter.append(QObject::tr("MED files (*.med)"));
174 filter.append(QObject::tr("All files (*)"));
175 }else if (theCommandID == 112){
176 filter.append(QObject::tr("IDEAS files (*.unv)"));
177 }else if (theCommandID == 111){
178 filter.append(QObject::tr("DAT files (*.dat)"));
180 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
183 QObject::tr("Import mesh"),
185 if(!filename.isEmpty()) {
186 SUIT_OverrideCursor wc;
187 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
190 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
191 switch ( theCommandID ) {
194 aMeshes->length( 1 );
195 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
200 SMESH::DriverMED_ReadStatus res;
201 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
202 if ( res != SMESH::DRS_OK ) {
204 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
205 QObject::tr("SMESH_WRN_WARNING"),
206 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
207 QObject::tr("SMESH_BUT_OK"));
208 aMeshes->length( 0 );
215 bool isEmpty = false;
216 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
217 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
219 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
220 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
221 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
222 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
223 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
230 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
231 QObject::tr("SMESH_WRN_WARNING"),
232 QObject::tr("SMESH_DRS_EMPTY"),
233 QObject::tr("SMESH_BUT_OK"));
237 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
239 catch (const SALOME::SALOME_Exception& S_ex){
241 SalomeApp_Tools::QtCatchCorbaException(S_ex);
248 void ExportMeshToFile( int theCommandID )
250 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
251 SALOME_ListIO selected;
253 aSel->selectedObjects( selected );
255 if(selected.Extent()){
256 Handle(SALOME_InteractiveObject) anIObject = selected.First();
257 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
258 if ( !aMesh->_is_nil() ) {
259 QString aFilter, aTitle = QObject::tr("Export mesh");
260 QMap<QString, SMESH::MED_VERSION> aFilterMap;
261 switch ( theCommandID ) {
264 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
265 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
269 aFilter = QObject::tr("DAT files (*.dat)");
273 if(aMesh->NbPyramids()){
274 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
275 QObject::tr("SMESH_WRN_WARNING"),
276 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
277 QObject::tr("SMESH_BUT_YES"),
278 QObject::tr("SMESH_BUT_NO"),
283 aFilter = QObject::tr("IDEAS files (*.unv)");
290 SMESH::MED_VERSION aFormat;
291 // Init the parameter with the default value
292 bool toCreateGroups = false;
293 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
295 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
297 if ( theCommandID != 122 && theCommandID != 125 )
298 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
302 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
303 filters.push_back( it.key() );
305 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
306 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
307 fd->setCaption( aTitle );
308 fd->setFilters( filters );
309 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
310 fd->SetChecked(toCreateGroups);
314 aFilename = fd->selectedFile();
315 aFormat = aFilterMap[fd->selectedFilter()];
317 if( !aFilename.isEmpty()
318 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
319 && aFormat==SMESH::MED_V2_1){
320 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
321 QObject::tr("SMESH_WRN_WARNING"),
322 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
323 QObject::tr("SMESH_BUT_YES"),
324 QObject::tr("SMESH_BUT_NO"),
331 toCreateGroups = fd->IsChecked();
334 if ( !aFilename.isEmpty() ) {
335 // Check whether the file already exists and delete it if yes
336 QFile aFile( aFilename );
337 if ( aFile.exists() )
339 SUIT_OverrideCursor wc;
340 switch ( theCommandID ) {
343 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
347 aMesh->ExportDAT( aFilename.latin1() );
351 aMesh->ExportUNV( aFilename.latin1() );
361 inline void InverseEntityMode(unsigned int& theOutputMode,
362 unsigned int theMode)
364 bool anIsNotPresent = ~theOutputMode & theMode;
366 theOutputMode |= theMode;
368 theOutputMode &= ~theMode;
371 void SetDisplayEntity(int theCommandID){
372 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
373 SALOME_ListIO selected;
375 aSel->selectedObjects( selected );
377 if(selected.Extent() >= 1){
378 SALOME_ListIteratorOfListIO It( selected );
379 for(; It.More(); It.Next()){
380 Handle(SALOME_InteractiveObject) IObject = It.Value();
381 if(IObject->hasEntry()){
382 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
383 unsigned int aMode = anActor->GetEntityMode();
384 switch(theCommandID){
386 InverseEntityMode(aMode,SMESH_Actor::eEdges);
389 InverseEntityMode(aMode,SMESH_Actor::eFaces);
392 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
395 aMode = SMESH_Actor::eAllEntity;
399 anActor->SetEntityMode(aMode);
406 void SetDisplayMode(int theCommandID){
407 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
408 SALOME_ListIO selected;
410 aSel->selectedObjects( selected );
412 if(selected.Extent() >= 1){
413 switch(theCommandID){
415 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
416 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
420 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
421 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
424 SALOME_ListIteratorOfListIO It( selected );
425 for(; It.More(); It.Next()){
426 Handle(SALOME_InteractiveObject) IObject = It.Value();
427 if(IObject->hasEntry()){
428 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
429 switch(theCommandID){
431 anActor->SetRepresentation(SMESH_Actor::eEdge);
434 anActor->SetRepresentation(SMESH_Actor::eSurface);
437 if(anActor->IsShrunk())
440 anActor->SetShrink();
443 anActor->SetRepresentation(SMESH_Actor::ePoint);
447 anActor->GetSufaceColor(color[0], color[1], color[2]);
448 int c0 = int (color[0] * 255);
449 int c1 = int (color[1] * 255);
450 int c2 = int (color[2] * 255);
451 QColor c(c0, c1, c2);
454 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
455 c0 = int (edgecolor[0] * 255);
456 c1 = int (edgecolor[1] * 255);
457 c2 = int (edgecolor[2] * 255);
458 QColor e(c0, c1, c2);
460 float backfacecolor[3];
461 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
462 c0 = int (backfacecolor[0] * 255);
463 c1 = int (backfacecolor[1] * 255);
464 c2 = int (backfacecolor[2] * 255);
465 QColor b(c0, c1, c2);
468 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
469 c0 = int (nodecolor[0] * 255);
470 c1 = int (nodecolor[1] * 255);
471 c2 = int (nodecolor[2] * 255);
472 QColor n(c0, c1, c2);
474 int Edgewidth = (int)anActor->GetLineWidth();
477 int intValue = int(anActor->GetNodeSize());
478 float Shrink = anActor->GetShrinkFactor();
480 SMESHGUI_Preferences_ColorDlg *aDlg =
481 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
482 aDlg->SetColor(1, c);
483 aDlg->SetColor(2, e);
484 aDlg->SetColor(3, n);
485 aDlg->SetColor(4, b);
486 aDlg->SetIntValue(1, Edgewidth);
487 aDlg->SetIntValue(2, intValue);
488 aDlg->SetIntValue(3, int(Shrink*100.));
490 QColor color = aDlg->GetColor(1);
491 QColor edgecolor = aDlg->GetColor(2);
492 QColor nodecolor = aDlg->GetColor(3);
493 QColor backfacecolor = aDlg->GetColor(4);
494 /* actor color and backface color */
495 anActor->SetSufaceColor(float (color.red()) / 255.,
496 float (color.green()) / 255.,
497 float (color.blue()) / 255.);
498 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
499 float (backfacecolor.green()) / 255.,
500 float (backfacecolor.blue()) / 255.);
503 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
504 float (edgecolor.green()) / 255.,
505 float (edgecolor.blue()) / 255.);
507 /* Shrink factor and size edges */
508 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
509 anActor->SetLineWidth(aDlg->GetIntValue(1));
511 /* Nodes color and size */
512 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
513 float (nodecolor.green()) / 255.,
514 float (nodecolor.blue()) / 255.);
515 anActor->SetNodeSize(aDlg->GetIntValue(2));
524 SMESH::RepaintCurrentView();
528 void Control( int theCommandID )
530 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
531 SALOME_ListIO selected;
533 aSel->selectedObjects( selected );
535 if( !selected.IsEmpty() ){
536 Handle(SALOME_InteractiveObject) anIO = selected.First();
539 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
540 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
541 switch ( theCommandID ){
543 aTitle = QObject::tr( "LENGTH_EDGES" );
544 aControl = SMESH_Actor::eLength;
547 aTitle = QObject::tr( "LENGTH2D_EDGES" );
548 aControl = SMESH_Actor::eLength2D;
551 aTitle = QObject::tr( "FREE_EDGES" );
552 aControl = SMESH_Actor::eFreeEdges;
555 aTitle = QObject::tr( "FREE_BORDERS" );
556 aControl = SMESH_Actor::eFreeBorders;
559 aTitle = QObject::tr( "MULTI_BORDERS" );
560 aControl = SMESH_Actor::eMultiConnection;
563 aTitle = QObject::tr( "MULTI2D_BORDERS" );
564 aControl = SMESH_Actor::eMultiConnection2D;
567 aTitle = QObject::tr( "AREA_ELEMENTS" );
568 aControl = SMESH_Actor::eArea;
571 aTitle = QObject::tr( "TAPER_ELEMENTS" );
572 aControl = SMESH_Actor::eTaper;
575 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
576 aControl = SMESH_Actor::eAspectRatio;
579 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
580 aControl = SMESH_Actor::eAspectRatio3D;
583 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
584 aControl = SMESH_Actor::eMinimumAngle;
587 aTitle = QObject::tr( "WARP_ELEMENTS" );
588 aControl = SMESH_Actor::eWarping;
591 aTitle = QObject::tr( "SKEW_ELEMENTS" );
592 aControl = SMESH_Actor::eSkew;
595 aTitle = QObject::tr( "SMESH_VOLUME" );
596 aControl = SMESH_Actor::eVolume3D;
599 anActor->SetControlMode(aControl);
600 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
601 SMESH::RepaintCurrentView();
608 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
609 MeshObjectType theType,
610 const QString theInTypeName,
611 QString & theOutTypeName)
613 SMESH_TypeFilter aTypeFilter( theType );
615 if( !theIO.IsNull() )
617 entry = theIO->getEntry();
618 LightApp_DataOwner owner( entry );
619 if ( aTypeFilter.isOk( &owner )) {
620 theOutTypeName = theInTypeName;
628 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
630 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
631 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
633 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
634 CORBA::String_var anID = aSComp->GetID().c_str();
635 if (!strcmp(anID.in(),theIO->getEntry()))
641 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
642 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
643 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
644 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
645 CheckOIType ( theIO, GROUP, "Group", aTypeName )
653 QString CheckHomogeneousSelection()
655 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
656 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
657 SALOME_ListIO selected;
659 aSel->selectedObjects( selected );
661 QString RefType = CheckTypeObject(selected.First());
662 SALOME_ListIteratorOfListIO It(selected);
663 for (; It.More(); It.Next())
665 Handle(SALOME_InteractiveObject) IObject = It.Value();
666 QString Type = CheckTypeObject(IObject);
667 if (Type.compare(RefType) != 0)
668 return "Heterogeneous Selection";
675 void SMESHGUI::OnEditDelete()
677 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
678 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
679 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
681 QString aParentComponent = QString::null;
682 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
684 QString cur = anIt.Value()->getComponentDataType();
685 if( aParentComponent.isNull() )
686 aParentComponent = cur;
687 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
688 aParentComponent = "";
691 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
692 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
693 QObject::tr("ERR_ERROR"),
694 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
695 QObject::tr("BUT_OK") );
698 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
699 if (SUIT_MessageBox::warn2
700 (SMESHGUI::desktop(),
701 QObject::tr("SMESH_WRN_WARNING"),
702 QObject::tr("SMESH_REALLY_DELETE"),
703 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
706 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
707 SUIT_ViewManager* vm = anApp->activeViewManager();
708 int nbSf = vm->getViewsCount();
710 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
711 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
712 _PTR(GenericAttribute) anAttr;
713 _PTR(AttributeIOR) anIOR;
715 SALOME_ListIteratorOfListIO It(selected);
717 aStudyBuilder->NewCommand(); // There is a transaction
718 for(; It.More(); It.Next()){
719 Handle(SALOME_InteractiveObject) IObject = It.Value();
720 if(IObject->hasEntry()){
721 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
723 // disable removal of "SMESH" component object
724 if(SO->FindAttribute(anAttr, "AttributeIOR")){
726 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
730 /* Erase child graphical objects */
731 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
732 for(it->InitEx(true); it->More(); it->Next()){
733 _PTR(SObject) CSO = it->Value();
734 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
737 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
738 for(int i = 0; i < nbSf; i++){
739 SUIT_ViewWindow *sf = aViews[i];
740 CORBA::String_var anEntry = CSO->GetID().c_str();
741 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
742 SMESH::RemoveActor(sf,anActor);
748 /* Erase main graphical object */
749 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
750 for(int i = 0; i < nbSf; i++){
751 SUIT_ViewWindow *sf = aViews[i];
752 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
753 SMESH::RemoveActor(sf,anActor);
757 // Remove object(s) from data structures
758 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
760 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
761 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
762 QString objType = CheckTypeObject(IObject);
763 if ( !aGroup->_is_nil() ) { // DELETE GROUP
764 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
765 aMesh->RemoveGroup( aGroup );
767 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
768 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
769 aMesh->RemoveSubMesh( aSubMesh );
771 else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
772 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
773 aStudyBuilder->RemoveObjectWithChildren( obj );
775 else {// default action: remove SObject from the study
776 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
777 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
779 aStudyBuilder->RemoveObjectWithChildren( obj );
784 } /* IObject->hasEntry() */
786 aStudyBuilder->CommitCommand();
788 /* Clear any previous selection */
790 aSel->setSelectedObjects( l1 );
792 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
797 Standard_EXPORT CAM_Module* createModule()
799 return new SMESHGUI();
803 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
805 //=============================================================================
809 //=============================================================================
810 SMESHGUI::SMESHGUI() :
811 SalomeApp_Module( "SMESH" )
813 if ( CORBA::is_nil( myComponentSMESH ) )
815 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
816 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
817 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
820 myActiveDialogBox = 0;
824 SMESH::GetFilterManager();
827 /* load resources for all available meshers */
828 SMESH::InitAvailableHypotheses();
831 //=============================================================================
835 //=============================================================================
836 SMESHGUI::~SMESHGUI()
838 SMESH::GetFilterManager()->Destroy();
839 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
842 //=============================================================================
846 //=============================================================================
847 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
849 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
851 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
856 bool SMESHGUI::automaticUpdate()
858 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
862 return resMgr->booleanValue( "SMESH", "auto_update", false );
865 //=============================================================================
869 //=============================================================================
870 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
872 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
875 //=============================================================================
879 //=============================================================================
880 SMESHGUI* SMESHGUI::GetSMESHGUI()
882 SMESHGUI* smeshMod = 0;
883 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
886 CAM_Module* module = app->module( "Mesh" );
887 smeshMod = dynamic_cast<SMESHGUI*>( module );
890 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
892 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
895 _PTR(Study) aStudy = study->studyDS();
897 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
906 Standard_EXPORT SMESHGUI* GetComponentGUI()
908 return SMESHGUI::GetSMESHGUI();
912 //=============================================================================
916 //=============================================================================
917 void SMESHGUI::SetState(int aState)
922 //=============================================================================
926 //=============================================================================
927 void SMESHGUI::ResetState()
932 //=============================================================================
936 //=============================================================================
937 void SMESHGUI::EmitSignalDeactivateDialog()
939 emit SignalDeactivateActiveDialog();
942 //=============================================================================
946 //=============================================================================
947 void SMESHGUI::EmitSignalStudyFrameChanged()
949 emit SignalStudyFrameChanged();
952 //=============================================================================
956 //=============================================================================
957 void SMESHGUI::EmitSignalCloseAllDialogs()
959 emit SignalCloseAllDialogs();
962 //=============================================================================
966 //=============================================================================
967 QDialog *SMESHGUI::GetActiveDialogBox()
969 return myActiveDialogBox;
972 //=============================================================================
976 //=============================================================================
977 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
979 myActiveDialogBox = (QDialog *) aDlg;
983 //=============================================================================
987 //=============================================================================
988 SUIT_Desktop* SMESHGUI::desktop()
990 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
992 return app->desktop();
997 //=============================================================================
1001 //=============================================================================
1002 SalomeApp_Study* SMESHGUI::activeStudy()
1004 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1006 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1011 //=============================================================================
1015 //=============================================================================
1016 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1018 /* Here the position is on the bottom right corner - 10 */
1019 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1021 SUIT_Desktop *PP = desktop();
1022 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1023 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1027 //=============================================================================
1031 //=============================================================================
1032 static int isStudyLocked(_PTR(Study) theStudy){
1033 return theStudy->GetProperties()->IsLocked();
1036 static bool checkLock(_PTR(Study) theStudy) {
1037 if (isStudyLocked(theStudy)) {
1038 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1039 QObject::tr("WRN_WARNING"),
1040 QObject::tr("WRN_STUDY_LOCKED"),
1041 QObject::tr("BUT_OK") );
1047 //=======================================================================
1048 //function : CheckActiveStudyLocked
1050 //=======================================================================
1052 bool SMESHGUI::isActiveStudyLocked()
1054 _PTR(Study) aStudy = activeStudy()->studyDS();
1055 return checkLock( aStudy );
1058 //=============================================================================
1062 //=============================================================================
1063 bool SMESHGUI::OnGUIEvent( int theCommandID )
1065 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1069 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1070 SUIT_ResourceMgr* mgr = resourceMgr();
1074 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1075 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1077 //QAction* act = action( theCommandID );
1079 switch (theCommandID) {
1081 if(checkLock(aStudy)) break;
1089 if(checkLock(aStudy)) break;
1090 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1094 case 122: // EXPORT MED
1101 ::ExportMeshToFile(theCommandID);
1105 case 200: // SCALAR BAR
1107 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1108 SALOME_ListIO selected;
1110 aSel->selectedObjects( selected );
1112 if( selected.Extent() ) {
1113 Handle(SALOME_InteractiveObject) anIO = selected.First();
1114 if( anIO->hasEntry() ) {
1115 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1116 anActor->SetControlMode( SMESH_Actor::eNone );
1124 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1128 case 1134: // Clipping
1129 case 1133: // Tranparency
1130 case 1132: // Colors / Size
1137 ::SetDisplayMode(theCommandID);
1143 case 219: // Volumes
1144 case 220: // All Entity
1145 ::SetDisplayEntity(theCommandID);
1150 if(checkLock(aStudy)) break;
1151 SMESH::UpdateView();
1154 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1155 aSel->selectedObjects( l );
1156 aSel->setSelectedObjects( l );
1161 case 301: // DISPLAY
1162 case 302: // DISPLAY ONLY
1164 SMESH::EDisplaing anAction;
1165 switch (theCommandID) {
1166 case 300: anAction = SMESH::eErase; break;
1167 case 301: anAction = SMESH::eDisplay; break;
1168 case 302: anAction = SMESH::eDisplayOnly; break;
1171 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1172 SALOME_ListIO sel_objects, to_process;
1174 aSel->selectedObjects( sel_objects );
1176 if( theCommandID==302 )
1177 startOperation( myEraseAll );
1179 extractContainers( sel_objects, to_process );
1182 SALOME_ListIteratorOfListIO It( to_process );
1183 for (; It.More(); It.Next()) {
1184 Handle(SALOME_InteractiveObject) IOS = It.Value();
1185 if (IOS->hasEntry()) {
1186 SMESH::UpdateView(anAction, IOS->getEntry());
1187 if (anAction == SMESH::eDisplayOnly)
1188 anAction = SMESH::eDisplay;
1193 if (anAction == SMESH::eErase) {
1195 aSel->setSelectedObjects( l1 );
1198 aSel->setSelectedObjects( to_process );
1204 if(checkLock(aStudy)) break;
1207 EmitSignalDeactivateDialog();
1209 new SMESHGUI_NodesDlg(this);
1212 SUIT_MessageBox::warn1(desktop(),
1213 tr("SMESH_WRN_WARNING"),
1214 tr("SMESH_WRN_VIEWER_VTK"),
1215 tr("SMESH_BUT_OK"));
1220 case 2151: // FILTER
1224 EmitSignalDeactivateDialog();
1225 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1230 case 406: // MOVE NODE
1234 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1235 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1239 if(checkLock(aStudy)) break;
1240 new SMESHGUI_MoveNodesDlg(this);
1244 case 701: // COMPUTE MESH
1246 if(checkLock(aStudy)) break;
1248 LightApp_SelectionMgr *Sel = selectionMgr();
1249 SALOME_ListIO selected; Sel->selectedObjects( selected );
1252 int nbSel = selected.Extent();
1257 SMESH::SMESH_Mesh_var aMesh;
1258 SMESH::SMESH_subMesh_var aSubMesh;
1259 Handle(SALOME_InteractiveObject) IObject = selected.First();
1260 if (IObject->hasEntry()) {
1261 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1262 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1263 if ( aShapeObject->_is_nil() ) {
1268 aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1269 aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1270 if ( !aSubMesh->_is_nil() )
1271 aMesh = aSubMesh->GetFather();
1273 if (!aMesh->_is_nil()) {
1274 // if(!GetSMESHGen()->IsReadyToCompute(aMesh,aShapeObject)) {
1275 // SUIT_MessageBox::warn1(desktop(),
1276 // tr("SMESH_WRN_WARNING"),
1277 // tr("SMESH_WRN_MISSING_PARAMETERS"),
1278 // tr("SMESH_BUT_OK"));
1281 SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1282 if ( errors->length() > 0 ) {
1283 SUIT_MessageBox::warn1(desktop(),
1284 tr("SMESH_WRN_WARNING"),
1285 SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1286 tr("SMESH_BUT_OK"));
1290 if (GetSMESHGen()->Compute(aMesh,aShapeObject))
1291 SMESH::ModifiedMesh(aMeshSObj,true);
1293 SUIT_MessageBox::warn1(desktop(),
1294 tr("SMESH_WRN_WARNING"),
1295 tr("SMESH_WRN_COMPUTE_FAILED"),
1296 tr("SMESH_BUT_OK"));
1298 catch(const SALOME::SALOME_Exception & S_ex){
1299 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1304 CORBA::Long anId = aStudy->StudyId();
1305 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1306 if ( automaticUpdate() && aVisualObj){
1307 aVisualObj->Update();
1308 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1310 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1312 SMESH::DisplayActor(view,anActor); //apo
1316 SMESH::RepaintCurrentView();
1319 SUIT_MessageBox::warn1(desktop(),
1320 tr("SMESH_WRN_WARNING"),
1321 tr("SMESH_WRN_VIEWER_VTK"),
1322 tr("SMESH_BUT_OK"));
1325 Sel->setSelectedObjects( selected );
1329 case 702: // Create mesh
1330 startOperation( 702 );
1332 case 703: // Create sub-mesh
1333 startOperation( 703 );
1335 case 704: // Edit mesh/sub-mesh
1336 startOperation( 704 );
1338 case 407: // DIAGONAL INVERSION
1339 case 408: // Delete diagonal
1343 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1344 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1348 if ( checkLock( aStudy ) )
1351 /*Standard_Boolean aRes;
1352 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1353 if ( aMesh->_is_nil() )
1355 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1356 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1360 EmitSignalDeactivateDialog();
1361 if ( theCommandID == 407 )
1362 new SMESHGUI_TrianglesInversionDlg(this);
1364 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1367 case 409: // Change orientation
1368 case 410: // Union of triangles
1369 case 411: // Cutting of quadrangles
1373 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1374 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1378 if ( checkLock( aStudy ) )
1381 EmitSignalDeactivateDialog();
1382 SMESHGUI_MultiEditDlg* aDlg = NULL;
1383 if ( theCommandID == 409 )
1384 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1385 else if ( theCommandID == 410 )
1386 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1388 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1391 DefineDlgPosition( aDlg, x, y );
1396 case 412: // Smoothing
1398 if(checkLock(aStudy)) break;
1400 EmitSignalDeactivateDialog();
1401 new SMESHGUI_SmoothingDlg( this );
1404 SUIT_MessageBox::warn1(desktop(),
1405 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1406 tr("SMESH_BUT_OK"));
1410 case 413: // Extrusion
1412 if (checkLock(aStudy)) break;
1414 EmitSignalDeactivateDialog();
1415 new SMESHGUI_ExtrusionDlg ( this );
1417 SUIT_MessageBox::warn1(desktop(),
1418 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1419 tr("SMESH_BUT_OK"));
1423 case 414: // Revolution
1425 if(checkLock(aStudy)) break;
1427 EmitSignalDeactivateDialog();
1428 new SMESHGUI_RevolutionDlg( this );
1431 SUIT_MessageBox::warn1(desktop(),
1432 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1433 tr("SMESH_BUT_OK"));
1437 case 415: // Pattern mapping
1439 if ( checkLock( aStudy ) )
1443 EmitSignalDeactivateDialog();
1444 new SMESHGUI_MeshPatternDlg( this );
1447 SUIT_MessageBox::warn1(desktop(),
1448 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1449 tr("SMESH_BUT_OK"));
1453 case 416: // Extrusion along a path
1455 if (checkLock(aStudy)) break;
1457 EmitSignalDeactivateDialog();
1458 new SMESHGUI_ExtrusionAlongPathDlg( this );
1460 SUIT_MessageBox::warn1(desktop(),
1461 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1462 tr("SMESH_BUT_OK"));
1466 case 801: // CREATE GROUP
1470 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1471 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1475 if(checkLock(aStudy)) break;
1476 EmitSignalDeactivateDialog();
1477 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1479 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1480 SALOME_ListIO selected;
1482 aSel->selectedObjects( selected );
1484 int nbSel = selected.Extent();
1486 // check if mesh is selected
1487 aMesh = SMESH::GetMeshByIO( selected.First() );
1489 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1494 case 802: // CONSTRUCT GROUP
1498 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1499 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1503 if(checkLock(aStudy)) break;
1504 EmitSignalDeactivateDialog();
1506 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1507 SALOME_ListIO selected;
1509 aSel->selectedObjects( selected );
1511 int nbSel = selected.Extent();
1513 // check if submesh is selected
1514 Handle(SALOME_InteractiveObject) IObject = selected.First();
1515 if (IObject->hasEntry()) {
1516 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1518 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1519 if (!aSubMesh->_is_nil()) {
1521 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1522 // get submesh elements list by types
1523 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1524 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1525 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1526 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1527 // create group for each type o elements
1528 QString aName = IObject->getName();
1529 if (aNodes->length() > 0) {
1530 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1531 aGroup->Add(aNodes.inout());
1533 if (aEdges->length() > 0) {
1534 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1535 aGroup->Add(aEdges.inout());
1537 if (aFaces->length() > 0) {
1538 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1539 aGroup->Add(aFaces.inout());
1541 if (aVolumes->length() > 0) {
1542 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1543 aGroup->Add(aVolumes.inout());
1547 }catch(const SALOME::SALOME_Exception & S_ex){
1548 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1557 case 803: // EDIT GROUP
1561 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1562 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1566 if(checkLock(aStudy)) break;
1567 EmitSignalDeactivateDialog();
1569 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1570 SALOME_ListIO selected;
1572 aSel->selectedObjects( selected );
1574 SALOME_ListIteratorOfListIO It (selected);
1575 int nbSelectedGroups = 0;
1576 for ( ; It.More(); It.Next() )
1578 SMESH::SMESH_Group_var aGroup =
1579 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1580 if (!aGroup->_is_nil()) {
1582 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1586 if (nbSelectedGroups == 0)
1588 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1594 case 804: // Add elements to group
1596 if(checkLock(aStudy)) break;
1597 if (myState == 800) {
1598 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1599 if (aDlg) aDlg->onAdd();
1604 case 805: // Remove elements from group
1606 if(checkLock(aStudy)) break;
1607 if (myState == 800) {
1608 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1609 if (aDlg) aDlg->onRemove();
1614 case 810: // Union Groups
1615 case 811: // Intersect groups
1616 case 812: // Cut groups
1620 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1621 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1625 if ( checkLock( aStudy ) )
1628 EmitSignalDeactivateDialog();
1631 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1632 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1633 else aMode = SMESHGUI_GroupOpDlg::CUT;
1635 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1639 case 813: // Delete groups with their contents
1643 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1644 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1648 if ( checkLock( aStudy ) )
1651 EmitSignalDeactivateDialog();
1653 new SMESHGUI_DeleteGroupDlg( this );
1657 case 900: // MESH INFOS
1659 EmitSignalDeactivateDialog();
1660 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1661 SALOME_ListIO selected;
1663 aSel->selectedObjects( selected );
1665 if ( selected.Extent() > 1 ) { // a dlg for each IO
1667 SALOME_ListIteratorOfListIO It (selected);
1668 for ( ; It.More(); It.Next() ) {
1669 IOs.Clear(); IOs.Append( It.Value() );
1670 aSel->setSelectedObjects( IOs );
1671 new SMESHGUI_MeshInfosDlg(this, "", false);
1673 // restore selection
1674 aSel->setSelectedObjects( selected );
1677 new SMESHGUI_MeshInfosDlg(this, "", false);
1681 case 902: // STANDARD MESH INFOS
1683 EmitSignalDeactivateDialog();
1684 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1685 SALOME_ListIO selected;
1687 aSel->selectedObjects( selected );
1689 if ( selected.Extent() > 1 ) { // a dlg for each IO
1691 SALOME_ListIteratorOfListIO It (selected);
1692 for ( ; It.More(); It.Next() ) {
1694 IOs.Append( It.Value() );
1695 aSel->setSelectedObjects( IOs );
1696 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1698 // restore selection
1699 aSel->setSelectedObjects( selected );
1702 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1706 case 1100: // EDIT HYPOTHESIS
1708 if(checkLock(aStudy)) break;
1710 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1711 SALOME_ListIO selected;
1713 aSel->selectedObjects( selected );
1715 int nbSel = selected.Extent();
1718 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1720 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1721 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1722 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1723 if ( !Hyp->_is_nil() )
1725 char* sName = Hyp->GetName();
1726 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1728 aCreator->edit( Hyp.in(), desktop() );
1735 updateObjBrowser( true );
1739 case 1101: // RENAME
1741 if ( checkLock( aStudy ) )
1744 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1745 SALOME_ListIO selected;
1747 aSel->selectedObjects( selected );
1749 SALOME_ListIteratorOfListIO It( selected );
1750 for ( ; It.More(); It.Next() )
1752 Handle(SALOME_InteractiveObject) IObject = It.Value();
1753 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1754 _PTR(GenericAttribute) anAttr;
1755 _PTR(AttributeName) aName;
1758 if ( obj->FindAttribute(anAttr, "AttributeName") )
1761 QString newName = QString(aName->Value().c_str());
1763 newName = QInputDialog::getText( tr( "Rename" ), tr( "Enter new name:" ), QLineEdit::Normal,
1764 newName, &ok, desktop() );
1765 if ( ok && !newName.isEmpty() )
1767 //old source: aStudy->renameIObject( IObject, newName );
1768 aName->SetValue( newName.latin1() );
1770 // if current object is group update group's name
1771 SMESH::SMESH_GroupBase_var aGroup =
1772 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1773 if (!aGroup->_is_nil() )
1774 aGroup->SetName( newName.latin1() );
1784 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1786 if(checkLock(aStudy)) break;
1787 SUIT_OverrideCursor wc;
1789 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1790 SALOME_ListIO selected;
1792 aSel->selectedObjects( selected, QString::null, false );
1794 SALOME_ListIteratorOfListIO It(selected);
1795 for (int i = 0; It.More(); It.Next(), i++) {
1796 Handle(SALOME_InteractiveObject) IObject = It.Value();
1797 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1800 aSel->setSelectedObjects( l1 );
1805 case 401: // GEOM::EDGE
1806 case 4021: // TRIANGLE
1808 case 4023: // POLYGON
1812 if(checkLock(aStudy)) break;
1814 EmitSignalDeactivateDialog();
1815 SMDSAbs_ElementType type = SMDSAbs_Edge;
1817 switch (theCommandID) {
1818 case 4021: // TRIANGLE
1819 type = SMDSAbs_Face; nbNodes = 3; break;
1821 type = SMDSAbs_Face; nbNodes = 4; break;
1823 type = SMDSAbs_Volume; nbNodes = 4; break;
1824 case 4023: // POLYGON
1825 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1827 type = SMDSAbs_Volume; nbNodes = 8; break;
1828 case 4033: // POLYHEDRE
1829 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1832 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1835 SUIT_MessageBox::warn1(desktop(),
1836 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1837 tr("SMESH_BUT_OK"));
1841 case 4033: // POLYHEDRON
1843 if(checkLock(aStudy)) break;
1845 EmitSignalDeactivateDialog();
1846 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1849 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1850 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1851 tr("SMESH_BUT_OK"));
1855 case 4041: // REMOVES NODES
1857 if(checkLock(aStudy)) break;
1859 EmitSignalDeactivateDialog();
1860 new SMESHGUI_RemoveNodesDlg(this);
1863 SUIT_MessageBox::warn1(desktop(),
1864 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1865 tr("SMESH_BUT_OK"));
1869 case 4042: // REMOVES ELEMENTS
1871 if(checkLock(aStudy)) break;
1873 EmitSignalDeactivateDialog();
1874 new SMESHGUI_RemoveElementsDlg(this);
1878 SUIT_MessageBox::warn1(desktop(),
1879 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1880 tr("SMESH_BUT_OK"));
1884 case 4051: // RENUMBERING NODES
1886 if(checkLock(aStudy)) break;
1888 EmitSignalDeactivateDialog();
1889 new SMESHGUI_RenumberingDlg( this, "", 0);
1893 SUIT_MessageBox::warn1(desktop(),
1894 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1895 tr("SMESH_BUT_OK"));
1899 case 4052: // RENUMBERING ELEMENTS
1901 if(checkLock(aStudy)) break;
1903 EmitSignalDeactivateDialog();
1904 new SMESHGUI_RenumberingDlg( this, "", 1);
1908 SUIT_MessageBox::warn1(desktop(),
1909 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1910 tr("SMESH_BUT_OK"));
1914 case 4061: // TRANSLATION
1916 if(checkLock(aStudy)) break;
1918 EmitSignalDeactivateDialog();
1919 new SMESHGUI_TranslationDlg( this );
1922 SUIT_MessageBox::warn1(desktop(),
1923 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1924 tr("SMESH_BUT_OK"));
1928 case 4062: // ROTATION
1930 if(checkLock(aStudy)) break;
1932 EmitSignalDeactivateDialog();
1933 new SMESHGUI_RotationDlg( this );
1936 SUIT_MessageBox::warn1(desktop(),
1937 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1938 tr("SMESH_BUT_OK"));
1942 case 4063: // SYMMETRY
1944 if(checkLock(aStudy)) break;
1946 EmitSignalDeactivateDialog();
1947 new SMESHGUI_SymmetryDlg( this );
1950 SUIT_MessageBox::warn1(desktop(),
1951 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1952 tr("SMESH_BUT_OK"));
1956 case 4064: // SEWING
1958 if(checkLock(aStudy)) break;
1960 EmitSignalDeactivateDialog();
1961 new SMESHGUI_SewingDlg( this );
1964 SUIT_MessageBox::warn1(desktop(),
1965 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1966 tr("SMESH_BUT_OK"));
1970 case 4065: // MERGE NODES
1972 if(checkLock(aStudy)) break;
1974 EmitSignalDeactivateDialog();
1975 new SMESHGUI_MergeNodesDlg( this );
1978 SUIT_MessageBox::warn1(desktop(),
1979 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1980 tr("SMESH_BUT_OK"));
1984 case 4066: // MERGE EQUAL ELEMENTS
1986 if (checkLock(aStudy)) break;
1988 EmitSignalDeactivateDialog();
1989 new SMESHGUI_EditMeshDlg(this,
1990 "SMESH_MERGE_ELEMENTS_TITLE",
1991 "ICON_DLG_MERGE_ELEMENTS",
1992 1); // MergeEqualElemets
1994 SUIT_MessageBox::warn1(desktop(),
1995 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1996 tr("SMESH_BUT_OK"));
2001 case 5105: // Library of selection filters
2003 static QValueList<int> aTypes;
2004 if ( aTypes.isEmpty() )
2006 aTypes.append( SMESH::NODE );
2007 aTypes.append( SMESH::EDGE );
2008 aTypes.append( SMESH::FACE );
2009 aTypes.append( SMESH::VOLUME );
2011 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2015 case 6017: // CONTROLS
2031 LightApp_SelectionMgr* mgr = selectionMgr();
2032 SALOME_ListIO selected; mgr->selectedObjects( selected );
2034 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2035 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2037 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2038 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2039 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2040 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2041 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2042 ::Control( theCommandID );
2047 SUIT_MessageBox::warn1(desktop(),
2048 tr( "SMESH_WRN_WARNING" ),
2049 tr( "SMESH_BAD_SELECTION" ),
2050 tr( "SMESH_BUT_OK" ) );
2054 SUIT_MessageBox::warn1(desktop(),
2055 tr( "SMESH_WRN_WARNING" ),
2056 tr( "NOT_A_VTK_VIEWER" ),
2057 tr( "SMESH_BUT_OK" ) );
2062 LightApp_SelectionMgr* mgr = selectionMgr();
2063 SALOME_ListIO selected; mgr->selectedObjects( selected );
2065 if (selected.Extent() == 1) {
2066 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2067 if(anIObject->hasEntry())
2068 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2069 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2076 LightApp_SelectionMgr* mgr = selectionMgr();
2077 SALOME_ListIO selected; mgr->selectedObjects( selected );
2079 if (selected.Extent() == 1) {
2080 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2081 if(anIObject->hasEntry())
2082 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2083 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2090 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2091 //updateObjBrowser();
2095 //=============================================================================
2099 //=============================================================================
2100 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2105 //=============================================================================
2109 //=============================================================================
2110 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2115 //=============================================================================
2119 //=============================================================================
2120 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2125 //=============================================================================
2126 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2127 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2129 //=============================================================================
2130 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2131 SUIT_ViewWindow* wnd )
2133 if(theIO->hasEntry()){
2134 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2135 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2139 //=======================================================================
2140 // function : createSMESHAction
2142 //=======================================================================
2143 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2146 QWidget* parent = application()->desktop();
2147 SUIT_ResourceMgr* resMgr = resourceMgr();
2149 if ( icon_id.length() )
2150 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2152 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2153 if ( !pix.isNull() )
2154 icon = QIconSet( pix );
2156 QString tooltip = tr( QString( "TOP_" )+po_id ),
2157 menu = tr( QString( "MEN_" )+po_id ),
2158 status_bar = tr( QString( "STB_" )+po_id );
2160 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2163 //=======================================================================
2164 // function : createPopupItem
2166 //=======================================================================
2167 void SMESHGUI::createPopupItem( const int id,
2168 const QString& clients,
2169 const QString& types,
2170 const QString& theRule,
2175 parentId = popupMgr()->actionId( action( pId ) );
2177 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2178 popupMgr()->insert( action( id ), parentId, 0 );
2180 QChar lc = QtxPopupMgr::Selection::defEquality();
2181 QString rule = "(%1) and (%2) and (%3)";
2182 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2183 if( clients.isEmpty() )
2184 rule = rule.arg( QString( "true" ) );
2186 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2187 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2190 bool cont = myRules.contains( id );
2192 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2194 popupMgr()->setRule( action( id ), rule, true );
2195 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2198 //=======================================================================
2199 // function : initialize
2201 //=======================================================================
2202 void SMESHGUI::initialize( CAM_Application* app )
2204 SalomeApp_Module::initialize( app );
2206 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2208 /* Automatic Update flag */
2209 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2211 // ----- create actions --------------
2213 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2214 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2215 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2216 createSMESHAction( 114, "NUM" );
2217 createSMESHAction( 121, "DAT" );
2218 createSMESHAction( 122, "MED" );
2219 createSMESHAction( 123, "UNV" );
2220 createSMESHAction( 124, "EXPORT_DAT" );
2221 createSMESHAction( 125, "EXPORT_MED" );
2222 createSMESHAction( 126, "EXPORT_UNV" );
2223 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2224 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2225 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2226 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2227 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2228 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2229 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2230 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2231 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2232 createSMESHAction( 804, "ADD" );
2233 createSMESHAction( 805, "REMOVE" );
2234 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2235 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2236 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2237 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2238 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2239 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2240 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2241 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2242 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2243 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2244 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2245 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2246 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2247 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2248 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2249 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2250 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2251 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2252 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2253 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2254 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2255 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2256 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2257 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2258 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2259 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2260 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2261 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2262 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2263 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2264 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2265 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2266 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2267 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2268 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2269 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2270 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2271 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2272 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2273 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2274 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2275 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2276 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2277 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2278 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2279 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2280 createSMESHAction( 415, "MAP", "ICON_MAP" );
2281 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2282 createSMESHAction( 200, "RESET" );
2283 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2284 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2285 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2286 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2287 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2288 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2289 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2290 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2291 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2292 createSMESHAction( 220, "ALL" );
2293 createSMESHAction( 1100, "EDIT_HYPO" );
2294 createSMESHAction( 1101, "RENAME" );
2295 createSMESHAction( 1102, "UNASSIGN" );
2296 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2297 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2298 createSMESHAction( 1131, "DISPMODE" );
2299 createSMESHAction( 1132, "COLORS" );
2300 createSMESHAction( 1133, "TRANSP" );
2301 createSMESHAction( 1134, "CLIP" );
2302 createSMESHAction( 1135, "DISP_ENT" );
2303 createSMESHAction( 2000, "CTRL" );
2305 createSMESHAction( 300, "ERASE" );
2306 createSMESHAction( 301, "DISPLAY" );
2307 createSMESHAction( 302, "DISPLAY_ONLY" );
2308 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2310 // ----- create menu --------------
2311 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2312 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2313 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2314 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2315 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2316 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2317 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2319 createMenu( separator(), fileId );
2321 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2322 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2323 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2324 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2325 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2326 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2328 createMenu( 111, importId, -1 );
2329 createMenu( 112, importId, -1 );
2330 createMenu( 113, importId, -1 );
2332 createMenu( 121, exportId, -1 );
2333 createMenu( 122, exportId, -1 );
2334 createMenu( 123, exportId, -1 );
2336 createMenu( separator(), fileId, 10 );
2338 createMenu( 33, editId, -1 );
2340 createMenu( 5105, toolsId, -1 );
2342 createMenu( 702, meshId, -1 );
2343 createMenu( 703, meshId, -1 );
2344 createMenu( 704, meshId, -1 );
2345 createMenu( separator(), meshId, -1 );
2346 createMenu( 701, meshId, -1 );
2347 createMenu( separator(), meshId, -1 );
2348 createMenu( 801, meshId, -1 );
2349 createMenu( 802, meshId, -1 );
2350 createMenu( 803, meshId, -1 );
2351 createMenu( separator(), meshId, -1 );
2352 createMenu( 810, meshId, -1 );
2353 createMenu( 811, meshId, -1 );
2354 createMenu( 812, meshId, -1 );
2355 createMenu( separator(), meshId, -1 );
2356 createMenu( 813, meshId, -1 );
2357 createMenu( separator(), meshId, -1 );
2358 createMenu( 900, meshId, -1 );
2359 createMenu( 902, meshId, -1 );
2360 createMenu( separator(), meshId, -1 );
2362 createMenu( 6003, ctrlId, -1 );
2363 createMenu( 6001, ctrlId, -1 );
2364 createMenu( 6004, ctrlId, -1 );
2365 createMenu( separator(), ctrlId, -1 );
2366 createMenu( 6002, ctrlId, -1 );
2367 createMenu( 6018, ctrlId, -1 );
2368 createMenu( 6019, ctrlId, -1 );
2369 createMenu( 6011, ctrlId, -1 );
2370 createMenu( 6012, ctrlId, -1 );
2371 createMenu( 6013, ctrlId, -1 );
2372 createMenu( 6014, ctrlId, -1 );
2373 createMenu( 6015, ctrlId, -1 );
2374 createMenu( 6016, ctrlId, -1 );
2375 createMenu( separator(), ctrlId, -1 );
2376 createMenu( 6017, ctrlId, -1 );
2377 createMenu( 6009, ctrlId, -1 );
2378 createMenu( separator(), ctrlId, -1 );
2380 createMenu( 400, addId, -1 );
2381 createMenu( 401, addId, -1 );
2382 createMenu( 4021, addId, -1 );
2383 createMenu( 4022, addId, -1 );
2384 createMenu( 4023, addId, -1 );
2385 createMenu( 4031, addId, -1 );
2386 createMenu( 4032, addId, -1 );
2387 createMenu( 4033, addId, -1 );
2389 createMenu( 4041, removeId, -1 );
2390 createMenu( 4042, removeId, -1 );
2392 createMenu( 4051, renumId, -1 );
2393 createMenu( 4052, renumId, -1 );
2395 createMenu( 4061, transfId, -1 );
2396 createMenu( 4062, transfId, -1 );
2397 createMenu( 4063, transfId, -1 );
2398 createMenu( 4064, transfId, -1 );
2399 createMenu( 4065, transfId, -1 );
2400 createMenu( 4066, transfId, -1 );
2402 createMenu( 406, modifyId, -1 );
2403 createMenu( 407, modifyId, -1 );
2404 createMenu( 408, modifyId, -1 );
2405 createMenu( 409, modifyId, -1 );
2406 createMenu( 410, modifyId, -1 );
2407 createMenu( 411, modifyId, -1 );
2408 createMenu( 412, modifyId, -1 );
2409 createMenu( 413, modifyId, -1 );
2410 createMenu( 416, modifyId, -1 );
2411 createMenu( 414, modifyId, -1 );
2412 createMenu( 415, modifyId, -1 );
2414 createMenu( 214, viewId, -1 );
2416 // ----- create toolbars --------------
2417 int meshTb = createTool( tr( "TB_MESH" ) ),
2418 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2419 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2420 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2421 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2423 createTool( 702, meshTb );
2424 createTool( 703, meshTb );
2425 createTool( 704, meshTb );
2426 createTool( separator(), meshTb );
2427 createTool( 701, meshTb );
2428 createTool( separator(), meshTb );
2429 createTool( 801, meshTb );
2430 createTool( 802, meshTb );
2431 createTool( 803, meshTb );
2432 createTool( separator(), meshTb );
2433 createTool( 900, meshTb );
2434 createTool( 902, meshTb );
2435 createTool( separator(), meshTb );
2437 createTool( 6001, ctrlTb );
2438 createTool( 6003, ctrlTb );
2439 createTool( 6004, ctrlTb );
2440 createTool( separator(), ctrlTb );
2441 createTool( 6002, ctrlTb );
2442 createTool( 6018, ctrlTb );
2443 createTool( 6019, ctrlTb );
2444 createTool( 6011, ctrlTb );
2445 createTool( 6012, ctrlTb );
2446 createTool( 6013, ctrlTb );
2447 createTool( 6014, ctrlTb );
2448 createTool( 6015, ctrlTb );
2449 createTool( 6016, ctrlTb );
2450 createTool( separator(), ctrlTb );
2451 createTool( 6017, ctrlTb );
2452 createTool( 6009, ctrlTb );
2453 createTool( separator(), ctrlTb );
2455 createTool( 400, addRemTb );
2456 createTool( 401, addRemTb );
2457 createTool( 4021, addRemTb );
2458 createTool( 4022, addRemTb );
2459 createTool( 4023, addRemTb );
2460 createTool( 4031, addRemTb );
2461 createTool( 4032, addRemTb );
2462 createTool( 4033, addRemTb );
2463 createTool( separator(), addRemTb );
2464 createTool( 4041, addRemTb );
2465 createTool( 4042, addRemTb );
2466 createTool( separator(), addRemTb );
2467 createTool( 4051, addRemTb );
2468 createTool( 4052, addRemTb );
2469 createTool( separator(), addRemTb );
2470 createTool( 4061, addRemTb );
2471 createTool( 4062, addRemTb );
2472 createTool( 4063, addRemTb );
2473 createTool( 4064, addRemTb );
2474 createTool( 4065, addRemTb );
2475 createTool( 4066, addRemTb );
2476 createTool( separator(), addRemTb );
2478 createTool( 406, modifyTb );
2479 createTool( 407, modifyTb );
2480 createTool( 408, modifyTb );
2481 createTool( 409, modifyTb );
2482 createTool( 410, modifyTb );
2483 createTool( 411, modifyTb );
2484 createTool( 412, modifyTb );
2485 createTool( 413, modifyTb );
2486 createTool( 416, modifyTb );
2487 createTool( 414, modifyTb );
2488 createTool( 415, modifyTb );
2490 createTool( 214, dispModeTb );
2494 QString OB = "'ObjectBrowser'",
2495 View = "'" + SVTK_Viewer::Type() + "'",
2497 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2498 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2499 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2500 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2501 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2502 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2503 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2504 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2505 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2506 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2508 mesh_group = mesh + " " + subMesh + " " + group,
2509 hyp_alg = hypo + " " + algo;
2511 // popup for object browser
2513 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2514 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2515 createPopupItem( 803, OB, group ); // EDIT_GROUP
2516 popupMgr()->insert( separator(), -1, 0 );
2517 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2518 createPopupItem( 214, OB, mesh_group ); // UPDATE
2519 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2520 createPopupItem( 902, OB, mesh ); // STD_INFO
2521 popupMgr()->insert( separator(), -1, 0 );
2522 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2523 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2524 popupMgr()->insert( separator(), -1, 0 );
2525 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2526 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2527 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2528 popupMgr()->insert( separator(), -1, 0 );
2530 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2531 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2532 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2533 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2534 popupMgr()->insert( separator(), -1, 0 );
2537 createPopupItem( 803, View, group ); // EDIT_GROUP
2538 createPopupItem( 804, View, elems ); // ADD
2539 createPopupItem( 805, View, elems ); // REMOVE
2540 popupMgr()->insert( separator(), -1, 0 );
2541 createPopupItem( 214, View, mesh_group ); // UPDATE
2542 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2543 createPopupItem( 902, View, mesh ); // STD_INFO
2544 popupMgr()->insert( separator(), -1, 0 );
2548 isInvisible("not( isVisible )"),
2549 isEmpty("numberOfNodes = 0"),
2550 isNotEmpty("numberOfNodes <> 0"),
2552 // has nodes, edges, etc in VISIBLE! actor
2553 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2554 hasElems("(count( elemTypes ) > 0)"),
2555 hasDifferentElems("(count( elemTypes ) > 1)"),
2556 hasEdges("({'Edge'} in elemTypes)"),
2557 hasFaces("({'Face'} in elemTypes)"),
2558 hasVolumes("({'Volume'} in elemTypes)");
2560 QString lc = QtxPopupMgr::Selection::defEquality();
2561 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2562 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2563 aType = aType.arg( mesh_group );
2564 QString aMeshInVTK = aClient + "&&" + aType;
2566 //-------------------------------------------------
2568 //-------------------------------------------------
2569 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2571 popupMgr()->insert( action( 9010 ), anId, -1 );
2572 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2573 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2575 popupMgr()->insert( action( 9011 ), anId, -1 );
2576 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2577 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2579 popupMgr()->insert( separator(), -1, -1 );
2581 //-------------------------------------------------
2583 //-------------------------------------------------
2584 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2586 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2587 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2588 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2590 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2591 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2592 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2594 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2595 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2596 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2598 popupMgr()->insert( separator(), anId, -1 );
2600 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2601 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2602 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2604 //-------------------------------------------------
2606 //-------------------------------------------------
2607 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2609 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2611 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2612 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2613 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2615 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2616 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2617 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2619 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2620 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2621 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2623 popupMgr()->insert( separator(), anId, -1 );
2625 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2626 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2628 //-------------------------------------------------
2630 //-------------------------------------------------
2631 popupMgr()->insert( action( 1132 ), -1, -1 );
2632 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2634 //-------------------------------------------------
2636 //-------------------------------------------------
2637 popupMgr()->insert( action( 1133 ), -1, -1 );
2638 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2640 //-------------------------------------------------
2642 //-------------------------------------------------
2643 popupMgr()->insert( action( 1134 ), -1, -1 );
2644 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2646 popupMgr()->insert( separator(), -1, -1 );
2648 //-------------------------------------------------
2650 //-------------------------------------------------
2652 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2653 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2654 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2656 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2658 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2659 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2661 popupMgr()->insert( separator(), anId, -1 );
2663 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2664 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2665 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2667 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2668 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2669 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2671 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2672 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2673 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2675 popupMgr()->insert( separator(), anId, -1 );
2677 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2678 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2679 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2681 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2682 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2683 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2685 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2686 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2687 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2689 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2690 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2691 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2693 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2694 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2695 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2697 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2698 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2699 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2701 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2702 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2703 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2705 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2706 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2707 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2709 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2710 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2711 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2713 popupMgr()->insert( separator(), anId, -1 );
2715 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2716 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2717 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2719 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2720 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2721 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2723 popupMgr()->insert( separator(), anId, -1 );
2725 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2726 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2728 popupMgr()->insert( separator(), -1, -1 );
2730 //-------------------------------------------------
2732 //-------------------------------------------------
2733 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2734 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2735 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2737 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2738 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2739 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2740 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2742 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2743 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2745 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2746 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2748 popupMgr()->insert( separator(), -1, -1 );
2750 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2751 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2754 bool SMESHGUI::activateModule( SUIT_Study* study )
2756 bool res = SalomeApp_Module::activateModule( study );
2758 setMenuShown( true );
2759 setToolShown( true );
2764 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2766 setMenuShown( false );
2767 setToolShown( false );
2769 EmitSignalCloseAllDialogs();
2771 return SalomeApp_Module::deactivateModule( study );
2774 void SMESHGUI::OnGUIEvent()
2776 const QObject* obj = sender();
2777 if ( !obj || !obj->inherits( "QAction" ) )
2779 int id = actionId((QAction*)obj);
2784 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2786 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2787 if ( CORBA::is_nil( myComponentSMESH ) )
2789 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2791 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2792 return aGUI.myComponentSMESH;
2795 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2796 return myComponentSMESH;
2799 QString SMESHGUI::engineIOR() const
2801 CORBA::ORB_var anORB = getApp()->orb();
2802 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2806 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2808 SMESHGUI_Selection sel;
2809 sel.init( client, selectionMgr() );
2810 popupMgr()->updatePopup( menu, &sel );
2813 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2815 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2816 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2819 void SMESHGUI::viewManagers( QStringList& list ) const
2821 list.append( SVTK_Viewer::Type() );
2824 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
2826 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
2827 SMESH::UpdateSelectionProp( this );
2830 void SMESHGUI::createPreferences()
2832 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2834 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2835 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
2837 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2838 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
2839 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
2841 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2842 setPreferenceProperty( precGroup, "columns", 1 );
2844 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2846 setPreferenceProperty( prec, "min", 0 );
2847 setPreferenceProperty( prec, "max", 16 );
2849 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2850 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
2852 modes.append( "Wireframe" );
2853 modes.append( "Shading" );
2854 modes.append( "Nodes" );
2855 modes.append( "Shrink" );
2856 QValueList<QVariant> indices;
2857 indices.append( 0 );
2858 indices.append( 1 );
2859 indices.append( 2 );
2860 indices.append( 3 );
2861 setPreferenceProperty( dispmode, "strings", modes );
2862 setPreferenceProperty( dispmode, "indexes", indices );
2864 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
2865 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
2867 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2868 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2870 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
2871 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
2873 setPreferenceProperty( nodeSz, "min", 1 );
2874 setPreferenceProperty( nodeSz, "max", 5 );
2876 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2878 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
2879 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
2880 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
2881 addPreference( "", elemGroup, LightApp_Preferences::Space );
2883 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
2884 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2886 setPreferenceProperty( elemW, "min", 1 );
2887 setPreferenceProperty( elemW, "max", 5 );
2889 setPreferenceProperty( shrink, "min", 0 );
2890 setPreferenceProperty( shrink, "max", 100 );
2892 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2894 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2896 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
2897 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
2898 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
2900 setPreferenceProperty( selW, "min", 1 );
2901 setPreferenceProperty( selW, "max", 5 );
2903 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2905 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
2906 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2908 setPreferenceProperty( preW, "min", 1 );
2909 setPreferenceProperty( preW, "max", 5 );
2911 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2913 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
2914 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
2916 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2917 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2919 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2920 addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2921 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2922 addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
2925 fam.append( tr( "SMESH_FONT_ARIAL" ) );
2926 fam.append( tr( "SMESH_FONT_COURIER" ) );
2927 fam.append( tr( "SMESH_FONT_TIMES" ) );
2928 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2930 setPreferenceProperty( tfont, "families", fam );
2931 setPreferenceProperty( tfont, "system", false );
2932 setPreferenceProperty( tfont, "widget_flags", wflag );
2933 setPreferenceProperty( lfont, "families", fam );
2934 setPreferenceProperty( lfont, "system", false );
2935 setPreferenceProperty( lfont, "widget_flags", wflag );
2937 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
2939 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
2940 setPreferenceProperty( numcol, "min", 2 );
2941 setPreferenceProperty( numcol, "max", 256 );
2943 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
2944 setPreferenceProperty( numlab, "min", 2 );
2945 setPreferenceProperty( numlab, "max", 65 );
2947 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
2948 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2949 QStringList orients;
2950 orients.append( tr( "SMESH_VERTICAL" ) );
2951 orients.append( tr( "SMESH_HORIZONTAL" ) );
2952 indices.clear(); indices.append( 0 ); indices.append( 1 );
2953 setPreferenceProperty( orient, "strings", orients );
2954 setPreferenceProperty( orient, "indexes", indices );
2956 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
2957 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2958 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2959 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2960 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
2961 setPreferenceProperty( xv, "step", 0.1 );
2962 setPreferenceProperty( xv, "min", 0.0 );
2963 setPreferenceProperty( xv, "max", 1.0 );
2964 setPreferenceProperty( yv, "step", 0.1 );
2965 setPreferenceProperty( yv, "min", 0.0 );
2966 setPreferenceProperty( yv, "max", 1.0 );
2967 setPreferenceProperty( wv, "step", 0.1 );
2968 setPreferenceProperty( wv, "min", 0.0 );
2969 setPreferenceProperty( wv, "max", 1.0 );
2970 setPreferenceProperty( hv, "min", 0.0 );
2971 setPreferenceProperty( hv, "max", 1.0 );
2972 setPreferenceProperty( hv, "step", 0.1 );
2974 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
2975 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
2976 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
2977 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
2978 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
2979 setPreferenceProperty( xv, "min", 0.0 );
2980 setPreferenceProperty( xv, "max", 1.0 );
2981 setPreferenceProperty( xv, "step", 0.1 );
2982 setPreferenceProperty( xh, "min", 0.0 );
2983 setPreferenceProperty( xh, "max", 1.0 );
2984 setPreferenceProperty( xh, "step", 0.1 );
2985 setPreferenceProperty( yh, "min", 0.0 );
2986 setPreferenceProperty( yh, "max", 1.0 );
2987 setPreferenceProperty( yh, "step", 0.1 );
2988 setPreferenceProperty( wh, "min", 0.0 );
2989 setPreferenceProperty( wh, "max", 1.0 );
2990 setPreferenceProperty( wh, "step", 0.1 );
2991 setPreferenceProperty( hh, "min", 0.0 );
2992 setPreferenceProperty( hh, "max", 1.0 );
2993 setPreferenceProperty( hh, "step", 0.1 );
2996 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
2999 if( name=="selection_object_color" || name=="selection_element_color" ||
3000 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3001 name=="selection_precision_node" || name=="selection_precision_element" )
3002 SMESH::UpdateSelectionProp( this );
3005 //================================================================================
3007 * \brief Update something in accordance with update flags
3008 * \param theFlags - update flags
3010 * Update viewer or/and object browser etc. in accordance with update flags ( see
3011 * LightApp_UpdateFlags enumeration ).
3013 //================================================================================
3014 void SMESHGUI::update( const int flags )
3016 if ( flags & UF_Viewer | flags & UF_Forced )
3017 SMESH::UpdateView();
3019 SalomeApp_Module::update( flags );
3022 //================================================================================
3024 * \brief Set default selection mode
3026 * SLOT called when operation commited. Sets default selection mode
3028 //================================================================================
3029 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3031 SVTK_ViewWindow* vtkWnd =
3032 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3034 vtkWnd->SetSelectionMode( ActorSelection );
3037 //================================================================================
3039 * \brief Set default selection mode
3041 * SLOT called when operation aborted. Sets default selection mode
3043 //================================================================================
3044 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3046 SVTK_ViewWindow* vtkWnd =
3047 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3049 vtkWnd->SetSelectionMode( ActorSelection );
3052 //================================================================================
3054 * \brief Creates operation with given identifier
3055 * \param id - identifier of operation to be started
3056 * \return Pointer on created operation or NULL if operation is not created
3058 * Virtual method redefined from the base class creates operation with given id.
3059 * It is called called automatically from startOperation method of base class.
3061 //================================================================================
3062 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3064 LightApp_Operation* op = 0;
3065 // to do : create operation here
3068 case 702: // Create mesh
3069 op = new SMESHGUI_MeshOp( true, true );
3071 case 703: // Create sub-mesh
3072 op = new SMESHGUI_MeshOp( true, false );
3074 case 704: // Edit mesh/sub-mesh
3075 op = new SMESHGUI_MeshOp( false );
3082 op = SalomeApp_Module::createOperation( id );
3086 //================================================================================
3088 * \brief Stops current operations and starts a given one
3089 * \param id - The id of the operation to start
3091 //================================================================================
3093 void SMESHGUI::switchToOperation(int id)
3095 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3096 activeStudy()->abortAllOperations();
3097 startOperation( id );
3100 LightApp_Displayer* SMESHGUI::displayer()
3103 myDisplayer = new SMESHGUI_Displayer( getApp() );