1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESHGUI_NodesDlg.h"
30 #include "SMESHGUI_TransparencyDlg.h"
31 #include "SMESHGUI_ClippingDlg.h"
32 #include "SMESHGUI_GroupDlg.h"
33 #include "SMESHGUI_RemoveNodesDlg.h"
34 #include "SMESHGUI_RemoveElementsDlg.h"
35 #include "SMESHGUI_MeshInfosDlg.h"
36 #include "SMESHGUI_StandardMeshInfosDlg.h"
37 #include "SMESHGUI_Preferences_ColorDlg.h"
38 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
39 #include "SMESHGUI_Preferences_SelectionDlg.h"
40 #include "SMESHGUI_Hypotheses.h"
41 #include "SMESHGUI_MoveNodesDlg.h"
42 #include "SMESHGUI_AddMeshElementDlg.h"
43 #include "SMESHGUI_EditHypothesesDlg.h"
44 #include "SMESHGUI_CreateHypothesesDlg.h"
45 #include "SMESHGUI_FilterDlg.h"
46 #include "SMESHGUI_FilterLibraryDlg.h"
47 #include "SMESHGUI_SingleEditDlg.h"
48 #include "SMESHGUI_MultiEditDlg.h"
49 #include "SMESHGUI_GroupOpDlg.h"
50 #include "SMESHGUI_DeleteGroupDlg.h"
51 #include "SMESHGUI_SmoothingDlg.h"
52 #include "SMESHGUI_RenumberingDlg.h"
53 #include "SMESHGUI_ExtrusionDlg.h"
54 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
55 #include "SMESHGUI_RevolutionDlg.h"
56 #include "SMESHGUI_TranslationDlg.h"
57 #include "SMESHGUI_RotationDlg.h"
58 #include "SMESHGUI_SymmetryDlg.h"
59 #include "SMESHGUI_SewingDlg.h"
60 #include "SMESHGUI_MergeNodesDlg.h"
61 #include "SMESHGUI_EditMeshDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_PrecisionDlg.h"
64 #include "SMESHGUI_Selection.h"
65 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
66 #include "SMESHGUI_MeshOp.h"
67 #include "SMESHGUI_Displayer.h"
69 #include "SMESHGUI_Utils.h"
70 #include "SMESHGUI_GEOMGenUtils.h"
71 #include "SMESHGUI_MeshUtils.h"
72 #include "SMESHGUI_GroupUtils.h"
73 #include "SMESHGUI_FilterUtils.h"
74 #include "SMESHGUI_PatternUtils.h"
75 #include "SMESHGUI_VTKUtils.h"
76 #include "SMESHGUI_HypothesesUtils.h"
78 #include "SMESH_Actor.h"
79 #include "SMESH_Object.h"
80 #include "SMESH_TypeFilter.hxx"
82 #include "SalomeApp_Tools.h"
83 #include "SalomeApp_Study.h"
84 #include "SalomeApp_Application.h"
85 #include "SalomeApp_CheckFileDlg.h"
86 #include "LightApp_DataOwner.h"
87 #include "LightApp_Preferences.h"
88 #include "LightApp_VTKSelector.h"
89 #include "LightApp_Operation.h"
90 #include "LightApp_UpdateFlags.h"
92 #include "SalomeApp_ImportOperation.h"
94 #include <SVTK_ViewWindow.h>
95 #include <SVTK_ViewModel.h>
96 #include <SVTK_InteractorStyle.h>
97 #include <SVTK_RenderWindowInteractor.h>
98 #include <SVTK_ViewManager.h>
100 #include "OB_Browser.h"
102 #include "SUIT_Tools.h"
103 #include "SUIT_MessageBox.h"
104 #include "SUIT_ResourceMgr.h"
105 #include "SUIT_FileDlg.h"
106 #include "SUIT_Desktop.h"
107 #include "SUIT_OverrideCursor.h"
108 #include "SUIT_Study.h"
109 #include "SUIT_Session.h"
111 #include "QtxPopupMgr.h"
113 #include "SALOME_ListIO.hxx"
114 #include "SALOME_ListIteratorOfListIO.hxx"
115 #include "SALOME_InteractiveObject.hxx"
116 #include "SALOME_NamingService.hxx"
117 #include "SALOME_LifeCycleCORBA.hxx"
119 #include "SALOMEconfig.h"
120 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
123 #define INCLUDE_MENUITEM_DEF
124 #include <qpopupmenu.h>
128 #include <qinputdialog.h>
131 #include <boost/shared_ptr.hpp>
134 #include <vtkRenderer.h>
135 #include <vtkRenderWindow.h>
136 #include <vtkActorCollection.h>
137 #include <vtkScalarBarActor.h>
138 #include <vtkUnstructuredGrid.h>
140 #include "utilities.h"
142 #include "SALOMEDS_Study.hxx"
143 #include "SALOMEDSClient_StudyBuilder.hxx"
144 #include "SALOMEDSClient_SComponent.hxx"
150 //=============================================================
151 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
154 void ExportMeshToFile(int theCommandID);
156 void SetDisplayMode(int theCommandID);
158 void SetDisplayEntity(int theCommandID);
160 void Control( int theCommandID );
164 //=============================================================
165 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
171 if(theCommandID == 113){
172 filter.append(QObject::tr("MED files (*.med)"));
173 filter.append(QObject::tr("All files (*)"));
174 }else if (theCommandID == 112){
175 filter.append(QObject::tr("IDEAS files (*.unv)"));
176 }else if (theCommandID == 111){
177 filter.append(QObject::tr("DAT files (*.dat)"));
179 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
182 QObject::tr("Import mesh"),
184 if(!filename.isEmpty()) {
185 SUIT_OverrideCursor wc;
186 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
189 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
190 switch ( theCommandID ) {
193 aMeshes->length( 1 );
194 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
199 SMESH::DriverMED_ReadStatus res;
200 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
201 if ( res != SMESH::DRS_OK ) {
203 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
204 QObject::tr("SMESH_WRN_WARNING"),
205 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
206 QObject::tr("SMESH_BUT_OK"));
207 aMeshes->length( 0 );
214 bool isEmpty = false;
215 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
216 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
218 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
219 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
220 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
221 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
222 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
229 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
230 QObject::tr("SMESH_WRN_WARNING"),
231 QObject::tr("SMESH_DRS_EMPTY"),
232 QObject::tr("SMESH_BUT_OK"));
236 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
238 catch (const SALOME::SALOME_Exception& S_ex){
240 SalomeApp_Tools::QtCatchCorbaException(S_ex);
247 void ExportMeshToFile( int theCommandID )
249 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
250 SALOME_ListIO selected;
252 aSel->selectedObjects( selected );
254 if(selected.Extent()){
255 Handle(SALOME_InteractiveObject) anIObject = selected.First();
256 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
257 if ( !aMesh->_is_nil() ) {
258 QString aFilter, aTitle = QObject::tr("Export mesh");
259 QMap<QString, SMESH::MED_VERSION> aFilterMap;
260 switch ( theCommandID ) {
263 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
264 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
268 aFilter = QObject::tr("DAT files (*.dat)");
272 if(aMesh->NbPyramids()){
273 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
274 QObject::tr("SMESH_WRN_WARNING"),
275 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
276 QObject::tr("SMESH_BUT_YES"),
277 QObject::tr("SMESH_BUT_NO"),
282 aFilter = QObject::tr("IDEAS files (*.unv)");
289 SMESH::MED_VERSION aFormat;
290 // Init the parameter with the default value
291 bool toCreateGroups = false;
292 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
294 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
296 if ( theCommandID != 122 && theCommandID != 125 )
297 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
301 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
302 filters.push_back( it.key() );
304 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
305 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
306 fd->setCaption( aTitle );
307 fd->setFilters( filters );
308 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
309 fd->SetChecked(toCreateGroups);
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"),
330 toCreateGroups = fd->IsChecked();
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(), toCreateGroups, aFormat );
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 LightApp_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 LightApp_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 LightApp_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 aTitle = QObject::tr( "SMESH_VOLUME" );
595 aControl = SMESH_Actor::eVolume3D;
598 anActor->SetControlMode(aControl);
599 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
600 SMESH::RepaintCurrentView();
607 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
608 MeshObjectType theType,
609 const QString theInTypeName,
610 QString & theOutTypeName)
612 SMESH_TypeFilter aTypeFilter( theType );
614 if( !theIO.IsNull() )
616 entry = theIO->getEntry();
617 LightApp_DataOwner owner( entry );
618 if ( aTypeFilter.isOk( &owner )) {
619 theOutTypeName = theInTypeName;
627 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
629 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
630 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
632 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
633 CORBA::String_var anID = aSComp->GetID().c_str();
634 if (!strcmp(anID.in(),theIO->getEntry()))
640 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
641 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
642 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
643 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
644 CheckOIType ( theIO, GROUP, "Group", aTypeName )
652 QString CheckHomogeneousSelection()
654 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
655 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
656 SALOME_ListIO selected;
658 aSel->selectedObjects( selected );
660 QString RefType = CheckTypeObject(selected.First());
661 SALOME_ListIteratorOfListIO It(selected);
662 for (; It.More(); It.Next())
664 Handle(SALOME_InteractiveObject) IObject = It.Value();
665 QString Type = CheckTypeObject(IObject);
666 if (Type.compare(RefType) != 0)
667 return "Heterogeneous Selection";
674 void SMESHGUI::OnEditDelete()
676 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
677 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
678 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
680 QString aParentComponent = QString::null;
681 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
683 QString cur = anIt.Value()->getComponentDataType();
684 if( aParentComponent.isNull() )
685 aParentComponent = cur;
686 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
687 aParentComponent = "";
690 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
691 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
692 QObject::tr("ERR_ERROR"),
693 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
694 QObject::tr("BUT_OK") );
697 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
698 if (SUIT_MessageBox::warn2
699 (SMESHGUI::desktop(),
700 QObject::tr("SMESH_WRN_WARNING"),
701 QObject::tr("SMESH_REALLY_DELETE"),
702 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
705 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
706 SUIT_ViewManager* vm = anApp->activeViewManager();
707 int nbSf = vm->getViewsCount();
709 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
710 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
711 _PTR(GenericAttribute) anAttr;
712 _PTR(AttributeIOR) anIOR;
714 SALOME_ListIteratorOfListIO It(selected);
716 aStudyBuilder->NewCommand(); // There is a transaction
717 for(; It.More(); It.Next()){
718 Handle(SALOME_InteractiveObject) IObject = It.Value();
719 if(IObject->hasEntry()){
720 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
722 // disable removal of "SMESH" component object
723 if(SO->FindAttribute(anAttr, "AttributeIOR")){
725 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
729 /* Erase child graphical objects */
730 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
731 for(it->InitEx(true); it->More(); it->Next()){
732 _PTR(SObject) CSO = it->Value();
733 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
736 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
737 for(int i = 0; i < nbSf; i++){
738 SUIT_ViewWindow *sf = aViews[i];
739 CORBA::String_var anEntry = CSO->GetID().c_str();
740 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
741 SMESH::RemoveActor(sf,anActor);
747 /* Erase main graphical object */
748 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
749 for(int i = 0; i < nbSf; i++){
750 SUIT_ViewWindow *sf = aViews[i];
751 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
752 SMESH::RemoveActor(sf,anActor);
756 // Remove object(s) from data structures
757 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
759 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
760 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
761 QString objType = CheckTypeObject(IObject);
762 if ( !aGroup->_is_nil() ) { // DELETE GROUP
763 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
764 aMesh->RemoveGroup( aGroup );
766 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
767 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
768 aMesh->RemoveSubMesh( aSubMesh );
770 else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
771 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
772 aStudyBuilder->RemoveObjectWithChildren( obj );
774 else {// default action: remove SObject from the study
775 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
776 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
778 aStudyBuilder->RemoveObjectWithChildren( obj );
783 } /* IObject->hasEntry() */
785 aStudyBuilder->CommitCommand();
787 /* Clear any previous selection */
789 aSel->setSelectedObjects( l1 );
791 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
796 Standard_EXPORT CAM_Module* createModule()
798 return new SMESHGUI();
802 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
804 //=============================================================================
808 //=============================================================================
809 SMESHGUI::SMESHGUI() :
810 SalomeApp_Module( "SMESH" )
812 if ( CORBA::is_nil( myComponentSMESH ) )
814 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
815 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
816 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
819 myActiveDialogBox = 0;
823 SMESH::GetFilterManager();
826 /* load resources for all available meshers */
827 SMESH::InitAvailableHypotheses();
830 //=============================================================================
834 //=============================================================================
835 SMESHGUI::~SMESHGUI()
837 SMESH::GetFilterManager()->Destroy();
838 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
841 //=============================================================================
845 //=============================================================================
846 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
848 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
850 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
855 bool SMESHGUI::automaticUpdate()
857 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
861 return resMgr->booleanValue( "SMESH", "auto_update", false );
864 //=============================================================================
868 //=============================================================================
869 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
871 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
874 //=============================================================================
878 //=============================================================================
879 SMESHGUI* SMESHGUI::GetSMESHGUI()
881 SMESHGUI* smeshMod = 0;
882 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
885 CAM_Module* module = app->module( "Mesh" );
886 smeshMod = dynamic_cast<SMESHGUI*>( module );
889 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
891 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
894 _PTR(Study) aStudy = study->studyDS();
896 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
905 Standard_EXPORT SMESHGUI* GetComponentGUI()
907 return SMESHGUI::GetSMESHGUI();
911 //=============================================================================
915 //=============================================================================
916 void SMESHGUI::SetState(int aState)
921 //=============================================================================
925 //=============================================================================
926 void SMESHGUI::ResetState()
931 //=============================================================================
935 //=============================================================================
936 void SMESHGUI::EmitSignalDeactivateDialog()
938 emit SignalDeactivateActiveDialog();
941 //=============================================================================
945 //=============================================================================
946 void SMESHGUI::EmitSignalStudyFrameChanged()
948 emit SignalStudyFrameChanged();
951 //=============================================================================
955 //=============================================================================
956 void SMESHGUI::EmitSignalCloseAllDialogs()
958 emit SignalCloseAllDialogs();
961 //=============================================================================
965 //=============================================================================
966 QDialog *SMESHGUI::GetActiveDialogBox()
968 return myActiveDialogBox;
971 //=============================================================================
975 //=============================================================================
976 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
978 myActiveDialogBox = (QDialog *) aDlg;
982 //=============================================================================
986 //=============================================================================
987 SUIT_Desktop* SMESHGUI::desktop()
989 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
991 return app->desktop();
996 //=============================================================================
1000 //=============================================================================
1001 SalomeApp_Study* SMESHGUI::activeStudy()
1003 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1005 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1010 //=============================================================================
1014 //=============================================================================
1015 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1017 /* Here the position is on the bottom right corner - 10 */
1018 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1020 SUIT_Desktop *PP = desktop();
1021 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1022 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1026 //=============================================================================
1030 //=============================================================================
1031 static int isStudyLocked(_PTR(Study) theStudy){
1032 return theStudy->GetProperties()->IsLocked();
1035 static bool checkLock(_PTR(Study) theStudy) {
1036 if (isStudyLocked(theStudy)) {
1037 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1038 QObject::tr("WRN_WARNING"),
1039 QObject::tr("WRN_STUDY_LOCKED"),
1040 QObject::tr("BUT_OK") );
1046 //=======================================================================
1047 //function : CheckActiveStudyLocked
1049 //=======================================================================
1051 bool SMESHGUI::isActiveStudyLocked()
1053 _PTR(Study) aStudy = activeStudy()->studyDS();
1054 return checkLock( aStudy );
1057 //=============================================================================
1061 //=============================================================================
1062 bool SMESHGUI::OnGUIEvent( int theCommandID )
1064 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1068 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1069 SUIT_ResourceMgr* mgr = resourceMgr();
1073 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1074 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1076 //QAction* act = action( theCommandID );
1078 switch (theCommandID) {
1080 if(checkLock(aStudy)) break;
1088 if(checkLock(aStudy)) break;
1089 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1093 case 122: // EXPORT MED
1100 ::ExportMeshToFile(theCommandID);
1104 case 200: // SCALAR BAR
1106 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1107 SALOME_ListIO selected;
1109 aSel->selectedObjects( selected );
1111 if( selected.Extent() ) {
1112 Handle(SALOME_InteractiveObject) anIO = selected.First();
1113 if( anIO->hasEntry() ) {
1114 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1115 anActor->SetControlMode( SMESH_Actor::eNone );
1123 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1127 case 1134: // Clipping
1128 case 1133: // Tranparency
1129 case 1132: // Colors / Size
1136 ::SetDisplayMode(theCommandID);
1142 case 219: // Volumes
1143 case 220: // All Entity
1144 ::SetDisplayEntity(theCommandID);
1149 if(checkLock(aStudy)) break;
1150 SMESH::UpdateView();
1153 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1154 aSel->selectedObjects( l );
1155 aSel->setSelectedObjects( l );
1160 case 301: // DISPLAY
1161 case 302: // DISPLAY ONLY
1163 SMESH::EDisplaing anAction;
1164 switch (theCommandID) {
1165 case 300: anAction = SMESH::eErase; break;
1166 case 301: anAction = SMESH::eDisplay; break;
1167 case 302: anAction = SMESH::eDisplayOnly; break;
1170 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1171 SALOME_ListIO sel_objects, to_process;
1173 aSel->selectedObjects( sel_objects );
1175 if( theCommandID==302 )
1176 startOperation( myEraseAll );
1178 extractContainers( sel_objects, to_process );
1181 SALOME_ListIteratorOfListIO It( to_process );
1182 for (; It.More(); It.Next()) {
1183 Handle(SALOME_InteractiveObject) IOS = It.Value();
1184 if (IOS->hasEntry()) {
1185 SMESH::UpdateView(anAction, IOS->getEntry());
1186 if (anAction == SMESH::eDisplayOnly)
1187 anAction = SMESH::eDisplay;
1192 if (anAction == SMESH::eErase) {
1194 aSel->setSelectedObjects( l1 );
1197 aSel->setSelectedObjects( to_process );
1203 if(checkLock(aStudy)) break;
1206 EmitSignalDeactivateDialog();
1208 new SMESHGUI_NodesDlg(this);
1211 SUIT_MessageBox::warn1(desktop(),
1212 tr("SMESH_WRN_WARNING"),
1213 tr("SMESH_WRN_VIEWER_VTK"),
1214 tr("SMESH_BUT_OK"));
1219 case 2151: // FILTER
1223 EmitSignalDeactivateDialog();
1224 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1229 case 406: // MOVE NODE
1233 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1234 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1238 if(checkLock(aStudy)) break;
1239 new SMESHGUI_MoveNodesDlg(this);
1243 case 701: // COMPUTE MESH
1245 if(checkLock(aStudy)) break;
1247 LightApp_SelectionMgr *Sel = selectionMgr();
1248 SALOME_ListIO selected; Sel->selectedObjects( selected );
1251 int nbSel = selected.Extent();
1256 SMESH::SMESH_Mesh_var aMesh;
1257 SMESH::SMESH_subMesh_var aSubMesh;
1258 Handle(SALOME_InteractiveObject) IObject = selected.First();
1259 if (IObject->hasEntry()) {
1260 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1261 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1262 if ( aShapeObject->_is_nil() ) {
1267 aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1268 aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1269 if ( !aSubMesh->_is_nil() )
1270 aMesh = aSubMesh->GetFather();
1272 if (!aMesh->_is_nil()) {
1273 // if(!GetSMESHGen()->IsReadyToCompute(aMesh,aShapeObject)) {
1274 // SUIT_MessageBox::warn1(desktop(),
1275 // tr("SMESH_WRN_WARNING"),
1276 // tr("SMESH_WRN_MISSING_PARAMETERS"),
1277 // tr("SMESH_BUT_OK"));
1280 SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1281 if ( errors->length() > 0 ) {
1282 SUIT_MessageBox::warn1(desktop(),
1283 tr("SMESH_WRN_WARNING"),
1284 SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1285 tr("SMESH_BUT_OK"));
1289 if (GetSMESHGen()->Compute(aMesh,aShapeObject))
1290 SMESH::ModifiedMesh(aMeshSObj,true);
1292 SUIT_MessageBox::warn1(desktop(),
1293 tr("SMESH_WRN_WARNING"),
1294 tr("SMESH_WRN_COMPUTE_FAILED"),
1295 tr("SMESH_BUT_OK"));
1297 catch(const SALOME::SALOME_Exception & S_ex){
1298 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1303 CORBA::Long anId = aStudy->StudyId();
1304 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1305 if ( automaticUpdate() && aVisualObj){
1306 aVisualObj->Update();
1307 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1309 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1311 SMESH::DisplayActor(view,anActor); //apo
1315 SMESH::RepaintCurrentView();
1318 SUIT_MessageBox::warn1(desktop(),
1319 tr("SMESH_WRN_WARNING"),
1320 tr("SMESH_WRN_VIEWER_VTK"),
1321 tr("SMESH_BUT_OK"));
1324 Sel->setSelectedObjects( selected );
1328 case 702: // Create mesh
1329 startOperation( 702 );
1331 case 703: // Create sub-mesh
1332 startOperation( 703 );
1334 case 704: // Edit mesh/sub-mesh
1335 startOperation( 704 );
1337 case 407: // DIAGONAL INVERSION
1338 case 408: // Delete diagonal
1342 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1343 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1347 if ( checkLock( aStudy ) )
1350 /*Standard_Boolean aRes;
1351 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1352 if ( aMesh->_is_nil() )
1354 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1355 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1359 EmitSignalDeactivateDialog();
1360 if ( theCommandID == 407 )
1361 new SMESHGUI_TrianglesInversionDlg(this);
1363 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1366 case 409: // Change orientation
1367 case 410: // Union of triangles
1368 case 411: // Cutting of quadrangles
1372 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1373 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1377 if ( checkLock( aStudy ) )
1380 EmitSignalDeactivateDialog();
1381 SMESHGUI_MultiEditDlg* aDlg = NULL;
1382 if ( theCommandID == 409 )
1383 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1384 else if ( theCommandID == 410 )
1385 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1387 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1390 DefineDlgPosition( aDlg, x, y );
1395 case 412: // Smoothing
1397 if(checkLock(aStudy)) break;
1399 EmitSignalDeactivateDialog();
1400 new SMESHGUI_SmoothingDlg( this );
1403 SUIT_MessageBox::warn1(desktop(),
1404 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1405 tr("SMESH_BUT_OK"));
1409 case 413: // Extrusion
1411 if (checkLock(aStudy)) break;
1413 EmitSignalDeactivateDialog();
1414 new SMESHGUI_ExtrusionDlg ( this );
1416 SUIT_MessageBox::warn1(desktop(),
1417 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1418 tr("SMESH_BUT_OK"));
1422 case 414: // Revolution
1424 if(checkLock(aStudy)) break;
1426 EmitSignalDeactivateDialog();
1427 new SMESHGUI_RevolutionDlg( this );
1430 SUIT_MessageBox::warn1(desktop(),
1431 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1432 tr("SMESH_BUT_OK"));
1436 case 415: // Pattern mapping
1438 if ( checkLock( aStudy ) )
1442 EmitSignalDeactivateDialog();
1443 new SMESHGUI_MeshPatternDlg( this );
1446 SUIT_MessageBox::warn1(desktop(),
1447 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1448 tr("SMESH_BUT_OK"));
1452 case 416: // Extrusion along a path
1454 if (checkLock(aStudy)) break;
1456 EmitSignalDeactivateDialog();
1457 new SMESHGUI_ExtrusionAlongPathDlg( this );
1459 SUIT_MessageBox::warn1(desktop(),
1460 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1461 tr("SMESH_BUT_OK"));
1465 case 801: // CREATE GROUP
1469 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1470 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1474 if(checkLock(aStudy)) break;
1475 EmitSignalDeactivateDialog();
1476 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1478 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1479 SALOME_ListIO selected;
1481 aSel->selectedObjects( selected );
1483 int nbSel = selected.Extent();
1485 // check if mesh is selected
1486 aMesh = SMESH::GetMeshByIO( selected.First() );
1488 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1493 case 802: // CONSTRUCT GROUP
1497 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1498 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1502 if(checkLock(aStudy)) break;
1503 EmitSignalDeactivateDialog();
1505 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1506 SALOME_ListIO selected;
1508 aSel->selectedObjects( selected );
1510 int nbSel = selected.Extent();
1512 // check if submesh is selected
1513 Handle(SALOME_InteractiveObject) IObject = selected.First();
1514 if (IObject->hasEntry()) {
1515 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1517 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1518 if (!aSubMesh->_is_nil()) {
1520 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1521 // get submesh elements list by types
1522 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1523 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1524 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1525 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1526 // create group for each type o elements
1527 QString aName = IObject->getName();
1528 if (aNodes->length() > 0) {
1529 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1530 aGroup->Add(aNodes.inout());
1532 if (aEdges->length() > 0) {
1533 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1534 aGroup->Add(aEdges.inout());
1536 if (aFaces->length() > 0) {
1537 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1538 aGroup->Add(aFaces.inout());
1540 if (aVolumes->length() > 0) {
1541 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1542 aGroup->Add(aVolumes.inout());
1546 }catch(const SALOME::SALOME_Exception & S_ex){
1547 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1556 case 803: // EDIT GROUP
1560 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1561 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1565 if(checkLock(aStudy)) break;
1566 EmitSignalDeactivateDialog();
1568 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1569 SALOME_ListIO selected;
1571 aSel->selectedObjects( selected );
1573 SALOME_ListIteratorOfListIO It (selected);
1574 int nbSelectedGroups = 0;
1575 for ( ; It.More(); It.Next() )
1577 SMESH::SMESH_Group_var aGroup =
1578 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1579 if (!aGroup->_is_nil()) {
1581 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1585 if (nbSelectedGroups == 0)
1587 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1593 case 804: // Add elements to group
1595 if(checkLock(aStudy)) break;
1596 if (myState == 800) {
1597 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1598 if (aDlg) aDlg->onAdd();
1603 case 805: // Remove elements from group
1605 if(checkLock(aStudy)) break;
1606 if (myState == 800) {
1607 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1608 if (aDlg) aDlg->onRemove();
1613 case 810: // Union Groups
1614 case 811: // Intersect groups
1615 case 812: // Cut groups
1619 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1620 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1624 if ( checkLock( aStudy ) )
1627 EmitSignalDeactivateDialog();
1630 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1631 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1632 else aMode = SMESHGUI_GroupOpDlg::CUT;
1634 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1638 case 813: // Delete groups with their contents
1642 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1643 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1647 if ( checkLock( aStudy ) )
1650 EmitSignalDeactivateDialog();
1652 new SMESHGUI_DeleteGroupDlg( this );
1656 case 900: // MESH INFOS
1658 EmitSignalDeactivateDialog();
1659 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1660 SALOME_ListIO selected;
1662 aSel->selectedObjects( selected );
1664 if ( selected.Extent() > 1 ) { // a dlg for each IO
1666 SALOME_ListIteratorOfListIO It (selected);
1667 for ( ; It.More(); It.Next() ) {
1668 IOs.Clear(); IOs.Append( It.Value() );
1669 aSel->setSelectedObjects( IOs );
1670 new SMESHGUI_MeshInfosDlg(this, "", false);
1672 // restore selection
1673 aSel->setSelectedObjects( selected );
1676 new SMESHGUI_MeshInfosDlg(this, "", false);
1680 case 902: // STANDARD MESH INFOS
1682 EmitSignalDeactivateDialog();
1683 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1684 SALOME_ListIO selected;
1686 aSel->selectedObjects( selected );
1688 if ( selected.Extent() > 1 ) { // a dlg for each IO
1690 SALOME_ListIteratorOfListIO It (selected);
1691 for ( ; It.More(); It.Next() ) {
1693 IOs.Append( It.Value() );
1694 aSel->setSelectedObjects( IOs );
1695 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1697 // restore selection
1698 aSel->setSelectedObjects( selected );
1701 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1705 case 1100: // EDIT HYPOTHESIS
1707 if(checkLock(aStudy)) break;
1709 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1710 SALOME_ListIO selected;
1712 aSel->selectedObjects( selected );
1714 int nbSel = selected.Extent();
1717 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1719 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1720 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1721 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1722 if ( !Hyp->_is_nil() )
1724 char* sName = Hyp->GetName();
1725 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1727 aCreator->edit( Hyp.in(), desktop() );
1734 updateObjBrowser( true );
1738 case 1101: // RENAME
1740 if ( checkLock( aStudy ) )
1743 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1744 SALOME_ListIO selected;
1746 aSel->selectedObjects( selected );
1748 SALOME_ListIteratorOfListIO It( selected );
1749 for ( ; It.More(); It.Next() )
1751 Handle(SALOME_InteractiveObject) IObject = It.Value();
1752 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1753 _PTR(GenericAttribute) anAttr;
1754 _PTR(AttributeName) aName;
1757 if ( obj->FindAttribute(anAttr, "AttributeName") )
1760 QString newName = QString(aName->Value().c_str());
1762 newName = QInputDialog::getText( tr( "Rename" ), tr( "Enter new name:" ), QLineEdit::Normal,
1763 newName, &ok, desktop() );
1764 if ( ok && !newName.isEmpty() )
1766 //old source: aStudy->renameIObject( IObject, newName );
1767 aName->SetValue( newName.latin1() );
1769 // if current object is group update group's name
1770 SMESH::SMESH_GroupBase_var aGroup =
1771 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1772 if (!aGroup->_is_nil() )
1773 aGroup->SetName( newName.latin1() );
1783 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1785 if(checkLock(aStudy)) break;
1786 SUIT_OverrideCursor wc;
1788 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1789 SALOME_ListIO selected;
1791 aSel->selectedObjects( selected, QString::null, false );
1793 SALOME_ListIteratorOfListIO It(selected);
1794 for (int i = 0; It.More(); It.Next(), i++) {
1795 Handle(SALOME_InteractiveObject) IObject = It.Value();
1796 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1799 aSel->setSelectedObjects( l1 );
1804 case 401: // GEOM::EDGE
1805 case 4021: // TRIANGLE
1807 case 4023: // POLYGON
1811 if(checkLock(aStudy)) break;
1813 EmitSignalDeactivateDialog();
1814 SMDSAbs_ElementType type = SMDSAbs_Edge;
1816 switch (theCommandID) {
1817 case 4021: // TRIANGLE
1818 type = SMDSAbs_Face; nbNodes = 3; break;
1820 type = SMDSAbs_Face; nbNodes = 4; break;
1822 type = SMDSAbs_Volume; nbNodes = 4; break;
1823 case 4023: // POLYGON
1824 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1826 type = SMDSAbs_Volume; nbNodes = 8; break;
1827 case 4033: // POLYHEDRE
1828 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1831 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1834 SUIT_MessageBox::warn1(desktop(),
1835 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1836 tr("SMESH_BUT_OK"));
1840 case 4033: // POLYHEDRON
1842 if(checkLock(aStudy)) break;
1844 EmitSignalDeactivateDialog();
1845 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1848 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1849 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1850 tr("SMESH_BUT_OK"));
1854 case 4041: // REMOVES NODES
1856 if(checkLock(aStudy)) break;
1858 EmitSignalDeactivateDialog();
1859 new SMESHGUI_RemoveNodesDlg(this);
1862 SUIT_MessageBox::warn1(desktop(),
1863 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1864 tr("SMESH_BUT_OK"));
1868 case 4042: // REMOVES ELEMENTS
1870 if(checkLock(aStudy)) break;
1872 EmitSignalDeactivateDialog();
1873 new SMESHGUI_RemoveElementsDlg(this);
1877 SUIT_MessageBox::warn1(desktop(),
1878 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1879 tr("SMESH_BUT_OK"));
1883 case 4051: // RENUMBERING NODES
1885 if(checkLock(aStudy)) break;
1887 EmitSignalDeactivateDialog();
1888 new SMESHGUI_RenumberingDlg( this, "", 0);
1892 SUIT_MessageBox::warn1(desktop(),
1893 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1894 tr("SMESH_BUT_OK"));
1898 case 4052: // RENUMBERING ELEMENTS
1900 if(checkLock(aStudy)) break;
1902 EmitSignalDeactivateDialog();
1903 new SMESHGUI_RenumberingDlg( this, "", 1);
1907 SUIT_MessageBox::warn1(desktop(),
1908 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1909 tr("SMESH_BUT_OK"));
1913 case 4061: // TRANSLATION
1915 if(checkLock(aStudy)) break;
1917 EmitSignalDeactivateDialog();
1918 new SMESHGUI_TranslationDlg( this );
1921 SUIT_MessageBox::warn1(desktop(),
1922 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1923 tr("SMESH_BUT_OK"));
1927 case 4062: // ROTATION
1929 if(checkLock(aStudy)) break;
1931 EmitSignalDeactivateDialog();
1932 new SMESHGUI_RotationDlg( this );
1935 SUIT_MessageBox::warn1(desktop(),
1936 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1937 tr("SMESH_BUT_OK"));
1941 case 4063: // SYMMETRY
1943 if(checkLock(aStudy)) break;
1945 EmitSignalDeactivateDialog();
1946 new SMESHGUI_SymmetryDlg( this );
1949 SUIT_MessageBox::warn1(desktop(),
1950 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1951 tr("SMESH_BUT_OK"));
1955 case 4064: // SEWING
1957 if(checkLock(aStudy)) break;
1959 EmitSignalDeactivateDialog();
1960 new SMESHGUI_SewingDlg( this );
1963 SUIT_MessageBox::warn1(desktop(),
1964 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1965 tr("SMESH_BUT_OK"));
1969 case 4065: // MERGE NODES
1971 if(checkLock(aStudy)) break;
1973 EmitSignalDeactivateDialog();
1974 new SMESHGUI_MergeNodesDlg( this );
1977 SUIT_MessageBox::warn1(desktop(),
1978 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1979 tr("SMESH_BUT_OK"));
1983 case 4066: // MERGE EQUAL ELEMENTS
1985 if (checkLock(aStudy)) break;
1987 EmitSignalDeactivateDialog();
1988 new SMESHGUI_EditMeshDlg(this,
1989 "SMESH_MERGE_ELEMENTS_TITLE",
1990 "ICON_DLG_MERGE_ELEMENTS",
1991 1); // MergeEqualElemets
1993 SUIT_MessageBox::warn1(desktop(),
1994 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1995 tr("SMESH_BUT_OK"));
2000 case 5105: // Library of selection filters
2002 static QValueList<int> aTypes;
2003 if ( aTypes.isEmpty() )
2005 aTypes.append( SMESH::NODE );
2006 aTypes.append( SMESH::EDGE );
2007 aTypes.append( SMESH::FACE );
2008 aTypes.append( SMESH::VOLUME );
2010 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2014 case 6017: // CONTROLS
2030 LightApp_SelectionMgr* mgr = selectionMgr();
2031 SALOME_ListIO selected; mgr->selectedObjects( selected );
2033 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2034 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2036 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2037 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2038 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2039 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2040 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2041 ::Control( theCommandID );
2046 SUIT_MessageBox::warn1(desktop(),
2047 tr( "SMESH_WRN_WARNING" ),
2048 tr( "SMESH_BAD_SELECTION" ),
2049 tr( "SMESH_BUT_OK" ) );
2053 SUIT_MessageBox::warn1(desktop(),
2054 tr( "SMESH_WRN_WARNING" ),
2055 tr( "NOT_A_VTK_VIEWER" ),
2056 tr( "SMESH_BUT_OK" ) );
2061 LightApp_SelectionMgr* mgr = selectionMgr();
2062 SALOME_ListIO selected; mgr->selectedObjects( selected );
2064 if (selected.Extent() == 1) {
2065 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2066 if(anIObject->hasEntry())
2067 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2068 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2075 LightApp_SelectionMgr* mgr = selectionMgr();
2076 SALOME_ListIO selected; mgr->selectedObjects( selected );
2078 if (selected.Extent() == 1) {
2079 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2080 if(anIObject->hasEntry())
2081 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2082 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2089 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2090 //updateObjBrowser();
2094 //=============================================================================
2098 //=============================================================================
2099 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2104 //=============================================================================
2108 //=============================================================================
2109 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2114 //=============================================================================
2118 //=============================================================================
2119 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2124 //=============================================================================
2125 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2126 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2128 //=============================================================================
2129 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2130 SUIT_ViewWindow* wnd )
2132 if(theIO->hasEntry()){
2133 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2134 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2138 //=======================================================================
2139 // function : createSMESHAction
2141 //=======================================================================
2142 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2145 QWidget* parent = application()->desktop();
2146 SUIT_ResourceMgr* resMgr = resourceMgr();
2148 if ( icon_id.length() )
2149 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2151 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2152 if ( !pix.isNull() )
2153 icon = QIconSet( pix );
2155 QString tooltip = tr( QString( "TOP_" )+po_id ),
2156 menu = tr( QString( "MEN_" )+po_id ),
2157 status_bar = tr( QString( "STB_" )+po_id );
2159 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2162 //=======================================================================
2163 // function : createPopupItem
2165 //=======================================================================
2166 void SMESHGUI::createPopupItem( const int id,
2167 const QString& clients,
2168 const QString& types,
2169 const QString& theRule,
2174 parentId = popupMgr()->actionId( action( pId ) );
2176 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2177 popupMgr()->insert( action( id ), parentId, 0 );
2179 QChar lc = QtxPopupMgr::Selection::defEquality();
2180 QString rule = "(%1) and (%2) and (%3)";
2181 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2182 if( clients.isEmpty() )
2183 rule = rule.arg( QString( "true" ) );
2185 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2186 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2189 bool cont = myRules.contains( id );
2191 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2193 popupMgr()->setRule( action( id ), rule, true );
2194 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2197 //=======================================================================
2198 // function : initialize
2200 //=======================================================================
2201 void SMESHGUI::initialize( CAM_Application* app )
2203 SalomeApp_Module::initialize( app );
2205 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2207 /* Automatic Update flag */
2208 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2210 // ----- create actions --------------
2212 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2213 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2214 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2215 createSMESHAction( 114, "NUM" );
2216 createSMESHAction( 121, "DAT" );
2217 createSMESHAction( 122, "MED" );
2218 createSMESHAction( 123, "UNV" );
2219 createSMESHAction( 124, "EXPORT_DAT" );
2220 createSMESHAction( 125, "EXPORT_MED" );
2221 createSMESHAction( 126, "EXPORT_UNV" );
2222 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2223 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2224 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2225 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2226 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2227 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2228 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2229 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2230 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2231 createSMESHAction( 804, "ADD" );
2232 createSMESHAction( 805, "REMOVE" );
2233 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2234 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2235 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2236 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2237 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2238 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2239 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2240 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2241 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2242 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2243 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2244 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2245 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2246 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2247 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2248 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2249 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2250 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2251 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2252 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2253 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2254 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2255 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2256 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2257 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2258 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2259 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2260 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2261 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2262 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2263 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2264 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2265 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2266 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2267 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2268 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2269 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2270 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2271 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2272 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2273 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2274 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2275 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2276 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2277 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2278 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2279 createSMESHAction( 415, "MAP", "ICON_MAP" );
2280 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2281 createSMESHAction( 200, "RESET" );
2282 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2283 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2284 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2285 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2286 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2287 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2288 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2289 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2290 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2291 createSMESHAction( 220, "ALL" );
2292 createSMESHAction( 1100, "EDIT_HYPO" );
2293 createSMESHAction( 1101, "RENAME" );
2294 createSMESHAction( 1102, "UNASSIGN" );
2295 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2296 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2297 createSMESHAction( 1131, "DISPMODE" );
2298 createSMESHAction( 1132, "COLORS" );
2299 createSMESHAction( 1133, "TRANSP" );
2300 createSMESHAction( 1134, "CLIP" );
2301 createSMESHAction( 1135, "DISP_ENT" );
2302 createSMESHAction( 2000, "CTRL" );
2304 createSMESHAction( 300, "ERASE" );
2305 createSMESHAction( 301, "DISPLAY" );
2306 createSMESHAction( 302, "DISPLAY_ONLY" );
2307 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2309 // ----- create menu --------------
2310 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2311 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2312 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2313 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2314 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2315 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2316 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2318 createMenu( separator(), fileId );
2320 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2321 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2322 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2323 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2324 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2325 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2327 createMenu( 111, importId, -1 );
2328 createMenu( 112, importId, -1 );
2329 createMenu( 113, importId, -1 );
2331 createMenu( 121, exportId, -1 );
2332 createMenu( 122, exportId, -1 );
2333 createMenu( 123, exportId, -1 );
2335 createMenu( separator(), fileId, 10 );
2337 createMenu( 33, editId, -1 );
2339 createMenu( 5105, toolsId, -1 );
2341 createMenu( 702, meshId, -1 );
2342 createMenu( 703, meshId, -1 );
2343 createMenu( 704, meshId, -1 );
2344 createMenu( separator(), meshId, -1 );
2345 createMenu( 701, meshId, -1 );
2346 createMenu( separator(), meshId, -1 );
2347 createMenu( 801, meshId, -1 );
2348 createMenu( 802, meshId, -1 );
2349 createMenu( 803, meshId, -1 );
2350 createMenu( separator(), meshId, -1 );
2351 createMenu( 810, meshId, -1 );
2352 createMenu( 811, meshId, -1 );
2353 createMenu( 812, meshId, -1 );
2354 createMenu( separator(), meshId, -1 );
2355 createMenu( 813, meshId, -1 );
2356 createMenu( separator(), meshId, -1 );
2357 createMenu( 900, meshId, -1 );
2358 createMenu( 902, meshId, -1 );
2359 createMenu( separator(), meshId, -1 );
2361 createMenu( 6003, ctrlId, -1 );
2362 createMenu( 6001, ctrlId, -1 );
2363 createMenu( 6004, ctrlId, -1 );
2364 createMenu( separator(), ctrlId, -1 );
2365 createMenu( 6002, ctrlId, -1 );
2366 createMenu( 6018, ctrlId, -1 );
2367 createMenu( 6019, ctrlId, -1 );
2368 createMenu( 6011, ctrlId, -1 );
2369 createMenu( 6012, ctrlId, -1 );
2370 createMenu( 6013, ctrlId, -1 );
2371 createMenu( 6014, ctrlId, -1 );
2372 createMenu( 6015, ctrlId, -1 );
2373 createMenu( 6016, ctrlId, -1 );
2374 createMenu( separator(), ctrlId, -1 );
2375 createMenu( 6017, ctrlId, -1 );
2376 createMenu( 6009, ctrlId, -1 );
2377 createMenu( separator(), ctrlId, -1 );
2379 createMenu( 400, addId, -1 );
2380 createMenu( 401, addId, -1 );
2381 createMenu( 4021, addId, -1 );
2382 createMenu( 4022, addId, -1 );
2383 createMenu( 4023, addId, -1 );
2384 createMenu( 4031, addId, -1 );
2385 createMenu( 4032, addId, -1 );
2386 createMenu( 4033, addId, -1 );
2388 createMenu( 4041, removeId, -1 );
2389 createMenu( 4042, removeId, -1 );
2391 createMenu( 4051, renumId, -1 );
2392 createMenu( 4052, renumId, -1 );
2394 createMenu( 4061, transfId, -1 );
2395 createMenu( 4062, transfId, -1 );
2396 createMenu( 4063, transfId, -1 );
2397 createMenu( 4064, transfId, -1 );
2398 createMenu( 4065, transfId, -1 );
2399 createMenu( 4066, transfId, -1 );
2401 createMenu( 406, modifyId, -1 );
2402 createMenu( 407, modifyId, -1 );
2403 createMenu( 408, modifyId, -1 );
2404 createMenu( 409, modifyId, -1 );
2405 createMenu( 410, modifyId, -1 );
2406 createMenu( 411, modifyId, -1 );
2407 createMenu( 412, modifyId, -1 );
2408 createMenu( 413, modifyId, -1 );
2409 createMenu( 416, modifyId, -1 );
2410 createMenu( 414, modifyId, -1 );
2411 createMenu( 415, modifyId, -1 );
2413 createMenu( 214, viewId, -1 );
2415 // ----- create toolbars --------------
2416 int meshTb = createTool( tr( "TB_MESH" ) ),
2417 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2418 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2419 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2420 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2422 createTool( 702, meshTb );
2423 createTool( 703, meshTb );
2424 createTool( 704, meshTb );
2425 createTool( separator(), meshTb );
2426 createTool( 701, meshTb );
2427 createTool( separator(), meshTb );
2428 createTool( 801, meshTb );
2429 createTool( 802, meshTb );
2430 createTool( 803, meshTb );
2431 createTool( separator(), meshTb );
2432 createTool( 900, meshTb );
2433 createTool( 902, meshTb );
2434 createTool( separator(), meshTb );
2436 createTool( 6001, ctrlTb );
2437 createTool( 6003, ctrlTb );
2438 createTool( 6004, ctrlTb );
2439 createTool( separator(), ctrlTb );
2440 createTool( 6002, ctrlTb );
2441 createTool( 6018, ctrlTb );
2442 createTool( 6019, ctrlTb );
2443 createTool( 6011, ctrlTb );
2444 createTool( 6012, ctrlTb );
2445 createTool( 6013, ctrlTb );
2446 createTool( 6014, ctrlTb );
2447 createTool( 6015, ctrlTb );
2448 createTool( 6016, ctrlTb );
2449 createTool( separator(), ctrlTb );
2450 createTool( 6017, ctrlTb );
2451 createTool( 6009, ctrlTb );
2452 createTool( separator(), ctrlTb );
2454 createTool( 400, addRemTb );
2455 createTool( 401, addRemTb );
2456 createTool( 4021, addRemTb );
2457 createTool( 4022, addRemTb );
2458 createTool( 4023, addRemTb );
2459 createTool( 4031, addRemTb );
2460 createTool( 4032, addRemTb );
2461 createTool( 4033, addRemTb );
2462 createTool( separator(), addRemTb );
2463 createTool( 4041, addRemTb );
2464 createTool( 4042, addRemTb );
2465 createTool( separator(), addRemTb );
2466 createTool( 4051, addRemTb );
2467 createTool( 4052, addRemTb );
2468 createTool( separator(), addRemTb );
2469 createTool( 4061, addRemTb );
2470 createTool( 4062, addRemTb );
2471 createTool( 4063, addRemTb );
2472 createTool( 4064, addRemTb );
2473 createTool( 4065, addRemTb );
2474 createTool( 4066, addRemTb );
2475 createTool( separator(), addRemTb );
2477 createTool( 406, modifyTb );
2478 createTool( 407, modifyTb );
2479 createTool( 408, modifyTb );
2480 createTool( 409, modifyTb );
2481 createTool( 410, modifyTb );
2482 createTool( 411, modifyTb );
2483 createTool( 412, modifyTb );
2484 createTool( 413, modifyTb );
2485 createTool( 416, modifyTb );
2486 createTool( 414, modifyTb );
2487 createTool( 415, modifyTb );
2489 createTool( 214, dispModeTb );
2493 QString OB = "'ObjectBrowser'",
2494 View = "'" + SVTK_Viewer::Type() + "'",
2496 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2497 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2498 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2499 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2500 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2501 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2502 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2503 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2504 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2505 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2507 mesh_group = mesh + " " + subMesh + " " + group,
2508 hyp_alg = hypo + " " + algo;
2510 // popup for object browser
2512 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2513 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2514 createPopupItem( 803, OB, group ); // EDIT_GROUP
2515 popupMgr()->insert( separator(), -1, 0 );
2516 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2517 createPopupItem( 214, OB, mesh_group ); // UPDATE
2518 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2519 createPopupItem( 902, OB, mesh ); // STD_INFO
2520 popupMgr()->insert( separator(), -1, 0 );
2521 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2522 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2523 popupMgr()->insert( separator(), -1, 0 );
2524 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2525 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2526 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2527 popupMgr()->insert( separator(), -1, 0 );
2529 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2530 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2531 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2532 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2533 popupMgr()->insert( separator(), -1, 0 );
2536 createPopupItem( 803, View, group ); // EDIT_GROUP
2537 createPopupItem( 804, View, elems ); // ADD
2538 createPopupItem( 805, View, elems ); // REMOVE
2539 popupMgr()->insert( separator(), -1, 0 );
2540 createPopupItem( 214, View, mesh_group ); // UPDATE
2541 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2542 createPopupItem( 902, View, mesh ); // STD_INFO
2543 popupMgr()->insert( separator(), -1, 0 );
2547 isInvisible("not( isVisible )"),
2548 isEmpty("numberOfNodes = 0"),
2549 isNotEmpty("numberOfNodes <> 0"),
2551 // has nodes, edges, etc in VISIBLE! actor
2552 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2553 hasElems("(count( elemTypes ) > 0)"),
2554 hasDifferentElems("(count( elemTypes ) > 1)"),
2555 hasEdges("({'Edge'} in elemTypes)"),
2556 hasFaces("({'Face'} in elemTypes)"),
2557 hasVolumes("({'Volume'} in elemTypes)");
2559 QString lc = QtxPopupMgr::Selection::defEquality();
2560 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2561 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2562 aType = aType.arg( mesh_group );
2563 QString aMeshInVTK = aClient + "&&" + aType;
2565 //-------------------------------------------------
2567 //-------------------------------------------------
2568 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2570 popupMgr()->insert( action( 9010 ), anId, -1 );
2571 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2572 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2574 popupMgr()->insert( action( 9011 ), anId, -1 );
2575 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2576 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2578 popupMgr()->insert( separator(), -1, -1 );
2580 //-------------------------------------------------
2582 //-------------------------------------------------
2583 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2585 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2586 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2587 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2589 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2590 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2591 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2593 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2594 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2595 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2597 popupMgr()->insert( separator(), anId, -1 );
2599 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2600 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2601 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2603 //-------------------------------------------------
2605 //-------------------------------------------------
2606 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2608 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2610 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2611 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2612 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2614 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2615 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2616 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2618 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2619 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2620 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2622 popupMgr()->insert( separator(), anId, -1 );
2624 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2625 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2627 //-------------------------------------------------
2629 //-------------------------------------------------
2630 popupMgr()->insert( action( 1132 ), -1, -1 );
2631 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2633 //-------------------------------------------------
2635 //-------------------------------------------------
2636 popupMgr()->insert( action( 1133 ), -1, -1 );
2637 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2639 //-------------------------------------------------
2641 //-------------------------------------------------
2642 popupMgr()->insert( action( 1134 ), -1, -1 );
2643 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2645 popupMgr()->insert( separator(), -1, -1 );
2647 //-------------------------------------------------
2649 //-------------------------------------------------
2651 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2652 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2653 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2655 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2657 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2658 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2660 popupMgr()->insert( separator(), anId, -1 );
2662 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2663 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2664 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2666 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2667 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2668 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2670 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2671 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2672 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2674 popupMgr()->insert( separator(), anId, -1 );
2676 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2677 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2678 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2680 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2681 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2682 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2684 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2685 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2686 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2688 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2689 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2690 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2692 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2693 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2694 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2696 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2697 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2698 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2700 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2701 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2702 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2704 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2705 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2706 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2708 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2709 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2710 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2712 popupMgr()->insert( separator(), anId, -1 );
2714 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2715 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2716 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2718 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2719 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2720 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2722 popupMgr()->insert( separator(), anId, -1 );
2724 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2725 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2727 popupMgr()->insert( separator(), -1, -1 );
2729 //-------------------------------------------------
2731 //-------------------------------------------------
2732 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2733 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2734 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2736 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2737 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2738 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2739 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2741 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2742 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2744 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2745 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2747 popupMgr()->insert( separator(), -1, -1 );
2749 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2750 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2753 bool SMESHGUI::activateModule( SUIT_Study* study )
2755 bool res = SalomeApp_Module::activateModule( study );
2757 setMenuShown( true );
2758 setToolShown( true );
2763 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2765 setMenuShown( false );
2766 setToolShown( false );
2768 EmitSignalCloseAllDialogs();
2770 return SalomeApp_Module::deactivateModule( study );
2773 void SMESHGUI::OnGUIEvent()
2775 const QObject* obj = sender();
2776 if ( !obj || !obj->inherits( "QAction" ) )
2778 int id = actionId((QAction*)obj);
2783 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2785 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2786 if ( CORBA::is_nil( myComponentSMESH ) )
2788 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2790 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2791 return aGUI.myComponentSMESH;
2794 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2795 return myComponentSMESH;
2798 QString SMESHGUI::engineIOR() const
2800 CORBA::ORB_var anORB = getApp()->orb();
2801 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2805 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2807 SMESHGUI_Selection sel;
2808 sel.init( client, selectionMgr() );
2809 popupMgr()->updatePopup( menu, &sel );
2812 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2814 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2815 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2818 void SMESHGUI::viewManagers( QStringList& list ) const
2820 list.append( SVTK_Viewer::Type() );
2823 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
2825 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
2826 SMESH::UpdateSelectionProp( this );
2829 void SMESHGUI::createPreferences()
2831 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2833 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2834 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
2836 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2837 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
2838 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
2840 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2841 setPreferenceProperty( precGroup, "columns", 1 );
2843 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2845 setPreferenceProperty( prec, "min", 0 );
2846 setPreferenceProperty( prec, "max", 16 );
2848 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2849 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
2851 modes.append( "Wireframe" );
2852 modes.append( "Shading" );
2853 modes.append( "Nodes" );
2854 modes.append( "Shrink" );
2855 QValueList<QVariant> indices;
2856 indices.append( 0 );
2857 indices.append( 1 );
2858 indices.append( 2 );
2859 indices.append( 3 );
2860 setPreferenceProperty( dispmode, "strings", modes );
2861 setPreferenceProperty( dispmode, "indexes", indices );
2863 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
2864 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
2866 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2867 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2869 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
2870 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_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, LightApp_Preferences::Color, "SMESH", "fill_color" );
2878 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
2879 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
2880 addPreference( "", elemGroup, LightApp_Preferences::Space );
2882 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
2883 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_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, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
2896 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
2897 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_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, LightApp_Preferences::Color, "SMESH", "highlight_color" );
2905 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_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, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
2913 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_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, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2919 addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2920 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2921 addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_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, LightApp_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, LightApp_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, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2948 QStringList orients;
2949 orients.append( tr( "SMESH_VERTICAL" ) );
2950 orients.append( tr( "SMESH_HORIZONTAL" ) );
2951 indices.clear(); 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, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2957 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2958 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2959 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_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, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
2975 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
2976 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
2977 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_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 )
2997 if( sect=="SMESH" ){
2998 float sbX1,sbY1,sbW,sbH;
2999 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3000 if( name=="selection_object_color" || name=="selection_element_color" ||
3001 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3002 name=="selection_precision_node" || name=="selection_precision_element" )
3003 SMESH::UpdateSelectionProp( this );
3004 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3005 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3006 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3010 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3011 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3014 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3015 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3016 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3020 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3021 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3024 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3025 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3026 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3030 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3031 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3034 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3035 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3036 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3040 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3041 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3047 //================================================================================
3049 * \brief Update something in accordance with update flags
3050 * \param theFlags - update flags
3052 * Update viewer or/and object browser etc. in accordance with update flags ( see
3053 * LightApp_UpdateFlags enumeration ).
3055 //================================================================================
3056 void SMESHGUI::update( const int flags )
3058 if ( flags & UF_Viewer | flags & UF_Forced )
3059 SMESH::UpdateView();
3061 SalomeApp_Module::update( flags );
3064 //================================================================================
3066 * \brief Set default selection mode
3068 * SLOT called when operation commited. Sets default selection mode
3070 //================================================================================
3071 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3073 SVTK_ViewWindow* vtkWnd =
3074 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3076 vtkWnd->SetSelectionMode( ActorSelection );
3079 //================================================================================
3081 * \brief Set default selection mode
3083 * SLOT called when operation aborted. Sets default selection mode
3085 //================================================================================
3086 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3088 SVTK_ViewWindow* vtkWnd =
3089 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3091 vtkWnd->SetSelectionMode( ActorSelection );
3094 //================================================================================
3096 * \brief Creates operation with given identifier
3097 * \param id - identifier of operation to be started
3098 * \return Pointer on created operation or NULL if operation is not created
3100 * Virtual method redefined from the base class creates operation with given id.
3101 * It is called called automatically from startOperation method of base class.
3103 //================================================================================
3104 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3106 LightApp_Operation* op = 0;
3107 // to do : create operation here
3110 case 702: // Create mesh
3111 op = new SMESHGUI_MeshOp( true, true );
3113 case 703: // Create sub-mesh
3114 op = new SMESHGUI_MeshOp( true, false );
3116 case 704: // Edit mesh/sub-mesh
3117 op = new SMESHGUI_MeshOp( false );
3124 op = SalomeApp_Module::createOperation( id );
3128 //================================================================================
3130 * \brief Stops current operations and starts a given one
3131 * \param id - The id of the operation to start
3133 //================================================================================
3135 void SMESHGUI::switchToOperation(int id)
3137 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3138 activeStudy()->abortAllOperations();
3139 startOperation( id );
3142 LightApp_Displayer* SMESHGUI::displayer()
3145 myDisplayer = new SMESHGUI_Displayer( getApp() );