1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
28 #include "SMESHGUI_InitMeshDlg.h"
29 #include "SMESHGUI_AddSubMeshDlg.h"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_HypothesesUtils.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_EditHypothesesDlg.h"
46 #include "SMESHGUI_CreateHypothesesDlg.h"
47 #include "SMESHGUI_FilterDlg.h"
48 #include "SMESHGUI_FilterLibraryDlg.h"
49 #include "SMESHGUI_SingleEditDlg.h"
50 #include "SMESHGUI_MultiEditDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_DeleteGroupDlg.h"
53 #include "SMESHGUI_SmoothingDlg.h"
54 #include "SMESHGUI_RenumberingDlg.h"
55 #include "SMESHGUI_ExtrusionDlg.h"
56 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
57 #include "SMESHGUI_RevolutionDlg.h"
58 #include "SMESHGUI_TranslationDlg.h"
59 #include "SMESHGUI_RotationDlg.h"
60 #include "SMESHGUI_SymmetryDlg.h"
61 #include "SMESHGUI_SewingDlg.h"
62 #include "SMESHGUI_MergeNodesDlg.h"
63 #include "SMESHGUI_MeshPatternDlg.h"
64 #include "SMESHGUI_PrecisionDlg.h"
65 #include "SMESHGUI_Selection.h"
66 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
68 #include <SVTK_InteractorStyle.h>
69 #include <SVTK_RenderWindowInteractor.h>
71 #include "SMESH_Actor.h"
72 #include "SMESH_Object.h"
73 #include "SMESH_TypeFilter.hxx"
75 #include "SUIT_Tools.h"
76 #include "SUIT_MessageBox.h"
77 #include "SUIT_ResourceMgr.h"
78 #include "SUIT_FileDlg.h"
79 #include "SUIT_Desktop.h"
80 #include "SUIT_ResourceMgr.h"
81 #include "SUIT_OverrideCursor.h"
82 #include "SUIT_Study.h"
83 #include "SUIT_Session.h"
85 #include "SALOME_NamingService.hxx"
86 #include "SALOME_ListIteratorOfListIO.hxx"
87 #include "SALOME_InteractiveObject.hxx"
88 #include "SALOME_ListIO.hxx"
89 #include <SALOME_LifeCycleCORBA.hxx>
91 #include "OB_Browser.h"
93 #include "QtxPopupMgr.h"
95 #include "SalomeApp_Application.h"
96 #include "SalomeApp_NameDlg.h"
97 #include "SalomeApp_DataOwner.h"
98 #include "SalomeApp_ImportOperation.h"
99 #include "SalomeApp_Tools.h"
100 #include "SalomeApp_Study.h"
101 #include "SalomeApp_VTKSelector.h"
103 #include <SVTK_ViewWindow.h>
104 #include <SVTK_ViewModel.h>
106 #include <VTKViewer_ViewManager.h>
108 #include "SMESHGUI_Utils.h"
109 #include "SMESHGUI_GEOMGenUtils.h"
110 #include "SMESHGUI_MeshUtils.h"
111 #include "SMESHGUI_GroupUtils.h"
112 #include "SMESHGUI_FilterUtils.h"
113 #include "SMESHGUI_PatternUtils.h"
114 #include "SMESHGUI_VTKUtils.h"
116 #include "SALOMEconfig.h"
117 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
120 #define INCLUDE_MENUITEM_DEF
121 #include <qapplication.h>
122 #include <qlineedit.h>
123 #include <qmenudata.h>
124 #include <qmenubar.h>
125 #include <qpopupmenu.h>
128 #include <qpainter.h>
129 #include <qcheckbox.h>
130 #include <qcolordialog.h>
131 #include <qspinbox.h>
136 #include <qradiobutton.h>
138 #include <boost/shared_ptr.hpp>
140 #include <vtkRenderer.h>
141 #include <vtkRenderWindow.h>
142 #include <vtkActorCollection.h>
143 #include <vtkScalarBarActor.h>
144 #include <vtkUnstructuredGrid.h>
146 #include "utilities.h"
148 #include "SALOMEDS_Study.hxx"
149 #include "SALOMEDSClient_StudyBuilder.hxx"
150 #include "SALOMEDSClient_SComponent.hxx"
156 //=============================================================
157 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
160 void ExportMeshToFile(int theCommandID);
162 void SetDisplayMode(int theCommandID);
164 void SetDisplayEntity(int theCommandID);
166 void Control( int theCommandID );
168 void SetDisplaySettings();
172 //=============================================================
173 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
179 if(theCommandID == 113){
180 filter.append(QObject::tr("MED files (*.med)"));
181 filter.append(QObject::tr("All files (*)"));
182 }else if (theCommandID == 112){
183 filter.append(QObject::tr("IDEAS files (*.unv)"));
184 }else if (theCommandID == 111){
185 filter.append(QObject::tr("DAT files (*.dat)"));
187 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
190 QObject::tr("Import mesh"),
192 if(!filename.isEmpty()) {
193 SUIT_OverrideCursor wc;
194 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
197 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
198 switch ( theCommandID ) {
201 aMeshes->length( 1 );
202 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
207 SMESH::DriverMED_ReadStatus res;
208 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
209 if ( res != SMESH::DRS_OK ) {
211 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
212 QObject::tr("SMESH_WRN_WARNING"),
213 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
214 QObject::tr("SMESH_BUT_OK"));
215 aMeshes->length( 0 );
222 bool isEmpty = false;
223 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
224 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
226 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
227 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
228 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
229 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
230 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
237 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
238 QObject::tr("SMESH_WRN_WARNING"),
239 QObject::tr("SMESH_DRS_EMPTY"),
240 QObject::tr("SMESH_BUT_OK"));
244 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
246 catch (const SALOME::SALOME_Exception& S_ex){
248 SalomeApp_Tools::QtCatchCorbaException(S_ex);
255 void ExportMeshToFile( int theCommandID )
257 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
258 SALOME_ListIO selected;
260 aSel->selectedObjects( selected );
262 if(selected.Extent()){
263 Handle(SALOME_InteractiveObject) anIObject = selected.First();
264 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
265 if ( !aMesh->_is_nil() ) {
266 QString aFilter, aTitle = QObject::tr("Export mesh");
267 QMap<QString, SMESH::MED_VERSION> aFilterMap;
268 switch ( theCommandID ) {
271 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
272 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
276 aFilter = QObject::tr("DAT files (*.dat)");
280 if(aMesh->NbPyramids()){
281 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
282 QObject::tr("SMESH_WRN_WARNING"),
283 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
284 QObject::tr("SMESH_BUT_YES"),
285 QObject::tr("SMESH_BUT_NO"),
290 aFilter = QObject::tr("IDEAS files (*.unv)");
297 SMESH::MED_VERSION aFormat;
299 if ( theCommandID != 122 && theCommandID != 125 )
300 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
304 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
305 filters.push_back( it.key() );
307 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
308 fd->setCaption( aTitle );
309 fd->setFilters( filters );
311 aFilename = fd->selectedFile();
312 aFormat = aFilterMap[fd->selectedFilter()];
315 if ( !aFilename.isEmpty() ) {
316 // Check whether the file already exists and delete it if yes
317 QFile aFile( aFilename );
318 if ( aFile.exists() )
320 SUIT_OverrideCursor wc;
321 switch ( theCommandID ) {
324 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
328 aMesh->ExportDAT( aFilename.latin1() );
332 aMesh->ExportUNV( aFilename.latin1() );
342 inline void InverseEntityMode(unsigned int& theOutputMode,
343 unsigned int theMode)
345 bool anIsNotPresent = ~theOutputMode & theMode;
347 theOutputMode |= theMode;
349 theOutputMode &= ~theMode;
352 void SetDisplayEntity(int theCommandID){
353 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
354 SALOME_ListIO selected;
356 aSel->selectedObjects( selected );
358 if(selected.Extent() >= 1){
359 SALOME_ListIteratorOfListIO It( selected );
360 for(; It.More(); It.Next()){
361 Handle(SALOME_InteractiveObject) IObject = It.Value();
362 if(IObject->hasEntry()){
363 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
364 unsigned int aMode = anActor->GetEntityMode();
365 switch(theCommandID){
367 InverseEntityMode(aMode,SMESH_Actor::eEdges);
370 InverseEntityMode(aMode,SMESH_Actor::eFaces);
373 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
376 aMode = SMESH_Actor::eAllEntity;
380 anActor->SetEntityMode(aMode);
387 void SetDisplayMode(int theCommandID){
388 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
389 SALOME_ListIO selected;
391 aSel->selectedObjects( selected );
393 if(selected.Extent() >= 1){
394 switch(theCommandID){
396 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
397 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
401 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
402 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
405 SALOME_ListIteratorOfListIO It( selected );
406 for(; It.More(); It.Next()){
407 Handle(SALOME_InteractiveObject) IObject = It.Value();
408 if(IObject->hasEntry()){
409 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
410 switch(theCommandID){
412 anActor->SetRepresentation(SMESH_Actor::eEdge);
415 anActor->SetRepresentation(SMESH_Actor::eSurface);
418 if(anActor->IsShrunk())
421 anActor->SetShrink();
424 anActor->SetRepresentation(SMESH_Actor::ePoint);
428 anActor->GetSufaceColor(color[0], color[1], color[2]);
429 int c0 = int (color[0] * 255);
430 int c1 = int (color[1] * 255);
431 int c2 = int (color[2] * 255);
432 QColor c(c0, c1, c2);
435 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
436 c0 = int (edgecolor[0] * 255);
437 c1 = int (edgecolor[1] * 255);
438 c2 = int (edgecolor[2] * 255);
439 QColor e(c0, c1, c2);
441 float backfacecolor[3];
442 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
443 c0 = int (backfacecolor[0] * 255);
444 c1 = int (backfacecolor[1] * 255);
445 c2 = int (backfacecolor[2] * 255);
446 QColor b(c0, c1, c2);
449 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
450 c0 = int (nodecolor[0] * 255);
451 c1 = int (nodecolor[1] * 255);
452 c2 = int (nodecolor[2] * 255);
453 QColor n(c0, c1, c2);
455 int Edgewidth = (int)anActor->GetLineWidth();
458 int intValue = int(anActor->GetNodeSize());
459 float Shrink = anActor->GetShrinkFactor();
461 SMESHGUI_Preferences_ColorDlg *aDlg =
462 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
463 aDlg->SetColor(1, c);
464 aDlg->SetColor(2, e);
465 aDlg->SetColor(3, n);
466 aDlg->SetColor(4, b);
467 aDlg->SetIntValue(1, Edgewidth);
468 aDlg->SetIntValue(2, intValue);
469 aDlg->SetIntValue(3, int(Shrink*100.));
471 QColor color = aDlg->GetColor(1);
472 QColor edgecolor = aDlg->GetColor(2);
473 QColor nodecolor = aDlg->GetColor(3);
474 QColor backfacecolor = aDlg->GetColor(4);
475 /* actor color and backface color */
476 anActor->SetSufaceColor(float (color.red()) / 255.,
477 float (color.green()) / 255.,
478 float (color.blue()) / 255.);
479 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
480 float (backfacecolor.green()) / 255.,
481 float (backfacecolor.blue()) / 255.);
484 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
485 float (edgecolor.green()) / 255.,
486 float (edgecolor.blue()) / 255.);
488 /* Shrink factor and size edges */
489 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
490 anActor->SetLineWidth(aDlg->GetIntValue(1));
492 /* Nodes color and size */
493 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
494 float (nodecolor.green()) / 255.,
495 float (nodecolor.blue()) / 255.);
496 anActor->SetNodeSize(aDlg->GetIntValue(2));
505 SMESH::RepaintCurrentView();
510 void SetDisplaySettings()
512 SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
516 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
517 SMESHGUI_Preferences_ColorDlg *aDlg =
518 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
520 QColor color = mgr->colorValue( "SMESH", "SettingsFillColor", QColor(0, 170, 255) );
521 aDlg->SetColor(1, color);
523 color = mgr->colorValue( "SMESH", "SettingsOutlineColor", QColor(0, 170, 255) );
524 aDlg->SetColor(2, color);
526 color = mgr->colorValue( "SMESH", "SettingsNodeColor", Qt::red );
527 aDlg->SetColor(3, color);
529 color = mgr->colorValue( "SMESH", "SettingsBackFaceColor", Qt::blue );
530 aDlg->SetColor(4, color);
532 int iVal = mgr->integerValue( "SMESH", "SettingsWidth", 1 );
533 aDlg->SetIntValue(1, iVal);
535 iVal = mgr->integerValue( "SMESH", "SettingsNodesSize", 3 );
536 aDlg->SetIntValue(2, iVal);
538 iVal = mgr->integerValue( "SMESH", "SettingsShrinkCoeff", 75 );
539 aDlg->SetIntValue(3, iVal);
542 mgr->setValue( "SMESH", "SettingsFillColor", aDlg->GetColor(1) );
543 mgr->setValue( "SMESH", "SettingsOutlineColor", aDlg->GetColor(2) );
544 mgr->setValue( "SMESH", "SettingsNodeColor", aDlg->GetColor(3) );
545 mgr->setValue( "SMESH", "SettingsBackFaceColor", aDlg->GetColor(4) );
547 mgr->setValue( "SMESH", "SettingsWidth", aDlg->GetIntValue(1) );
548 mgr->setValue( "SMESH", "SettingsNodesSize", aDlg->GetIntValue(2) );
549 mgr->setValue( "SMESH", "SettingsShrinkCoeff", aDlg->GetIntValue(3) );
556 void Control( int theCommandID )
558 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
559 SALOME_ListIO selected;
561 aSel->selectedObjects( selected );
563 if( !selected.IsEmpty() ){
564 Handle(SALOME_InteractiveObject) anIO = selected.First();
567 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
568 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
569 switch ( theCommandID ){
571 aTitle = QObject::tr( "LENGTH_EDGES" );
572 aControl = SMESH_Actor::eLength;
575 aTitle = QObject::tr( "LENGTH2D_EDGES" );
576 aControl = SMESH_Actor::eLength2D;
579 aTitle = QObject::tr( "FREE_EDGES" );
580 aControl = SMESH_Actor::eFreeEdges;
583 aTitle = QObject::tr( "FREE_BORDERS" );
584 aControl = SMESH_Actor::eFreeBorders;
587 aTitle = QObject::tr( "MULTI_BORDERS" );
588 aControl = SMESH_Actor::eMultiConnection;
591 aTitle = QObject::tr( "MULTI2D_BORDERS" );
592 aControl = SMESH_Actor::eMultiConnection2D;
595 aTitle = QObject::tr( "AREA_ELEMENTS" );
596 aControl = SMESH_Actor::eArea;
599 aTitle = QObject::tr( "TAPER_ELEMENTS" );
600 aControl = SMESH_Actor::eTaper;
603 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
604 aControl = SMESH_Actor::eAspectRatio;
607 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
608 aControl = SMESH_Actor::eAspectRatio3D;
611 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
612 aControl = SMESH_Actor::eMinimumAngle;
615 aTitle = QObject::tr( "WARP_ELEMENTS" );
616 aControl = SMESH_Actor::eWarping;
619 aTitle = QObject::tr( "SKEW_ELEMENTS" );
620 aControl = SMESH_Actor::eSkew;
623 anActor->SetControlMode(aControl);
624 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
631 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
632 MeshObjectType theType,
633 const QString theInTypeName,
634 QString & theOutTypeName)
636 SMESH_TypeFilter aTypeFilter( theType );
638 if( !theIO.IsNull() )
640 entry = theIO->getEntry();
641 SalomeApp_DataOwner owner( entry );
642 if ( aTypeFilter.isOk( &owner )) {
643 theOutTypeName = theInTypeName;
651 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
653 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
654 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
656 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
657 CORBA::String_var anID = aSComp->GetID().c_str();
658 if (!strcmp(anID.in(),theIO->getEntry()))
664 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
665 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
666 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
667 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
668 CheckOIType ( theIO, GROUP, "Group", aTypeName )
676 QString CheckHomogeneousSelection()
678 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
679 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
680 SALOME_ListIO selected;
682 aSel->selectedObjects( selected );
684 QString RefType = CheckTypeObject(selected.First());
685 SALOME_ListIteratorOfListIO It(selected);
686 for (; It.More(); It.Next())
688 Handle(SALOME_InteractiveObject) IObject = It.Value();
689 QString Type = CheckTypeObject(IObject);
690 if (Type.compare(RefType) != 0)
691 return "Heterogeneous Selection";
699 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
700 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
701 SALOME_ListIO selected; aSel->selectedObjects( selected );
703 QString aParentComponent = QString::null;
704 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
706 QString cur = anIt.Value()->getComponentDataType();
707 if( aParentComponent.isNull() )
708 aParentComponent = cur;
709 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
710 aParentComponent = "";
713 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
714 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
715 QObject::tr("ERR_ERROR"),
716 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
717 QObject::tr("BUT_OK") );
720 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
721 if (SUIT_MessageBox::warn2
722 (SMESHGUI::desktop(),
723 QObject::tr("SMESH_WRN_WARNING"),
724 QObject::tr("SMESH_REALLY_DELETE"),
725 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
728 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
729 SUIT_ViewManager* vm = anApp->activeViewManager();
730 int nbSf = vm->getViewsCount();
732 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
733 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
734 _PTR(GenericAttribute) anAttr;
735 _PTR(AttributeIOR) anIOR;
737 SALOME_ListIteratorOfListIO It(selected);
739 aStudyBuilder->NewCommand(); // There is a transaction
740 for(; It.More(); It.Next()){
741 Handle(SALOME_InteractiveObject) IObject = It.Value();
742 if(IObject->hasEntry()){
743 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
745 /* Erase child graphical objects */
746 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
747 for(it->InitEx(true); it->More(); it->Next()){
748 _PTR(SObject) CSO = it->Value();
749 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
752 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
753 for(int i = 0; i < nbSf; i++){
754 SUIT_ViewWindow *sf = aViews[i];
755 CORBA::String_var anEntry = CSO->GetID().c_str();
756 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
757 SMESH::RemoveActor(sf,anActor);
763 /* Erase main graphical object */
764 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
765 for(int i = 0; i < nbSf; i++){
766 SUIT_ViewWindow *sf = aViews[i];
767 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
768 SMESH::RemoveActor(sf,anActor);
772 // Remove object(s) from data structures
773 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
775 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
776 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
778 if ( !aGroup->_is_nil() ) { // DELETE GROUP
779 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
780 aMesh->RemoveGroup( aGroup );
782 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
783 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
784 aMesh->RemoveSubMesh( aSubMesh );
786 else {// default action: remove SObject from the study
787 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
788 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
790 aStudyBuilder->RemoveObjectWithChildren( obj );
795 } /* IObject->hasEntry() */
797 aStudyBuilder->CommitCommand();
799 /* Clear any previous selection */
801 aSel->setSelectedObjects( l1 );
803 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
807 //=============================================================================
811 //=============================================================================
812 class CustomItem : public QCustomMenuItem
815 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
818 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
821 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
822 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
823 p->setFont( myFont );
824 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
830 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
833 bool fullSpan() const
844 Standard_EXPORT CAM_Module* createModule()
846 return SMESHGUI::GetSMESHGUI();
850 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
852 //=============================================================================
856 //=============================================================================
857 SMESHGUI::SMESHGUI() :
858 SalomeApp_Module( "SMESH" )
860 if ( CORBA::is_nil( myComponentSMESH ) )
862 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
863 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
864 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
867 myActiveDialogBox = 0 ;
870 SMESH::GetFilterManager();
873 /* load resources for all available meshers */
874 SMESH::InitAvailableHypotheses();
877 //=============================================================================
881 //=============================================================================
882 SMESHGUI::~SMESHGUI()
884 SMESH::GetFilterManager()->Destroy();
887 //=============================================================================
891 //=============================================================================
892 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
894 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
896 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
901 //=============================================================================
905 //=============================================================================
906 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
908 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
911 //=============================================================================
915 //=============================================================================
916 SMESHGUI* SMESHGUI::GetSMESHGUI()
918 static SMESHGUI* aSMESHGUI = NULL;
920 aSMESHGUI = new SMESHGUI();
922 if(_PTR(Study) aStudy = SMESH::GetActiveStudyDocument())
923 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
925 SUIT_ResourceMgr* mgr = resourceMgr();
927 /* Automatic Update flag */
928 aSMESHGUI->myAutomaticUpdate = ( mgr->stringValue( "SMESH", "AutomaticUpdate" ).compare( "true" ) == 0 );
935 Standard_EXPORT SMESHGUI* GetComponentGUI() {
936 return SMESHGUI::GetSMESHGUI();
940 //=============================================================================
944 //=============================================================================
945 void SMESHGUI::SetState(int aState)
950 //=============================================================================
954 //=============================================================================
955 void SMESHGUI::ResetState()
960 //=============================================================================
964 //=============================================================================
965 void SMESHGUI::EmitSignalDeactivateDialog()
967 emit SignalDeactivateActiveDialog();
970 //=============================================================================
974 //=============================================================================
975 void SMESHGUI::EmitSignalStudyFrameChanged()
977 emit SignalStudyFrameChanged();
980 //=============================================================================
984 //=============================================================================
985 void SMESHGUI::EmitSignalCloseAllDialogs()
987 emit SignalCloseAllDialogs();
990 //=============================================================================
994 //=============================================================================
995 QDialog *SMESHGUI::GetActiveDialogBox()
997 return myActiveDialogBox;
1000 //=============================================================================
1004 //=============================================================================
1005 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1007 myActiveDialogBox = (QDialog *) aDlg;
1011 //=============================================================================
1015 //=============================================================================
1016 SUIT_Desktop* SMESHGUI::desktop()
1018 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1020 return app->desktop();
1025 //=============================================================================
1029 //=============================================================================
1030 SalomeApp_Study* SMESHGUI::activeStudy()
1032 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1034 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1039 //=============================================================================
1043 //=============================================================================
1044 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1046 /* Here the position is on the bottom right corner - 10 */
1047 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1049 SUIT_Desktop *PP = desktop();
1050 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1051 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1055 //=============================================================================
1059 //=============================================================================
1060 static int isStudyLocked(_PTR(Study) theStudy){
1061 return theStudy->GetProperties()->IsLocked();
1064 static bool checkLock(_PTR(Study) theStudy) {
1065 if (isStudyLocked(theStudy)) {
1066 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1067 QObject::tr("WRN_WARNING"),
1068 QObject::tr("WRN_STUDY_LOCKED"),
1069 QObject::tr("BUT_OK") );
1075 //=======================================================================
1076 //function : CheckActiveStudyLocked
1078 //=======================================================================
1080 bool SMESHGUI::isActiveStudyLocked()
1082 _PTR(Study) aStudy = activeStudy()->studyDS();
1083 return checkLock( aStudy );
1086 //=============================================================================
1090 //=============================================================================
1091 bool SMESHGUI::OnGUIEvent( int theCommandID )
1093 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1097 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1098 SUIT_ResourceMgr* mgr = resourceMgr();
1102 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1103 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1105 QAction* act = action( theCommandID );
1107 switch (theCommandID) {
1109 if(checkLock(aStudy)) break;
1117 if(checkLock(aStudy)) break;
1118 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1122 case 122: // EXPORT MED
1129 ::ExportMeshToFile(theCommandID);
1133 case 200: // SCALAR BAR
1135 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1136 SALOME_ListIO selected;
1138 aSel->selectedObjects( selected );
1140 if( selected.Extent() ) {
1141 Handle(SALOME_InteractiveObject) anIO = selected.First();
1142 if( anIO->hasEntry() ) {
1143 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1144 anActor->SetControlMode( SMESH_Actor::eNone );
1152 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1156 case 1134: // Clipping
1157 case 1133: // Tranparency
1158 case 1132: // Colors / Size
1165 ::SetDisplayMode(theCommandID);
1171 case 219: // Volumes
1172 case 220: // All Entity
1173 ::SetDisplayEntity(theCommandID);
1178 if(checkLock(aStudy)) break;
1179 SMESH::UpdateView();
1182 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1183 aSel->setSelectedObjects( l );
1188 case 301: // DISPLAY
1189 case 302: // DISPLAY ONLY
1191 SMESH::EDisplaing anAction;
1192 switch(theCommandID){
1193 case 300: anAction = SMESH::eErase; break;
1194 case 301: anAction = SMESH::eDisplay; break;
1195 case 302: anAction = SMESH::eDisplayOnly; break;
1198 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1199 SALOME_ListIO selected;
1201 aSel->selectedObjects( selected );
1204 SALOME_ListIteratorOfListIO It(selected);
1205 for (; It.More(); It.Next()) {
1206 Handle(SALOME_InteractiveObject) IOS = It.Value();
1207 if (IOS->hasEntry()) {
1208 SMESH::UpdateView(anAction,IOS->getEntry());
1213 aSel->setSelectedObjects( l1 );
1219 if(checkLock(aStudy)) break;
1222 EmitSignalDeactivateDialog();
1224 new SMESHGUI_NodesDlg(this);
1227 SUIT_MessageBox::warn1(desktop(),
1228 tr("SMESH_WRN_WARNING"),
1229 tr("SMESH_WRN_VIEWER_VTK"),
1230 tr("SMESH_BUT_OK"));
1235 case 2151: // FILTER
1239 EmitSignalDeactivateDialog();
1240 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1245 case 406: // MOVE NODE
1249 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1250 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1254 if(checkLock(aStudy)) break;
1255 new SMESHGUI_MoveNodesDlg(this);
1259 case 701: // COMPUTE MESH
1261 if(checkLock(aStudy)) break;
1263 SalomeApp_SelectionMgr *Sel = selectionMgr();
1264 SALOME_ListIO selected; Sel->selectedObjects( selected );
1266 int nbSel = selected.Extent();
1271 SMESH::SMESH_Mesh_var aMesh;
1272 SMESH::SMESH_subMesh_var aSubMesh;
1273 Handle(SALOME_InteractiveObject) IObject = selected.First();
1274 if (IObject->hasEntry()){
1275 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1276 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1277 if ( aShapeObject->_is_nil() ) {
1282 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1283 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1285 if (!aMesh->_is_nil()){
1286 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1287 if (!refShapeObject->_is_nil()) {
1288 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1289 SUIT_MessageBox::warn1(desktop(),
1290 tr("SMESH_WRN_WARNING"),
1291 tr("SMESH_WRN_MISSING_PARAMETERS"),
1292 tr("SMESH_BUT_OK"));
1296 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1297 SMESH::ModifiedMesh(aMeshSObj,true);
1298 // TO Do : change icon of all submeshes
1300 SUIT_MessageBox::warn1(desktop(),
1301 tr("SMESH_WRN_WARNING"),
1302 tr("SMESH_WRN_COMPUTE_FAILED"),
1303 tr("SMESH_BUT_OK"));
1305 catch(const SALOME::SALOME_Exception & S_ex){
1306 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1309 }else if(!aSubMesh->_is_nil()){
1310 aMesh = aSubMesh->GetFather();
1311 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1312 if(!refShapeObject->_is_nil()){
1313 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1315 SUIT_MessageBox::warn1(desktop(),
1316 tr("SMESH_WRN_WARNING"),
1317 tr("SMESH_WRN_MISSING_PARAMETERS"),
1318 tr("SMESH_BUT_OK"));
1322 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1323 SMESH::ModifiedMesh(aMeshSObj,true);
1324 // TO Do : change icon of all submeshes
1326 SUIT_MessageBox::warn1(desktop(),
1327 tr("SMESH_WRN_WARNING"),
1328 tr("SMESH_WRN_COMPUTE_FAILED"),
1329 tr("SMESH_BUT_OK"));
1330 }catch(const SALOME::SALOME_Exception & S_ex){
1331 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1337 CORBA::Long anId = aStudy->StudyId();
1338 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1339 cout<<"myAutomaticUpdate - "<<myAutomaticUpdate<<endl;
1340 if(myAutomaticUpdate && aVisualObj){
1341 aVisualObj->Update();
1342 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1344 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1346 SMESH::DisplayActor(view,anActor); //apo
1352 SUIT_MessageBox::warn1(desktop(),
1353 tr("SMESH_WRN_WARNING"),
1354 tr("SMESH_WRN_VIEWER_VTK"),
1355 tr("SMESH_BUT_OK"));
1361 case 702: // ADD SUB MESH
1363 if(checkLock(aStudy)) break;
1365 EmitSignalDeactivateDialog();
1366 new SMESHGUI_AddSubMeshDlg( this );
1369 SUIT_MessageBox::warn1(desktop(),
1370 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1371 tr("SMESH_BUT_OK"));
1376 case 703: // INIT MESH
1378 if(checkLock(aStudy)) break;
1379 EmitSignalDeactivateDialog();
1380 new SMESHGUI_InitMeshDlg( this );
1384 case 704: // EDIT Hypothesis
1386 if(checkLock(aStudy)) break;
1387 EmitSignalDeactivateDialog();
1388 new SMESHGUI_EditHypothesesDlg( this );
1392 case 705: // EDIT Global Hypothesis
1394 if(checkLock(aStudy)) break;
1395 EmitSignalDeactivateDialog();
1396 new SMESHGUI_EditHypothesesDlg( this );
1400 case 706: // EDIT Local Hypothesis
1402 if(checkLock(aStudy)) break;
1403 EmitSignalDeactivateDialog();
1404 new SMESHGUI_EditHypothesesDlg( this );
1408 case 407: // DIAGONAL INVERSION
1409 case 408: // Delete diagonal
1413 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1414 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1418 if ( checkLock( aStudy ) )
1421 /*Standard_Boolean aRes;
1422 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1423 if ( aMesh->_is_nil() )
1425 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1426 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1430 EmitSignalDeactivateDialog();
1431 if ( theCommandID == 407 )
1432 new SMESHGUI_TrianglesInversionDlg(this);
1434 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1437 case 409: // Change orientation
1438 case 410: // Union of triangles
1439 case 411: // Cutting of quadrangles
1443 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1444 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1448 if ( checkLock( aStudy ) )
1451 EmitSignalDeactivateDialog();
1452 SMESHGUI_MultiEditDlg* aDlg = NULL;
1453 if ( theCommandID == 409 )
1454 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1455 else if ( theCommandID == 410 )
1456 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1458 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1461 DefineDlgPosition( aDlg, x, y );
1466 case 412: // Smoothing
1468 if(checkLock(aStudy)) break;
1470 EmitSignalDeactivateDialog();
1471 new SMESHGUI_SmoothingDlg( this );
1474 SUIT_MessageBox::warn1(desktop(),
1475 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1476 tr("SMESH_BUT_OK"));
1480 case 413: // Extrusion
1482 if (checkLock(aStudy)) break;
1484 EmitSignalDeactivateDialog();
1485 new SMESHGUI_ExtrusionDlg ( this );
1487 SUIT_MessageBox::warn1(desktop(),
1488 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1489 tr("SMESH_BUT_OK"));
1493 case 414: // Revolution
1495 if(checkLock(aStudy)) break;
1497 EmitSignalDeactivateDialog();
1498 new SMESHGUI_RevolutionDlg( this );
1501 SUIT_MessageBox::warn1(desktop(),
1502 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1503 tr("SMESH_BUT_OK"));
1507 case 415: // Pattern mapping
1509 if ( checkLock( aStudy ) )
1513 EmitSignalDeactivateDialog();
1514 new SMESHGUI_MeshPatternDlg( this );
1517 SUIT_MessageBox::warn1(desktop(),
1518 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1519 tr("SMESH_BUT_OK"));
1523 case 416: // Extrusion along a path
1525 if (checkLock(aStudy)) break;
1527 EmitSignalDeactivateDialog();
1528 new SMESHGUI_ExtrusionAlongPathDlg( this );
1530 SUIT_MessageBox::warn1(desktop(),
1531 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1532 tr("SMESH_BUT_OK"));
1536 case 801: // CREATE GROUP
1540 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1541 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1545 if(checkLock(aStudy)) break;
1546 EmitSignalDeactivateDialog();
1547 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1549 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1550 SALOME_ListIO selected;
1552 aSel->selectedObjects( selected );
1554 int nbSel = selected.Extent();
1556 // check if mesh is selected
1557 aMesh = SMESH::GetMeshByIO( selected.First() );
1559 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1564 case 802: // CONSTRUCT GROUP
1568 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1569 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1573 if(checkLock(aStudy)) break;
1574 EmitSignalDeactivateDialog();
1576 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1577 SALOME_ListIO selected;
1579 aSel->selectedObjects( selected );
1581 int nbSel = selected.Extent();
1583 // check if submesh is selected
1584 Handle(SALOME_InteractiveObject) IObject = selected.First();
1585 if (IObject->hasEntry()) {
1586 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1588 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1589 if (!aSubMesh->_is_nil()) {
1591 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1592 // get submesh elements list by types
1593 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1594 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1595 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1596 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1597 // create group for each type o elements
1598 QString aName = IObject->getName();
1599 if (aNodes->length() > 0) {
1600 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1601 aGroup->Add(aNodes.inout());
1603 if (aEdges->length() > 0) {
1604 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1605 aGroup->Add(aEdges.inout());
1607 if (aFaces->length() > 0) {
1608 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1609 aGroup->Add(aFaces.inout());
1611 if (aVolumes->length() > 0) {
1612 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1613 aGroup->Add(aVolumes.inout());
1617 }catch(const SALOME::SALOME_Exception & S_ex){
1618 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1627 case 803: // EDIT GROUP
1629 if(checkLock(aStudy)) break;
1630 EmitSignalDeactivateDialog();
1632 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1633 SALOME_ListIO selected;
1635 aSel->selectedObjects( selected );
1637 SALOME_ListIteratorOfListIO It (selected);
1638 int nbSelectedGroups = 0;
1639 for ( ; It.More(); It.Next() )
1641 SMESH::SMESH_Group_var aGroup =
1642 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1643 if (!aGroup->_is_nil()) {
1645 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1649 if (nbSelectedGroups == 0)
1651 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1657 case 804: // Add elements to group
1659 if(checkLock(aStudy)) break;
1660 if (myState == 800) {
1661 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1662 if (aDlg) aDlg->onAdd();
1667 case 805: // Remove elements from group
1669 if(checkLock(aStudy)) break;
1670 if (myState == 800) {
1671 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1672 if (aDlg) aDlg->onRemove();
1677 case 810: // Union Groups
1678 case 811: // Intersect groups
1679 case 812: // Cut groups
1681 if ( checkLock( aStudy ) )
1684 EmitSignalDeactivateDialog();
1687 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1688 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1689 else aMode = SMESHGUI_GroupOpDlg::CUT;
1691 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1695 case 813: // Delete groups with their contents
1697 if ( checkLock( aStudy ) )
1700 EmitSignalDeactivateDialog();
1702 new SMESHGUI_DeleteGroupDlg( this );
1706 case 900: // MESH INFOS
1708 EmitSignalDeactivateDialog();
1709 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1710 SALOME_ListIO selected;
1712 aSel->selectedObjects( selected );
1714 if ( selected.Extent() > 1 ) { // a dlg for each IO
1716 SALOME_ListIteratorOfListIO It (selected);
1717 for ( ; It.More(); It.Next() ) {
1718 IOs.Clear(); IOs.Append( It.Value() );
1719 aSel->setSelectedObjects( IOs );
1720 new SMESHGUI_MeshInfosDlg(this, "", false);
1722 // restore selection
1723 aSel->setSelectedObjects( selected );
1726 new SMESHGUI_MeshInfosDlg(this, "", false);
1730 case 902: // STANDARD MESH INFOS
1732 EmitSignalDeactivateDialog();
1733 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1734 SALOME_ListIO selected;
1736 aSel->selectedObjects( selected );
1738 if ( selected.Extent() > 1 ) { // a dlg for each IO
1740 SALOME_ListIteratorOfListIO It (selected);
1741 for ( ; It.More(); It.Next() ) {
1743 IOs.Append( It.Value() );
1744 aSel->setSelectedObjects( IOs );
1745 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1747 // restore selection
1748 aSel->setSelectedObjects( selected );
1751 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1755 case 1001: // AUTOMATIC UPDATE PREFERENCES
1758 mgr->setValue( "SMESH", "AutomaticUpdate", true );
1759 myAutomaticUpdate = true;
1762 mgr->setValue( "SMESH", "AutomaticUpdate", false );
1763 myAutomaticUpdate = false;
1768 case 1003: // MESH PREFERENCES
1770 ::SetDisplaySettings();
1776 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( this );
1782 ( new SMESHGUI_PrecisionDlg( this ) )->exec();
1789 mgr->setValue( "SMESH", "DispayEntity", true );
1792 mgr->setValue( "SMESH", "DispayEntity", false );
1798 SMESHGUI_Preferences_SelectionDlg* aDlg =
1799 new SMESHGUI_Preferences_SelectionDlg( this );
1801 QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
1802 aDlg->SetColor(1, aColor);
1804 aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow );
1805 aDlg->SetColor(2, aColor);
1807 aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white );
1808 aDlg->SetColor(3, aColor);
1810 aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) );
1811 aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) );
1812 aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) );
1813 aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) );
1816 QColor aPreColor = aDlg->GetColor(1),
1817 aSelColor = aDlg->GetColor(2),
1818 aHiColor = aDlg->GetColor(3);
1819 int aPreWidth = aDlg->GetWidth(1),
1820 aSelWidth = aDlg->GetWidth(2);
1821 double aTolNodes = aDlg->GetPrecision(1),
1822 aTolItems = aDlg->GetPrecision(2);
1824 mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor );
1825 mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor );
1826 mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor );
1828 mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth );
1829 mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth );
1830 mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes );
1831 mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems );
1833 // update current study settings
1834 SMESH::UpdateSelectionProp( this );
1837 // update VTK viewer properties
1838 SVTK_RenderWindowInteractor* anInteractor =
1839 dynamic_cast<SVTK_RenderWindowInteractor*>( vtkwnd->getRWInteractor() );
1841 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1842 aSelColor.blue()/255., aSelWidth);
1843 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1844 SVTK_InteractorStyle* aStyle =
1845 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
1848 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1849 aPreColor.blue()/255., aPreWidth);
1852 vtkRenderer* aRenderer = vtkwnd->getRenderer();
1853 vtkActorCollection *aCollection = aRenderer->GetActors();
1854 aCollection->InitTraversal();
1855 while(vtkActor *anAct = aCollection->GetNextActor()){
1856 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1857 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1858 aHiColor.blue()/255.);
1859 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1860 aPreColor.blue()/255.);
1869 case 1100: // EDIT HYPOTHESIS
1871 if(checkLock(aStudy)) break;
1873 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1874 SALOME_ListIO selected;
1876 aSel->selectedObjects( selected );
1878 int nbSel = selected.Extent();
1881 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1883 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1884 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1885 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1886 if ( !Hyp->_is_nil() )
1888 char* sName = Hyp->GetName();
1889 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1892 aCreator->EditHypothesis(Hyp);
1900 updateObjBrowser( true );
1904 case 1101: // RENAME
1906 if ( checkLock( aStudy ) )
1909 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1910 SALOME_ListIO selected;
1912 aSel->selectedObjects( selected );
1914 SALOME_ListIteratorOfListIO It( selected );
1915 for ( ; It.More(); It.Next() )
1917 Handle(SALOME_InteractiveObject) IObject = It.Value();
1918 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1919 _PTR(GenericAttribute) anAttr;
1920 _PTR(AttributeName) aName;
1923 if ( obj->FindAttribute(anAttr, "AttributeName") )
1926 QString newName = QString(aName->Value().c_str());
1927 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1928 if ( !newName.isEmpty() )
1930 //old source: aStudy->renameIObject( IObject, newName );
1931 aName->SetValue( newName.latin1() );
1933 // if current object is group update group's name
1934 SMESH::SMESH_GroupBase_var aGroup =
1935 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1936 if (!aGroup->_is_nil() )
1937 aGroup->SetName( newName.latin1() );
1947 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1949 if(checkLock(aStudy)) break;
1950 SUIT_OverrideCursor wc;
1952 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1953 SALOME_ListIO selected;
1955 aSel->selectedObjects( selected );
1957 SALOME_ListIteratorOfListIO It(selected);
1958 for (int i = 0; It.More(); It.Next(), i++) {
1959 Handle(SALOME_InteractiveObject) IObject = It.Value();
1960 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1963 aSel->setSelectedObjects( l1 );
1968 case 401: // GEOM::EDGE
1969 case 4021: // TRIANGLE
1971 case 4023: // POLYGON
1975 if(checkLock(aStudy)) break;
1977 EmitSignalDeactivateDialog();
1978 SMDSAbs_ElementType type = SMDSAbs_Edge;
1980 switch (theCommandID) {
1981 case 4021: // TRIANGLE
1982 type = SMDSAbs_Face; nbNodes = 3; break;
1984 type = SMDSAbs_Face; nbNodes = 4; break;
1986 type = SMDSAbs_Volume; nbNodes = 4; break;
1987 case 4023: // POLYGON
1988 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1990 type = SMDSAbs_Volume; nbNodes = 8; break;
1991 case 4033: // POLYHEDRE
1992 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1995 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1998 SUIT_MessageBox::warn1(desktop(),
1999 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2000 tr("SMESH_BUT_OK"));
2004 case 4033: // POLYHEDRON
2006 if(checkLock(aStudy)) break;
2008 EmitSignalDeactivateDialog();
2009 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2012 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2013 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2014 tr("SMESH_BUT_OK"));
2018 case 4041: // REMOVES NODES
2020 if(checkLock(aStudy)) break;
2022 EmitSignalDeactivateDialog();
2023 new SMESHGUI_RemoveNodesDlg(this);
2026 SUIT_MessageBox::warn1(desktop(),
2027 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2028 tr("SMESH_BUT_OK"));
2032 case 4042: // REMOVES ELEMENTS
2034 if(checkLock(aStudy)) break;
2036 EmitSignalDeactivateDialog();
2037 new SMESHGUI_RemoveElementsDlg(this);
2041 SUIT_MessageBox::warn1(desktop(),
2042 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2043 tr("SMESH_BUT_OK"));
2047 case 4051: // RENUMBERING NODES
2049 if(checkLock(aStudy)) break;
2051 EmitSignalDeactivateDialog();
2052 new SMESHGUI_RenumberingDlg( this, "", 0);
2056 SUIT_MessageBox::warn1(desktop(),
2057 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2058 tr("SMESH_BUT_OK"));
2062 case 4052: // RENUMBERING ELEMENTS
2064 if(checkLock(aStudy)) break;
2066 EmitSignalDeactivateDialog();
2067 new SMESHGUI_RenumberingDlg( this, "", 1);
2071 SUIT_MessageBox::warn1(desktop(),
2072 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2073 tr("SMESH_BUT_OK"));
2077 case 4061: // TRANSLATION
2079 if(checkLock(aStudy)) break;
2081 EmitSignalDeactivateDialog();
2082 new SMESHGUI_TranslationDlg( this );
2085 SUIT_MessageBox::warn1(desktop(),
2086 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2087 tr("SMESH_BUT_OK"));
2091 case 4062: // ROTATION
2093 if(checkLock(aStudy)) break;
2095 EmitSignalDeactivateDialog();
2096 new SMESHGUI_RotationDlg( this );
2099 SUIT_MessageBox::warn1(desktop(),
2100 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2101 tr("SMESH_BUT_OK"));
2105 case 4063: // SYMMETRY
2107 if(checkLock(aStudy)) break;
2109 EmitSignalDeactivateDialog();
2110 new SMESHGUI_SymmetryDlg( this );
2113 SUIT_MessageBox::warn1(desktop(),
2114 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2115 tr("SMESH_BUT_OK"));
2119 case 4064: // SEWING
2121 if(checkLock(aStudy)) break;
2123 EmitSignalDeactivateDialog();
2124 new SMESHGUI_SewingDlg( this );
2127 SUIT_MessageBox::warn1(desktop(),
2128 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2129 tr("SMESH_BUT_OK"));
2133 case 4065: // MERGE NODES
2135 if(checkLock(aStudy)) break;
2137 EmitSignalDeactivateDialog();
2138 new SMESHGUI_MergeNodesDlg( this );
2141 SUIT_MessageBox::warn1(desktop(),
2142 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2143 tr("SMESH_BUT_OK"));
2149 case 5000: // HYPOTHESIS
2151 if(checkLock(aStudy)) break;
2152 EmitSignalDeactivateDialog();
2153 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2158 if(checkLock(aStudy)) break;
2159 EmitSignalDeactivateDialog();
2160 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2164 case 5105: // Library of selection filters
2166 static QValueList<int> aTypes;
2167 if ( aTypes.isEmpty() )
2169 aTypes.append( SMESH::NODE );
2170 aTypes.append( SMESH::EDGE );
2171 aTypes.append( SMESH::FACE );
2172 aTypes.append( SMESH::VOLUME );
2174 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2178 case 6017: // CONTROLS
2193 SalomeApp_SelectionMgr* mgr = selectionMgr();
2194 SALOME_ListIO selected; mgr->selectedObjects( selected );
2196 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2197 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2199 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2200 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2201 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2202 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2203 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2204 ::Control( theCommandID );
2209 SUIT_MessageBox::warn1(desktop(),
2210 tr( "SMESH_WRN_WARNING" ),
2211 tr( "SMESH_BAD_SELECTION" ),
2212 tr( "SMESH_BUT_OK" ) );
2216 SUIT_MessageBox::warn1(desktop(),
2217 tr( "SMESH_WRN_WARNING" ),
2218 tr( "NOT_A_VTK_VIEWER" ),
2219 tr( "SMESH_BUT_OK" ) );
2224 SalomeApp_SelectionMgr* mgr = selectionMgr();
2225 SALOME_ListIO selected; mgr->selectedObjects( selected );
2227 if (selected.Extent() == 1) {
2228 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2229 if(anIObject->hasEntry())
2230 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2231 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2238 SalomeApp_SelectionMgr* mgr = selectionMgr();
2239 SALOME_ListIO selected; mgr->selectedObjects( selected );
2241 if (selected.Extent() == 1) {
2242 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2243 if(anIObject->hasEntry())
2244 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2245 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2250 case 10001: // DISPLAY MODE PREFERENCE
2254 action( 10002 )->setOn( false );
2255 action( 10004 )->setOn( false );
2256 action( 10003 )->setOn( true );
2257 mgr->setValue( "SMESH", "DisplayMode", "Wireframe");
2263 action( 10001 )->setOn( false );
2264 action( 10004 )->setOn( false );
2265 action( 10003 )->setOn( true );
2266 mgr->setValue( "SMESH", "DisplayMode", "Shading");
2271 mgr->setValue( "SMESH", "Shrink", act->isOn() );
2277 action( 10001 )->setOn( false );
2278 action( 10002 )->setOn( false );
2279 action( 10003 )->setOn( false );
2280 mgr->setValue( "SMESH", "DisplayMode", "Nodes" );
2286 //updateObjBrowser();
2290 //=============================================================================
2294 //=============================================================================
2295 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2300 //=============================================================================
2304 //=============================================================================
2305 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2310 //=============================================================================
2314 //=============================================================================
2315 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2320 //=============================================================================
2324 //=============================================================================
2325 bool SMESHGUI::SetSettings(SUIT_Desktop* parent)
2327 SMESHGUI::GetSMESHGUI();
2329 SUIT_ResourceMgr* mgr = resourceMgr();
2334 QString DisplayMode = "Shading";
2335 if ( mgr->hasValue("SMESH","DisplayMode") )
2336 DisplayMode = mgr->stringValue("SMESH","DisplayMode");
2338 mgr->setValue("SMESH","DisplayMode", "Shading");
2340 bool Shrink = false;
2341 if ( mgr->hasValue("SMESH","Shrink") )
2342 Shrink = mgr->stringValue("SMESH","Shrink") == "yes";
2344 if (DisplayMode == "Wireframe") {
2346 action( 10004 )->setOn( false );
2347 action( 10002 )->setOn( false );
2348 action( 10001 )->setOn( true );
2349 action( 10003 )->setOn( true );
2351 else if (DisplayMode == "Nodes") {
2353 action( 10004 )->setOn( true );
2354 action( 10002 )->setOn( false );
2355 action( 10001 )->setOn( false );
2356 action( 10003 )->setOn( false );
2359 // default is shading
2360 action( 10004 )->setOn( false );
2361 action( 10002 )->setOn( true );
2362 action( 10001 )->setOn( false );
2363 action( 10003 )->setOn( true );
2366 action( 10003 )->setOn( Shrink );
2369 if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) {
2370 action( 1001 )->setOn( true );
2371 myAutomaticUpdate = true;
2374 action( 1001 )->setOn( false );
2375 myAutomaticUpdate = false;
2378 if ( mgr->booleanValue( "SMESH","DispayEntity", false ) )
2379 action( 10071 )->setOn( true );
2381 action( 10071 )->setOn( false );
2384 SMESH::UpdateSelectionProp( this );
2387 action( 111 )->setEnabled( false ); // IMPORT DAT
2389 //action( 112 )->setEnabled( false );
2390 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2395 //=============================================================================
2396 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2397 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2399 //=============================================================================
2400 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2401 SUIT_ViewWindow* wnd )
2403 if(theIO->hasEntry()){
2404 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2405 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2409 //=======================================================================
2410 // function : createSMESHAction
2412 //=======================================================================
2413 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2416 QWidget* parent = application()->desktop();
2417 SUIT_ResourceMgr* resMgr = resourceMgr();
2419 if ( icon_id.length() )
2420 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2422 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ) );
2423 if ( !pix.isNull() )
2424 icon = QIconSet( pix );
2426 QString tooltip = tr( QString( "TOP_" )+po_id ),
2427 menu = tr( QString( "MEN_" )+po_id ),
2428 status_bar = tr( QString( "STB_" )+po_id );
2430 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2433 //=======================================================================
2434 // function : createPopupItem
2436 //=======================================================================
2437 void SMESHGUI::createPopupItem( const int id,
2438 const QString& clients,
2439 const QString& types,
2440 const QString& theRule,
2445 parentId = popupMgr()->actionId( action( pId ) );
2447 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2448 popupMgr()->insert( action( id ), parentId, 0 );
2450 QChar lc = QtxPopupMgr::Selection::defEquality();
2451 QString rule = "(%1) and (%2) and (%3)";
2452 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2453 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2454 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2457 bool cont = myRules.contains( id );
2459 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2461 popupMgr()->setRule( action( id ), rule, true );
2462 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2465 //=======================================================================
2466 // function : initialize
2468 //=======================================================================
2469 void SMESHGUI::initialize( CAM_Application* app )
2471 SalomeApp_Module::initialize( app );
2473 // ----- create actions --------------
2475 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2476 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2477 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2478 createSMESHAction( 114, "NUM" );
2479 createSMESHAction( 121, "DAT" );
2480 createSMESHAction( 122, "MED" );
2481 createSMESHAction( 123, "UNV" );
2482 createSMESHAction( 124, "EXPORT_DAT" );
2483 createSMESHAction( 125, "EXPORT_MED" );
2484 createSMESHAction( 126, "EXPORT_UNV" );
2485 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2486 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2487 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2488 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2489 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2490 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2491 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2492 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2493 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2494 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2495 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2496 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2497 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2498 createSMESHAction( 804, "ADD" );
2499 createSMESHAction( 805, "REMOVE" );
2500 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2501 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2502 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2503 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2504 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2505 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2506 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2507 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2508 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2509 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2510 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2511 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2512 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2513 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2514 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2515 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2516 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2517 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2518 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2519 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2520 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2521 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2522 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2523 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2524 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2525 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2526 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2527 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2528 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2529 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2530 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2531 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2532 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2533 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2534 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2535 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2536 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2537 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2538 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2539 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2540 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2541 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2542 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2543 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2544 createSMESHAction( 415, "MAP", "ICON_MAP" );
2545 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2546 createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true );
2547 createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true );
2548 createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true );
2549 createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true );
2550 createSMESHAction( 1001, "AUTO_UPD", "", 0, true );
2551 createSMESHAction( 1003, "COLORS" );
2552 createSMESHAction( 1005, "SCALAR_BAR" );
2553 createSMESHAction( 1006, "SELECTION" );
2554 createSMESHAction( 10070, "PRECISION", "", 0, true );
2555 createSMESHAction( 10071, "DISP_ENT", "", 0, true );
2556 createSMESHAction( 200, "RESET" );
2557 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2558 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2559 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2560 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2561 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2562 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2563 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2564 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2565 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2566 createSMESHAction( 220, "ALL" );
2567 createSMESHAction( 1100, "EDIT_HYPO" );
2568 createSMESHAction( 1101, "RENAME" );
2569 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2570 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2571 createSMESHAction( 1131, "DISPMODE" );
2572 createSMESHAction( 1132, "COLORS" );
2573 createSMESHAction( 1133, "TRANSP" );
2574 createSMESHAction( 1134, "CLIP" );
2575 createSMESHAction( 1135, "DISP_ENT" );
2576 createSMESHAction( 2000, "CTRL" );
2578 createSMESHAction( 300, "ERASE" );
2579 createSMESHAction( 301, "DISPLAY" );
2580 createSMESHAction( 302, "DISPLAY_ONLY" );
2581 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2583 // ----- create menu --------------
2584 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2585 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2586 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2587 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2588 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2589 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2590 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2591 prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ),
2592 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2594 createMenu( separator(), fileId );
2596 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2597 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2599 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2600 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2601 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2602 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
2604 meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ),
2606 dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ),
2607 qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 );
2609 createMenu( 111, importId, -1 );
2610 createMenu( 112, importId, -1 );
2611 createMenu( 113, importId, -1 );
2613 createMenu( 121, exportId, -1 );
2614 createMenu( 122, exportId, -1 );
2615 createMenu( 123, exportId, -1 );
2617 createMenu( separator(), fileId, 10 );
2619 createMenu( 33, editId, -1 );
2621 createMenu( 5105, toolsId, -1 );
2623 createMenu( 5000, hypoId, -1 );
2624 createMenu( 5010, hypoId, -1 );
2626 createMenu( 703, meshId, -1 );
2627 createMenu( 702, meshId, -1 );
2628 createMenu( 704, meshId, -1 );
2629 createMenu( separator(), meshId, -1 );
2630 createMenu( 701, meshId, -1 );
2631 createMenu( separator(), meshId, -1 );
2632 createMenu( 801, meshId, -1 );
2633 createMenu( 802, meshId, -1 );
2634 createMenu( 803, meshId, -1 );
2635 createMenu( separator(), meshId, -1 );
2636 createMenu( 810, meshId, -1 );
2637 createMenu( 811, meshId, -1 );
2638 createMenu( 812, meshId, -1 );
2639 createMenu( separator(), meshId, -1 );
2640 createMenu( 813, meshId, -1 );
2641 createMenu( separator(), meshId, -1 );
2642 createMenu( 900, meshId, -1 );
2643 createMenu( 902, meshId, -1 );
2644 createMenu( separator(), meshId, -1 );
2646 createMenu( 6003, ctrlId, -1 );
2647 createMenu( 6001, ctrlId, -1 );
2648 createMenu( 6004, ctrlId, -1 );
2649 createMenu( separator(), ctrlId, -1 );
2650 createMenu( 6002, ctrlId, -1 );
2651 createMenu( 6018, ctrlId, -1 );
2652 createMenu( 6019, ctrlId, -1 );
2653 createMenu( 6011, ctrlId, -1 );
2654 createMenu( 6012, ctrlId, -1 );
2655 createMenu( 6013, ctrlId, -1 );
2656 createMenu( 6014, ctrlId, -1 );
2657 createMenu( 6015, ctrlId, -1 );
2658 createMenu( 6016, ctrlId, -1 );
2659 createMenu( separator(), ctrlId, -1 );
2660 createMenu( 6017, ctrlId, -1 );
2661 createMenu( separator(), ctrlId, -1 );
2663 createMenu( 400, addId, -1 );
2664 createMenu( 401, addId, -1 );
2665 createMenu( 4021, addId, -1 );
2666 createMenu( 4022, addId, -1 );
2667 createMenu( 4023, addId, -1 );
2668 createMenu( 4031, addId, -1 );
2669 createMenu( 4032, addId, -1 );
2670 createMenu( 4033, addId, -1 );
2672 createMenu( 4041, removeId, -1 );
2673 createMenu( 4042, removeId, -1 );
2675 createMenu( 4051, renumId, -1 );
2676 createMenu( 4052, renumId, -1 );
2678 createMenu( 4061, transfId, -1 );
2679 createMenu( 4062, transfId, -1 );
2680 createMenu( 4063, transfId, -1 );
2681 createMenu( 4064, transfId, -1 );
2682 createMenu( 4065, transfId, -1 );
2684 createMenu( 406, modifyId, -1 );
2685 createMenu( 407, modifyId, -1 );
2686 createMenu( 408, modifyId, -1 );
2687 createMenu( 409, modifyId, -1 );
2688 createMenu( 410, modifyId, -1 );
2689 createMenu( 411, modifyId, -1 );
2690 createMenu( 412, modifyId, -1 );
2691 createMenu( 413, modifyId, -1 );
2692 createMenu( 416, modifyId, -1 );
2693 createMenu( 414, modifyId, -1 );
2694 createMenu( 415, modifyId, -1 );
2696 createMenu( 10001, dispModeId, -1 );
2697 createMenu( 10002, dispModeId, -1 );
2698 createMenu( 10004, dispModeId, -1 );
2699 createMenu( 10003, dispModeId, -1 );
2701 createMenu( 1001, prefId, -1 );
2702 createMenu( separator(), prefId, -1 );
2703 createMenu( 1003, prefId, -1 );
2704 createMenu( separator(), prefId, -1 );
2705 createMenu( 1005, prefId, -1 );
2706 createMenu( separator(), prefId, -1 );
2707 createMenu( 1006, prefId, -1 );
2708 createMenu( separator(), prefId, -1 );
2710 createMenu( 10070, qualityId, -1 );
2711 createMenu( 10071, qualityId, -1 );
2713 createMenu( separator(), prefId, -1 );
2715 createMenu( 214, viewId, -1 );
2717 // ----- create toolbars --------------
2718 int meshTb = createTool( tr( "TB_MESH" ) ),
2719 hypoTb = createTool( tr( "TB_HYPO" ) ),
2720 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2721 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2722 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2723 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2725 createTool( 703, meshTb );
2726 createTool( 702, meshTb );
2727 createTool( 704, meshTb );
2728 createTool( separator(), meshTb );
2729 createTool( 701, meshTb );
2730 createTool( separator(), meshTb );
2731 createTool( 801, meshTb );
2732 createTool( 802, meshTb );
2733 createTool( 803, meshTb );
2734 createTool( separator(), meshTb );
2735 createTool( 900, meshTb );
2736 createTool( 902, meshTb );
2737 createTool( separator(), meshTb );
2739 createTool( 5000, hypoTb );
2740 createTool( 5010, hypoTb );
2742 createTool( 6001, ctrlTb );
2743 createTool( 6003, ctrlTb );
2744 createTool( 6004, ctrlTb );
2745 createTool( separator(), ctrlTb );
2746 createTool( 6002, ctrlTb );
2747 createTool( 6018, ctrlTb );
2748 createTool( 6019, ctrlTb );
2749 createTool( 6011, ctrlTb );
2750 createTool( 6012, ctrlTb );
2751 createTool( 6013, ctrlTb );
2752 createTool( 6014, ctrlTb );
2753 createTool( 6015, ctrlTb );
2754 createTool( 6016, ctrlTb );
2755 createTool( separator(), ctrlTb );
2756 createTool( 6017, ctrlTb );
2757 createTool( separator(), ctrlTb );
2759 createTool( 400, addRemTb );
2760 createTool( 401, addRemTb );
2761 createTool( 4021, addRemTb );
2762 createTool( 4022, addRemTb );
2763 createTool( 4023, addRemTb );
2764 createTool( 4031, addRemTb );
2765 createTool( 4032, addRemTb );
2766 createTool( 4033, addRemTb );
2767 createTool( separator(), addRemTb );
2768 createTool( 4041, addRemTb );
2769 createTool( 4042, addRemTb );
2770 createTool( separator(), addRemTb );
2771 createTool( 4051, addRemTb );
2772 createTool( 4052, addRemTb );
2773 createTool( separator(), addRemTb );
2774 createTool( 4061, addRemTb );
2775 createTool( 4062, addRemTb );
2776 createTool( 4063, addRemTb );
2777 createTool( 4064, addRemTb );
2778 createTool( 4065, addRemTb );
2779 createTool( separator(), addRemTb );
2781 createTool( 406, modifyTb );
2782 createTool( 407, modifyTb );
2783 createTool( 408, modifyTb );
2784 createTool( 409, modifyTb );
2785 createTool( 410, modifyTb );
2786 createTool( 411, modifyTb );
2787 createTool( 412, modifyTb );
2788 createTool( 413, modifyTb );
2789 createTool( 416, modifyTb );
2790 createTool( 414, modifyTb );
2791 createTool( 415, modifyTb );
2793 createTool( 214, dispModeTb );
2797 QString OB = "'ObjectBrowser'",
2798 View = "'" + SVTK_Viewer::Type() + "'",
2800 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2801 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2802 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2803 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2804 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2805 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2806 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2807 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2808 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2809 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2811 mesh_group = mesh + " " + subMesh + " " + group,
2812 hyp_alg = hypo + " " + algo;
2814 // popup for object browser
2816 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2817 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2818 createPopupItem( 803, OB, group ); // EDIT_GROUP
2819 popupMgr()->insert( separator(), -1, 0 );
2820 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2821 createPopupItem( 214, OB, mesh_group ); // UPDATE
2822 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2823 createPopupItem( 902, OB, mesh ); // STD_INFO
2824 popupMgr()->insert( separator(), -1, 0 );
2825 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2826 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2827 popupMgr()->insert( separator(), -1, 0 );
2828 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2829 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2830 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2831 popupMgr()->insert( separator(), -1, 0 );
2832 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2833 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2834 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2835 popupMgr()->insert( separator(), -1, 0 );
2838 createPopupItem( 803, View, group ); // EDIT_GROUP
2839 createPopupItem( 804, View, elems ); // ADD
2840 createPopupItem( 805, View, elems ); // REMOVE
2841 popupMgr()->insert( separator(), -1, 0 );
2842 createPopupItem( 214, View, mesh_group ); // UPDATE
2843 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2844 createPopupItem( 902, View, mesh ); // STD_INFO
2845 popupMgr()->insert( separator(), -1, 0 );
2849 isInvisible("not( isVisible )"),
2850 isEmpty("numberOfNodes = 0"),
2851 isNotEmpty("numberOfNodes <> 0"),
2853 // has nodes, edges, etc in VISIBLE! actor
2854 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2855 hasElems("(count( elemTypes ) > 0)"),
2856 hasDifferentElems("(count( elemTypes ) > 1)"),
2857 hasEdges("({'Edge'} in elemTypes)"),
2858 hasFaces("({'Face'} in elemTypes)"),
2859 hasVolumes("({'Volume'} in elemTypes)");
2861 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2862 QString lc = QtxPopupMgr::Selection::defEquality();
2863 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2864 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2865 QString aMeshInVTK = aClient + "&&" + aType;// + "&&" + aSelCount;
2867 //-------------------------------------------------
2869 //-------------------------------------------------
2870 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2872 popupMgr()->insert( action( 9010 ), anId, -1 );
2873 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true );
2874 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2876 popupMgr()->insert( action( 9011 ), anId, -1 );
2877 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true );
2878 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2880 popupMgr()->insert( separator(), -1, -1 );
2882 //-------------------------------------------------
2884 //-------------------------------------------------
2885 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2887 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2888 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2889 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2891 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2892 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2893 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2895 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2896 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2897 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2899 popupMgr()->insert( separator(), anId, -1 );
2901 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2902 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2903 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2905 //-------------------------------------------------
2907 //-------------------------------------------------
2908 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2910 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2912 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2913 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true );
2914 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2916 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2917 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true );
2918 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2920 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2921 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true );
2922 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2924 popupMgr()->insert( separator(), anId, -1 );
2926 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2927 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true );
2929 //-------------------------------------------------
2931 //-------------------------------------------------
2932 popupMgr()->insert( action( 1132 ), -1, -1 );
2933 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2935 //-------------------------------------------------
2937 //-------------------------------------------------
2938 popupMgr()->insert( action( 1133 ), -1, -1 );
2939 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2941 //-------------------------------------------------
2943 //-------------------------------------------------
2944 popupMgr()->insert( action( 1134 ), -1, -1 );
2945 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2947 popupMgr()->insert( separator(), -1, -1 );
2949 //-------------------------------------------------
2951 //-------------------------------------------------
2953 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2954 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2955 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2957 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2959 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2960 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2962 popupMgr()->insert( separator(), anId, -1 );
2964 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2965 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2966 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2968 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2969 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2970 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2972 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2973 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2974 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2976 popupMgr()->insert( separator(), anId, -1 );
2978 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2979 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2980 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2982 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2983 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2984 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2986 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2987 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2988 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2990 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2991 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2992 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2994 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2995 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2996 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2998 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2999 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
3000 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
3002 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3003 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3004 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3006 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3007 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3008 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3010 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3011 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3012 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3014 popupMgr()->insert( separator(), anId, -1 );
3016 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3017 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3018 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3020 popupMgr()->insert( separator(), anId, -1 );
3022 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3023 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3025 popupMgr()->insert( separator(), -1, -1 );
3027 //-------------------------------------------------
3029 //-------------------------------------------------
3030 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3031 QString aRule = aClient + " and " + aType + " and " + aSelCount;
3032 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3033 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
3035 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3036 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
3038 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3039 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
3041 popupMgr()->insert( separator(), -1, -1 );
3043 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
3044 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
3047 bool SMESHGUI::activateModule( SUIT_Study* study )
3049 bool res = SalomeApp_Module::activateModule( study );
3051 setMenuShown( true );
3052 setToolShown( true );
3053 SetSettings( desktop() );
3058 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3060 setMenuShown( false );
3061 setToolShown( false );
3063 EmitSignalCloseAllDialogs();
3065 return SalomeApp_Module::deactivateModule( study );
3068 void SMESHGUI::OnGUIEvent()
3070 const QObject* obj = sender();
3071 if ( !obj || !obj->inherits( "QAction" ) )
3073 int id = actionId((QAction*)obj);
3078 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3080 return myComponentSMESH;
3083 QString SMESHGUI::engineIOR() const
3085 CORBA::ORB_var anORB = getApp()->orb();
3086 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3090 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3092 SMESHGUI_Selection sel;
3093 sel.init( client, selectionMgr() );
3094 popupMgr()->updatePopup( menu, &sel );
3097 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3099 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3100 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3103 void SMESHGUI::viewManagers( QStringList& list ) const
3105 list.append( SVTK_Viewer::Type() );
3108 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
3110 if( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
3111 SMESH::UpdateSelectionProp( this );