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 catch (const SALOME::SALOME_Exception& S_ex){
246 SalomeApp_Tools::QtCatchCorbaException(S_ex);
253 void ExportMeshToFile( int theCommandID )
255 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
256 SALOME_ListIO selected;
258 aSel->selectedObjects( selected );
260 if(selected.Extent()){
261 Handle(SALOME_InteractiveObject) anIObject = selected.First();
262 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
263 if ( !aMesh->_is_nil() ) {
264 QString aFilter, aTitle = QObject::tr("Export mesh");
265 QMap<QString, SMESH::MED_VERSION> aFilterMap;
266 switch ( theCommandID ) {
269 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
270 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
274 aFilter = QObject::tr("DAT files (*.dat)");
278 if(aMesh->NbPyramids()){
279 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
280 QObject::tr("SMESH_WRN_WARNING"),
281 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
282 QObject::tr("SMESH_BUT_YES"),
283 QObject::tr("SMESH_BUT_NO"),
288 aFilter = QObject::tr("IDEAS files (*.unv)");
295 SMESH::MED_VERSION aFormat;
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 fd->setCaption( aTitle );
307 fd->setFilters( filters );
309 aFilename = fd->selectedFile();
310 aFormat = aFilterMap[fd->selectedFilter()];
313 if ( !aFilename.isEmpty() ) {
314 // Check whether the file already exists and delete it if yes
315 QFile aFile( aFilename );
316 if ( aFile.exists() )
318 SUIT_OverrideCursor wc;
319 switch ( theCommandID ) {
322 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
326 aMesh->ExportDAT( aFilename.latin1() );
330 aMesh->ExportUNV( aFilename.latin1() );
340 inline void InverseEntityMode(unsigned int& theOutputMode,
341 unsigned int theMode)
343 bool anIsNotPresent = ~theOutputMode & theMode;
345 theOutputMode |= theMode;
347 theOutputMode &= ~theMode;
350 void SetDisplayEntity(int theCommandID){
351 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
352 SALOME_ListIO selected;
354 aSel->selectedObjects( selected );
356 if(selected.Extent() >= 1){
357 SALOME_ListIteratorOfListIO It( selected );
358 for(; It.More(); It.Next()){
359 Handle(SALOME_InteractiveObject) IObject = It.Value();
360 if(IObject->hasEntry()){
361 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
362 unsigned int aMode = anActor->GetEntityMode();
363 switch(theCommandID){
365 InverseEntityMode(aMode,SMESH_Actor::eEdges);
368 InverseEntityMode(aMode,SMESH_Actor::eFaces);
371 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
374 aMode = SMESH_Actor::eAllEntity;
378 anActor->SetEntityMode(aMode);
385 void SetDisplayMode(int theCommandID){
386 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
387 SALOME_ListIO selected;
389 aSel->selectedObjects( selected );
391 if(selected.Extent() >= 1){
392 switch(theCommandID){
394 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
395 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
399 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
400 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
403 SALOME_ListIteratorOfListIO It( selected );
404 for(; It.More(); It.Next()){
405 Handle(SALOME_InteractiveObject) IObject = It.Value();
406 if(IObject->hasEntry()){
407 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
408 switch(theCommandID){
410 anActor->SetRepresentation(SMESH_Actor::eEdge);
413 anActor->SetRepresentation(SMESH_Actor::eSurface);
416 if(anActor->IsShrunk())
419 anActor->SetShrink();
422 anActor->SetRepresentation(SMESH_Actor::ePoint);
426 anActor->GetSufaceColor(color[0], color[1], color[2]);
427 int c0 = int (color[0] * 255);
428 int c1 = int (color[1] * 255);
429 int c2 = int (color[2] * 255);
430 QColor c(c0, c1, c2);
433 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
434 c0 = int (edgecolor[0] * 255);
435 c1 = int (edgecolor[1] * 255);
436 c2 = int (edgecolor[2] * 255);
437 QColor e(c0, c1, c2);
439 float backfacecolor[3];
440 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
441 c0 = int (backfacecolor[0] * 255);
442 c1 = int (backfacecolor[1] * 255);
443 c2 = int (backfacecolor[2] * 255);
444 QColor b(c0, c1, c2);
447 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
448 c0 = int (nodecolor[0] * 255);
449 c1 = int (nodecolor[1] * 255);
450 c2 = int (nodecolor[2] * 255);
451 QColor n(c0, c1, c2);
453 int Edgewidth = (int)anActor->GetLineWidth();
456 int intValue = int(anActor->GetNodeSize());
457 float Shrink = anActor->GetShrinkFactor();
459 SMESHGUI_Preferences_ColorDlg *aDlg =
460 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
461 aDlg->SetColor(1, c);
462 aDlg->SetColor(2, e);
463 aDlg->SetColor(3, n);
464 aDlg->SetColor(4, b);
465 aDlg->SetIntValue(1, Edgewidth);
466 aDlg->SetIntValue(2, intValue);
467 aDlg->SetIntValue(3, int(Shrink*100.));
469 QColor color = aDlg->GetColor(1);
470 QColor edgecolor = aDlg->GetColor(2);
471 QColor nodecolor = aDlg->GetColor(3);
472 QColor backfacecolor = aDlg->GetColor(4);
473 /* actor color and backface color */
474 anActor->SetSufaceColor(float (color.red()) / 255.,
475 float (color.green()) / 255.,
476 float (color.blue()) / 255.);
477 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
478 float (backfacecolor.green()) / 255.,
479 float (backfacecolor.blue()) / 255.);
482 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
483 float (edgecolor.green()) / 255.,
484 float (edgecolor.blue()) / 255.);
486 /* Shrink factor and size edges */
487 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
488 anActor->SetLineWidth(aDlg->GetIntValue(1));
490 /* Nodes color and size */
491 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
492 float (nodecolor.green()) / 255.,
493 float (nodecolor.blue()) / 255.);
494 anActor->SetNodeSize(aDlg->GetIntValue(2));
503 SMESH::RepaintCurrentView();
508 void SetDisplaySettings()
510 SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
514 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
515 SMESHGUI_Preferences_ColorDlg *aDlg =
516 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
518 QColor color = mgr->colorValue( "SMESH", "SettingsFillColor", QColor(0, 170, 255) );
519 aDlg->SetColor(1, color);
521 color = mgr->colorValue( "SMESH", "SettingsOutlineColor", QColor(0, 170, 255) );
522 aDlg->SetColor(2, color);
524 color = mgr->colorValue( "SMESH", "SettingsNodeColor", Qt::red );
525 aDlg->SetColor(3, color);
527 color = mgr->colorValue( "SMESH", "SettingsBackFaceColor", Qt::blue );
528 aDlg->SetColor(4, color);
530 int iVal = mgr->integerValue( "SMESH", "SettingsWidth", 1 );
531 aDlg->SetIntValue(1, iVal);
533 iVal = mgr->integerValue( "SMESH", "SettingsNodesSize", 3 );
534 aDlg->SetIntValue(2, iVal);
536 iVal = mgr->integerValue( "SMESH", "SettingsShrinkCoeff", 75 );
537 aDlg->SetIntValue(3, iVal);
540 mgr->setValue( "SMESH", "SettingsFillColor", aDlg->GetColor(1) );
541 mgr->setValue( "SMESH", "SettingsOutlineColor", aDlg->GetColor(2) );
542 mgr->setValue( "SMESH", "SettingsNodeColor", aDlg->GetColor(3) );
543 mgr->setValue( "SMESH", "SettingsBackFaceColor", aDlg->GetColor(4) );
545 mgr->setValue( "SMESH", "SettingsWidth", aDlg->GetIntValue(1) );
546 mgr->setValue( "SMESH", "SettingsNodesSize", aDlg->GetIntValue(2) );
547 mgr->setValue( "SMESH", "SettingsShrinkCoeff", aDlg->GetIntValue(3) );
554 void Control( int theCommandID )
556 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
557 SALOME_ListIO selected;
559 aSel->selectedObjects( selected );
561 if( !selected.IsEmpty() ){
562 Handle(SALOME_InteractiveObject) anIO = selected.First();
565 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
566 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
567 switch ( theCommandID ){
569 aTitle = QObject::tr( "LENGTH_EDGES" );
570 aControl = SMESH_Actor::eLength;
573 aTitle = QObject::tr( "LENGTH2D_EDGES" );
574 aControl = SMESH_Actor::eLength2D;
577 aTitle = QObject::tr( "FREE_EDGES" );
578 aControl = SMESH_Actor::eFreeEdges;
581 aTitle = QObject::tr( "FREE_BORDERS" );
582 aControl = SMESH_Actor::eFreeBorders;
585 aTitle = QObject::tr( "MULTI_BORDERS" );
586 aControl = SMESH_Actor::eMultiConnection;
589 aTitle = QObject::tr( "MULTI2D_BORDERS" );
590 aControl = SMESH_Actor::eMultiConnection2D;
593 aTitle = QObject::tr( "AREA_ELEMENTS" );
594 aControl = SMESH_Actor::eArea;
597 aTitle = QObject::tr( "TAPER_ELEMENTS" );
598 aControl = SMESH_Actor::eTaper;
601 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
602 aControl = SMESH_Actor::eAspectRatio;
605 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
606 aControl = SMESH_Actor::eAspectRatio3D;
609 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
610 aControl = SMESH_Actor::eMinimumAngle;
613 aTitle = QObject::tr( "WARP_ELEMENTS" );
614 aControl = SMESH_Actor::eWarping;
617 aTitle = QObject::tr( "SKEW_ELEMENTS" );
618 aControl = SMESH_Actor::eSkew;
621 anActor->SetControlMode(aControl);
622 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
629 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
630 MeshObjectType theType,
631 const QString theInTypeName,
632 QString & theOutTypeName)
634 SMESH_TypeFilter aTypeFilter( theType );
636 if( !theIO.IsNull() )
638 entry = theIO->getEntry();
639 SalomeApp_DataOwner owner( entry );
640 if ( aTypeFilter.isOk( &owner )) {
641 theOutTypeName = theInTypeName;
649 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
651 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
652 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
654 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
655 CORBA::String_var anID = aSComp->GetID().c_str();
656 if (!strcmp(anID.in(),theIO->getEntry()))
662 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
663 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
664 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
665 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
666 CheckOIType ( theIO, GROUP, "Group", aTypeName )
674 QString CheckHomogeneousSelection()
676 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
677 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
678 SALOME_ListIO selected;
680 aSel->selectedObjects( selected );
682 QString RefType = CheckTypeObject(selected.First());
683 SALOME_ListIteratorOfListIO It(selected);
684 for (; It.More(); It.Next())
686 Handle(SALOME_InteractiveObject) IObject = It.Value();
687 QString Type = CheckTypeObject(IObject);
688 if (Type.compare(RefType) != 0)
689 return "Heterogeneous Selection";
697 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
698 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
699 SALOME_ListIO selected; aSel->selectedObjects( selected );
701 QString aParentComponent = QString::null;
702 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
704 QString cur = anIt.Value()->getComponentDataType();
705 if( aParentComponent.isNull() )
706 aParentComponent = cur;
707 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
708 aParentComponent = "";
711 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
712 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
713 QObject::tr("ERR_ERROR"),
714 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
715 QObject::tr("BUT_OK") );
718 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
719 if (SUIT_MessageBox::warn2
720 (SMESHGUI::desktop(),
721 QObject::tr("SMESH_WRN_WARNING"),
722 QObject::tr("SMESH_REALLY_DELETE"),
723 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
726 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
727 SUIT_ViewManager* vm = anApp->activeViewManager();
728 int nbSf = vm->getViewsCount();
730 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
731 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
732 _PTR(GenericAttribute) anAttr;
733 _PTR(AttributeIOR) anIOR;
735 SALOME_ListIteratorOfListIO It(selected);
737 aStudyBuilder->NewCommand(); // There is a transaction
738 for(; It.More(); It.Next()){
739 Handle(SALOME_InteractiveObject) IObject = It.Value();
740 if(IObject->hasEntry()){
741 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
743 /* Erase child graphical objects */
744 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
745 for(it->InitEx(true); it->More(); it->Next()){
746 _PTR(SObject) CSO = it->Value();
747 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
750 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
751 for(int i = 0; i < nbSf; i++){
752 SUIT_ViewWindow *sf = aViews[i];
753 CORBA::String_var anEntry = CSO->GetID().c_str();
754 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
755 SMESH::RemoveActor(sf,anActor);
761 /* Erase main graphical object */
762 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
763 for(int i = 0; i < nbSf; i++){
764 SUIT_ViewWindow *sf = aViews[i];
765 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
766 SMESH::RemoveActor(sf,anActor);
770 // Remove object(s) from data structures
771 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
773 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
774 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
776 if ( !aGroup->_is_nil() ) { // DELETE GROUP
777 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
778 aMesh->RemoveGroup( aGroup );
780 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
781 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
782 aMesh->RemoveSubMesh( aSubMesh );
784 else {// default action: remove SObject from the study
785 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
786 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
788 aStudyBuilder->RemoveObjectWithChildren( obj );
793 } /* IObject->hasEntry() */
795 aStudyBuilder->CommitCommand();
797 /* Clear any previous selection */
799 aSel->setSelectedObjects( l1 );
801 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
805 //=============================================================================
809 //=============================================================================
810 class CustomItem : public QCustomMenuItem
813 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
816 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
819 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
820 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
821 p->setFont( myFont );
822 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
828 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
831 bool fullSpan() const
842 Standard_EXPORT CAM_Module* createModule()
844 return SMESHGUI::GetSMESHGUI();
848 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
850 //=============================================================================
854 //=============================================================================
855 SMESHGUI::SMESHGUI() :
856 SalomeApp_Module( "SMESH" )
858 if ( CORBA::is_nil( myComponentSMESH ) )
860 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
861 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
862 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
865 myActiveDialogBox = 0 ;
868 SMESH::GetFilterManager();
871 /* load resources for all available meshers */
872 SMESH::InitAvailableHypotheses();
875 //=============================================================================
879 //=============================================================================
880 SMESHGUI::~SMESHGUI()
882 SMESH::GetFilterManager()->Destroy();
885 //=============================================================================
889 //=============================================================================
890 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
892 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
894 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
899 //=============================================================================
903 //=============================================================================
904 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
906 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
909 //=============================================================================
913 //=============================================================================
914 SMESHGUI* SMESHGUI::GetSMESHGUI()
916 static SMESHGUI* aSMESHGUI = NULL;
918 aSMESHGUI = new SMESHGUI();
920 if(_PTR(Study) aStudy = SMESH::GetActiveStudyDocument())
921 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
923 SUIT_ResourceMgr* mgr = resourceMgr();
925 /* Automatic Update flag */
926 aSMESHGUI->myAutomaticUpdate = ( mgr->stringValue( "SMESH", "AutomaticUpdate" ).compare( "true" ) == 0 );
933 Standard_EXPORT SMESHGUI* GetComponentGUI() {
934 return SMESHGUI::GetSMESHGUI();
938 //=============================================================================
942 //=============================================================================
943 void SMESHGUI::SetState(int aState)
948 //=============================================================================
952 //=============================================================================
953 void SMESHGUI::ResetState()
958 //=============================================================================
962 //=============================================================================
963 void SMESHGUI::EmitSignalDeactivateDialog()
965 emit SignalDeactivateActiveDialog();
968 //=============================================================================
972 //=============================================================================
973 void SMESHGUI::EmitSignalStudyFrameChanged()
975 emit SignalStudyFrameChanged();
978 //=============================================================================
982 //=============================================================================
983 void SMESHGUI::EmitSignalCloseAllDialogs()
985 emit SignalCloseAllDialogs();
988 //=============================================================================
992 //=============================================================================
993 QDialog *SMESHGUI::GetActiveDialogBox()
995 return myActiveDialogBox;
998 //=============================================================================
1002 //=============================================================================
1003 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1005 myActiveDialogBox = (QDialog *) aDlg;
1009 //=============================================================================
1013 //=============================================================================
1014 SUIT_Desktop* SMESHGUI::desktop()
1016 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1018 return app->desktop();
1023 //=============================================================================
1027 //=============================================================================
1028 SalomeApp_Study* SMESHGUI::activeStudy()
1030 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1032 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1037 //=============================================================================
1041 //=============================================================================
1042 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1044 /* Here the position is on the bottom right corner - 10 */
1045 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1047 SUIT_Desktop *PP = desktop();
1048 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1049 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1053 //=============================================================================
1057 //=============================================================================
1058 static int isStudyLocked(_PTR(Study) theStudy){
1059 return theStudy->GetProperties()->IsLocked();
1062 static bool checkLock(_PTR(Study) theStudy) {
1063 if (isStudyLocked(theStudy)) {
1064 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1065 QObject::tr("WRN_WARNING"),
1066 QObject::tr("WRN_STUDY_LOCKED"),
1067 QObject::tr("BUT_OK") );
1073 //=======================================================================
1074 //function : CheckActiveStudyLocked
1076 //=======================================================================
1078 bool SMESHGUI::isActiveStudyLocked()
1080 _PTR(Study) aStudy = activeStudy()->studyDS();
1081 return checkLock( aStudy );
1084 //=============================================================================
1088 //=============================================================================
1089 bool SMESHGUI::OnGUIEvent( int theCommandID )
1091 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1095 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1096 SUIT_ResourceMgr* mgr = resourceMgr();
1100 SUIT_ViewManager* vm = application()->activeViewManager();
1104 SUIT_ViewWindow* view =vm->getActiveView();
1105 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1107 QAction* act = action( theCommandID );
1109 switch (theCommandID) {
1111 if(checkLock(aStudy)) break;
1119 if(checkLock(aStudy)) break;
1120 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1124 case 122: // EXPORT MED
1131 ::ExportMeshToFile(theCommandID);
1135 case 200: // SCALAR BAR
1137 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1138 SALOME_ListIO selected;
1140 aSel->selectedObjects( selected );
1142 if( selected.Extent() ) {
1143 Handle(SALOME_InteractiveObject) anIO = selected.First();
1144 if( anIO->hasEntry() ) {
1145 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1146 anActor->SetControlMode( SMESH_Actor::eNone );
1154 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1158 case 1134: // Clipping
1159 case 1133: // Tranparency
1160 case 1132: // Colors / Size
1167 ::SetDisplayMode(theCommandID);
1173 case 219: // Volumes
1174 case 220: // All Entity
1175 ::SetDisplayEntity(theCommandID);
1180 if(checkLock(aStudy)) break;
1181 SMESH::UpdateView();
1186 case 301: // DISPLAY
1187 case 302: // DISPLAY ONLY
1189 SMESH::EDisplaing anAction;
1190 switch(theCommandID){
1191 case 300: anAction = SMESH::eErase; break;
1192 case 301: anAction = SMESH::eDisplay; break;
1193 case 302: anAction = SMESH::eDisplayOnly; break;
1196 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1197 SALOME_ListIO selected;
1199 aSel->selectedObjects( selected );
1202 SALOME_ListIteratorOfListIO It(selected);
1203 for (; It.More(); It.Next()) {
1204 Handle(SALOME_InteractiveObject) IOS = It.Value();
1205 if (IOS->hasEntry()) {
1206 SMESH::UpdateView(anAction,IOS->getEntry());
1211 aSel->setSelectedObjects( l1 );
1217 if(checkLock(aStudy)) break;
1220 EmitSignalDeactivateDialog();
1222 new SMESHGUI_NodesDlg(this);
1225 SUIT_MessageBox::warn1(desktop(),
1226 tr("SMESH_WRN_WARNING"),
1227 tr("SMESH_WRN_VIEWER_VTK"),
1228 tr("SMESH_BUT_OK"));
1233 case 2151: // FILTER
1237 EmitSignalDeactivateDialog();
1238 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1243 case 406: // MOVE NODE
1247 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1248 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1252 if(checkLock(aStudy)) break;
1253 new SMESHGUI_MoveNodesDlg(this);
1257 case 701: // COMPUTE MESH
1259 if(checkLock(aStudy)) break;
1261 SalomeApp_SelectionMgr *Sel = selectionMgr();
1262 SALOME_ListIO selected; Sel->selectedObjects( selected );
1264 int nbSel = selected.Extent();
1269 SMESH::SMESH_Mesh_var aMesh;
1270 SMESH::SMESH_subMesh_var aSubMesh;
1271 Handle(SALOME_InteractiveObject) IObject = selected.First();
1272 if (IObject->hasEntry()){
1273 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1274 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1275 if ( aShapeObject->_is_nil() ) {
1280 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1281 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1283 if (!aMesh->_is_nil()){
1284 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1285 if (!refShapeObject->_is_nil()) {
1286 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1287 SUIT_MessageBox::warn1(desktop(),
1288 tr("SMESH_WRN_WARNING"),
1289 tr("SMESH_WRN_MISSING_PARAMETERS"),
1290 tr("SMESH_BUT_OK"));
1294 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1295 SMESH::ModifiedMesh(aMeshSObj,true);
1296 // TO Do : change icon of all submeshes
1298 SUIT_MessageBox::warn1(desktop(),
1299 tr("SMESH_WRN_WARNING"),
1300 tr("SMESH_WRN_COMPUTE_FAILED"),
1301 tr("SMESH_BUT_OK"));
1303 catch(const SALOME::SALOME_Exception & S_ex){
1304 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1307 }else if(!aSubMesh->_is_nil()){
1308 aMesh = aSubMesh->GetFather();
1309 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1310 if(!refShapeObject->_is_nil()){
1311 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1313 SUIT_MessageBox::warn1(desktop(),
1314 tr("SMESH_WRN_WARNING"),
1315 tr("SMESH_WRN_MISSING_PARAMETERS"),
1316 tr("SMESH_BUT_OK"));
1320 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1321 SMESH::ModifiedMesh(aMeshSObj,true);
1322 // TO Do : change icon of all submeshes
1324 SUIT_MessageBox::warn1(desktop(),
1325 tr("SMESH_WRN_WARNING"),
1326 tr("SMESH_WRN_COMPUTE_FAILED"),
1327 tr("SMESH_BUT_OK"));
1328 }catch(const SALOME::SALOME_Exception & S_ex){
1329 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1335 CORBA::Long anId = aStudy->StudyId();
1336 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1337 cout<<"myAutomaticUpdate - "<<myAutomaticUpdate<<endl;
1338 if(myAutomaticUpdate && aVisualObj){
1339 aVisualObj->Update();
1340 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1342 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1344 SMESH::DisplayActor(view,anActor); //apo
1350 SUIT_MessageBox::warn1(desktop(),
1351 tr("SMESH_WRN_WARNING"),
1352 tr("SMESH_WRN_VIEWER_VTK"),
1353 tr("SMESH_BUT_OK"));
1358 case 702: // ADD SUB MESH
1360 if(checkLock(aStudy)) break;
1362 EmitSignalDeactivateDialog();
1363 new SMESHGUI_AddSubMeshDlg( this );
1366 SUIT_MessageBox::warn1(desktop(),
1367 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1368 tr("SMESH_BUT_OK"));
1373 case 703: // INIT MESH
1375 if(checkLock(aStudy)) break;
1376 EmitSignalDeactivateDialog();
1377 new SMESHGUI_InitMeshDlg( this );
1381 case 704: // EDIT Hypothesis
1383 if(checkLock(aStudy)) break;
1384 EmitSignalDeactivateDialog();
1385 new SMESHGUI_EditHypothesesDlg( this );
1389 case 705: // EDIT Global Hypothesis
1391 if(checkLock(aStudy)) break;
1392 EmitSignalDeactivateDialog();
1393 new SMESHGUI_EditHypothesesDlg( this );
1397 case 706: // EDIT Local Hypothesis
1399 if(checkLock(aStudy)) break;
1400 EmitSignalDeactivateDialog();
1401 new SMESHGUI_EditHypothesesDlg( this );
1405 case 407: // DIAGONAL INVERSION
1406 case 408: // Delete diagonal
1410 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1411 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1415 if ( checkLock( aStudy ) )
1418 /*Standard_Boolean aRes;
1419 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1420 if ( aMesh->_is_nil() )
1422 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1423 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1427 EmitSignalDeactivateDialog();
1428 if ( theCommandID == 407 )
1429 new SMESHGUI_TrianglesInversionDlg(this);
1431 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1434 case 409: // Change orientation
1435 case 410: // Union of triangles
1436 case 411: // Cutting of quadrangles
1440 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1441 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1445 if ( checkLock( aStudy ) )
1448 EmitSignalDeactivateDialog();
1449 SMESHGUI_MultiEditDlg* aDlg = NULL;
1450 if ( theCommandID == 409 )
1451 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1452 else if ( theCommandID == 410 )
1453 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1455 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1458 DefineDlgPosition( aDlg, x, y );
1463 case 412: // Smoothing
1465 if(checkLock(aStudy)) break;
1467 EmitSignalDeactivateDialog();
1468 new SMESHGUI_SmoothingDlg( this );
1471 SUIT_MessageBox::warn1(desktop(),
1472 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1473 tr("SMESH_BUT_OK"));
1477 case 413: // Extrusion
1479 if (checkLock(aStudy)) break;
1481 EmitSignalDeactivateDialog();
1482 new SMESHGUI_ExtrusionDlg ( this );
1484 SUIT_MessageBox::warn1(desktop(),
1485 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1486 tr("SMESH_BUT_OK"));
1490 case 414: // Revolution
1492 if(checkLock(aStudy)) break;
1494 EmitSignalDeactivateDialog();
1495 new SMESHGUI_RevolutionDlg( this );
1498 SUIT_MessageBox::warn1(desktop(),
1499 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1500 tr("SMESH_BUT_OK"));
1504 case 415: // Pattern mapping
1506 if ( checkLock( aStudy ) )
1510 EmitSignalDeactivateDialog();
1511 new SMESHGUI_MeshPatternDlg( this );
1514 SUIT_MessageBox::warn1(desktop(),
1515 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1516 tr("SMESH_BUT_OK"));
1520 case 416: // Extrusion along a path
1522 if (checkLock(aStudy)) break;
1524 EmitSignalDeactivateDialog();
1525 new SMESHGUI_ExtrusionAlongPathDlg( this );
1527 SUIT_MessageBox::warn1(desktop(),
1528 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1529 tr("SMESH_BUT_OK"));
1533 case 801: // CREATE GROUP
1535 if(checkLock(aStudy)) break;
1536 EmitSignalDeactivateDialog();
1537 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1539 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1540 SALOME_ListIO selected;
1542 aSel->selectedObjects( selected );
1544 int nbSel = selected.Extent();
1546 // check if mesh is selected
1547 aMesh = SMESH::GetMeshByIO( selected.First() );
1549 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1554 case 802: // CONSTRUCT GROUP
1556 if(checkLock(aStudy)) break;
1557 EmitSignalDeactivateDialog();
1559 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1560 SALOME_ListIO selected;
1562 aSel->selectedObjects( selected );
1564 int nbSel = selected.Extent();
1566 // check if submesh is selected
1567 Handle(SALOME_InteractiveObject) IObject = selected.First();
1568 if (IObject->hasEntry()) {
1569 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1571 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1572 if (!aSubMesh->_is_nil()) {
1574 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1575 // get submesh elements list by types
1576 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1577 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1578 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1579 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1580 // create group for each type o elements
1581 QString aName = IObject->getName();
1582 if (aNodes->length() > 0) {
1583 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1584 aGroup->Add(aNodes.inout());
1586 if (aEdges->length() > 0) {
1587 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1588 aGroup->Add(aEdges.inout());
1590 if (aFaces->length() > 0) {
1591 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1592 aGroup->Add(aFaces.inout());
1594 if (aVolumes->length() > 0) {
1595 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1596 aGroup->Add(aVolumes.inout());
1600 }catch(const SALOME::SALOME_Exception & S_ex){
1601 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1610 case 803: // EDIT GROUP
1612 if(checkLock(aStudy)) break;
1613 EmitSignalDeactivateDialog();
1615 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1616 SALOME_ListIO selected;
1618 aSel->selectedObjects( selected );
1620 SALOME_ListIteratorOfListIO It (selected);
1621 int nbSelectedGroups = 0;
1622 for ( ; It.More(); It.Next() )
1624 SMESH::SMESH_Group_var aGroup =
1625 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1626 if (!aGroup->_is_nil()) {
1628 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1632 if (nbSelectedGroups == 0)
1634 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1640 case 804: // Add elements to group
1642 if(checkLock(aStudy)) break;
1643 if (myState == 800) {
1644 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1645 if (aDlg) aDlg->onAdd();
1650 case 805: // Remove elements from group
1652 if(checkLock(aStudy)) break;
1653 if (myState == 800) {
1654 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1655 if (aDlg) aDlg->onRemove();
1660 case 810: // Union Groups
1661 case 811: // Intersect groups
1662 case 812: // Cut groups
1664 if ( checkLock( aStudy ) )
1667 EmitSignalDeactivateDialog();
1670 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1671 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1672 else aMode = SMESHGUI_GroupOpDlg::CUT;
1674 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1678 case 813: // Delete groups with their contents
1680 if ( checkLock( aStudy ) )
1683 EmitSignalDeactivateDialog();
1685 new SMESHGUI_DeleteGroupDlg( this );
1689 case 900: // MESH INFOS
1691 EmitSignalDeactivateDialog();
1692 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1693 SALOME_ListIO selected;
1695 aSel->selectedObjects( selected );
1697 if ( selected.Extent() > 1 ) { // a dlg for each IO
1699 SALOME_ListIteratorOfListIO It (selected);
1700 for ( ; It.More(); It.Next() ) {
1701 IOs.Clear(); IOs.Append( It.Value() );
1702 aSel->setSelectedObjects( IOs );
1703 new SMESHGUI_MeshInfosDlg(this, "", false);
1705 // restore selection
1706 aSel->setSelectedObjects( selected );
1709 new SMESHGUI_MeshInfosDlg(this, "", false);
1713 case 902: // STANDARD MESH INFOS
1715 EmitSignalDeactivateDialog();
1716 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1717 SALOME_ListIO selected;
1719 aSel->selectedObjects( selected );
1721 if ( selected.Extent() > 1 ) { // a dlg for each IO
1723 SALOME_ListIteratorOfListIO It (selected);
1724 for ( ; It.More(); It.Next() ) {
1726 IOs.Append( It.Value() );
1727 aSel->setSelectedObjects( IOs );
1728 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1730 // restore selection
1731 aSel->setSelectedObjects( selected );
1734 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1738 case 1001: // AUTOMATIC UPDATE PREFERENCES
1741 mgr->setValue( "SMESH", "AutomaticUpdate", true );
1742 myAutomaticUpdate = true;
1745 mgr->setValue( "SMESH", "AutomaticUpdate", false );
1746 myAutomaticUpdate = false;
1751 case 1003: // MESH PREFERENCES
1753 ::SetDisplaySettings();
1759 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( this );
1765 ( new SMESHGUI_PrecisionDlg( this ) )->exec();
1772 mgr->setValue( "SMESH", "DispayEntity", true );
1775 mgr->setValue( "SMESH", "DispayEntity", false );
1781 SMESHGUI_Preferences_SelectionDlg* aDlg =
1782 new SMESHGUI_Preferences_SelectionDlg( this );
1784 QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
1785 aDlg->SetColor(1, aColor);
1787 aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow );
1788 aDlg->SetColor(2, aColor);
1790 aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white );
1791 aDlg->SetColor(3, aColor);
1793 aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) );
1794 aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) );
1795 aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) );
1796 aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) );
1799 QColor aPreColor = aDlg->GetColor(1),
1800 aSelColor = aDlg->GetColor(2),
1801 aHiColor = aDlg->GetColor(3);
1802 int aPreWidth = aDlg->GetWidth(1),
1803 aSelWidth = aDlg->GetWidth(2);
1804 double aTolNodes = aDlg->GetPrecision(1),
1805 aTolItems = aDlg->GetPrecision(2);
1807 mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor );
1808 mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor );
1809 mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor );
1811 mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth );
1812 mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth );
1813 mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes );
1814 mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems );
1816 // update current study settings
1817 SMESH::UpdateSelectionProp( this );
1820 // update VTK viewer properties
1821 SVTK_RenderWindowInteractor* anInteractor =
1822 dynamic_cast<SVTK_RenderWindowInteractor*>( vtkwnd->getRWInteractor() );
1824 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1825 aSelColor.blue()/255., aSelWidth);
1826 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1827 SVTK_InteractorStyle* aStyle =
1828 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
1831 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1832 aPreColor.blue()/255., aPreWidth);
1835 vtkRenderer* aRenderer = vtkwnd->getRenderer();
1836 vtkActorCollection *aCollection = aRenderer->GetActors();
1837 aCollection->InitTraversal();
1838 while(vtkActor *anAct = aCollection->GetNextActor()){
1839 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1840 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1841 aHiColor.blue()/255.);
1842 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1843 aPreColor.blue()/255.);
1852 case 1100: // EDIT HYPOTHESIS
1854 if(checkLock(aStudy)) break;
1856 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1857 SALOME_ListIO selected;
1859 aSel->selectedObjects( selected );
1861 int nbSel = selected.Extent();
1864 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1866 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1867 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1868 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1869 if ( !Hyp->_is_nil() )
1871 char* sName = Hyp->GetName();
1872 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1875 aCreator->EditHypothesis(Hyp);
1886 case 1101: // RENAME
1888 if ( checkLock( aStudy ) )
1891 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1892 SALOME_ListIO selected;
1894 aSel->selectedObjects( selected );
1896 SALOME_ListIteratorOfListIO It( selected );
1897 for ( ; It.More(); It.Next() )
1899 Handle(SALOME_InteractiveObject) IObject = It.Value();
1900 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1901 _PTR(GenericAttribute) anAttr;
1902 _PTR(AttributeName) aName;
1905 if ( obj->FindAttribute(anAttr, "AttributeName") )
1908 QString newName = QString(aName->Value().c_str());
1909 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1910 if ( !newName.isEmpty() )
1912 //old source: aStudy->renameIObject( IObject, newName );
1913 aName->SetValue( newName.latin1() );
1915 // if current object is group update group's name
1916 SMESH::SMESH_GroupBase_var aGroup =
1917 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1918 if (!aGroup->_is_nil() )
1919 aGroup->SetName( newName.latin1() );
1929 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1931 if(checkLock(aStudy)) break;
1932 SUIT_OverrideCursor wc;
1934 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1935 SALOME_ListIO selected;
1937 aSel->selectedObjects( selected );
1939 SALOME_ListIteratorOfListIO It(selected);
1940 for (int i = 0; It.More(); It.Next(), i++) {
1941 Handle(SALOME_InteractiveObject) IObject = It.Value();
1942 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1945 aSel->setSelectedObjects( l1 );
1950 case 401: // GEOM::EDGE
1951 case 4021: // TRIANGLE
1953 case 4023: // POLYGON
1957 if(checkLock(aStudy)) break;
1959 EmitSignalDeactivateDialog();
1960 SMDSAbs_ElementType type = SMDSAbs_Edge;
1962 switch (theCommandID) {
1963 case 4021: // TRIANGLE
1964 type = SMDSAbs_Face; nbNodes = 3; break;
1966 type = SMDSAbs_Face; nbNodes = 4; break;
1968 type = SMDSAbs_Volume; nbNodes = 4; break;
1969 case 4023: // POLYGON
1970 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1972 type = SMDSAbs_Volume; nbNodes = 8; break;
1973 case 4033: // POLYHEDRE
1974 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1977 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1980 SUIT_MessageBox::warn1(desktop(),
1981 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1982 tr("SMESH_BUT_OK"));
1986 case 4033: // POLYHEDRON
1988 if(checkLock(aStudy)) break;
1990 EmitSignalDeactivateDialog();
1991 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1994 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1995 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1996 tr("SMESH_BUT_OK"));
2000 case 4041: // REMOVES NODES
2002 if(checkLock(aStudy)) break;
2004 EmitSignalDeactivateDialog();
2005 new SMESHGUI_RemoveNodesDlg(this);
2008 SUIT_MessageBox::warn1(desktop(),
2009 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2010 tr("SMESH_BUT_OK"));
2014 case 4042: // REMOVES ELEMENTS
2016 if(checkLock(aStudy)) break;
2018 EmitSignalDeactivateDialog();
2019 new SMESHGUI_RemoveElementsDlg(this);
2023 SUIT_MessageBox::warn1(desktop(),
2024 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2025 tr("SMESH_BUT_OK"));
2029 case 4051: // RENUMBERING NODES
2031 if(checkLock(aStudy)) break;
2033 EmitSignalDeactivateDialog();
2034 new SMESHGUI_RenumberingDlg( this, "", 0);
2038 SUIT_MessageBox::warn1(desktop(),
2039 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2040 tr("SMESH_BUT_OK"));
2044 case 4052: // RENUMBERING ELEMENTS
2046 if(checkLock(aStudy)) break;
2048 EmitSignalDeactivateDialog();
2049 new SMESHGUI_RenumberingDlg( this, "", 1);
2053 SUIT_MessageBox::warn1(desktop(),
2054 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2055 tr("SMESH_BUT_OK"));
2059 case 4061: // TRANSLATION
2061 if(checkLock(aStudy)) break;
2063 EmitSignalDeactivateDialog();
2064 new SMESHGUI_TranslationDlg( this );
2067 SUIT_MessageBox::warn1(desktop(),
2068 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2069 tr("SMESH_BUT_OK"));
2073 case 4062: // ROTATION
2075 if(checkLock(aStudy)) break;
2077 EmitSignalDeactivateDialog();
2078 new SMESHGUI_RotationDlg( this );
2081 SUIT_MessageBox::warn1(desktop(),
2082 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2083 tr("SMESH_BUT_OK"));
2087 case 4063: // SYMMETRY
2089 if(checkLock(aStudy)) break;
2091 EmitSignalDeactivateDialog();
2092 new SMESHGUI_SymmetryDlg( this );
2095 SUIT_MessageBox::warn1(desktop(),
2096 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2097 tr("SMESH_BUT_OK"));
2101 case 4064: // SEWING
2103 if(checkLock(aStudy)) break;
2105 EmitSignalDeactivateDialog();
2106 new SMESHGUI_SewingDlg( this );
2109 SUIT_MessageBox::warn1(desktop(),
2110 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2111 tr("SMESH_BUT_OK"));
2115 case 4065: // MERGE NODES
2117 if(checkLock(aStudy)) break;
2119 EmitSignalDeactivateDialog();
2120 new SMESHGUI_MergeNodesDlg( this );
2123 SUIT_MessageBox::warn1(desktop(),
2124 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2125 tr("SMESH_BUT_OK"));
2131 case 5000: // HYPOTHESIS
2133 if(checkLock(aStudy)) break;
2134 EmitSignalDeactivateDialog();
2135 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2140 if(checkLock(aStudy)) break;
2141 EmitSignalDeactivateDialog();
2142 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2146 case 5105: // Library of selection filters
2148 static QValueList<int> aTypes;
2149 if ( aTypes.isEmpty() )
2151 aTypes.append( SMESH::NODE );
2152 aTypes.append( SMESH::EDGE );
2153 aTypes.append( SMESH::FACE );
2154 aTypes.append( SMESH::VOLUME );
2156 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2160 case 6017: // CONTROLS
2175 SalomeApp_SelectionMgr* mgr = selectionMgr();
2176 SALOME_ListIO selected; mgr->selectedObjects( selected );
2178 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2179 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2181 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2182 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2183 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2184 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2185 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2186 ::Control( theCommandID );
2191 SUIT_MessageBox::warn1(desktop(),
2192 tr( "SMESH_WRN_WARNING" ),
2193 tr( "SMESH_BAD_SELECTION" ),
2194 tr( "SMESH_BUT_OK" ) );
2198 SUIT_MessageBox::warn1(desktop(),
2199 tr( "SMESH_WRN_WARNING" ),
2200 tr( "NOT_A_VTK_VIEWER" ),
2201 tr( "SMESH_BUT_OK" ) );
2206 SalomeApp_SelectionMgr* mgr = selectionMgr();
2207 SALOME_ListIO selected; mgr->selectedObjects( selected );
2209 if (selected.Extent() == 1) {
2210 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2211 if(anIObject->hasEntry())
2212 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2213 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2220 SalomeApp_SelectionMgr* mgr = selectionMgr();
2221 SALOME_ListIO selected; mgr->selectedObjects( selected );
2223 if (selected.Extent() == 1) {
2224 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2225 if(anIObject->hasEntry())
2226 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2227 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2232 case 10001: // DISPLAY MODE PREFERENCE
2236 action( 10002 )->setOn( false );
2237 action( 10004 )->setOn( false );
2238 action( 10003 )->setOn( true );
2239 mgr->setValue( "SMESH", "DisplayMode", "Wireframe");
2245 action( 10001 )->setOn( false );
2246 action( 10004 )->setOn( false );
2247 action( 10003 )->setOn( true );
2248 mgr->setValue( "SMESH", "DisplayMode", "Shading");
2253 mgr->setValue( "SMESH", "Shrink", act->isOn() );
2259 action( 10001 )->setOn( false );
2260 action( 10002 )->setOn( false );
2261 action( 10003 )->setOn( false );
2262 mgr->setValue( "SMESH", "DisplayMode", "Nodes" );
2272 //=============================================================================
2276 //=============================================================================
2277 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2282 //=============================================================================
2286 //=============================================================================
2287 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2292 //=============================================================================
2296 //=============================================================================
2297 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2302 //=============================================================================
2306 //=============================================================================
2307 bool SMESHGUI::SetSettings(SUIT_Desktop* parent)
2309 SMESHGUI::GetSMESHGUI();
2311 SUIT_ResourceMgr* mgr = resourceMgr();
2316 QString DisplayMode = "Shading";
2317 if ( mgr->hasValue("SMESH","DisplayMode") )
2318 DisplayMode = mgr->stringValue("SMESH","DisplayMode");
2320 mgr->setValue("SMESH","DisplayMode", "Shading");
2322 bool Shrink = false;
2323 if ( mgr->hasValue("SMESH","Shrink") )
2324 Shrink = mgr->stringValue("SMESH","Shrink") == "yes";
2326 if (DisplayMode == "Wireframe") {
2328 action( 10004 )->setOn( false );
2329 action( 10002 )->setOn( false );
2330 action( 10001 )->setOn( true );
2331 action( 10003 )->setOn( true );
2333 else if (DisplayMode == "Nodes") {
2335 action( 10004 )->setOn( true );
2336 action( 10002 )->setOn( false );
2337 action( 10001 )->setOn( false );
2338 action( 10003 )->setOn( false );
2341 // default is shading
2342 action( 10004 )->setOn( false );
2343 action( 10002 )->setOn( true );
2344 action( 10001 )->setOn( false );
2345 action( 10003 )->setOn( true );
2348 action( 10003 )->setOn( Shrink );
2351 if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) {
2352 action( 1001 )->setOn( true );
2353 myAutomaticUpdate = true;
2356 action( 1001 )->setOn( false );
2357 myAutomaticUpdate = false;
2360 if ( mgr->booleanValue( "SMESH","DispayEntity", false ) )
2361 action( 10071 )->setOn( true );
2363 action( 10071 )->setOn( false );
2366 SMESH::UpdateSelectionProp( this );
2369 action( 111 )->setEnabled( false ); // IMPORT DAT
2371 //action( 112 )->setEnabled( false );
2372 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2377 //=============================================================================
2378 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2379 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2381 //=============================================================================
2382 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2383 SUIT_ViewWindow* wnd )
2385 if(theIO->hasEntry()){
2386 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2387 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2391 //=======================================================================
2392 // function : createSMESHAction
2394 //=======================================================================
2395 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2398 QWidget* parent = application()->desktop();
2399 SUIT_ResourceMgr* resMgr = resourceMgr();
2401 if ( icon_id.length() )
2402 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2404 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ) );
2405 if ( !pix.isNull() )
2406 icon = QIconSet( pix );
2408 QString tooltip = tr( QString( "TOP_" )+po_id ),
2409 menu = tr( QString( "MEN_" )+po_id ),
2410 status_bar = tr( QString( "STB_" )+po_id );
2412 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2415 //=======================================================================
2416 // function : createPopupItem
2418 //=======================================================================
2419 void SMESHGUI::createPopupItem( const int id,
2420 const QString& clients,
2421 const QString& types,
2422 const QString& theRule,
2427 parentId = popupMgr()->actionId( action( pId ) );
2429 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2430 popupMgr()->insert( action( id ), parentId, 0 );
2432 QChar lc = QtxPopupMgr::Selection::defEquality();
2433 QString rule = "(%1) and (%2) and (%3)";
2434 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2435 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2436 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2439 bool cont = myRules.contains( id );
2441 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2443 popupMgr()->setRule( action( id ), rule, true );
2444 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2447 //=======================================================================
2448 // function : initialize
2450 //=======================================================================
2451 void SMESHGUI::initialize( CAM_Application* app )
2453 SalomeApp_Module::initialize( app );
2455 // ----- create actions --------------
2457 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2458 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2459 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2460 createSMESHAction( 114, "NUM" );
2461 createSMESHAction( 121, "DAT" );
2462 createSMESHAction( 122, "MED" );
2463 createSMESHAction( 123, "UNV" );
2464 createSMESHAction( 124, "EXPORT_DAT" );
2465 createSMESHAction( 125, "EXPORT_MED" );
2466 createSMESHAction( 126, "EXPORT_UNV" );
2467 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2468 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2469 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2470 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2471 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2472 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2473 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2474 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2475 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2476 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2477 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2478 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2479 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2480 createSMESHAction( 804, "ADD" );
2481 createSMESHAction( 805, "REMOVE" );
2482 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2483 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2484 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2485 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2486 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2487 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2488 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2489 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2490 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2491 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2492 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2493 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2494 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2495 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2496 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2497 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2498 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2499 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2500 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2501 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2502 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2503 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2504 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2505 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2506 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2507 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2508 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2509 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2510 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2511 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2512 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2513 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2514 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2515 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2516 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2517 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2518 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2519 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2520 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2521 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2522 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2523 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2524 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2525 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2526 createSMESHAction( 415, "MAP", "ICON_MAP" );
2527 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2528 createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true );
2529 createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true );
2530 createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true );
2531 createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true );
2532 createSMESHAction( 1001, "AUTO_UPD", "", 0, true );
2533 createSMESHAction( 1003, "COLORS" );
2534 createSMESHAction( 1005, "SCALAR_BAR" );
2535 createSMESHAction( 1006, "SELECTION" );
2536 createSMESHAction( 10070, "PRECISION", "", 0, true );
2537 createSMESHAction( 10071, "DISP_ENT", "", 0, true );
2538 createSMESHAction( 200, "RESET" );
2539 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2540 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2541 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2542 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2543 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2544 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2545 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2546 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2547 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2548 createSMESHAction( 220, "ALL" );
2549 createSMESHAction( 1100, "EDIT_HYPO" );
2550 createSMESHAction( 1101, "RENAME" );
2551 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2552 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2553 createSMESHAction( 1131, "DISPMODE" );
2554 createSMESHAction( 1132, "COLORS" );
2555 createSMESHAction( 1133, "TRANSP" );
2556 createSMESHAction( 1134, "CLIP" );
2557 createSMESHAction( 1135, "DISP_ENT" );
2558 createSMESHAction( 2000, "CTRL" );
2560 createSMESHAction( 300, "ERASE" );
2561 createSMESHAction( 301, "DISPLAY" );
2562 createSMESHAction( 302, "DISPLAY_ONLY" );
2563 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2565 // ----- create menu --------------
2566 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2567 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2568 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2569 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2570 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2571 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2572 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2573 prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ),
2574 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2576 createMenu( separator(), fileId );
2578 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2579 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2581 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2582 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2583 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2584 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
2586 meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ),
2588 dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ),
2589 qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 );
2591 createMenu( 111, importId, -1 );
2592 createMenu( 112, importId, -1 );
2593 createMenu( 113, importId, -1 );
2595 createMenu( 121, exportId, -1 );
2596 createMenu( 122, exportId, -1 );
2597 createMenu( 123, exportId, -1 );
2599 createMenu( separator(), fileId, 10 );
2601 createMenu( 33, editId, -1 );
2603 createMenu( 5105, toolsId, -1 );
2605 createMenu( 5000, hypoId, -1 );
2606 createMenu( 5010, hypoId, -1 );
2608 createMenu( 703, meshId, -1 );
2609 createMenu( 702, meshId, -1 );
2610 createMenu( 704, meshId, -1 );
2611 createMenu( separator(), meshId, -1 );
2612 createMenu( 701, meshId, -1 );
2613 createMenu( separator(), meshId, -1 );
2614 createMenu( 801, meshId, -1 );
2615 createMenu( 802, meshId, -1 );
2616 createMenu( 803, meshId, -1 );
2617 createMenu( separator(), meshId, -1 );
2618 createMenu( 810, meshId, -1 );
2619 createMenu( 811, meshId, -1 );
2620 createMenu( 812, meshId, -1 );
2621 createMenu( separator(), meshId, -1 );
2622 createMenu( 813, meshId, -1 );
2623 createMenu( separator(), meshId, -1 );
2624 createMenu( 900, meshId, -1 );
2625 createMenu( 902, meshId, -1 );
2626 createMenu( separator(), meshId, -1 );
2628 createMenu( 6003, ctrlId, -1 );
2629 createMenu( 6001, ctrlId, -1 );
2630 createMenu( 6004, ctrlId, -1 );
2631 createMenu( separator(), ctrlId, -1 );
2632 createMenu( 6002, ctrlId, -1 );
2633 createMenu( 6018, ctrlId, -1 );
2634 createMenu( 6019, ctrlId, -1 );
2635 createMenu( 6011, ctrlId, -1 );
2636 createMenu( 6012, ctrlId, -1 );
2637 createMenu( 6013, ctrlId, -1 );
2638 createMenu( 6014, ctrlId, -1 );
2639 createMenu( 6015, ctrlId, -1 );
2640 createMenu( 6016, ctrlId, -1 );
2641 createMenu( separator(), ctrlId, -1 );
2642 createMenu( 6017, ctrlId, -1 );
2643 createMenu( separator(), ctrlId, -1 );
2645 createMenu( 400, addId, -1 );
2646 createMenu( 401, addId, -1 );
2647 createMenu( 4021, addId, -1 );
2648 createMenu( 4022, addId, -1 );
2649 createMenu( 4023, addId, -1 );
2650 createMenu( 4031, addId, -1 );
2651 createMenu( 4032, addId, -1 );
2652 createMenu( 4033, addId, -1 );
2654 createMenu( 4041, removeId, -1 );
2655 createMenu( 4042, removeId, -1 );
2657 createMenu( 4051, renumId, -1 );
2658 createMenu( 4052, renumId, -1 );
2660 createMenu( 4061, transfId, -1 );
2661 createMenu( 4062, transfId, -1 );
2662 createMenu( 4063, transfId, -1 );
2663 createMenu( 4064, transfId, -1 );
2664 createMenu( 4065, transfId, -1 );
2666 createMenu( 406, modifyId, -1 );
2667 createMenu( 407, modifyId, -1 );
2668 createMenu( 408, modifyId, -1 );
2669 createMenu( 409, modifyId, -1 );
2670 createMenu( 410, modifyId, -1 );
2671 createMenu( 411, modifyId, -1 );
2672 createMenu( 412, modifyId, -1 );
2673 createMenu( 413, modifyId, -1 );
2674 createMenu( 416, modifyId, -1 );
2675 createMenu( 414, modifyId, -1 );
2676 createMenu( 415, modifyId, -1 );
2678 createMenu( 10001, dispModeId, -1 );
2679 createMenu( 10002, dispModeId, -1 );
2680 createMenu( 10004, dispModeId, -1 );
2681 createMenu( 10003, dispModeId, -1 );
2683 createMenu( 1001, prefId, -1 );
2684 createMenu( separator(), prefId, -1 );
2685 createMenu( 1003, prefId, -1 );
2686 createMenu( separator(), prefId, -1 );
2687 createMenu( 1005, prefId, -1 );
2688 createMenu( separator(), prefId, -1 );
2689 createMenu( 1006, prefId, -1 );
2690 createMenu( separator(), prefId, -1 );
2692 createMenu( 10070, qualityId, -1 );
2693 createMenu( 10071, qualityId, -1 );
2695 createMenu( separator(), prefId, -1 );
2697 createMenu( 214, viewId, -1 );
2699 // ----- create toolbars --------------
2700 int meshTb = createTool( tr( "TB_MESH" ) ),
2701 hypoTb = createTool( tr( "TB_HYPO" ) ),
2702 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2703 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2704 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2705 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2707 createTool( 703, meshTb );
2708 createTool( 702, meshTb );
2709 createTool( 704, meshTb );
2710 createTool( separator(), meshTb );
2711 createTool( 701, meshTb );
2712 createTool( separator(), meshTb );
2713 createTool( 801, meshTb );
2714 createTool( 802, meshTb );
2715 createTool( 803, meshTb );
2716 createTool( separator(), meshTb );
2717 createTool( 900, meshTb );
2718 createTool( 902, meshTb );
2719 createTool( separator(), meshTb );
2721 createTool( 5000, hypoTb );
2722 createTool( 5010, hypoTb );
2724 createTool( 6001, ctrlTb );
2725 createTool( 6003, ctrlTb );
2726 createTool( 6004, ctrlTb );
2727 createTool( separator(), ctrlTb );
2728 createTool( 6002, ctrlTb );
2729 createTool( 6018, ctrlTb );
2730 createTool( 6019, ctrlTb );
2731 createTool( 6011, ctrlTb );
2732 createTool( 6012, ctrlTb );
2733 createTool( 6013, ctrlTb );
2734 createTool( 6014, ctrlTb );
2735 createTool( 6015, ctrlTb );
2736 createTool( 6016, ctrlTb );
2737 createTool( separator(), ctrlTb );
2738 createTool( 6017, ctrlTb );
2739 createTool( separator(), ctrlTb );
2741 createTool( 400, addRemTb );
2742 createTool( 401, addRemTb );
2743 createTool( 4021, addRemTb );
2744 createTool( 4022, addRemTb );
2745 createTool( 4023, addRemTb );
2746 createTool( 4031, addRemTb );
2747 createTool( 4032, addRemTb );
2748 createTool( 4033, addRemTb );
2749 createTool( separator(), addRemTb );
2750 createTool( 4041, addRemTb );
2751 createTool( 4042, addRemTb );
2752 createTool( separator(), addRemTb );
2753 createTool( 4051, addRemTb );
2754 createTool( 4052, addRemTb );
2755 createTool( separator(), addRemTb );
2756 createTool( 4061, addRemTb );
2757 createTool( 4062, addRemTb );
2758 createTool( 4063, addRemTb );
2759 createTool( 4064, addRemTb );
2760 createTool( 4065, addRemTb );
2761 createTool( separator(), addRemTb );
2763 createTool( 406, modifyTb );
2764 createTool( 407, modifyTb );
2765 createTool( 408, modifyTb );
2766 createTool( 409, modifyTb );
2767 createTool( 410, modifyTb );
2768 createTool( 411, modifyTb );
2769 createTool( 412, modifyTb );
2770 createTool( 413, modifyTb );
2771 createTool( 416, modifyTb );
2772 createTool( 414, modifyTb );
2773 createTool( 415, modifyTb );
2775 createTool( 214, dispModeTb );
2779 QString OB = "'ObjectBrowser'",
2780 View = "'" + SVTK_Viewer::Type() + "'",
2782 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2783 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2784 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2785 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2786 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2787 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2788 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2789 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2790 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2791 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2793 mesh_group = mesh + " " + subMesh + " " + group,
2794 hyp_alg = hypo + " " + algo;
2796 // popup for object browser
2798 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2799 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2800 createPopupItem( 803, OB, group ); // EDIT_GROUP
2801 popupMgr()->insert( separator(), -1, 0 );
2802 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2803 createPopupItem( 214, OB, mesh_group ); // UPDATE
2804 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2805 createPopupItem( 902, OB, mesh ); // STD_INFO
2806 popupMgr()->insert( separator(), -1, 0 );
2807 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2808 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2809 popupMgr()->insert( separator(), -1, 0 );
2810 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2811 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2812 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2813 popupMgr()->insert( separator(), -1, 0 );
2814 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2815 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2816 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2817 popupMgr()->insert( separator(), -1, 0 );
2820 createPopupItem( 803, View, group ); // EDIT_GROUP
2821 createPopupItem( 804, View, elems ); // ADD
2822 createPopupItem( 805, View, elems ); // REMOVE
2823 popupMgr()->insert( separator(), -1, 0 );
2824 createPopupItem( 214, View, mesh_group ); // UPDATE
2825 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2826 createPopupItem( 902, View, mesh ); // STD_INFO
2827 popupMgr()->insert( separator(), -1, 0 );
2831 isInvisible("not( isVisible )"),
2832 isEmpty("numberOfNodes = 0"),
2833 isNotEmpty("numberOfNodes <> 0"),
2835 // has nodes, edges, etc in VISIBLE! actor
2836 hasNodes("(numberOfNodes > 0 && isVisible)"),
2837 hasElems("count( elemTypes ) > 0"),
2838 hasDifferentElems("count( elemTypes ) > 1"),
2839 hasEdges("{'Edge'} in elemTypes"),
2840 hasFaces("{'Face'} in elemTypes"),
2841 hasVolumes("{'Volume'} in elemTypes");
2843 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2844 QString aClient = QString( "%1client in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( View );
2845 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2846 QString aMeshInVTK = aClient + "&&" + aType + "&&" + aSelCount;
2848 //-------------------------------------------------
2850 //-------------------------------------------------
2851 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2853 popupMgr()->insert( action( 9010 ), anId, -1 );
2854 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true );
2855 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2857 popupMgr()->insert( action( 9011 ), anId, -1 );
2858 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true );
2859 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2861 popupMgr()->insert( separator(), -1, -1 );
2863 //-------------------------------------------------
2865 //-------------------------------------------------
2866 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2868 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2869 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2870 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2872 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2873 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2874 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2876 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2877 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2878 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2880 popupMgr()->insert( separator(), anId, -1 );
2882 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2883 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2884 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2886 //-------------------------------------------------
2888 //-------------------------------------------------
2889 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2891 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2893 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2894 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true );
2895 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2897 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2898 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true );
2899 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2901 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2902 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true );
2903 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2905 popupMgr()->insert( separator(), anId, -1 );
2907 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2908 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true );
2910 //-------------------------------------------------
2912 //-------------------------------------------------
2913 popupMgr()->insert( action( 1132 ), -1, -1 );
2914 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2916 //-------------------------------------------------
2918 //-------------------------------------------------
2919 popupMgr()->insert( action( 1133 ), -1, -1 );
2920 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2922 //-------------------------------------------------
2924 //-------------------------------------------------
2925 popupMgr()->insert( action( 1134 ), -1, -1 );
2926 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2928 popupMgr()->insert( separator(), -1, -1 );
2930 //-------------------------------------------------
2932 //-------------------------------------------------
2934 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2935 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2936 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2938 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2940 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2941 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2943 popupMgr()->insert( separator(), anId, -1 );
2945 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2946 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2947 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2949 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2950 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2951 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2953 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2954 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2955 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2957 popupMgr()->insert( separator(), anId, -1 );
2959 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2960 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2961 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2963 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2964 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2965 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2967 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2968 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2969 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2971 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2972 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2973 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2975 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2976 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2977 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2979 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2980 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2981 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2983 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2984 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2985 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2987 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2988 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2989 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2991 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2992 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2993 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2995 popupMgr()->insert( separator(), anId, -1 );
2997 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2998 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2999 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3001 popupMgr()->insert( separator(), anId, -1 );
3003 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3004 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3006 popupMgr()->insert( separator(), -1, -1 );
3008 //-------------------------------------------------
3010 //-------------------------------------------------
3011 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3012 QString aRule = aClient + " and " + aType + " and " + aSelCount;
3013 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3014 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
3016 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3017 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
3019 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3020 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
3022 popupMgr()->insert( separator(), -1, -1 );
3024 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
3025 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
3028 bool SMESHGUI::activateModule( SUIT_Study* study )
3030 bool res = SalomeApp_Module::activateModule( study );
3032 setMenuShown( true );
3033 setToolShown( true );
3034 SetSettings( desktop() );
3039 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3041 setMenuShown( false );
3042 setToolShown( false );
3044 EmitSignalCloseAllDialogs();
3046 return SalomeApp_Module::deactivateModule( study );
3049 void SMESHGUI::OnGUIEvent()
3051 const QObject* obj = sender();
3052 if ( !obj || !obj->inherits( "QAction" ) )
3054 int id = actionId((QAction*)obj);
3059 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3061 return myComponentSMESH;
3064 QString SMESHGUI::engineIOR() const
3066 CORBA::ORB_var anORB = getApp()->orb();
3067 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3071 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3073 SMESHGUI_Selection sel;
3074 sel.init( client, selectionMgr() );
3075 popupMgr()->updatePopup( menu, &sel );
3078 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3080 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3081 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3084 void SMESHGUI::viewManagers( QStringList& list ) const
3086 list.append( SVTK_Viewer::Type() );
3089 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
3091 if( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
3092 SMESH::UpdateSelectionProp( this );