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_Tools.h"
96 #include "SalomeApp_Study.h"
97 #include "SalomeApp_NameDlg.h"
98 #include "SalomeApp_DataOwner.h"
99 #include "SalomeApp_Application.h"
100 #include "SalomeApp_Preferences.h"
101 #include "SalomeApp_VTKSelector.h"
103 #include "SalomeApp_ImportOperation.h"
105 #include <SVTK_ViewWindow.h>
106 #include <SVTK_ViewModel.h>
108 #include <VTKViewer_ViewManager.h>
110 #include "SMESHGUI_Utils.h"
111 #include "SMESHGUI_GEOMGenUtils.h"
112 #include "SMESHGUI_MeshUtils.h"
113 #include "SMESHGUI_GroupUtils.h"
114 #include "SMESHGUI_FilterUtils.h"
115 #include "SMESHGUI_PatternUtils.h"
116 #include "SMESHGUI_VTKUtils.h"
118 #include "SALOMEconfig.h"
119 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
122 #define INCLUDE_MENUITEM_DEF
123 #include <qapplication.h>
124 #include <qlineedit.h>
125 #include <qmenudata.h>
126 #include <qmenubar.h>
127 #include <qpopupmenu.h>
130 #include <qpainter.h>
131 #include <qcheckbox.h>
132 #include <qcolordialog.h>
133 #include <qspinbox.h>
138 #include <qradiobutton.h>
140 #include <boost/shared_ptr.hpp>
142 #include <vtkRenderer.h>
143 #include <vtkRenderWindow.h>
144 #include <vtkActorCollection.h>
145 #include <vtkScalarBarActor.h>
146 #include <vtkUnstructuredGrid.h>
148 #include "utilities.h"
150 #include "SALOMEDS_Study.hxx"
151 #include "SALOMEDSClient_StudyBuilder.hxx"
152 #include "SALOMEDSClient_SComponent.hxx"
158 //=============================================================
159 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
162 void ExportMeshToFile(int theCommandID);
164 void SetDisplayMode(int theCommandID);
166 void SetDisplayEntity(int theCommandID);
168 void Control( int theCommandID );
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 );
313 aFilename = fd->selectedFile();
314 aFormat = aFilterMap[fd->selectedFilter()];
316 if( !aFilename.isEmpty()
317 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
318 && aFormat==SMESH::MED_V2_1){
319 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
320 QObject::tr("SMESH_WRN_WARNING"),
321 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
322 QObject::tr("SMESH_BUT_YES"),
323 QObject::tr("SMESH_BUT_NO"),
332 if ( !aFilename.isEmpty() ) {
333 // Check whether the file already exists and delete it if yes
334 QFile aFile( aFilename );
335 if ( aFile.exists() )
337 SUIT_OverrideCursor wc;
338 switch ( theCommandID ) {
341 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
345 aMesh->ExportDAT( aFilename.latin1() );
349 aMesh->ExportUNV( aFilename.latin1() );
359 inline void InverseEntityMode(unsigned int& theOutputMode,
360 unsigned int theMode)
362 bool anIsNotPresent = ~theOutputMode & theMode;
364 theOutputMode |= theMode;
366 theOutputMode &= ~theMode;
369 void SetDisplayEntity(int theCommandID){
370 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
371 SALOME_ListIO selected;
373 aSel->selectedObjects( selected );
375 if(selected.Extent() >= 1){
376 SALOME_ListIteratorOfListIO It( selected );
377 for(; It.More(); It.Next()){
378 Handle(SALOME_InteractiveObject) IObject = It.Value();
379 if(IObject->hasEntry()){
380 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
381 unsigned int aMode = anActor->GetEntityMode();
382 switch(theCommandID){
384 InverseEntityMode(aMode,SMESH_Actor::eEdges);
387 InverseEntityMode(aMode,SMESH_Actor::eFaces);
390 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
393 aMode = SMESH_Actor::eAllEntity;
397 anActor->SetEntityMode(aMode);
404 void SetDisplayMode(int theCommandID){
405 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
406 SALOME_ListIO selected;
408 aSel->selectedObjects( selected );
410 if(selected.Extent() >= 1){
411 switch(theCommandID){
413 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
414 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
418 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
419 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
422 SALOME_ListIteratorOfListIO It( selected );
423 for(; It.More(); It.Next()){
424 Handle(SALOME_InteractiveObject) IObject = It.Value();
425 if(IObject->hasEntry()){
426 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
427 switch(theCommandID){
429 anActor->SetRepresentation(SMESH_Actor::eEdge);
432 anActor->SetRepresentation(SMESH_Actor::eSurface);
435 if(anActor->IsShrunk())
438 anActor->SetShrink();
441 anActor->SetRepresentation(SMESH_Actor::ePoint);
445 anActor->GetSufaceColor(color[0], color[1], color[2]);
446 int c0 = int (color[0] * 255);
447 int c1 = int (color[1] * 255);
448 int c2 = int (color[2] * 255);
449 QColor c(c0, c1, c2);
452 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
453 c0 = int (edgecolor[0] * 255);
454 c1 = int (edgecolor[1] * 255);
455 c2 = int (edgecolor[2] * 255);
456 QColor e(c0, c1, c2);
458 float backfacecolor[3];
459 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
460 c0 = int (backfacecolor[0] * 255);
461 c1 = int (backfacecolor[1] * 255);
462 c2 = int (backfacecolor[2] * 255);
463 QColor b(c0, c1, c2);
466 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
467 c0 = int (nodecolor[0] * 255);
468 c1 = int (nodecolor[1] * 255);
469 c2 = int (nodecolor[2] * 255);
470 QColor n(c0, c1, c2);
472 int Edgewidth = (int)anActor->GetLineWidth();
475 int intValue = int(anActor->GetNodeSize());
476 float Shrink = anActor->GetShrinkFactor();
478 SMESHGUI_Preferences_ColorDlg *aDlg =
479 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
480 aDlg->SetColor(1, c);
481 aDlg->SetColor(2, e);
482 aDlg->SetColor(3, n);
483 aDlg->SetColor(4, b);
484 aDlg->SetIntValue(1, Edgewidth);
485 aDlg->SetIntValue(2, intValue);
486 aDlg->SetIntValue(3, int(Shrink*100.));
488 QColor color = aDlg->GetColor(1);
489 QColor edgecolor = aDlg->GetColor(2);
490 QColor nodecolor = aDlg->GetColor(3);
491 QColor backfacecolor = aDlg->GetColor(4);
492 /* actor color and backface color */
493 anActor->SetSufaceColor(float (color.red()) / 255.,
494 float (color.green()) / 255.,
495 float (color.blue()) / 255.);
496 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
497 float (backfacecolor.green()) / 255.,
498 float (backfacecolor.blue()) / 255.);
501 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
502 float (edgecolor.green()) / 255.,
503 float (edgecolor.blue()) / 255.);
505 /* Shrink factor and size edges */
506 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
507 anActor->SetLineWidth(aDlg->GetIntValue(1));
509 /* Nodes color and size */
510 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
511 float (nodecolor.green()) / 255.,
512 float (nodecolor.blue()) / 255.);
513 anActor->SetNodeSize(aDlg->GetIntValue(2));
522 SMESH::RepaintCurrentView();
526 void Control( int theCommandID )
528 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
529 SALOME_ListIO selected;
531 aSel->selectedObjects( selected );
533 if( !selected.IsEmpty() ){
534 Handle(SALOME_InteractiveObject) anIO = selected.First();
537 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
538 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
539 switch ( theCommandID ){
541 aTitle = QObject::tr( "LENGTH_EDGES" );
542 aControl = SMESH_Actor::eLength;
545 aTitle = QObject::tr( "LENGTH2D_EDGES" );
546 aControl = SMESH_Actor::eLength2D;
549 aTitle = QObject::tr( "FREE_EDGES" );
550 aControl = SMESH_Actor::eFreeEdges;
553 aTitle = QObject::tr( "FREE_BORDERS" );
554 aControl = SMESH_Actor::eFreeBorders;
557 aTitle = QObject::tr( "MULTI_BORDERS" );
558 aControl = SMESH_Actor::eMultiConnection;
561 aTitle = QObject::tr( "MULTI2D_BORDERS" );
562 aControl = SMESH_Actor::eMultiConnection2D;
565 aTitle = QObject::tr( "AREA_ELEMENTS" );
566 aControl = SMESH_Actor::eArea;
569 aTitle = QObject::tr( "TAPER_ELEMENTS" );
570 aControl = SMESH_Actor::eTaper;
573 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
574 aControl = SMESH_Actor::eAspectRatio;
577 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
578 aControl = SMESH_Actor::eAspectRatio3D;
581 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
582 aControl = SMESH_Actor::eMinimumAngle;
585 aTitle = QObject::tr( "WARP_ELEMENTS" );
586 aControl = SMESH_Actor::eWarping;
589 aTitle = QObject::tr( "SKEW_ELEMENTS" );
590 aControl = SMESH_Actor::eSkew;
593 anActor->SetControlMode(aControl);
594 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
601 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
602 MeshObjectType theType,
603 const QString theInTypeName,
604 QString & theOutTypeName)
606 SMESH_TypeFilter aTypeFilter( theType );
608 if( !theIO.IsNull() )
610 entry = theIO->getEntry();
611 SalomeApp_DataOwner owner( entry );
612 if ( aTypeFilter.isOk( &owner )) {
613 theOutTypeName = theInTypeName;
621 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
623 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
624 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
626 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
627 CORBA::String_var anID = aSComp->GetID().c_str();
628 if (!strcmp(anID.in(),theIO->getEntry()))
634 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
635 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
636 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
637 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
638 CheckOIType ( theIO, GROUP, "Group", aTypeName )
646 QString CheckHomogeneousSelection()
648 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
649 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
650 SALOME_ListIO selected;
652 aSel->selectedObjects( selected );
654 QString RefType = CheckTypeObject(selected.First());
655 SALOME_ListIteratorOfListIO It(selected);
656 for (; It.More(); It.Next())
658 Handle(SALOME_InteractiveObject) IObject = It.Value();
659 QString Type = CheckTypeObject(IObject);
660 if (Type.compare(RefType) != 0)
661 return "Heterogeneous Selection";
669 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
670 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
671 SALOME_ListIO selected; aSel->selectedObjects( selected );
673 QString aParentComponent = QString::null;
674 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
676 QString cur = anIt.Value()->getComponentDataType();
677 if( aParentComponent.isNull() )
678 aParentComponent = cur;
679 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
680 aParentComponent = "";
683 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
684 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
685 QObject::tr("ERR_ERROR"),
686 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
687 QObject::tr("BUT_OK") );
690 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
691 if (SUIT_MessageBox::warn2
692 (SMESHGUI::desktop(),
693 QObject::tr("SMESH_WRN_WARNING"),
694 QObject::tr("SMESH_REALLY_DELETE"),
695 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
698 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
699 SUIT_ViewManager* vm = anApp->activeViewManager();
700 int nbSf = vm->getViewsCount();
702 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
703 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
704 _PTR(GenericAttribute) anAttr;
705 _PTR(AttributeIOR) anIOR;
707 SALOME_ListIteratorOfListIO It(selected);
709 aStudyBuilder->NewCommand(); // There is a transaction
710 for(; It.More(); It.Next()){
711 Handle(SALOME_InteractiveObject) IObject = It.Value();
712 if(IObject->hasEntry()){
713 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
715 /* Erase child graphical objects */
716 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
717 for(it->InitEx(true); it->More(); it->Next()){
718 _PTR(SObject) CSO = it->Value();
719 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
722 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
723 for(int i = 0; i < nbSf; i++){
724 SUIT_ViewWindow *sf = aViews[i];
725 CORBA::String_var anEntry = CSO->GetID().c_str();
726 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
727 SMESH::RemoveActor(sf,anActor);
733 /* Erase main graphical object */
734 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
735 for(int i = 0; i < nbSf; i++){
736 SUIT_ViewWindow *sf = aViews[i];
737 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
738 SMESH::RemoveActor(sf,anActor);
742 // Remove object(s) from data structures
743 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
745 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
746 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
747 QString objType = CheckTypeObject(IObject);
748 if ( !aGroup->_is_nil() ) { // DELETE GROUP
749 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
750 aMesh->RemoveGroup( aGroup );
752 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
753 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
754 aMesh->RemoveSubMesh( aSubMesh );
756 else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
757 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
758 aStudyBuilder->RemoveObjectWithChildren( obj );
760 else {// default action: remove SObject from the study
761 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
762 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
764 aStudyBuilder->RemoveObjectWithChildren( obj );
769 } /* IObject->hasEntry() */
771 aStudyBuilder->CommitCommand();
773 /* Clear any previous selection */
775 aSel->setSelectedObjects( l1 );
777 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
782 Standard_EXPORT CAM_Module* createModule()
784 return new SMESHGUI();
788 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
790 //=============================================================================
794 //=============================================================================
795 SMESHGUI::SMESHGUI() :
796 SalomeApp_Module( "SMESH" )
798 if ( CORBA::is_nil( myComponentSMESH ) )
800 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
801 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
802 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
805 myActiveDialogBox = 0 ;
808 SMESH::GetFilterManager();
811 /* load resources for all available meshers */
812 SMESH::InitAvailableHypotheses();
815 //=============================================================================
819 //=============================================================================
820 SMESHGUI::~SMESHGUI()
822 SMESH::GetFilterManager()->Destroy();
825 //=============================================================================
829 //=============================================================================
830 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
832 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
834 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
839 bool SMESHGUI::automaticUpdate()
841 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
845 return resMgr->booleanValue( "SMESH", "auto_update", false );
848 //=============================================================================
852 //=============================================================================
853 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
855 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
858 //=============================================================================
862 //=============================================================================
863 SMESHGUI* SMESHGUI::GetSMESHGUI()
865 SMESHGUI* smeshMod = 0;
866 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
869 CAM_Module* module = app->module( "Mesh" );
870 smeshMod = dynamic_cast<SMESHGUI*>( module );
873 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
875 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
878 _PTR(Study) aStudy = study->studyDS();
880 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
889 Standard_EXPORT SMESHGUI* GetComponentGUI()
891 return SMESHGUI::GetSMESHGUI();
895 //=============================================================================
899 //=============================================================================
900 void SMESHGUI::SetState(int aState)
905 //=============================================================================
909 //=============================================================================
910 void SMESHGUI::ResetState()
915 //=============================================================================
919 //=============================================================================
920 void SMESHGUI::EmitSignalDeactivateDialog()
922 emit SignalDeactivateActiveDialog();
925 //=============================================================================
929 //=============================================================================
930 void SMESHGUI::EmitSignalStudyFrameChanged()
932 emit SignalStudyFrameChanged();
935 //=============================================================================
939 //=============================================================================
940 void SMESHGUI::EmitSignalCloseAllDialogs()
942 emit SignalCloseAllDialogs();
945 //=============================================================================
949 //=============================================================================
950 QDialog *SMESHGUI::GetActiveDialogBox()
952 return myActiveDialogBox;
955 //=============================================================================
959 //=============================================================================
960 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
962 myActiveDialogBox = (QDialog *) aDlg;
966 //=============================================================================
970 //=============================================================================
971 SUIT_Desktop* SMESHGUI::desktop()
973 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
975 return app->desktop();
980 //=============================================================================
984 //=============================================================================
985 SalomeApp_Study* SMESHGUI::activeStudy()
987 SUIT_Application* app = SUIT_Session::session()->activeApplication();
989 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
994 //=============================================================================
998 //=============================================================================
999 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1001 /* Here the position is on the bottom right corner - 10 */
1002 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1004 SUIT_Desktop *PP = desktop();
1005 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1006 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1010 //=============================================================================
1014 //=============================================================================
1015 static int isStudyLocked(_PTR(Study) theStudy){
1016 return theStudy->GetProperties()->IsLocked();
1019 static bool checkLock(_PTR(Study) theStudy) {
1020 if (isStudyLocked(theStudy)) {
1021 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1022 QObject::tr("WRN_WARNING"),
1023 QObject::tr("WRN_STUDY_LOCKED"),
1024 QObject::tr("BUT_OK") );
1030 //=======================================================================
1031 //function : CheckActiveStudyLocked
1033 //=======================================================================
1035 bool SMESHGUI::isActiveStudyLocked()
1037 _PTR(Study) aStudy = activeStudy()->studyDS();
1038 return checkLock( aStudy );
1041 //=============================================================================
1045 //=============================================================================
1046 bool SMESHGUI::OnGUIEvent( int theCommandID )
1048 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1052 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1053 SUIT_ResourceMgr* mgr = resourceMgr();
1057 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1058 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1060 QAction* act = action( theCommandID );
1062 switch (theCommandID) {
1064 if(checkLock(aStudy)) break;
1072 if(checkLock(aStudy)) break;
1073 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1077 case 122: // EXPORT MED
1084 ::ExportMeshToFile(theCommandID);
1088 case 200: // SCALAR BAR
1090 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1091 SALOME_ListIO selected;
1093 aSel->selectedObjects( selected );
1095 if( selected.Extent() ) {
1096 Handle(SALOME_InteractiveObject) anIO = selected.First();
1097 if( anIO->hasEntry() ) {
1098 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1099 anActor->SetControlMode( SMESH_Actor::eNone );
1107 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1111 case 1134: // Clipping
1112 case 1133: // Tranparency
1113 case 1132: // Colors / Size
1120 ::SetDisplayMode(theCommandID);
1126 case 219: // Volumes
1127 case 220: // All Entity
1128 ::SetDisplayEntity(theCommandID);
1133 if(checkLock(aStudy)) break;
1134 SMESH::UpdateView();
1137 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1138 aSel->setSelectedObjects( l );
1143 case 301: // DISPLAY
1144 case 302: // DISPLAY ONLY
1146 SMESH::EDisplaing anAction;
1147 switch(theCommandID){
1148 case 300: anAction = SMESH::eErase; break;
1149 case 301: anAction = SMESH::eDisplay; break;
1150 case 302: anAction = SMESH::eDisplayOnly; break;
1153 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1154 SALOME_ListIO selected;
1156 aSel->selectedObjects( selected );
1159 SALOME_ListIteratorOfListIO It(selected);
1160 for (; It.More(); It.Next()) {
1161 Handle(SALOME_InteractiveObject) IOS = It.Value();
1162 if (IOS->hasEntry()) {
1163 SMESH::UpdateView(anAction,IOS->getEntry());
1168 aSel->setSelectedObjects( l1 );
1174 if(checkLock(aStudy)) break;
1177 EmitSignalDeactivateDialog();
1179 new SMESHGUI_NodesDlg(this);
1182 SUIT_MessageBox::warn1(desktop(),
1183 tr("SMESH_WRN_WARNING"),
1184 tr("SMESH_WRN_VIEWER_VTK"),
1185 tr("SMESH_BUT_OK"));
1190 case 2151: // FILTER
1194 EmitSignalDeactivateDialog();
1195 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1200 case 406: // MOVE NODE
1204 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1205 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1209 if(checkLock(aStudy)) break;
1210 new SMESHGUI_MoveNodesDlg(this);
1214 case 701: // COMPUTE MESH
1216 if(checkLock(aStudy)) break;
1218 SalomeApp_SelectionMgr *Sel = selectionMgr();
1219 SALOME_ListIO selected; Sel->selectedObjects( selected );
1221 int nbSel = selected.Extent();
1226 SMESH::SMESH_Mesh_var aMesh;
1227 SMESH::SMESH_subMesh_var aSubMesh;
1228 Handle(SALOME_InteractiveObject) IObject = selected.First();
1229 if (IObject->hasEntry()){
1230 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1231 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1232 if ( aShapeObject->_is_nil() ) {
1237 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1238 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1240 if (!aMesh->_is_nil()){
1241 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1242 if (!refShapeObject->_is_nil()) {
1243 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1244 SUIT_MessageBox::warn1(desktop(),
1245 tr("SMESH_WRN_WARNING"),
1246 tr("SMESH_WRN_MISSING_PARAMETERS"),
1247 tr("SMESH_BUT_OK"));
1251 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1252 SMESH::ModifiedMesh(aMeshSObj,true);
1253 // TO Do : change icon of all submeshes
1255 SUIT_MessageBox::warn1(desktop(),
1256 tr("SMESH_WRN_WARNING"),
1257 tr("SMESH_WRN_COMPUTE_FAILED"),
1258 tr("SMESH_BUT_OK"));
1260 catch(const SALOME::SALOME_Exception & S_ex){
1261 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1264 }else if(!aSubMesh->_is_nil()){
1265 aMesh = aSubMesh->GetFather();
1266 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1267 if(!refShapeObject->_is_nil()){
1268 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1270 SUIT_MessageBox::warn1(desktop(),
1271 tr("SMESH_WRN_WARNING"),
1272 tr("SMESH_WRN_MISSING_PARAMETERS"),
1273 tr("SMESH_BUT_OK"));
1277 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1278 SMESH::ModifiedMesh(aMeshSObj,true);
1279 // TO Do : change icon of all submeshes
1281 SUIT_MessageBox::warn1(desktop(),
1282 tr("SMESH_WRN_WARNING"),
1283 tr("SMESH_WRN_COMPUTE_FAILED"),
1284 tr("SMESH_BUT_OK"));
1285 }catch(const SALOME::SALOME_Exception & S_ex){
1286 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1292 CORBA::Long anId = aStudy->StudyId();
1293 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1294 if ( automaticUpdate() && aVisualObj){
1295 aVisualObj->Update();
1296 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1298 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1300 SMESH::DisplayActor(view,anActor); //apo
1306 SUIT_MessageBox::warn1(desktop(),
1307 tr("SMESH_WRN_WARNING"),
1308 tr("SMESH_WRN_VIEWER_VTK"),
1309 tr("SMESH_BUT_OK"));
1315 case 702: // ADD SUB MESH
1317 if(checkLock(aStudy)) break;
1319 EmitSignalDeactivateDialog();
1320 new SMESHGUI_AddSubMeshDlg( this );
1323 SUIT_MessageBox::warn1(desktop(),
1324 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1325 tr("SMESH_BUT_OK"));
1330 case 703: // INIT MESH
1332 if(checkLock(aStudy)) break;
1333 EmitSignalDeactivateDialog();
1334 new SMESHGUI_InitMeshDlg( this );
1338 case 704: // EDIT Hypothesis
1340 if(checkLock(aStudy)) break;
1341 EmitSignalDeactivateDialog();
1342 new SMESHGUI_EditHypothesesDlg( this );
1346 case 705: // EDIT Global Hypothesis
1348 if(checkLock(aStudy)) break;
1349 EmitSignalDeactivateDialog();
1350 new SMESHGUI_EditHypothesesDlg( this );
1354 case 706: // EDIT Local Hypothesis
1356 if(checkLock(aStudy)) break;
1357 EmitSignalDeactivateDialog();
1358 new SMESHGUI_EditHypothesesDlg( this );
1362 case 407: // DIAGONAL INVERSION
1363 case 408: // Delete diagonal
1367 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1368 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1372 if ( checkLock( aStudy ) )
1375 /*Standard_Boolean aRes;
1376 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1377 if ( aMesh->_is_nil() )
1379 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1380 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1384 EmitSignalDeactivateDialog();
1385 if ( theCommandID == 407 )
1386 new SMESHGUI_TrianglesInversionDlg(this);
1388 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1391 case 409: // Change orientation
1392 case 410: // Union of triangles
1393 case 411: // Cutting of quadrangles
1397 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1398 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1402 if ( checkLock( aStudy ) )
1405 EmitSignalDeactivateDialog();
1406 SMESHGUI_MultiEditDlg* aDlg = NULL;
1407 if ( theCommandID == 409 )
1408 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1409 else if ( theCommandID == 410 )
1410 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1412 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1415 DefineDlgPosition( aDlg, x, y );
1420 case 412: // Smoothing
1422 if(checkLock(aStudy)) break;
1424 EmitSignalDeactivateDialog();
1425 new SMESHGUI_SmoothingDlg( this );
1428 SUIT_MessageBox::warn1(desktop(),
1429 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1430 tr("SMESH_BUT_OK"));
1434 case 413: // Extrusion
1436 if (checkLock(aStudy)) break;
1438 EmitSignalDeactivateDialog();
1439 new SMESHGUI_ExtrusionDlg ( this );
1441 SUIT_MessageBox::warn1(desktop(),
1442 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1443 tr("SMESH_BUT_OK"));
1447 case 414: // Revolution
1449 if(checkLock(aStudy)) break;
1451 EmitSignalDeactivateDialog();
1452 new SMESHGUI_RevolutionDlg( this );
1455 SUIT_MessageBox::warn1(desktop(),
1456 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1457 tr("SMESH_BUT_OK"));
1461 case 415: // Pattern mapping
1463 if ( checkLock( aStudy ) )
1467 EmitSignalDeactivateDialog();
1468 new SMESHGUI_MeshPatternDlg( this );
1471 SUIT_MessageBox::warn1(desktop(),
1472 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1473 tr("SMESH_BUT_OK"));
1477 case 416: // Extrusion along a path
1479 if (checkLock(aStudy)) break;
1481 EmitSignalDeactivateDialog();
1482 new SMESHGUI_ExtrusionAlongPathDlg( this );
1484 SUIT_MessageBox::warn1(desktop(),
1485 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1486 tr("SMESH_BUT_OK"));
1490 case 801: // CREATE GROUP
1494 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1495 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1499 if(checkLock(aStudy)) break;
1500 EmitSignalDeactivateDialog();
1501 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1503 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1504 SALOME_ListIO selected;
1506 aSel->selectedObjects( selected );
1508 int nbSel = selected.Extent();
1510 // check if mesh is selected
1511 aMesh = SMESH::GetMeshByIO( selected.First() );
1513 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1518 case 802: // CONSTRUCT GROUP
1522 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1523 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1527 if(checkLock(aStudy)) break;
1528 EmitSignalDeactivateDialog();
1530 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1531 SALOME_ListIO selected;
1533 aSel->selectedObjects( selected );
1535 int nbSel = selected.Extent();
1537 // check if submesh is selected
1538 Handle(SALOME_InteractiveObject) IObject = selected.First();
1539 if (IObject->hasEntry()) {
1540 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1542 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1543 if (!aSubMesh->_is_nil()) {
1545 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1546 // get submesh elements list by types
1547 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1548 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1549 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1550 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1551 // create group for each type o elements
1552 QString aName = IObject->getName();
1553 if (aNodes->length() > 0) {
1554 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1555 aGroup->Add(aNodes.inout());
1557 if (aEdges->length() > 0) {
1558 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1559 aGroup->Add(aEdges.inout());
1561 if (aFaces->length() > 0) {
1562 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1563 aGroup->Add(aFaces.inout());
1565 if (aVolumes->length() > 0) {
1566 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1567 aGroup->Add(aVolumes.inout());
1571 }catch(const SALOME::SALOME_Exception & S_ex){
1572 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1581 case 803: // EDIT GROUP
1585 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1586 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1590 if(checkLock(aStudy)) break;
1591 EmitSignalDeactivateDialog();
1593 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1594 SALOME_ListIO selected;
1596 aSel->selectedObjects( selected );
1598 SALOME_ListIteratorOfListIO It (selected);
1599 int nbSelectedGroups = 0;
1600 for ( ; It.More(); It.Next() )
1602 SMESH::SMESH_Group_var aGroup =
1603 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1604 if (!aGroup->_is_nil()) {
1606 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1610 if (nbSelectedGroups == 0)
1612 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1618 case 804: // Add elements to group
1620 if(checkLock(aStudy)) break;
1621 if (myState == 800) {
1622 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1623 if (aDlg) aDlg->onAdd();
1628 case 805: // Remove elements from group
1630 if(checkLock(aStudy)) break;
1631 if (myState == 800) {
1632 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1633 if (aDlg) aDlg->onRemove();
1638 case 810: // Union Groups
1639 case 811: // Intersect groups
1640 case 812: // Cut groups
1644 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1645 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1649 if ( checkLock( aStudy ) )
1652 EmitSignalDeactivateDialog();
1655 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1656 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1657 else aMode = SMESHGUI_GroupOpDlg::CUT;
1659 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1663 case 813: // Delete groups with their contents
1667 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1668 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1672 if ( checkLock( aStudy ) )
1675 EmitSignalDeactivateDialog();
1677 new SMESHGUI_DeleteGroupDlg( this );
1681 case 900: // MESH INFOS
1683 EmitSignalDeactivateDialog();
1684 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1685 SALOME_ListIO selected;
1687 aSel->selectedObjects( selected );
1689 if ( selected.Extent() > 1 ) { // a dlg for each IO
1691 SALOME_ListIteratorOfListIO It (selected);
1692 for ( ; It.More(); It.Next() ) {
1693 IOs.Clear(); IOs.Append( It.Value() );
1694 aSel->setSelectedObjects( IOs );
1695 new SMESHGUI_MeshInfosDlg(this, "", false);
1697 // restore selection
1698 aSel->setSelectedObjects( selected );
1701 new SMESHGUI_MeshInfosDlg(this, "", false);
1705 case 902: // STANDARD MESH INFOS
1707 EmitSignalDeactivateDialog();
1708 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1709 SALOME_ListIO selected;
1711 aSel->selectedObjects( selected );
1713 if ( selected.Extent() > 1 ) { // a dlg for each IO
1715 SALOME_ListIteratorOfListIO It (selected);
1716 for ( ; It.More(); It.Next() ) {
1718 IOs.Append( It.Value() );
1719 aSel->setSelectedObjects( IOs );
1720 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1722 // restore selection
1723 aSel->setSelectedObjects( selected );
1726 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1730 case 1100: // EDIT HYPOTHESIS
1732 if(checkLock(aStudy)) break;
1734 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1735 SALOME_ListIO selected;
1737 aSel->selectedObjects( selected );
1739 int nbSel = selected.Extent();
1742 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1744 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1745 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1746 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1747 if ( !Hyp->_is_nil() )
1749 char* sName = Hyp->GetName();
1750 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1753 aCreator->EditHypothesis(Hyp);
1761 updateObjBrowser( true );
1765 case 1101: // RENAME
1767 if ( checkLock( aStudy ) )
1770 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1771 SALOME_ListIO selected;
1773 aSel->selectedObjects( selected );
1775 SALOME_ListIteratorOfListIO It( selected );
1776 for ( ; It.More(); It.Next() )
1778 Handle(SALOME_InteractiveObject) IObject = It.Value();
1779 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1780 _PTR(GenericAttribute) anAttr;
1781 _PTR(AttributeName) aName;
1784 if ( obj->FindAttribute(anAttr, "AttributeName") )
1787 QString newName = QString(aName->Value().c_str());
1788 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1789 if ( !newName.isEmpty() )
1791 //old source: aStudy->renameIObject( IObject, newName );
1792 aName->SetValue( newName.latin1() );
1794 // if current object is group update group's name
1795 SMESH::SMESH_GroupBase_var aGroup =
1796 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1797 if (!aGroup->_is_nil() )
1798 aGroup->SetName( newName.latin1() );
1808 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1810 if(checkLock(aStudy)) break;
1811 SUIT_OverrideCursor wc;
1813 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1814 SALOME_ListIO selected;
1816 aSel->selectedObjects( selected );
1818 SALOME_ListIteratorOfListIO It(selected);
1819 for (int i = 0; It.More(); It.Next(), i++) {
1820 Handle(SALOME_InteractiveObject) IObject = It.Value();
1821 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1824 aSel->setSelectedObjects( l1 );
1829 case 401: // GEOM::EDGE
1830 case 4021: // TRIANGLE
1832 case 4023: // POLYGON
1836 if(checkLock(aStudy)) break;
1838 EmitSignalDeactivateDialog();
1839 SMDSAbs_ElementType type = SMDSAbs_Edge;
1841 switch (theCommandID) {
1842 case 4021: // TRIANGLE
1843 type = SMDSAbs_Face; nbNodes = 3; break;
1845 type = SMDSAbs_Face; nbNodes = 4; break;
1847 type = SMDSAbs_Volume; nbNodes = 4; break;
1848 case 4023: // POLYGON
1849 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1851 type = SMDSAbs_Volume; nbNodes = 8; break;
1852 case 4033: // POLYHEDRE
1853 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1856 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1859 SUIT_MessageBox::warn1(desktop(),
1860 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1861 tr("SMESH_BUT_OK"));
1865 case 4033: // POLYHEDRON
1867 if(checkLock(aStudy)) break;
1869 EmitSignalDeactivateDialog();
1870 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1873 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1874 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1875 tr("SMESH_BUT_OK"));
1879 case 4041: // REMOVES NODES
1881 if(checkLock(aStudy)) break;
1883 EmitSignalDeactivateDialog();
1884 new SMESHGUI_RemoveNodesDlg(this);
1887 SUIT_MessageBox::warn1(desktop(),
1888 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1889 tr("SMESH_BUT_OK"));
1893 case 4042: // REMOVES ELEMENTS
1895 if(checkLock(aStudy)) break;
1897 EmitSignalDeactivateDialog();
1898 new SMESHGUI_RemoveElementsDlg(this);
1902 SUIT_MessageBox::warn1(desktop(),
1903 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1904 tr("SMESH_BUT_OK"));
1908 case 4051: // RENUMBERING NODES
1910 if(checkLock(aStudy)) break;
1912 EmitSignalDeactivateDialog();
1913 new SMESHGUI_RenumberingDlg( this, "", 0);
1917 SUIT_MessageBox::warn1(desktop(),
1918 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1919 tr("SMESH_BUT_OK"));
1923 case 4052: // RENUMBERING ELEMENTS
1925 if(checkLock(aStudy)) break;
1927 EmitSignalDeactivateDialog();
1928 new SMESHGUI_RenumberingDlg( this, "", 1);
1932 SUIT_MessageBox::warn1(desktop(),
1933 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1934 tr("SMESH_BUT_OK"));
1938 case 4061: // TRANSLATION
1940 if(checkLock(aStudy)) break;
1942 EmitSignalDeactivateDialog();
1943 new SMESHGUI_TranslationDlg( this );
1946 SUIT_MessageBox::warn1(desktop(),
1947 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1948 tr("SMESH_BUT_OK"));
1952 case 4062: // ROTATION
1954 if(checkLock(aStudy)) break;
1956 EmitSignalDeactivateDialog();
1957 new SMESHGUI_RotationDlg( this );
1960 SUIT_MessageBox::warn1(desktop(),
1961 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1962 tr("SMESH_BUT_OK"));
1966 case 4063: // SYMMETRY
1968 if(checkLock(aStudy)) break;
1970 EmitSignalDeactivateDialog();
1971 new SMESHGUI_SymmetryDlg( this );
1974 SUIT_MessageBox::warn1(desktop(),
1975 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1976 tr("SMESH_BUT_OK"));
1980 case 4064: // SEWING
1982 if(checkLock(aStudy)) break;
1984 EmitSignalDeactivateDialog();
1985 new SMESHGUI_SewingDlg( this );
1988 SUIT_MessageBox::warn1(desktop(),
1989 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1990 tr("SMESH_BUT_OK"));
1994 case 4065: // MERGE NODES
1996 if(checkLock(aStudy)) break;
1998 EmitSignalDeactivateDialog();
1999 new SMESHGUI_MergeNodesDlg( this );
2002 SUIT_MessageBox::warn1(desktop(),
2003 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2004 tr("SMESH_BUT_OK"));
2010 case 5000: // HYPOTHESIS
2012 if(checkLock(aStudy)) break;
2013 EmitSignalDeactivateDialog();
2014 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2019 if(checkLock(aStudy)) break;
2020 EmitSignalDeactivateDialog();
2021 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2025 case 5105: // Library of selection filters
2027 static QValueList<int> aTypes;
2028 if ( aTypes.isEmpty() )
2030 aTypes.append( SMESH::NODE );
2031 aTypes.append( SMESH::EDGE );
2032 aTypes.append( SMESH::FACE );
2033 aTypes.append( SMESH::VOLUME );
2035 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2039 case 6017: // CONTROLS
2054 SalomeApp_SelectionMgr* mgr = selectionMgr();
2055 SALOME_ListIO selected; mgr->selectedObjects( selected );
2057 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2058 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2060 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2061 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2062 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2063 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2064 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2065 ::Control( theCommandID );
2070 SUIT_MessageBox::warn1(desktop(),
2071 tr( "SMESH_WRN_WARNING" ),
2072 tr( "SMESH_BAD_SELECTION" ),
2073 tr( "SMESH_BUT_OK" ) );
2077 SUIT_MessageBox::warn1(desktop(),
2078 tr( "SMESH_WRN_WARNING" ),
2079 tr( "NOT_A_VTK_VIEWER" ),
2080 tr( "SMESH_BUT_OK" ) );
2085 SalomeApp_SelectionMgr* mgr = selectionMgr();
2086 SALOME_ListIO selected; mgr->selectedObjects( selected );
2088 if (selected.Extent() == 1) {
2089 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2090 if(anIObject->hasEntry())
2091 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2092 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2099 SalomeApp_SelectionMgr* mgr = selectionMgr();
2100 SALOME_ListIO selected; mgr->selectedObjects( selected );
2102 if (selected.Extent() == 1) {
2103 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2104 if(anIObject->hasEntry())
2105 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2106 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2112 //updateObjBrowser();
2116 //=============================================================================
2120 //=============================================================================
2121 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2126 //=============================================================================
2130 //=============================================================================
2131 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2136 //=============================================================================
2140 //=============================================================================
2141 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2146 //=============================================================================
2147 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2148 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2150 //=============================================================================
2151 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2152 SUIT_ViewWindow* wnd )
2154 if(theIO->hasEntry()){
2155 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2156 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2160 //=======================================================================
2161 // function : createSMESHAction
2163 //=======================================================================
2164 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2167 QWidget* parent = application()->desktop();
2168 SUIT_ResourceMgr* resMgr = resourceMgr();
2170 if ( icon_id.length() )
2171 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2173 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2174 if ( !pix.isNull() )
2175 icon = QIconSet( pix );
2177 QString tooltip = tr( QString( "TOP_" )+po_id ),
2178 menu = tr( QString( "MEN_" )+po_id ),
2179 status_bar = tr( QString( "STB_" )+po_id );
2181 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2184 //=======================================================================
2185 // function : createPopupItem
2187 //=======================================================================
2188 void SMESHGUI::createPopupItem( const int id,
2189 const QString& clients,
2190 const QString& types,
2191 const QString& theRule,
2196 parentId = popupMgr()->actionId( action( pId ) );
2198 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2199 popupMgr()->insert( action( id ), parentId, 0 );
2201 QChar lc = QtxPopupMgr::Selection::defEquality();
2202 QString rule = "(%1) and (%2) and (%3)";
2203 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2204 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2205 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2208 bool cont = myRules.contains( id );
2210 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2212 popupMgr()->setRule( action( id ), rule, true );
2213 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2216 //=======================================================================
2217 // function : initialize
2219 //=======================================================================
2220 void SMESHGUI::initialize( CAM_Application* app )
2222 SalomeApp_Module::initialize( app );
2224 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2226 /* Automatic Update flag */
2227 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2229 // ----- create actions --------------
2231 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2232 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2233 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2234 createSMESHAction( 114, "NUM" );
2235 createSMESHAction( 121, "DAT" );
2236 createSMESHAction( 122, "MED" );
2237 createSMESHAction( 123, "UNV" );
2238 createSMESHAction( 124, "EXPORT_DAT" );
2239 createSMESHAction( 125, "EXPORT_MED" );
2240 createSMESHAction( 126, "EXPORT_UNV" );
2241 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2242 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2243 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2244 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2245 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2246 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2247 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2248 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2249 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2250 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2251 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2252 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2253 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2254 createSMESHAction( 804, "ADD" );
2255 createSMESHAction( 805, "REMOVE" );
2256 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2257 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2258 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2259 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2260 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2261 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2262 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2263 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2264 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2265 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2266 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2267 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2268 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2269 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2270 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2271 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2272 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2273 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2274 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2275 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2276 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2277 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2278 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2279 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2280 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2281 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2282 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2283 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2284 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2285 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2286 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2287 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2288 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2289 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2290 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2291 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2292 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2293 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2294 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2295 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2296 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2297 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2298 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2299 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2300 createSMESHAction( 415, "MAP", "ICON_MAP" );
2301 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2302 createSMESHAction( 200, "RESET" );
2303 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2304 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2305 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2306 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2307 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2308 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2309 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2310 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2311 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2312 createSMESHAction( 220, "ALL" );
2313 createSMESHAction( 1100, "EDIT_HYPO" );
2314 createSMESHAction( 1101, "RENAME" );
2315 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2316 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2317 createSMESHAction( 1131, "DISPMODE" );
2318 createSMESHAction( 1132, "COLORS" );
2319 createSMESHAction( 1133, "TRANSP" );
2320 createSMESHAction( 1134, "CLIP" );
2321 createSMESHAction( 1135, "DISP_ENT" );
2322 createSMESHAction( 2000, "CTRL" );
2324 createSMESHAction( 300, "ERASE" );
2325 createSMESHAction( 301, "DISPLAY" );
2326 createSMESHAction( 302, "DISPLAY_ONLY" );
2327 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2329 // ----- create menu --------------
2330 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2331 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2332 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ),
2333 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2334 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2335 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2336 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2337 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2339 createMenu( separator(), fileId );
2341 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2342 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2343 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2344 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2345 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2346 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2348 createMenu( 111, importId, -1 );
2349 createMenu( 112, importId, -1 );
2350 createMenu( 113, importId, -1 );
2352 createMenu( 121, exportId, -1 );
2353 createMenu( 122, exportId, -1 );
2354 createMenu( 123, exportId, -1 );
2356 createMenu( separator(), fileId, 10 );
2358 createMenu( 33, editId, -1 );
2360 createMenu( 5105, toolsId, -1 );
2362 createMenu( 5000, hypoId, -1 );
2363 createMenu( 5010, hypoId, -1 );
2365 createMenu( 703, meshId, -1 );
2366 createMenu( 702, meshId, -1 );
2367 createMenu( 704, meshId, -1 );
2368 createMenu( separator(), meshId, -1 );
2369 createMenu( 701, meshId, -1 );
2370 createMenu( separator(), meshId, -1 );
2371 createMenu( 801, meshId, -1 );
2372 createMenu( 802, meshId, -1 );
2373 createMenu( 803, meshId, -1 );
2374 createMenu( separator(), meshId, -1 );
2375 createMenu( 810, meshId, -1 );
2376 createMenu( 811, meshId, -1 );
2377 createMenu( 812, meshId, -1 );
2378 createMenu( separator(), meshId, -1 );
2379 createMenu( 813, meshId, -1 );
2380 createMenu( separator(), meshId, -1 );
2381 createMenu( 900, meshId, -1 );
2382 createMenu( 902, meshId, -1 );
2383 createMenu( separator(), meshId, -1 );
2385 createMenu( 6003, ctrlId, -1 );
2386 createMenu( 6001, ctrlId, -1 );
2387 createMenu( 6004, ctrlId, -1 );
2388 createMenu( separator(), ctrlId, -1 );
2389 createMenu( 6002, ctrlId, -1 );
2390 createMenu( 6018, ctrlId, -1 );
2391 createMenu( 6019, ctrlId, -1 );
2392 createMenu( 6011, ctrlId, -1 );
2393 createMenu( 6012, ctrlId, -1 );
2394 createMenu( 6013, ctrlId, -1 );
2395 createMenu( 6014, ctrlId, -1 );
2396 createMenu( 6015, ctrlId, -1 );
2397 createMenu( 6016, ctrlId, -1 );
2398 createMenu( separator(), ctrlId, -1 );
2399 createMenu( 6017, ctrlId, -1 );
2400 createMenu( separator(), ctrlId, -1 );
2402 createMenu( 400, addId, -1 );
2403 createMenu( 401, addId, -1 );
2404 createMenu( 4021, addId, -1 );
2405 createMenu( 4022, addId, -1 );
2406 createMenu( 4023, addId, -1 );
2407 createMenu( 4031, addId, -1 );
2408 createMenu( 4032, addId, -1 );
2409 createMenu( 4033, addId, -1 );
2411 createMenu( 4041, removeId, -1 );
2412 createMenu( 4042, removeId, -1 );
2414 createMenu( 4051, renumId, -1 );
2415 createMenu( 4052, renumId, -1 );
2417 createMenu( 4061, transfId, -1 );
2418 createMenu( 4062, transfId, -1 );
2419 createMenu( 4063, transfId, -1 );
2420 createMenu( 4064, transfId, -1 );
2421 createMenu( 4065, transfId, -1 );
2423 createMenu( 406, modifyId, -1 );
2424 createMenu( 407, modifyId, -1 );
2425 createMenu( 408, modifyId, -1 );
2426 createMenu( 409, modifyId, -1 );
2427 createMenu( 410, modifyId, -1 );
2428 createMenu( 411, modifyId, -1 );
2429 createMenu( 412, modifyId, -1 );
2430 createMenu( 413, modifyId, -1 );
2431 createMenu( 416, modifyId, -1 );
2432 createMenu( 414, modifyId, -1 );
2433 createMenu( 415, modifyId, -1 );
2435 createMenu( 214, viewId, -1 );
2437 // ----- create toolbars --------------
2438 int meshTb = createTool( tr( "TB_MESH" ) ),
2439 hypoTb = createTool( tr( "TB_HYPO" ) ),
2440 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2441 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2442 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2443 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2445 createTool( 703, meshTb );
2446 createTool( 702, meshTb );
2447 createTool( 704, meshTb );
2448 createTool( separator(), meshTb );
2449 createTool( 701, meshTb );
2450 createTool( separator(), meshTb );
2451 createTool( 801, meshTb );
2452 createTool( 802, meshTb );
2453 createTool( 803, meshTb );
2454 createTool( separator(), meshTb );
2455 createTool( 900, meshTb );
2456 createTool( 902, meshTb );
2457 createTool( separator(), meshTb );
2459 createTool( 5000, hypoTb );
2460 createTool( 5010, hypoTb );
2462 createTool( 6001, ctrlTb );
2463 createTool( 6003, ctrlTb );
2464 createTool( 6004, ctrlTb );
2465 createTool( separator(), ctrlTb );
2466 createTool( 6002, ctrlTb );
2467 createTool( 6018, ctrlTb );
2468 createTool( 6019, ctrlTb );
2469 createTool( 6011, ctrlTb );
2470 createTool( 6012, ctrlTb );
2471 createTool( 6013, ctrlTb );
2472 createTool( 6014, ctrlTb );
2473 createTool( 6015, ctrlTb );
2474 createTool( 6016, ctrlTb );
2475 createTool( separator(), ctrlTb );
2476 createTool( 6017, ctrlTb );
2477 createTool( separator(), ctrlTb );
2479 createTool( 400, addRemTb );
2480 createTool( 401, addRemTb );
2481 createTool( 4021, addRemTb );
2482 createTool( 4022, addRemTb );
2483 createTool( 4023, addRemTb );
2484 createTool( 4031, addRemTb );
2485 createTool( 4032, addRemTb );
2486 createTool( 4033, addRemTb );
2487 createTool( separator(), addRemTb );
2488 createTool( 4041, addRemTb );
2489 createTool( 4042, addRemTb );
2490 createTool( separator(), addRemTb );
2491 createTool( 4051, addRemTb );
2492 createTool( 4052, addRemTb );
2493 createTool( separator(), addRemTb );
2494 createTool( 4061, addRemTb );
2495 createTool( 4062, addRemTb );
2496 createTool( 4063, addRemTb );
2497 createTool( 4064, addRemTb );
2498 createTool( 4065, addRemTb );
2499 createTool( separator(), addRemTb );
2501 createTool( 406, modifyTb );
2502 createTool( 407, modifyTb );
2503 createTool( 408, modifyTb );
2504 createTool( 409, modifyTb );
2505 createTool( 410, modifyTb );
2506 createTool( 411, modifyTb );
2507 createTool( 412, modifyTb );
2508 createTool( 413, modifyTb );
2509 createTool( 416, modifyTb );
2510 createTool( 414, modifyTb );
2511 createTool( 415, modifyTb );
2513 createTool( 214, dispModeTb );
2517 QString OB = "'ObjectBrowser'",
2518 View = "'" + SVTK_Viewer::Type() + "'",
2520 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2521 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2522 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2523 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2524 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2525 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2526 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2527 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2528 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2529 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2531 mesh_group = mesh + " " + subMesh + " " + group,
2532 hyp_alg = hypo + " " + algo;
2534 // popup for object browser
2536 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2537 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2538 createPopupItem( 803, OB, group ); // EDIT_GROUP
2539 popupMgr()->insert( separator(), -1, 0 );
2540 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2541 createPopupItem( 214, OB, mesh_group ); // UPDATE
2542 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2543 createPopupItem( 902, OB, mesh ); // STD_INFO
2544 popupMgr()->insert( separator(), -1, 0 );
2545 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2546 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2547 popupMgr()->insert( separator(), -1, 0 );
2548 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2549 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2550 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2551 popupMgr()->insert( separator(), -1, 0 );
2552 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2553 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2554 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2555 popupMgr()->insert( separator(), -1, 0 );
2558 createPopupItem( 803, View, group ); // EDIT_GROUP
2559 createPopupItem( 804, View, elems ); // ADD
2560 createPopupItem( 805, View, elems ); // REMOVE
2561 popupMgr()->insert( separator(), -1, 0 );
2562 createPopupItem( 214, View, mesh_group ); // UPDATE
2563 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2564 createPopupItem( 902, View, mesh ); // STD_INFO
2565 popupMgr()->insert( separator(), -1, 0 );
2569 isInvisible("not( isVisible )"),
2570 isEmpty("numberOfNodes = 0"),
2571 isNotEmpty("numberOfNodes <> 0"),
2573 // has nodes, edges, etc in VISIBLE! actor
2574 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2575 hasElems("(count( elemTypes ) > 0)"),
2576 hasDifferentElems("(count( elemTypes ) > 1)"),
2577 hasEdges("({'Edge'} in elemTypes)"),
2578 hasFaces("({'Face'} in elemTypes)"),
2579 hasVolumes("({'Volume'} in elemTypes)");
2581 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2582 QString lc = QtxPopupMgr::Selection::defEquality();
2583 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2584 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2585 QString aMeshInVTK = aClient + "&&" + aType;// + "&&" + aSelCount;
2587 //-------------------------------------------------
2589 //-------------------------------------------------
2590 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2592 popupMgr()->insert( action( 9010 ), anId, -1 );
2593 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );//@
2594 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2596 popupMgr()->insert( action( 9011 ), anId, -1 );
2597 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2598 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2600 popupMgr()->insert( separator(), -1, -1 );
2602 //-------------------------------------------------
2604 //-------------------------------------------------
2605 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2607 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2608 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2609 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2611 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2612 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2613 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2615 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2616 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2617 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2619 popupMgr()->insert( separator(), anId, -1 );
2621 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2622 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2623 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2625 //-------------------------------------------------
2627 //-------------------------------------------------
2628 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2630 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2632 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2633 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2634 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2636 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2637 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2638 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2640 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2641 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2642 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2644 popupMgr()->insert( separator(), anId, -1 );
2646 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2647 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2649 //-------------------------------------------------
2651 //-------------------------------------------------
2652 popupMgr()->insert( action( 1132 ), -1, -1 );
2653 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2655 //-------------------------------------------------
2657 //-------------------------------------------------
2658 popupMgr()->insert( action( 1133 ), -1, -1 );
2659 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2661 //-------------------------------------------------
2663 //-------------------------------------------------
2664 popupMgr()->insert( action( 1134 ), -1, -1 );
2665 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2667 popupMgr()->insert( separator(), -1, -1 );
2669 //-------------------------------------------------
2671 //-------------------------------------------------
2673 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2674 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2675 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2677 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2679 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2680 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2682 popupMgr()->insert( separator(), anId, -1 );
2684 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2685 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2686 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2688 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2689 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2690 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2692 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2693 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2694 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2696 popupMgr()->insert( separator(), anId, -1 );
2698 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2699 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2700 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2702 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2703 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2704 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2706 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2707 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2708 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2710 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2711 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2712 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2714 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2715 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2716 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2718 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2719 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2720 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2722 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2723 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2724 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2726 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2727 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2728 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2730 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2731 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2732 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2734 popupMgr()->insert( separator(), anId, -1 );
2736 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2737 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2738 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2740 popupMgr()->insert( separator(), anId, -1 );
2742 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2743 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2745 popupMgr()->insert( separator(), -1, -1 );
2747 //-------------------------------------------------
2749 //-------------------------------------------------
2750 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2751 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
2752 QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
2753 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2754 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
2756 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2757 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
2759 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2760 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
2762 popupMgr()->insert( separator(), -1, -1 );
2764 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
2765 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
2768 bool SMESHGUI::activateModule( SUIT_Study* study )
2770 bool res = SalomeApp_Module::activateModule( study );
2772 setMenuShown( true );
2773 setToolShown( true );
2778 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2780 setMenuShown( false );
2781 setToolShown( false );
2783 EmitSignalCloseAllDialogs();
2785 return SalomeApp_Module::deactivateModule( study );
2788 void SMESHGUI::OnGUIEvent()
2790 const QObject* obj = sender();
2791 if ( !obj || !obj->inherits( "QAction" ) )
2793 int id = actionId((QAction*)obj);
2798 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2800 if ( CORBA::is_nil( myComponentSMESH ) )
2802 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2803 return aGUI.myComponentSMESH;
2805 return myComponentSMESH;
2808 QString SMESHGUI::engineIOR() const
2810 CORBA::ORB_var anORB = getApp()->orb();
2811 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2815 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2817 SMESHGUI_Selection sel;
2818 sel.init( client, selectionMgr() );
2819 popupMgr()->updatePopup( menu, &sel );
2822 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2824 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2825 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2828 void SMESHGUI::viewManagers( QStringList& list ) const
2830 list.append( SVTK_Viewer::Type() );
2833 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
2835 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
2836 SMESH::UpdateSelectionProp( this );
2839 void SMESHGUI::createPreferences()
2841 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2843 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2844 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "display_entity" );
2845 addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "auto_update" );
2847 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2848 setPreferenceProperty( precGroup, "columns", 1 );
2850 addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool );
2851 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2853 setPreferenceProperty( prec, "min", 0 );
2854 setPreferenceProperty( prec, "max", 16 );
2856 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2857 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, SalomeApp_Preferences::Selector, "SMESH", "display_mode" );
2859 modes.append( "Wireframe" );
2860 modes.append( "Shading" );
2861 modes.append( "Shrink" );
2862 modes.append( "Nodes" );
2863 setPreferenceProperty( dispmode, "strings", modes );
2865 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2866 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2868 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
2869 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
2871 setPreferenceProperty( nodeSz, "min", 1 );
2872 setPreferenceProperty( nodeSz, "max", 5 );
2874 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2876 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
2877 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
2878 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
2879 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
2881 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
2882 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2884 setPreferenceProperty( elemW, "min", 1 );
2885 setPreferenceProperty( elemW, "max", 5 );
2887 setPreferenceProperty( shrink, "min", 0 );
2888 setPreferenceProperty( shrink, "max", 100 );
2890 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2892 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2894 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
2895 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
2896 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
2898 setPreferenceProperty( selW, "min", 1 );
2899 setPreferenceProperty( selW, "max", 5 );
2901 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2903 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
2904 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2906 setPreferenceProperty( preW, "min", 1 );
2907 setPreferenceProperty( preW, "max", 5 );
2909 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2911 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
2912 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
2914 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2915 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2917 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2918 addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2919 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2920 addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
2923 fam.append( tr( "SMESH_FONT_ARIAL" ) );
2924 fam.append( tr( "SMESH_FONT_COURIER" ) );
2925 fam.append( tr( "SMESH_FONT_TIMES" ) );
2926 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2928 setPreferenceProperty( tfont, "families", fam );
2929 setPreferenceProperty( tfont, "system", false );
2930 setPreferenceProperty( tfont, "widget_flags", wflag );
2931 setPreferenceProperty( lfont, "families", fam );
2932 setPreferenceProperty( lfont, "system", false );
2933 setPreferenceProperty( lfont, "widget_flags", wflag );
2935 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
2937 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
2938 setPreferenceProperty( numcol, "min", 2 );
2939 setPreferenceProperty( numcol, "max", 256 );
2941 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
2942 setPreferenceProperty( numlab, "min", 2 );
2943 setPreferenceProperty( numlab, "max", 65 );
2945 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
2946 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2947 QStringList orients;
2948 orients.append( tr( "SMESH_VERTICAL" ) );
2949 orients.append( tr( "SMESH_HORIZONTAL" ) );
2950 QValueList<QVariant> indices; indices.append( 0 ); indices.append( 1 );
2951 setPreferenceProperty( orient, "strings", orients );
2952 setPreferenceProperty( orient, "indexes", indices );
2954 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
2955 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2956 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2957 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2958 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
2959 setPreferenceProperty( xv, "step", 0.1 );
2960 setPreferenceProperty( xv, "min", 0.0 );
2961 setPreferenceProperty( xv, "max", 1.0 );
2962 setPreferenceProperty( yv, "step", 0.1 );
2963 setPreferenceProperty( yv, "min", 0.0 );
2964 setPreferenceProperty( yv, "max", 1.0 );
2965 setPreferenceProperty( wv, "step", 0.1 );
2966 setPreferenceProperty( wv, "min", 0.0 );
2967 setPreferenceProperty( wv, "max", 1.0 );
2968 setPreferenceProperty( hv, "min", 0.0 );
2969 setPreferenceProperty( hv, "max", 1.0 );
2970 setPreferenceProperty( hv, "step", 0.1 );
2972 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
2973 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
2974 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
2975 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
2976 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
2977 setPreferenceProperty( xv, "min", 0.0 );
2978 setPreferenceProperty( xv, "max", 1.0 );
2979 setPreferenceProperty( xv, "step", 0.1 );
2980 setPreferenceProperty( xh, "min", 0.0 );
2981 setPreferenceProperty( xh, "max", 1.0 );
2982 setPreferenceProperty( xh, "step", 0.1 );
2983 setPreferenceProperty( yh, "min", 0.0 );
2984 setPreferenceProperty( yh, "max", 1.0 );
2985 setPreferenceProperty( yh, "step", 0.1 );
2986 setPreferenceProperty( wh, "min", 0.0 );
2987 setPreferenceProperty( wh, "max", 1.0 );
2988 setPreferenceProperty( wh, "step", 0.1 );
2989 setPreferenceProperty( hh, "min", 0.0 );
2990 setPreferenceProperty( hh, "max", 1.0 );
2991 setPreferenceProperty( hh, "step", 0.1 );
2994 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )