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();
195 theComponentMesh->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
198 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
199 switch ( theCommandID ) {
202 aMeshes->length( 1 );
203 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
208 SMESH::DriverMED_ReadStatus res;
209 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
210 if ( res != SMESH::DRS_OK ) {
212 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
213 QObject::tr("SMESH_WRN_WARNING"),
214 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
215 QObject::tr("SMESH_BUT_OK"));
216 aMeshes->length( 0 );
223 bool isEmpty = false;
224 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
225 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
227 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
228 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
229 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
230 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
231 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
238 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
239 QObject::tr("SMESH_WRN_WARNING"),
240 QObject::tr("SMESH_DRS_EMPTY"),
241 QObject::tr("SMESH_BUT_OK"));
245 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
247 catch (const SALOME::SALOME_Exception& S_ex){
249 SalomeApp_Tools::QtCatchCorbaException(S_ex);
256 void ExportMeshToFile( int theCommandID )
258 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
259 SALOME_ListIO selected;
261 aSel->selectedObjects( selected );
263 if(selected.Extent()){
264 Handle(SALOME_InteractiveObject) anIObject = selected.First();
265 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
266 if ( !aMesh->_is_nil() ) {
267 QString aFilter, aTitle = QObject::tr("Export mesh");
268 QMap<QString, SMESH::MED_VERSION> aFilterMap;
269 switch ( theCommandID ) {
272 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
273 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
277 aFilter = QObject::tr("DAT files (*.dat)");
281 if(aMesh->NbPyramids()){
282 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
283 QObject::tr("SMESH_WRN_WARNING"),
284 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
285 QObject::tr("SMESH_BUT_YES"),
286 QObject::tr("SMESH_BUT_NO"),
291 aFilter = QObject::tr("IDEAS files (*.unv)");
298 SMESH::MED_VERSION aFormat;
300 if ( theCommandID != 122 && theCommandID != 125 )
301 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
305 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
306 filters.push_back( it.key() );
308 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
309 fd->setCaption( aTitle );
310 fd->setFilters( filters );
314 aFilename = fd->selectedFile();
315 aFormat = aFilterMap[fd->selectedFilter()];
317 if( !aFilename.isEmpty()
318 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
319 && aFormat==SMESH::MED_V2_1){
320 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
321 QObject::tr("SMESH_WRN_WARNING"),
322 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
323 QObject::tr("SMESH_BUT_YES"),
324 QObject::tr("SMESH_BUT_NO"),
333 if ( !aFilename.isEmpty() ) {
334 // Check whether the file already exists and delete it if yes
335 QFile aFile( aFilename );
336 if ( aFile.exists() )
338 SUIT_OverrideCursor wc;
339 switch ( theCommandID ) {
342 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
346 aMesh->ExportDAT( aFilename.latin1() );
350 aMesh->ExportUNV( aFilename.latin1() );
360 inline void InverseEntityMode(unsigned int& theOutputMode,
361 unsigned int theMode)
363 bool anIsNotPresent = ~theOutputMode & theMode;
365 theOutputMode |= theMode;
367 theOutputMode &= ~theMode;
370 void SetDisplayEntity(int theCommandID){
371 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
372 SALOME_ListIO selected;
374 aSel->selectedObjects( selected );
376 if(selected.Extent() >= 1){
377 SALOME_ListIteratorOfListIO It( selected );
378 for(; It.More(); It.Next()){
379 Handle(SALOME_InteractiveObject) IObject = It.Value();
380 if(IObject->hasEntry()){
381 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
382 unsigned int aMode = anActor->GetEntityMode();
383 switch(theCommandID){
385 InverseEntityMode(aMode,SMESH_Actor::eEdges);
388 InverseEntityMode(aMode,SMESH_Actor::eFaces);
391 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
394 aMode = SMESH_Actor::eAllEntity;
398 anActor->SetEntityMode(aMode);
405 void SetDisplayMode(int theCommandID){
406 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
407 SALOME_ListIO selected;
409 aSel->selectedObjects( selected );
411 if(selected.Extent() >= 1){
412 switch(theCommandID){
414 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
415 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
419 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
420 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
423 SALOME_ListIteratorOfListIO It( selected );
424 for(; It.More(); It.Next()){
425 Handle(SALOME_InteractiveObject) IObject = It.Value();
426 if(IObject->hasEntry()){
427 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
428 switch(theCommandID){
430 anActor->SetRepresentation(SMESH_Actor::eEdge);
433 anActor->SetRepresentation(SMESH_Actor::eSurface);
436 if(anActor->IsShrunk())
439 anActor->SetShrink();
442 anActor->SetRepresentation(SMESH_Actor::ePoint);
446 anActor->GetSufaceColor(color[0], color[1], color[2]);
447 int c0 = int (color[0] * 255);
448 int c1 = int (color[1] * 255);
449 int c2 = int (color[2] * 255);
450 QColor c(c0, c1, c2);
453 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
454 c0 = int (edgecolor[0] * 255);
455 c1 = int (edgecolor[1] * 255);
456 c2 = int (edgecolor[2] * 255);
457 QColor e(c0, c1, c2);
459 float backfacecolor[3];
460 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
461 c0 = int (backfacecolor[0] * 255);
462 c1 = int (backfacecolor[1] * 255);
463 c2 = int (backfacecolor[2] * 255);
464 QColor b(c0, c1, c2);
467 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
468 c0 = int (nodecolor[0] * 255);
469 c1 = int (nodecolor[1] * 255);
470 c2 = int (nodecolor[2] * 255);
471 QColor n(c0, c1, c2);
473 int Edgewidth = (int)anActor->GetLineWidth();
476 int intValue = int(anActor->GetNodeSize());
477 float Shrink = anActor->GetShrinkFactor();
479 SMESHGUI_Preferences_ColorDlg *aDlg =
480 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
481 aDlg->SetColor(1, c);
482 aDlg->SetColor(2, e);
483 aDlg->SetColor(3, n);
484 aDlg->SetColor(4, b);
485 aDlg->SetIntValue(1, Edgewidth);
486 aDlg->SetIntValue(2, intValue);
487 aDlg->SetIntValue(3, int(Shrink*100.));
489 QColor color = aDlg->GetColor(1);
490 QColor edgecolor = aDlg->GetColor(2);
491 QColor nodecolor = aDlg->GetColor(3);
492 QColor backfacecolor = aDlg->GetColor(4);
493 /* actor color and backface color */
494 anActor->SetSufaceColor(float (color.red()) / 255.,
495 float (color.green()) / 255.,
496 float (color.blue()) / 255.);
497 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
498 float (backfacecolor.green()) / 255.,
499 float (backfacecolor.blue()) / 255.);
502 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
503 float (edgecolor.green()) / 255.,
504 float (edgecolor.blue()) / 255.);
506 /* Shrink factor and size edges */
507 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
508 anActor->SetLineWidth(aDlg->GetIntValue(1));
510 /* Nodes color and size */
511 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
512 float (nodecolor.green()) / 255.,
513 float (nodecolor.blue()) / 255.);
514 anActor->SetNodeSize(aDlg->GetIntValue(2));
523 SMESH::RepaintCurrentView();
527 void Control( int theCommandID )
529 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
530 SALOME_ListIO selected;
532 aSel->selectedObjects( selected );
534 if( !selected.IsEmpty() ){
535 Handle(SALOME_InteractiveObject) anIO = selected.First();
538 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
539 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
540 switch ( theCommandID ){
542 aTitle = QObject::tr( "LENGTH_EDGES" );
543 aControl = SMESH_Actor::eLength;
546 aTitle = QObject::tr( "LENGTH2D_EDGES" );
547 aControl = SMESH_Actor::eLength2D;
550 aTitle = QObject::tr( "FREE_EDGES" );
551 aControl = SMESH_Actor::eFreeEdges;
554 aTitle = QObject::tr( "FREE_BORDERS" );
555 aControl = SMESH_Actor::eFreeBorders;
558 aTitle = QObject::tr( "MULTI_BORDERS" );
559 aControl = SMESH_Actor::eMultiConnection;
562 aTitle = QObject::tr( "MULTI2D_BORDERS" );
563 aControl = SMESH_Actor::eMultiConnection2D;
566 aTitle = QObject::tr( "AREA_ELEMENTS" );
567 aControl = SMESH_Actor::eArea;
570 aTitle = QObject::tr( "TAPER_ELEMENTS" );
571 aControl = SMESH_Actor::eTaper;
574 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
575 aControl = SMESH_Actor::eAspectRatio;
578 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
579 aControl = SMESH_Actor::eAspectRatio3D;
582 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
583 aControl = SMESH_Actor::eMinimumAngle;
586 aTitle = QObject::tr( "WARP_ELEMENTS" );
587 aControl = SMESH_Actor::eWarping;
590 aTitle = QObject::tr( "SKEW_ELEMENTS" );
591 aControl = SMESH_Actor::eSkew;
594 anActor->SetControlMode(aControl);
595 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
602 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
603 MeshObjectType theType,
604 const QString theInTypeName,
605 QString & theOutTypeName)
607 SMESH_TypeFilter aTypeFilter( theType );
609 if( !theIO.IsNull() )
611 entry = theIO->getEntry();
612 SalomeApp_DataOwner owner( entry );
613 if ( aTypeFilter.isOk( &owner )) {
614 theOutTypeName = theInTypeName;
622 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
624 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
625 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
627 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
628 CORBA::String_var anID = aSComp->GetID().c_str();
629 if (!strcmp(anID.in(),theIO->getEntry()))
635 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
636 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
637 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
638 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
639 CheckOIType ( theIO, GROUP, "Group", aTypeName )
647 QString CheckHomogeneousSelection()
649 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
650 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
651 SALOME_ListIO selected;
653 aSel->selectedObjects( selected );
655 QString RefType = CheckTypeObject(selected.First());
656 SALOME_ListIteratorOfListIO It(selected);
657 for (; It.More(); It.Next())
659 Handle(SALOME_InteractiveObject) IObject = It.Value();
660 QString Type = CheckTypeObject(IObject);
661 if (Type.compare(RefType) != 0)
662 return "Heterogeneous Selection";
670 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
671 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
672 SALOME_ListIO selected; aSel->selectedObjects( selected );
674 QString aParentComponent = QString::null;
675 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
677 QString cur = anIt.Value()->getComponentDataType();
678 if( aParentComponent.isNull() )
679 aParentComponent = cur;
680 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
681 aParentComponent = "";
684 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
685 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
686 QObject::tr("ERR_ERROR"),
687 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
688 QObject::tr("BUT_OK") );
691 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
692 if (SUIT_MessageBox::warn2
693 (SMESHGUI::desktop(),
694 QObject::tr("SMESH_WRN_WARNING"),
695 QObject::tr("SMESH_REALLY_DELETE"),
696 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
699 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
700 SUIT_ViewManager* vm = anApp->activeViewManager();
701 int nbSf = vm->getViewsCount();
703 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
704 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
705 _PTR(GenericAttribute) anAttr;
706 _PTR(AttributeIOR) anIOR;
708 SALOME_ListIteratorOfListIO It(selected);
710 aStudyBuilder->NewCommand(); // There is a transaction
711 for(; It.More(); It.Next()){
712 Handle(SALOME_InteractiveObject) IObject = It.Value();
713 if(IObject->hasEntry()){
714 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
716 /* Erase child graphical objects */
717 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
718 for(it->InitEx(true); it->More(); it->Next()){
719 _PTR(SObject) CSO = it->Value();
720 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
723 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
724 for(int i = 0; i < nbSf; i++){
725 SUIT_ViewWindow *sf = aViews[i];
726 CORBA::String_var anEntry = CSO->GetID().c_str();
727 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
728 SMESH::RemoveActor(sf,anActor);
734 /* Erase main graphical object */
735 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
736 for(int i = 0; i < nbSf; i++){
737 SUIT_ViewWindow *sf = aViews[i];
738 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
739 SMESH::RemoveActor(sf,anActor);
743 // Remove object(s) from data structures
744 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
746 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
747 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
748 QString objType = CheckTypeObject(IObject);
749 if ( !aGroup->_is_nil() ) { // DELETE GROUP
750 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
751 aMesh->RemoveGroup( aGroup );
753 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
754 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
755 aMesh->RemoveSubMesh( aSubMesh );
757 else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
758 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
759 aStudyBuilder->RemoveObjectWithChildren( obj );
761 else {// default action: remove SObject from the study
762 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
763 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
765 aStudyBuilder->RemoveObjectWithChildren( obj );
770 } /* IObject->hasEntry() */
772 aStudyBuilder->CommitCommand();
774 /* Clear any previous selection */
776 aSel->setSelectedObjects( l1 );
778 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
783 Standard_EXPORT CAM_Module* createModule()
785 return new SMESHGUI();
789 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
791 //=============================================================================
795 //=============================================================================
796 SMESHGUI::SMESHGUI() :
797 SalomeApp_Module( "SMESH" )
799 if ( CORBA::is_nil( myComponentSMESH ) )
801 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
802 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
803 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
806 myActiveDialogBox = 0 ;
809 SMESH::GetFilterManager();
812 /* load resources for all available meshers */
813 SMESH::InitAvailableHypotheses();
816 //=============================================================================
820 //=============================================================================
821 SMESHGUI::~SMESHGUI()
823 SMESH::GetFilterManager()->Destroy();
826 //=============================================================================
830 //=============================================================================
831 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
833 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
835 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
840 bool SMESHGUI::automaticUpdate()
842 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
846 return resMgr->booleanValue( "SMESH", "auto_update", false );
849 //=============================================================================
853 //=============================================================================
854 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
856 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
859 //=============================================================================
863 //=============================================================================
864 SMESHGUI* SMESHGUI::GetSMESHGUI()
866 SMESHGUI* smeshMod = 0;
867 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
870 CAM_Module* module = app->module( "Mesh" );
871 smeshMod = dynamic_cast<SMESHGUI*>( module );
874 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
876 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
879 _PTR(Study) aStudy = study->studyDS();
881 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
890 Standard_EXPORT SMESHGUI* GetComponentGUI()
892 return SMESHGUI::GetSMESHGUI();
896 //=============================================================================
900 //=============================================================================
901 void SMESHGUI::SetState(int aState)
906 //=============================================================================
910 //=============================================================================
911 void SMESHGUI::ResetState()
916 //=============================================================================
920 //=============================================================================
921 void SMESHGUI::EmitSignalDeactivateDialog()
923 emit SignalDeactivateActiveDialog();
926 //=============================================================================
930 //=============================================================================
931 void SMESHGUI::EmitSignalStudyFrameChanged()
933 emit SignalStudyFrameChanged();
936 //=============================================================================
940 //=============================================================================
941 void SMESHGUI::EmitSignalCloseAllDialogs()
943 emit SignalCloseAllDialogs();
946 //=============================================================================
950 //=============================================================================
951 QDialog *SMESHGUI::GetActiveDialogBox()
953 return myActiveDialogBox;
956 //=============================================================================
960 //=============================================================================
961 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
963 myActiveDialogBox = (QDialog *) aDlg;
967 //=============================================================================
971 //=============================================================================
972 SUIT_Desktop* SMESHGUI::desktop()
974 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
976 return app->desktop();
981 //=============================================================================
985 //=============================================================================
986 SalomeApp_Study* SMESHGUI::activeStudy()
988 SUIT_Application* app = SUIT_Session::session()->activeApplication();
990 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
995 //=============================================================================
999 //=============================================================================
1000 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1002 /* Here the position is on the bottom right corner - 10 */
1003 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1005 SUIT_Desktop *PP = desktop();
1006 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1007 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1011 //=============================================================================
1015 //=============================================================================
1016 static int isStudyLocked(_PTR(Study) theStudy){
1017 return theStudy->GetProperties()->IsLocked();
1020 static bool checkLock(_PTR(Study) theStudy) {
1021 if (isStudyLocked(theStudy)) {
1022 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1023 QObject::tr("WRN_WARNING"),
1024 QObject::tr("WRN_STUDY_LOCKED"),
1025 QObject::tr("BUT_OK") );
1031 //=======================================================================
1032 //function : CheckActiveStudyLocked
1034 //=======================================================================
1036 bool SMESHGUI::isActiveStudyLocked()
1038 _PTR(Study) aStudy = activeStudy()->studyDS();
1039 return checkLock( aStudy );
1042 //=============================================================================
1046 //=============================================================================
1047 bool SMESHGUI::OnGUIEvent( int theCommandID )
1049 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1053 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1054 SUIT_ResourceMgr* mgr = resourceMgr();
1058 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1059 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1061 QAction* act = action( theCommandID );
1063 switch (theCommandID) {
1065 if(checkLock(aStudy)) break;
1073 if(checkLock(aStudy)) break;
1074 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1078 case 122: // EXPORT MED
1085 ::ExportMeshToFile(theCommandID);
1089 case 200: // SCALAR BAR
1091 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1092 SALOME_ListIO selected;
1094 aSel->selectedObjects( selected );
1096 if( selected.Extent() ) {
1097 Handle(SALOME_InteractiveObject) anIO = selected.First();
1098 if( anIO->hasEntry() ) {
1099 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1100 anActor->SetControlMode( SMESH_Actor::eNone );
1108 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1112 case 1134: // Clipping
1113 case 1133: // Tranparency
1114 case 1132: // Colors / Size
1121 ::SetDisplayMode(theCommandID);
1127 case 219: // Volumes
1128 case 220: // All Entity
1129 ::SetDisplayEntity(theCommandID);
1134 if(checkLock(aStudy)) break;
1135 SMESH::UpdateView();
1138 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1139 aSel->setSelectedObjects( l );
1144 case 301: // DISPLAY
1145 case 302: // DISPLAY ONLY
1147 SMESH::EDisplaing anAction;
1148 switch(theCommandID){
1149 case 300: anAction = SMESH::eErase; break;
1150 case 301: anAction = SMESH::eDisplay; break;
1151 case 302: anAction = SMESH::eDisplayOnly; break;
1154 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1155 SALOME_ListIO selected;
1157 aSel->selectedObjects( selected );
1160 SALOME_ListIteratorOfListIO It(selected);
1161 for (; It.More(); It.Next()) {
1162 Handle(SALOME_InteractiveObject) IOS = It.Value();
1163 if (IOS->hasEntry()) {
1164 SMESH::UpdateView(anAction,IOS->getEntry());
1169 aSel->setSelectedObjects( l1 );
1175 if(checkLock(aStudy)) break;
1178 EmitSignalDeactivateDialog();
1180 new SMESHGUI_NodesDlg(this);
1183 SUIT_MessageBox::warn1(desktop(),
1184 tr("SMESH_WRN_WARNING"),
1185 tr("SMESH_WRN_VIEWER_VTK"),
1186 tr("SMESH_BUT_OK"));
1191 case 2151: // FILTER
1195 EmitSignalDeactivateDialog();
1196 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1201 case 406: // MOVE NODE
1205 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1206 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1210 if(checkLock(aStudy)) break;
1211 new SMESHGUI_MoveNodesDlg(this);
1215 case 701: // COMPUTE MESH
1217 if(checkLock(aStudy)) break;
1219 SalomeApp_SelectionMgr *Sel = selectionMgr();
1220 SALOME_ListIO selected; Sel->selectedObjects( selected );
1222 int nbSel = selected.Extent();
1227 SMESH::SMESH_Mesh_var aMesh;
1228 SMESH::SMESH_subMesh_var aSubMesh;
1229 Handle(SALOME_InteractiveObject) IObject = selected.First();
1230 if (IObject->hasEntry()){
1231 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1232 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1233 if ( aShapeObject->_is_nil() ) {
1238 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1239 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1241 if (!aMesh->_is_nil()){
1242 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1243 if (!refShapeObject->_is_nil()) {
1244 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1245 SUIT_MessageBox::warn1(desktop(),
1246 tr("SMESH_WRN_WARNING"),
1247 tr("SMESH_WRN_MISSING_PARAMETERS"),
1248 tr("SMESH_BUT_OK"));
1252 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1253 SMESH::ModifiedMesh(aMeshSObj,true);
1254 // TO Do : change icon of all submeshes
1256 SUIT_MessageBox::warn1(desktop(),
1257 tr("SMESH_WRN_WARNING"),
1258 tr("SMESH_WRN_COMPUTE_FAILED"),
1259 tr("SMESH_BUT_OK"));
1261 catch(const SALOME::SALOME_Exception & S_ex){
1262 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1265 }else if(!aSubMesh->_is_nil()){
1266 aMesh = aSubMesh->GetFather();
1267 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1268 if(!refShapeObject->_is_nil()){
1269 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1271 SUIT_MessageBox::warn1(desktop(),
1272 tr("SMESH_WRN_WARNING"),
1273 tr("SMESH_WRN_MISSING_PARAMETERS"),
1274 tr("SMESH_BUT_OK"));
1278 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1279 SMESH::ModifiedMesh(aMeshSObj,true);
1280 // TO Do : change icon of all submeshes
1282 SUIT_MessageBox::warn1(desktop(),
1283 tr("SMESH_WRN_WARNING"),
1284 tr("SMESH_WRN_COMPUTE_FAILED"),
1285 tr("SMESH_BUT_OK"));
1286 }catch(const SALOME::SALOME_Exception & S_ex){
1287 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1293 CORBA::Long anId = aStudy->StudyId();
1294 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1295 if ( automaticUpdate() && aVisualObj){
1296 aVisualObj->Update();
1297 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1299 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1301 SMESH::DisplayActor(view,anActor); //apo
1307 SUIT_MessageBox::warn1(desktop(),
1308 tr("SMESH_WRN_WARNING"),
1309 tr("SMESH_WRN_VIEWER_VTK"),
1310 tr("SMESH_BUT_OK"));
1316 case 702: // ADD SUB MESH
1318 if(checkLock(aStudy)) break;
1320 EmitSignalDeactivateDialog();
1321 new SMESHGUI_AddSubMeshDlg( this );
1324 SUIT_MessageBox::warn1(desktop(),
1325 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1326 tr("SMESH_BUT_OK"));
1331 case 703: // INIT MESH
1333 if(checkLock(aStudy)) break;
1334 EmitSignalDeactivateDialog();
1335 new SMESHGUI_InitMeshDlg( this );
1339 case 704: // EDIT Hypothesis
1341 if(checkLock(aStudy)) break;
1342 EmitSignalDeactivateDialog();
1343 new SMESHGUI_EditHypothesesDlg( this );
1347 case 705: // EDIT Global Hypothesis
1349 if(checkLock(aStudy)) break;
1350 EmitSignalDeactivateDialog();
1351 new SMESHGUI_EditHypothesesDlg( this );
1355 case 706: // EDIT Local Hypothesis
1357 if(checkLock(aStudy)) break;
1358 EmitSignalDeactivateDialog();
1359 new SMESHGUI_EditHypothesesDlg( this );
1363 case 407: // DIAGONAL INVERSION
1364 case 408: // Delete diagonal
1368 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1369 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1373 if ( checkLock( aStudy ) )
1376 /*Standard_Boolean aRes;
1377 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1378 if ( aMesh->_is_nil() )
1380 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1381 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1385 EmitSignalDeactivateDialog();
1386 if ( theCommandID == 407 )
1387 new SMESHGUI_TrianglesInversionDlg(this);
1389 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1392 case 409: // Change orientation
1393 case 410: // Union of triangles
1394 case 411: // Cutting of quadrangles
1398 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1399 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1403 if ( checkLock( aStudy ) )
1406 EmitSignalDeactivateDialog();
1407 SMESHGUI_MultiEditDlg* aDlg = NULL;
1408 if ( theCommandID == 409 )
1409 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1410 else if ( theCommandID == 410 )
1411 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1413 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1416 DefineDlgPosition( aDlg, x, y );
1421 case 412: // Smoothing
1423 if(checkLock(aStudy)) break;
1425 EmitSignalDeactivateDialog();
1426 new SMESHGUI_SmoothingDlg( this );
1429 SUIT_MessageBox::warn1(desktop(),
1430 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1431 tr("SMESH_BUT_OK"));
1435 case 413: // Extrusion
1437 if (checkLock(aStudy)) break;
1439 EmitSignalDeactivateDialog();
1440 new SMESHGUI_ExtrusionDlg ( this );
1442 SUIT_MessageBox::warn1(desktop(),
1443 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1444 tr("SMESH_BUT_OK"));
1448 case 414: // Revolution
1450 if(checkLock(aStudy)) break;
1452 EmitSignalDeactivateDialog();
1453 new SMESHGUI_RevolutionDlg( this );
1456 SUIT_MessageBox::warn1(desktop(),
1457 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1458 tr("SMESH_BUT_OK"));
1462 case 415: // Pattern mapping
1464 if ( checkLock( aStudy ) )
1468 EmitSignalDeactivateDialog();
1469 new SMESHGUI_MeshPatternDlg( this );
1472 SUIT_MessageBox::warn1(desktop(),
1473 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1474 tr("SMESH_BUT_OK"));
1478 case 416: // Extrusion along a path
1480 if (checkLock(aStudy)) break;
1482 EmitSignalDeactivateDialog();
1483 new SMESHGUI_ExtrusionAlongPathDlg( this );
1485 SUIT_MessageBox::warn1(desktop(),
1486 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1487 tr("SMESH_BUT_OK"));
1491 case 801: // CREATE GROUP
1495 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1496 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1500 if(checkLock(aStudy)) break;
1501 EmitSignalDeactivateDialog();
1502 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1504 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1505 SALOME_ListIO selected;
1507 aSel->selectedObjects( selected );
1509 int nbSel = selected.Extent();
1511 // check if mesh is selected
1512 aMesh = SMESH::GetMeshByIO( selected.First() );
1514 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1519 case 802: // CONSTRUCT GROUP
1523 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1524 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1528 if(checkLock(aStudy)) break;
1529 EmitSignalDeactivateDialog();
1531 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1532 SALOME_ListIO selected;
1534 aSel->selectedObjects( selected );
1536 int nbSel = selected.Extent();
1538 // check if submesh is selected
1539 Handle(SALOME_InteractiveObject) IObject = selected.First();
1540 if (IObject->hasEntry()) {
1541 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1543 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1544 if (!aSubMesh->_is_nil()) {
1546 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1547 // get submesh elements list by types
1548 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1549 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1550 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1551 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1552 // create group for each type o elements
1553 QString aName = IObject->getName();
1554 if (aNodes->length() > 0) {
1555 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1556 aGroup->Add(aNodes.inout());
1558 if (aEdges->length() > 0) {
1559 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1560 aGroup->Add(aEdges.inout());
1562 if (aFaces->length() > 0) {
1563 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1564 aGroup->Add(aFaces.inout());
1566 if (aVolumes->length() > 0) {
1567 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1568 aGroup->Add(aVolumes.inout());
1572 }catch(const SALOME::SALOME_Exception & S_ex){
1573 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1582 case 803: // EDIT GROUP
1586 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1587 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1591 if(checkLock(aStudy)) break;
1592 EmitSignalDeactivateDialog();
1594 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1595 SALOME_ListIO selected;
1597 aSel->selectedObjects( selected );
1599 SALOME_ListIteratorOfListIO It (selected);
1600 int nbSelectedGroups = 0;
1601 for ( ; It.More(); It.Next() )
1603 SMESH::SMESH_Group_var aGroup =
1604 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1605 if (!aGroup->_is_nil()) {
1607 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1611 if (nbSelectedGroups == 0)
1613 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1619 case 804: // Add elements to group
1621 if(checkLock(aStudy)) break;
1622 if (myState == 800) {
1623 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1624 if (aDlg) aDlg->onAdd();
1629 case 805: // Remove elements from group
1631 if(checkLock(aStudy)) break;
1632 if (myState == 800) {
1633 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1634 if (aDlg) aDlg->onRemove();
1639 case 810: // Union Groups
1640 case 811: // Intersect groups
1641 case 812: // Cut groups
1645 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1646 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1650 if ( checkLock( aStudy ) )
1653 EmitSignalDeactivateDialog();
1656 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1657 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1658 else aMode = SMESHGUI_GroupOpDlg::CUT;
1660 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1664 case 813: // Delete groups with their contents
1668 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1669 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1673 if ( checkLock( aStudy ) )
1676 EmitSignalDeactivateDialog();
1678 new SMESHGUI_DeleteGroupDlg( this );
1682 case 900: // MESH INFOS
1684 EmitSignalDeactivateDialog();
1685 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1686 SALOME_ListIO selected;
1688 aSel->selectedObjects( selected );
1690 if ( selected.Extent() > 1 ) { // a dlg for each IO
1692 SALOME_ListIteratorOfListIO It (selected);
1693 for ( ; It.More(); It.Next() ) {
1694 IOs.Clear(); IOs.Append( It.Value() );
1695 aSel->setSelectedObjects( IOs );
1696 new SMESHGUI_MeshInfosDlg(this, "", false);
1698 // restore selection
1699 aSel->setSelectedObjects( selected );
1702 new SMESHGUI_MeshInfosDlg(this, "", false);
1706 case 902: // STANDARD MESH INFOS
1708 EmitSignalDeactivateDialog();
1709 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1710 SALOME_ListIO selected;
1712 aSel->selectedObjects( selected );
1714 if ( selected.Extent() > 1 ) { // a dlg for each IO
1716 SALOME_ListIteratorOfListIO It (selected);
1717 for ( ; It.More(); It.Next() ) {
1719 IOs.Append( It.Value() );
1720 aSel->setSelectedObjects( IOs );
1721 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1723 // restore selection
1724 aSel->setSelectedObjects( selected );
1727 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1731 case 1100: // EDIT HYPOTHESIS
1733 if(checkLock(aStudy)) break;
1735 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1736 SALOME_ListIO selected;
1738 aSel->selectedObjects( selected );
1740 int nbSel = selected.Extent();
1743 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1745 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1746 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1747 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1748 if ( !Hyp->_is_nil() )
1750 char* sName = Hyp->GetName();
1751 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1754 aCreator->EditHypothesis(Hyp);
1762 updateObjBrowser( true );
1766 case 1101: // RENAME
1768 if ( checkLock( aStudy ) )
1771 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1772 SALOME_ListIO selected;
1774 aSel->selectedObjects( selected );
1776 SALOME_ListIteratorOfListIO It( selected );
1777 for ( ; It.More(); It.Next() )
1779 Handle(SALOME_InteractiveObject) IObject = It.Value();
1780 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1781 _PTR(GenericAttribute) anAttr;
1782 _PTR(AttributeName) aName;
1785 if ( obj->FindAttribute(anAttr, "AttributeName") )
1788 QString newName = QString(aName->Value().c_str());
1789 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1790 if ( !newName.isEmpty() )
1792 //old source: aStudy->renameIObject( IObject, newName );
1793 aName->SetValue( newName.latin1() );
1795 // if current object is group update group's name
1796 SMESH::SMESH_GroupBase_var aGroup =
1797 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1798 if (!aGroup->_is_nil() )
1799 aGroup->SetName( newName.latin1() );
1809 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1811 if(checkLock(aStudy)) break;
1812 SUIT_OverrideCursor wc;
1814 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1815 SALOME_ListIO selected;
1817 aSel->selectedObjects( selected );
1819 SALOME_ListIteratorOfListIO It(selected);
1820 for (int i = 0; It.More(); It.Next(), i++) {
1821 Handle(SALOME_InteractiveObject) IObject = It.Value();
1822 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1825 aSel->setSelectedObjects( l1 );
1830 case 401: // GEOM::EDGE
1831 case 4021: // TRIANGLE
1833 case 4023: // POLYGON
1837 if(checkLock(aStudy)) break;
1839 EmitSignalDeactivateDialog();
1840 SMDSAbs_ElementType type = SMDSAbs_Edge;
1842 switch (theCommandID) {
1843 case 4021: // TRIANGLE
1844 type = SMDSAbs_Face; nbNodes = 3; break;
1846 type = SMDSAbs_Face; nbNodes = 4; break;
1848 type = SMDSAbs_Volume; nbNodes = 4; break;
1849 case 4023: // POLYGON
1850 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1852 type = SMDSAbs_Volume; nbNodes = 8; break;
1853 case 4033: // POLYHEDRE
1854 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1857 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1860 SUIT_MessageBox::warn1(desktop(),
1861 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1862 tr("SMESH_BUT_OK"));
1866 case 4033: // POLYHEDRON
1868 if(checkLock(aStudy)) break;
1870 EmitSignalDeactivateDialog();
1871 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1874 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1875 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1876 tr("SMESH_BUT_OK"));
1880 case 4041: // REMOVES NODES
1882 if(checkLock(aStudy)) break;
1884 EmitSignalDeactivateDialog();
1885 new SMESHGUI_RemoveNodesDlg(this);
1888 SUIT_MessageBox::warn1(desktop(),
1889 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1890 tr("SMESH_BUT_OK"));
1894 case 4042: // REMOVES ELEMENTS
1896 if(checkLock(aStudy)) break;
1898 EmitSignalDeactivateDialog();
1899 new SMESHGUI_RemoveElementsDlg(this);
1903 SUIT_MessageBox::warn1(desktop(),
1904 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1905 tr("SMESH_BUT_OK"));
1909 case 4051: // RENUMBERING NODES
1911 if(checkLock(aStudy)) break;
1913 EmitSignalDeactivateDialog();
1914 new SMESHGUI_RenumberingDlg( this, "", 0);
1918 SUIT_MessageBox::warn1(desktop(),
1919 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1920 tr("SMESH_BUT_OK"));
1924 case 4052: // RENUMBERING ELEMENTS
1926 if(checkLock(aStudy)) break;
1928 EmitSignalDeactivateDialog();
1929 new SMESHGUI_RenumberingDlg( this, "", 1);
1933 SUIT_MessageBox::warn1(desktop(),
1934 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1935 tr("SMESH_BUT_OK"));
1939 case 4061: // TRANSLATION
1941 if(checkLock(aStudy)) break;
1943 EmitSignalDeactivateDialog();
1944 new SMESHGUI_TranslationDlg( this );
1947 SUIT_MessageBox::warn1(desktop(),
1948 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1949 tr("SMESH_BUT_OK"));
1953 case 4062: // ROTATION
1955 if(checkLock(aStudy)) break;
1957 EmitSignalDeactivateDialog();
1958 new SMESHGUI_RotationDlg( this );
1961 SUIT_MessageBox::warn1(desktop(),
1962 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1963 tr("SMESH_BUT_OK"));
1967 case 4063: // SYMMETRY
1969 if(checkLock(aStudy)) break;
1971 EmitSignalDeactivateDialog();
1972 new SMESHGUI_SymmetryDlg( this );
1975 SUIT_MessageBox::warn1(desktop(),
1976 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1977 tr("SMESH_BUT_OK"));
1981 case 4064: // SEWING
1983 if(checkLock(aStudy)) break;
1985 EmitSignalDeactivateDialog();
1986 new SMESHGUI_SewingDlg( this );
1989 SUIT_MessageBox::warn1(desktop(),
1990 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1991 tr("SMESH_BUT_OK"));
1995 case 4065: // MERGE NODES
1997 if(checkLock(aStudy)) break;
1999 EmitSignalDeactivateDialog();
2000 new SMESHGUI_MergeNodesDlg( this );
2003 SUIT_MessageBox::warn1(desktop(),
2004 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2005 tr("SMESH_BUT_OK"));
2011 case 5000: // HYPOTHESIS
2013 if(checkLock(aStudy)) break;
2014 EmitSignalDeactivateDialog();
2015 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2020 if(checkLock(aStudy)) break;
2021 EmitSignalDeactivateDialog();
2022 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2026 case 5105: // Library of selection filters
2028 static QValueList<int> aTypes;
2029 if ( aTypes.isEmpty() )
2031 aTypes.append( SMESH::NODE );
2032 aTypes.append( SMESH::EDGE );
2033 aTypes.append( SMESH::FACE );
2034 aTypes.append( SMESH::VOLUME );
2036 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2040 case 6017: // CONTROLS
2055 SalomeApp_SelectionMgr* mgr = selectionMgr();
2056 SALOME_ListIO selected; mgr->selectedObjects( selected );
2058 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2059 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2061 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2062 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2063 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2064 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2065 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2066 ::Control( theCommandID );
2071 SUIT_MessageBox::warn1(desktop(),
2072 tr( "SMESH_WRN_WARNING" ),
2073 tr( "SMESH_BAD_SELECTION" ),
2074 tr( "SMESH_BUT_OK" ) );
2078 SUIT_MessageBox::warn1(desktop(),
2079 tr( "SMESH_WRN_WARNING" ),
2080 tr( "NOT_A_VTK_VIEWER" ),
2081 tr( "SMESH_BUT_OK" ) );
2086 SalomeApp_SelectionMgr* mgr = selectionMgr();
2087 SALOME_ListIO selected; mgr->selectedObjects( selected );
2089 if (selected.Extent() == 1) {
2090 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2091 if(anIObject->hasEntry())
2092 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2093 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2100 SalomeApp_SelectionMgr* mgr = selectionMgr();
2101 SALOME_ListIO selected; mgr->selectedObjects( selected );
2103 if (selected.Extent() == 1) {
2104 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2105 if(anIObject->hasEntry())
2106 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2107 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2113 //updateObjBrowser();
2117 //=============================================================================
2121 //=============================================================================
2122 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2127 //=============================================================================
2131 //=============================================================================
2132 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2137 //=============================================================================
2141 //=============================================================================
2142 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2147 //=============================================================================
2148 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2149 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2151 //=============================================================================
2152 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2153 SUIT_ViewWindow* wnd )
2155 if(theIO->hasEntry()){
2156 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2157 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2161 //=======================================================================
2162 // function : createSMESHAction
2164 //=======================================================================
2165 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2168 QWidget* parent = application()->desktop();
2169 SUIT_ResourceMgr* resMgr = resourceMgr();
2171 if ( icon_id.length() )
2172 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2174 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2175 if ( !pix.isNull() )
2176 icon = QIconSet( pix );
2178 QString tooltip = tr( QString( "TOP_" )+po_id ),
2179 menu = tr( QString( "MEN_" )+po_id ),
2180 status_bar = tr( QString( "STB_" )+po_id );
2182 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2185 //=======================================================================
2186 // function : createPopupItem
2188 //=======================================================================
2189 void SMESHGUI::createPopupItem( const int id,
2190 const QString& clients,
2191 const QString& types,
2192 const QString& theRule,
2197 parentId = popupMgr()->actionId( action( pId ) );
2199 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2200 popupMgr()->insert( action( id ), parentId, 0 );
2202 QChar lc = QtxPopupMgr::Selection::defEquality();
2203 QString rule = "(%1) and (%2) and (%3)";
2204 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2205 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2206 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2209 bool cont = myRules.contains( id );
2211 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2213 popupMgr()->setRule( action( id ), rule, true );
2214 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2217 //=======================================================================
2218 // function : initialize
2220 //=======================================================================
2221 void SMESHGUI::initialize( CAM_Application* app )
2223 SalomeApp_Module::initialize( app );
2225 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2227 /* Automatic Update flag */
2228 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2230 // ----- create actions --------------
2232 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2233 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2234 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2235 createSMESHAction( 114, "NUM" );
2236 createSMESHAction( 121, "DAT" );
2237 createSMESHAction( 122, "MED" );
2238 createSMESHAction( 123, "UNV" );
2239 createSMESHAction( 124, "EXPORT_DAT" );
2240 createSMESHAction( 125, "EXPORT_MED" );
2241 createSMESHAction( 126, "EXPORT_UNV" );
2242 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2243 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2244 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2245 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2246 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2247 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2248 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2249 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2250 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2251 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2252 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2253 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2254 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2255 createSMESHAction( 804, "ADD" );
2256 createSMESHAction( 805, "REMOVE" );
2257 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2258 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2259 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2260 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2261 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2262 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2263 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2264 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2265 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2266 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2267 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2268 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2269 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2270 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2271 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2272 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2273 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2274 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2275 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2276 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2277 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2278 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2279 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2280 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2281 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2282 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2283 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2284 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2285 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2286 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2287 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2288 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2289 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2290 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2291 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2292 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2293 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2294 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2295 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2296 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2297 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2298 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2299 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2300 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2301 createSMESHAction( 415, "MAP", "ICON_MAP" );
2302 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2303 createSMESHAction( 200, "RESET" );
2304 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2305 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2306 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2307 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2308 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2309 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2310 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2311 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2312 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2313 createSMESHAction( 220, "ALL" );
2314 createSMESHAction( 1100, "EDIT_HYPO" );
2315 createSMESHAction( 1101, "RENAME" );
2316 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2317 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2318 createSMESHAction( 1131, "DISPMODE" );
2319 createSMESHAction( 1132, "COLORS" );
2320 createSMESHAction( 1133, "TRANSP" );
2321 createSMESHAction( 1134, "CLIP" );
2322 createSMESHAction( 1135, "DISP_ENT" );
2323 createSMESHAction( 2000, "CTRL" );
2325 createSMESHAction( 300, "ERASE" );
2326 createSMESHAction( 301, "DISPLAY" );
2327 createSMESHAction( 302, "DISPLAY_ONLY" );
2328 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2330 // ----- create menu --------------
2331 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2332 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2333 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2334 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2335 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2336 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2337 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2338 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2340 createMenu( separator(), fileId );
2342 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2343 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2344 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2345 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2346 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2347 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2349 createMenu( 111, importId, -1 );
2350 createMenu( 112, importId, -1 );
2351 createMenu( 113, importId, -1 );
2353 createMenu( 121, exportId, -1 );
2354 createMenu( 122, exportId, -1 );
2355 createMenu( 123, exportId, -1 );
2357 createMenu( separator(), fileId, 10 );
2359 createMenu( 33, editId, -1 );
2361 createMenu( 5105, toolsId, -1 );
2363 createMenu( 5000, hypoId, -1 );
2364 createMenu( 5010, hypoId, -1 );
2366 createMenu( 703, meshId, -1 );
2367 createMenu( 702, meshId, -1 );
2368 createMenu( 704, meshId, -1 );
2369 createMenu( separator(), meshId, -1 );
2370 createMenu( 701, meshId, -1 );
2371 createMenu( separator(), meshId, -1 );
2372 createMenu( 801, meshId, -1 );
2373 createMenu( 802, meshId, -1 );
2374 createMenu( 803, meshId, -1 );
2375 createMenu( separator(), meshId, -1 );
2376 createMenu( 810, meshId, -1 );
2377 createMenu( 811, meshId, -1 );
2378 createMenu( 812, meshId, -1 );
2379 createMenu( separator(), meshId, -1 );
2380 createMenu( 813, meshId, -1 );
2381 createMenu( separator(), meshId, -1 );
2382 createMenu( 900, meshId, -1 );
2383 createMenu( 902, meshId, -1 );
2384 createMenu( separator(), meshId, -1 );
2386 createMenu( 6003, ctrlId, -1 );
2387 createMenu( 6001, ctrlId, -1 );
2388 createMenu( 6004, ctrlId, -1 );
2389 createMenu( separator(), ctrlId, -1 );
2390 createMenu( 6002, ctrlId, -1 );
2391 createMenu( 6018, ctrlId, -1 );
2392 createMenu( 6019, ctrlId, -1 );
2393 createMenu( 6011, ctrlId, -1 );
2394 createMenu( 6012, ctrlId, -1 );
2395 createMenu( 6013, ctrlId, -1 );
2396 createMenu( 6014, ctrlId, -1 );
2397 createMenu( 6015, ctrlId, -1 );
2398 createMenu( 6016, ctrlId, -1 );
2399 createMenu( separator(), ctrlId, -1 );
2400 createMenu( 6017, ctrlId, -1 );
2401 createMenu( separator(), ctrlId, -1 );
2403 createMenu( 400, addId, -1 );
2404 createMenu( 401, addId, -1 );
2405 createMenu( 4021, addId, -1 );
2406 createMenu( 4022, addId, -1 );
2407 createMenu( 4023, addId, -1 );
2408 createMenu( 4031, addId, -1 );
2409 createMenu( 4032, addId, -1 );
2410 createMenu( 4033, addId, -1 );
2412 createMenu( 4041, removeId, -1 );
2413 createMenu( 4042, removeId, -1 );
2415 createMenu( 4051, renumId, -1 );
2416 createMenu( 4052, renumId, -1 );
2418 createMenu( 4061, transfId, -1 );
2419 createMenu( 4062, transfId, -1 );
2420 createMenu( 4063, transfId, -1 );
2421 createMenu( 4064, transfId, -1 );
2422 createMenu( 4065, transfId, -1 );
2424 createMenu( 406, modifyId, -1 );
2425 createMenu( 407, modifyId, -1 );
2426 createMenu( 408, modifyId, -1 );
2427 createMenu( 409, modifyId, -1 );
2428 createMenu( 410, modifyId, -1 );
2429 createMenu( 411, modifyId, -1 );
2430 createMenu( 412, modifyId, -1 );
2431 createMenu( 413, modifyId, -1 );
2432 createMenu( 416, modifyId, -1 );
2433 createMenu( 414, modifyId, -1 );
2434 createMenu( 415, modifyId, -1 );
2436 createMenu( 214, viewId, -1 );
2438 // ----- create toolbars --------------
2439 int meshTb = createTool( tr( "TB_MESH" ) ),
2440 hypoTb = createTool( tr( "TB_HYPO" ) ),
2441 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2442 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2443 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2444 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2446 createTool( 703, meshTb );
2447 createTool( 702, meshTb );
2448 createTool( 704, meshTb );
2449 createTool( separator(), meshTb );
2450 createTool( 701, meshTb );
2451 createTool( separator(), meshTb );
2452 createTool( 801, meshTb );
2453 createTool( 802, meshTb );
2454 createTool( 803, meshTb );
2455 createTool( separator(), meshTb );
2456 createTool( 900, meshTb );
2457 createTool( 902, meshTb );
2458 createTool( separator(), meshTb );
2460 createTool( 5000, hypoTb );
2461 createTool( 5010, hypoTb );
2463 createTool( 6001, ctrlTb );
2464 createTool( 6003, ctrlTb );
2465 createTool( 6004, ctrlTb );
2466 createTool( separator(), ctrlTb );
2467 createTool( 6002, ctrlTb );
2468 createTool( 6018, ctrlTb );
2469 createTool( 6019, ctrlTb );
2470 createTool( 6011, ctrlTb );
2471 createTool( 6012, ctrlTb );
2472 createTool( 6013, ctrlTb );
2473 createTool( 6014, ctrlTb );
2474 createTool( 6015, ctrlTb );
2475 createTool( 6016, ctrlTb );
2476 createTool( separator(), ctrlTb );
2477 createTool( 6017, ctrlTb );
2478 createTool( separator(), ctrlTb );
2480 createTool( 400, addRemTb );
2481 createTool( 401, addRemTb );
2482 createTool( 4021, addRemTb );
2483 createTool( 4022, addRemTb );
2484 createTool( 4023, addRemTb );
2485 createTool( 4031, addRemTb );
2486 createTool( 4032, addRemTb );
2487 createTool( 4033, addRemTb );
2488 createTool( separator(), addRemTb );
2489 createTool( 4041, addRemTb );
2490 createTool( 4042, addRemTb );
2491 createTool( separator(), addRemTb );
2492 createTool( 4051, addRemTb );
2493 createTool( 4052, addRemTb );
2494 createTool( separator(), addRemTb );
2495 createTool( 4061, addRemTb );
2496 createTool( 4062, addRemTb );
2497 createTool( 4063, addRemTb );
2498 createTool( 4064, addRemTb );
2499 createTool( 4065, addRemTb );
2500 createTool( separator(), addRemTb );
2502 createTool( 406, modifyTb );
2503 createTool( 407, modifyTb );
2504 createTool( 408, modifyTb );
2505 createTool( 409, modifyTb );
2506 createTool( 410, modifyTb );
2507 createTool( 411, modifyTb );
2508 createTool( 412, modifyTb );
2509 createTool( 413, modifyTb );
2510 createTool( 416, modifyTb );
2511 createTool( 414, modifyTb );
2512 createTool( 415, modifyTb );
2514 createTool( 214, dispModeTb );
2518 QString OB = "'ObjectBrowser'",
2519 View = "'" + SVTK_Viewer::Type() + "'",
2521 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2522 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2523 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2524 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2525 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2526 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2527 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2528 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2529 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2530 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2532 mesh_group = mesh + " " + subMesh + " " + group,
2533 hyp_alg = hypo + " " + algo;
2535 // popup for object browser
2537 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2538 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2539 createPopupItem( 803, OB, group ); // EDIT_GROUP
2540 popupMgr()->insert( separator(), -1, 0 );
2541 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2542 createPopupItem( 214, OB, mesh_group ); // UPDATE
2543 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2544 createPopupItem( 902, OB, mesh ); // STD_INFO
2545 popupMgr()->insert( separator(), -1, 0 );
2546 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2547 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2548 popupMgr()->insert( separator(), -1, 0 );
2549 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2550 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2551 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2552 popupMgr()->insert( separator(), -1, 0 );
2553 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2554 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2555 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2556 popupMgr()->insert( separator(), -1, 0 );
2559 createPopupItem( 803, View, group ); // EDIT_GROUP
2560 createPopupItem( 804, View, elems ); // ADD
2561 createPopupItem( 805, View, elems ); // REMOVE
2562 popupMgr()->insert( separator(), -1, 0 );
2563 createPopupItem( 214, View, mesh_group ); // UPDATE
2564 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2565 createPopupItem( 902, View, mesh ); // STD_INFO
2566 popupMgr()->insert( separator(), -1, 0 );
2570 isInvisible("not( isVisible )"),
2571 isEmpty("numberOfNodes = 0"),
2572 isNotEmpty("numberOfNodes <> 0"),
2574 // has nodes, edges, etc in VISIBLE! actor
2575 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2576 hasElems("(count( elemTypes ) > 0)"),
2577 hasDifferentElems("(count( elemTypes ) > 1)"),
2578 hasEdges("({'Edge'} in elemTypes)"),
2579 hasFaces("({'Face'} in elemTypes)"),
2580 hasVolumes("({'Volume'} in elemTypes)");
2582 QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2583 QString lc = QtxPopupMgr::Selection::defEquality();
2584 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2585 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2586 QString aMeshInVTK = aClient + "&&" + aType;// + "&&" + aSelCount;
2588 //-------------------------------------------------
2590 //-------------------------------------------------
2591 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2593 popupMgr()->insert( action( 9010 ), anId, -1 );
2594 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );//@
2595 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2597 popupMgr()->insert( action( 9011 ), anId, -1 );
2598 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2599 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2601 popupMgr()->insert( separator(), -1, -1 );
2603 //-------------------------------------------------
2605 //-------------------------------------------------
2606 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2608 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2609 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2610 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2612 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2613 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2614 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2616 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2617 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2618 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2620 popupMgr()->insert( separator(), anId, -1 );
2622 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2623 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2624 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2626 //-------------------------------------------------
2628 //-------------------------------------------------
2629 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2631 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2633 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2634 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2635 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2637 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2638 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2639 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2641 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2642 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2643 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2645 popupMgr()->insert( separator(), anId, -1 );
2647 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2648 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2650 //-------------------------------------------------
2652 //-------------------------------------------------
2653 popupMgr()->insert( action( 1132 ), -1, -1 );
2654 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2656 //-------------------------------------------------
2658 //-------------------------------------------------
2659 popupMgr()->insert( action( 1133 ), -1, -1 );
2660 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2662 //-------------------------------------------------
2664 //-------------------------------------------------
2665 popupMgr()->insert( action( 1134 ), -1, -1 );
2666 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2668 popupMgr()->insert( separator(), -1, -1 );
2670 //-------------------------------------------------
2672 //-------------------------------------------------
2674 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2675 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2676 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2678 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2680 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2681 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2683 popupMgr()->insert( separator(), anId, -1 );
2685 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2686 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2687 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2689 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2690 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2691 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2693 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2694 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2695 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2697 popupMgr()->insert( separator(), anId, -1 );
2699 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2700 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2701 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2703 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2704 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2705 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2707 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2708 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2709 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2711 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2712 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2713 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2715 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2716 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2717 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2719 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2720 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2721 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2723 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2724 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2725 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2727 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2728 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2729 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2731 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2732 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2733 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2735 popupMgr()->insert( separator(), anId, -1 );
2737 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2738 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2739 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2741 popupMgr()->insert( separator(), anId, -1 );
2743 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2744 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2746 popupMgr()->insert( separator(), -1, -1 );
2748 //-------------------------------------------------
2750 //-------------------------------------------------
2751 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2752 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
2753 QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
2754 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2755 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
2757 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2758 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
2760 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2761 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
2763 popupMgr()->insert( separator(), -1, -1 );
2765 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
2766 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
2769 bool SMESHGUI::activateModule( SUIT_Study* study )
2771 bool res = SalomeApp_Module::activateModule( study );
2773 setMenuShown( true );
2774 setToolShown( true );
2779 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2781 setMenuShown( false );
2782 setToolShown( false );
2784 EmitSignalCloseAllDialogs();
2786 return SalomeApp_Module::deactivateModule( study );
2789 void SMESHGUI::OnGUIEvent()
2791 const QObject* obj = sender();
2792 if ( !obj || !obj->inherits( "QAction" ) )
2794 int id = actionId((QAction*)obj);
2799 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2801 if ( CORBA::is_nil( myComponentSMESH ) )
2803 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2804 return aGUI.myComponentSMESH;
2806 return myComponentSMESH;
2809 QString SMESHGUI::engineIOR() const
2811 CORBA::ORB_var anORB = getApp()->orb();
2812 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2816 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2818 SMESHGUI_Selection sel;
2819 sel.init( client, selectionMgr() );
2820 popupMgr()->updatePopup( menu, &sel );
2823 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2825 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2826 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2829 void SMESHGUI::viewManagers( QStringList& list ) const
2831 list.append( SVTK_Viewer::Type() );
2834 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
2836 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
2837 SMESH::UpdateSelectionProp( this );
2840 void SMESHGUI::createPreferences()
2842 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2844 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2845 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "display_entity" );
2846 addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "auto_update" );
2848 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2849 setPreferenceProperty( precGroup, "columns", 1 );
2851 addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool );
2852 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2854 setPreferenceProperty( prec, "min", 0 );
2855 setPreferenceProperty( prec, "max", 16 );
2857 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2858 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, SalomeApp_Preferences::Selector, "SMESH", "display_mode" );
2860 modes.append( "Wireframe" );
2861 modes.append( "Shading" );
2862 modes.append( "Shrink" );
2863 modes.append( "Nodes" );
2864 setPreferenceProperty( dispmode, "strings", modes );
2866 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2867 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2869 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
2870 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
2872 setPreferenceProperty( nodeSz, "min", 1 );
2873 setPreferenceProperty( nodeSz, "max", 5 );
2875 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2877 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
2878 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
2879 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
2880 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
2882 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
2883 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2885 setPreferenceProperty( elemW, "min", 1 );
2886 setPreferenceProperty( elemW, "max", 5 );
2888 setPreferenceProperty( shrink, "min", 0 );
2889 setPreferenceProperty( shrink, "max", 100 );
2891 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2893 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2895 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
2896 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
2897 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
2899 setPreferenceProperty( selW, "min", 1 );
2900 setPreferenceProperty( selW, "max", 5 );
2902 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2904 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
2905 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2907 setPreferenceProperty( preW, "min", 1 );
2908 setPreferenceProperty( preW, "max", 5 );
2910 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2912 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
2913 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
2915 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2916 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2918 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2919 addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2920 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2921 addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
2924 fam.append( tr( "SMESH_FONT_ARIAL" ) );
2925 fam.append( tr( "SMESH_FONT_COURIER" ) );
2926 fam.append( tr( "SMESH_FONT_TIMES" ) );
2927 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2929 setPreferenceProperty( tfont, "families", fam );
2930 setPreferenceProperty( tfont, "system", false );
2931 setPreferenceProperty( tfont, "widget_flags", wflag );
2932 setPreferenceProperty( lfont, "families", fam );
2933 setPreferenceProperty( lfont, "system", false );
2934 setPreferenceProperty( lfont, "widget_flags", wflag );
2936 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
2938 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
2939 setPreferenceProperty( numcol, "min", 2 );
2940 setPreferenceProperty( numcol, "max", 256 );
2942 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
2943 setPreferenceProperty( numlab, "min", 2 );
2944 setPreferenceProperty( numlab, "max", 65 );
2946 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
2947 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2948 QStringList orients;
2949 orients.append( tr( "SMESH_VERTICAL" ) );
2950 orients.append( tr( "SMESH_HORIZONTAL" ) );
2951 QValueList<QVariant> indices; indices.append( 0 ); indices.append( 1 );
2952 setPreferenceProperty( orient, "strings", orients );
2953 setPreferenceProperty( orient, "indexes", indices );
2955 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
2956 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2957 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2958 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2959 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
2960 setPreferenceProperty( xv, "step", 0.1 );
2961 setPreferenceProperty( xv, "min", 0.0 );
2962 setPreferenceProperty( xv, "max", 1.0 );
2963 setPreferenceProperty( yv, "step", 0.1 );
2964 setPreferenceProperty( yv, "min", 0.0 );
2965 setPreferenceProperty( yv, "max", 1.0 );
2966 setPreferenceProperty( wv, "step", 0.1 );
2967 setPreferenceProperty( wv, "min", 0.0 );
2968 setPreferenceProperty( wv, "max", 1.0 );
2969 setPreferenceProperty( hv, "min", 0.0 );
2970 setPreferenceProperty( hv, "max", 1.0 );
2971 setPreferenceProperty( hv, "step", 0.1 );
2973 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
2974 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
2975 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
2976 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
2977 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
2978 setPreferenceProperty( xv, "min", 0.0 );
2979 setPreferenceProperty( xv, "max", 1.0 );
2980 setPreferenceProperty( xv, "step", 0.1 );
2981 setPreferenceProperty( xh, "min", 0.0 );
2982 setPreferenceProperty( xh, "max", 1.0 );
2983 setPreferenceProperty( xh, "step", 0.1 );
2984 setPreferenceProperty( yh, "min", 0.0 );
2985 setPreferenceProperty( yh, "max", 1.0 );
2986 setPreferenceProperty( yh, "step", 0.1 );
2987 setPreferenceProperty( wh, "min", 0.0 );
2988 setPreferenceProperty( wh, "max", 1.0 );
2989 setPreferenceProperty( wh, "step", 0.1 );
2990 setPreferenceProperty( hh, "min", 0.0 );
2991 setPreferenceProperty( hh, "max", 1.0 );
2992 setPreferenceProperty( hh, "step", 0.1 );
2995 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )