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_NameDlg.h"
85 #include "SalomeApp_DataOwner.h"
86 #include "SalomeApp_Application.h"
87 #include "SalomeApp_Preferences.h"
88 #include "SalomeApp_VTKSelector.h"
89 #include "SalomeApp_Operation.h"
90 #include "SalomeApp_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_ResourceMgr.h"
108 #include "SUIT_OverrideCursor.h"
109 #include "SUIT_Study.h"
110 #include "SUIT_Session.h"
112 #include "QtxPopupMgr.h"
114 #include "SALOME_ListIO.hxx"
115 #include "SALOME_ListIteratorOfListIO.hxx"
116 #include "SALOME_InteractiveObject.hxx"
117 #include "SALOME_NamingService.hxx"
118 #include "SALOME_LifeCycleCORBA.hxx"
120 #include "SALOMEconfig.h"
121 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
124 #define INCLUDE_MENUITEM_DEF
125 #include <qpopupmenu.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();
187 theComponentMesh->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
190 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
191 switch ( theCommandID ) {
194 aMeshes->length( 1 );
195 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
200 SMESH::DriverMED_ReadStatus res;
201 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
202 if ( res != SMESH::DRS_OK ) {
204 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
205 QObject::tr("SMESH_WRN_WARNING"),
206 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
207 QObject::tr("SMESH_BUT_OK"));
208 aMeshes->length( 0 );
215 bool isEmpty = false;
216 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
217 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
219 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
220 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
221 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
222 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
223 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
230 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
231 QObject::tr("SMESH_WRN_WARNING"),
232 QObject::tr("SMESH_DRS_EMPTY"),
233 QObject::tr("SMESH_BUT_OK"));
237 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
239 catch (const SALOME::SALOME_Exception& S_ex){
241 SalomeApp_Tools::QtCatchCorbaException(S_ex);
248 void ExportMeshToFile( int theCommandID )
250 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
251 SALOME_ListIO selected;
253 aSel->selectedObjects( selected );
255 if(selected.Extent()){
256 Handle(SALOME_InteractiveObject) anIObject = selected.First();
257 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
258 if ( !aMesh->_is_nil() ) {
259 QString aFilter, aTitle = QObject::tr("Export mesh");
260 QMap<QString, SMESH::MED_VERSION> aFilterMap;
261 switch ( theCommandID ) {
264 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
265 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
269 aFilter = QObject::tr("DAT files (*.dat)");
273 if(aMesh->NbPyramids()){
274 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
275 QObject::tr("SMESH_WRN_WARNING"),
276 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
277 QObject::tr("SMESH_BUT_YES"),
278 QObject::tr("SMESH_BUT_NO"),
283 aFilter = QObject::tr("IDEAS files (*.unv)");
290 SMESH::MED_VERSION aFormat;
292 if ( theCommandID != 122 && theCommandID != 125 )
293 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
297 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
298 filters.push_back( it.key() );
300 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
301 fd->setCaption( aTitle );
302 fd->setFilters( filters );
306 aFilename = fd->selectedFile();
307 aFormat = aFilterMap[fd->selectedFilter()];
309 if( !aFilename.isEmpty()
310 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
311 && aFormat==SMESH::MED_V2_1){
312 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
313 QObject::tr("SMESH_WRN_WARNING"),
314 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
315 QObject::tr("SMESH_BUT_YES"),
316 QObject::tr("SMESH_BUT_NO"),
325 if ( !aFilename.isEmpty() ) {
326 // Check whether the file already exists and delete it if yes
327 QFile aFile( aFilename );
328 if ( aFile.exists() )
330 SUIT_OverrideCursor wc;
331 switch ( theCommandID ) {
334 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
338 aMesh->ExportDAT( aFilename.latin1() );
342 aMesh->ExportUNV( aFilename.latin1() );
352 inline void InverseEntityMode(unsigned int& theOutputMode,
353 unsigned int theMode)
355 bool anIsNotPresent = ~theOutputMode & theMode;
357 theOutputMode |= theMode;
359 theOutputMode &= ~theMode;
362 void SetDisplayEntity(int theCommandID){
363 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
364 SALOME_ListIO selected;
366 aSel->selectedObjects( selected );
368 if(selected.Extent() >= 1){
369 SALOME_ListIteratorOfListIO It( selected );
370 for(; It.More(); It.Next()){
371 Handle(SALOME_InteractiveObject) IObject = It.Value();
372 if(IObject->hasEntry()){
373 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
374 unsigned int aMode = anActor->GetEntityMode();
375 switch(theCommandID){
377 InverseEntityMode(aMode,SMESH_Actor::eEdges);
380 InverseEntityMode(aMode,SMESH_Actor::eFaces);
383 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
386 aMode = SMESH_Actor::eAllEntity;
390 anActor->SetEntityMode(aMode);
397 void SetDisplayMode(int theCommandID){
398 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
399 SALOME_ListIO selected;
401 aSel->selectedObjects( selected );
403 if(selected.Extent() >= 1){
404 switch(theCommandID){
406 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
407 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
411 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
412 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
415 SALOME_ListIteratorOfListIO It( selected );
416 for(; It.More(); It.Next()){
417 Handle(SALOME_InteractiveObject) IObject = It.Value();
418 if(IObject->hasEntry()){
419 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
420 switch(theCommandID){
422 anActor->SetRepresentation(SMESH_Actor::eEdge);
425 anActor->SetRepresentation(SMESH_Actor::eSurface);
428 if(anActor->IsShrunk())
431 anActor->SetShrink();
434 anActor->SetRepresentation(SMESH_Actor::ePoint);
438 anActor->GetSufaceColor(color[0], color[1], color[2]);
439 int c0 = int (color[0] * 255);
440 int c1 = int (color[1] * 255);
441 int c2 = int (color[2] * 255);
442 QColor c(c0, c1, c2);
445 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
446 c0 = int (edgecolor[0] * 255);
447 c1 = int (edgecolor[1] * 255);
448 c2 = int (edgecolor[2] * 255);
449 QColor e(c0, c1, c2);
451 float backfacecolor[3];
452 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
453 c0 = int (backfacecolor[0] * 255);
454 c1 = int (backfacecolor[1] * 255);
455 c2 = int (backfacecolor[2] * 255);
456 QColor b(c0, c1, c2);
459 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
460 c0 = int (nodecolor[0] * 255);
461 c1 = int (nodecolor[1] * 255);
462 c2 = int (nodecolor[2] * 255);
463 QColor n(c0, c1, c2);
465 int Edgewidth = (int)anActor->GetLineWidth();
468 int intValue = int(anActor->GetNodeSize());
469 float Shrink = anActor->GetShrinkFactor();
471 SMESHGUI_Preferences_ColorDlg *aDlg =
472 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
473 aDlg->SetColor(1, c);
474 aDlg->SetColor(2, e);
475 aDlg->SetColor(3, n);
476 aDlg->SetColor(4, b);
477 aDlg->SetIntValue(1, Edgewidth);
478 aDlg->SetIntValue(2, intValue);
479 aDlg->SetIntValue(3, int(Shrink*100.));
481 QColor color = aDlg->GetColor(1);
482 QColor edgecolor = aDlg->GetColor(2);
483 QColor nodecolor = aDlg->GetColor(3);
484 QColor backfacecolor = aDlg->GetColor(4);
485 /* actor color and backface color */
486 anActor->SetSufaceColor(float (color.red()) / 255.,
487 float (color.green()) / 255.,
488 float (color.blue()) / 255.);
489 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
490 float (backfacecolor.green()) / 255.,
491 float (backfacecolor.blue()) / 255.);
494 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
495 float (edgecolor.green()) / 255.,
496 float (edgecolor.blue()) / 255.);
498 /* Shrink factor and size edges */
499 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
500 anActor->SetLineWidth(aDlg->GetIntValue(1));
502 /* Nodes color and size */
503 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
504 float (nodecolor.green()) / 255.,
505 float (nodecolor.blue()) / 255.);
506 anActor->SetNodeSize(aDlg->GetIntValue(2));
515 SMESH::RepaintCurrentView();
519 void Control( int theCommandID )
521 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
522 SALOME_ListIO selected;
524 aSel->selectedObjects( selected );
526 if( !selected.IsEmpty() ){
527 Handle(SALOME_InteractiveObject) anIO = selected.First();
530 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
531 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
532 switch ( theCommandID ){
534 aTitle = QObject::tr( "LENGTH_EDGES" );
535 aControl = SMESH_Actor::eLength;
538 aTitle = QObject::tr( "LENGTH2D_EDGES" );
539 aControl = SMESH_Actor::eLength2D;
542 aTitle = QObject::tr( "FREE_EDGES" );
543 aControl = SMESH_Actor::eFreeEdges;
546 aTitle = QObject::tr( "FREE_BORDERS" );
547 aControl = SMESH_Actor::eFreeBorders;
550 aTitle = QObject::tr( "MULTI_BORDERS" );
551 aControl = SMESH_Actor::eMultiConnection;
554 aTitle = QObject::tr( "MULTI2D_BORDERS" );
555 aControl = SMESH_Actor::eMultiConnection2D;
558 aTitle = QObject::tr( "AREA_ELEMENTS" );
559 aControl = SMESH_Actor::eArea;
562 aTitle = QObject::tr( "TAPER_ELEMENTS" );
563 aControl = SMESH_Actor::eTaper;
566 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
567 aControl = SMESH_Actor::eAspectRatio;
570 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
571 aControl = SMESH_Actor::eAspectRatio3D;
574 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
575 aControl = SMESH_Actor::eMinimumAngle;
578 aTitle = QObject::tr( "WARP_ELEMENTS" );
579 aControl = SMESH_Actor::eWarping;
582 aTitle = QObject::tr( "SKEW_ELEMENTS" );
583 aControl = SMESH_Actor::eSkew;
586 aTitle = QObject::tr( "VOLUME_3D_ELEMENTS" );
587 aControl = SMESH_Actor::eVolume3D;
590 anActor->SetControlMode(aControl);
591 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
592 SMESH::RepaintCurrentView();
599 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
600 MeshObjectType theType,
601 const QString theInTypeName,
602 QString & theOutTypeName)
604 SMESH_TypeFilter aTypeFilter( theType );
606 if( !theIO.IsNull() )
608 entry = theIO->getEntry();
609 SalomeApp_DataOwner owner( entry );
610 if ( aTypeFilter.isOk( &owner )) {
611 theOutTypeName = theInTypeName;
619 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
621 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
622 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
624 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
625 CORBA::String_var anID = aSComp->GetID().c_str();
626 if (!strcmp(anID.in(),theIO->getEntry()))
632 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
633 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
634 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
635 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
636 CheckOIType ( theIO, GROUP, "Group", aTypeName )
644 QString CheckHomogeneousSelection()
646 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
647 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
648 SALOME_ListIO selected;
650 aSel->selectedObjects( selected );
652 QString RefType = CheckTypeObject(selected.First());
653 SALOME_ListIteratorOfListIO It(selected);
654 for (; It.More(); It.Next())
656 Handle(SALOME_InteractiveObject) IObject = It.Value();
657 QString Type = CheckTypeObject(IObject);
658 if (Type.compare(RefType) != 0)
659 return "Heterogeneous Selection";
666 void SMESHGUI::OnEditDelete()
668 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
669 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
670 SALOME_ListIO selected; aSel->selectedObjects( selected );
672 QString aParentComponent = QString::null;
673 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
675 QString cur = anIt.Value()->getComponentDataType();
676 if( aParentComponent.isNull() )
677 aParentComponent = cur;
678 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
679 aParentComponent = "";
682 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
683 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
684 QObject::tr("ERR_ERROR"),
685 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
686 QObject::tr("BUT_OK") );
689 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
690 if (SUIT_MessageBox::warn2
691 (SMESHGUI::desktop(),
692 QObject::tr("SMESH_WRN_WARNING"),
693 QObject::tr("SMESH_REALLY_DELETE"),
694 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
697 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
698 SUIT_ViewManager* vm = anApp->activeViewManager();
699 int nbSf = vm->getViewsCount();
701 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
702 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
703 _PTR(GenericAttribute) anAttr;
704 _PTR(AttributeIOR) anIOR;
706 SALOME_ListIteratorOfListIO It(selected);
708 aStudyBuilder->NewCommand(); // There is a transaction
709 for(; It.More(); It.Next()){
710 Handle(SALOME_InteractiveObject) IObject = It.Value();
711 if(IObject->hasEntry()){
712 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
714 // disable removal of "SMESH" component object
715 if(SO->FindAttribute(anAttr, "AttributeIOR")){
717 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
721 /* Erase child graphical objects */
722 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
723 for(it->InitEx(true); it->More(); it->Next()){
724 _PTR(SObject) CSO = it->Value();
725 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
728 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
729 for(int i = 0; i < nbSf; i++){
730 SUIT_ViewWindow *sf = aViews[i];
731 CORBA::String_var anEntry = CSO->GetID().c_str();
732 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
733 SMESH::RemoveActor(sf,anActor);
739 /* Erase main graphical object */
740 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
741 for(int i = 0; i < nbSf; i++){
742 SUIT_ViewWindow *sf = aViews[i];
743 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
744 SMESH::RemoveActor(sf,anActor);
748 // Remove object(s) from data structures
749 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
751 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
752 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
753 QString objType = CheckTypeObject(IObject);
754 if ( !aGroup->_is_nil() ) { // DELETE GROUP
755 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
756 aMesh->RemoveGroup( aGroup );
758 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
759 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
760 aMesh->RemoveSubMesh( aSubMesh );
762 else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
763 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
764 aStudyBuilder->RemoveObjectWithChildren( obj );
766 else {// default action: remove SObject from the study
767 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
768 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
770 aStudyBuilder->RemoveObjectWithChildren( obj );
775 } /* IObject->hasEntry() */
777 aStudyBuilder->CommitCommand();
779 /* Clear any previous selection */
781 aSel->setSelectedObjects( l1 );
783 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
788 Standard_EXPORT CAM_Module* createModule()
790 return new SMESHGUI();
794 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
796 //=============================================================================
800 //=============================================================================
801 SMESHGUI::SMESHGUI() :
802 SalomeApp_Module( "SMESH" )
804 if ( CORBA::is_nil( myComponentSMESH ) )
806 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
807 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
808 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
811 myActiveDialogBox = 0;
815 SMESH::GetFilterManager();
818 /* load resources for all available meshers */
819 SMESH::InitAvailableHypotheses();
822 //=============================================================================
826 //=============================================================================
827 SMESHGUI::~SMESHGUI()
829 SMESH::GetFilterManager()->Destroy();
830 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
833 //=============================================================================
837 //=============================================================================
838 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
840 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
842 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
847 bool SMESHGUI::automaticUpdate()
849 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
853 return resMgr->booleanValue( "SMESH", "auto_update", false );
856 //=============================================================================
860 //=============================================================================
861 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
863 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
866 //=============================================================================
870 //=============================================================================
871 SMESHGUI* SMESHGUI::GetSMESHGUI()
873 SMESHGUI* smeshMod = 0;
874 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
877 CAM_Module* module = app->module( "Mesh" );
878 smeshMod = dynamic_cast<SMESHGUI*>( module );
881 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
883 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
886 _PTR(Study) aStudy = study->studyDS();
888 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
897 Standard_EXPORT SMESHGUI* GetComponentGUI()
899 return SMESHGUI::GetSMESHGUI();
903 //=============================================================================
907 //=============================================================================
908 void SMESHGUI::SetState(int aState)
913 //=============================================================================
917 //=============================================================================
918 void SMESHGUI::ResetState()
923 //=============================================================================
927 //=============================================================================
928 void SMESHGUI::EmitSignalDeactivateDialog()
930 emit SignalDeactivateActiveDialog();
933 //=============================================================================
937 //=============================================================================
938 void SMESHGUI::EmitSignalStudyFrameChanged()
940 emit SignalStudyFrameChanged();
943 //=============================================================================
947 //=============================================================================
948 void SMESHGUI::EmitSignalCloseAllDialogs()
950 emit SignalCloseAllDialogs();
953 //=============================================================================
957 //=============================================================================
958 QDialog *SMESHGUI::GetActiveDialogBox()
960 return myActiveDialogBox;
963 //=============================================================================
967 //=============================================================================
968 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
970 myActiveDialogBox = (QDialog *) aDlg;
974 //=============================================================================
978 //=============================================================================
979 SUIT_Desktop* SMESHGUI::desktop()
981 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
983 return app->desktop();
988 //=============================================================================
992 //=============================================================================
993 SalomeApp_Study* SMESHGUI::activeStudy()
995 SUIT_Application* app = SUIT_Session::session()->activeApplication();
997 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1002 //=============================================================================
1006 //=============================================================================
1007 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1009 /* Here the position is on the bottom right corner - 10 */
1010 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1012 SUIT_Desktop *PP = desktop();
1013 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1014 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1018 //=============================================================================
1022 //=============================================================================
1023 static int isStudyLocked(_PTR(Study) theStudy){
1024 return theStudy->GetProperties()->IsLocked();
1027 static bool checkLock(_PTR(Study) theStudy) {
1028 if (isStudyLocked(theStudy)) {
1029 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1030 QObject::tr("WRN_WARNING"),
1031 QObject::tr("WRN_STUDY_LOCKED"),
1032 QObject::tr("BUT_OK") );
1038 //=======================================================================
1039 //function : CheckActiveStudyLocked
1041 //=======================================================================
1043 bool SMESHGUI::isActiveStudyLocked()
1045 _PTR(Study) aStudy = activeStudy()->studyDS();
1046 return checkLock( aStudy );
1049 //=============================================================================
1053 //=============================================================================
1054 bool SMESHGUI::OnGUIEvent( int theCommandID )
1056 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1060 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1061 SUIT_ResourceMgr* mgr = resourceMgr();
1065 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1066 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1069 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1070 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1072 //QAction* act = action( theCommandID );
1074 switch (theCommandID) {
1076 if(checkLock(aStudy)) break;
1084 if(checkLock(aStudy)) break;
1085 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1089 case 122: // EXPORT MED
1096 ::ExportMeshToFile(theCommandID);
1100 case 200: // SCALAR BAR
1102 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1103 SALOME_ListIO selected;
1105 aSel->selectedObjects( selected );
1107 if( selected.Extent() ) {
1108 Handle(SALOME_InteractiveObject) anIO = selected.First();
1109 if( anIO->hasEntry() ) {
1110 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1111 anActor->SetControlMode( SMESH_Actor::eNone );
1119 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1123 case 1134: // Clipping
1124 case 1133: // Tranparency
1125 case 1132: // Colors / Size
1132 ::SetDisplayMode(theCommandID);
1138 case 219: // Volumes
1139 case 220: // All Entity
1140 ::SetDisplayEntity(theCommandID);
1145 if(checkLock(aStudy)) break;
1146 SMESH::UpdateView();
1149 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1150 aSel->setSelectedObjects( l );
1155 case 301: // DISPLAY
1156 case 302: // DISPLAY ONLY
1158 SMESH::EDisplaing anAction;
1159 switch (theCommandID) {
1160 case 300: anAction = SMESH::eErase; break;
1161 case 301: anAction = SMESH::eDisplay; break;
1162 case 302: anAction = SMESH::eDisplayOnly; break;
1165 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1166 SALOME_ListIO sel_objects, to_process;
1168 aSel->selectedObjects( sel_objects );
1170 SALOME_ListIteratorOfListIO anIt( sel_objects );
1171 for( ; anIt.More(); anIt.Next() )
1173 Handle( SALOME_InteractiveObject ) obj = anIt.Value();
1174 if( obj->hasEntry() )
1176 _PTR(SObject) SO = activeStudy()->studyDS()->FindObjectID( obj->getEntry() );
1177 if( SO && QString( SO->GetID().c_str() ) == SO->GetFatherComponent()->GetID().c_str() )
1178 { //component is selected
1179 _PTR(SComponent) SC( SO->GetFatherComponent() );
1180 _PTR(ChildIterator) anIter ( activeStudy()->studyDS()->NewChildIterator( SC ) );
1181 anIter->InitEx( true );
1182 while( anIter->More() )
1184 _PTR(SObject) valSO ( anIter->Value() );
1185 _PTR(SObject) refSO;
1186 if( !valSO->ReferencedObject( refSO ) )
1188 QString id = valSO->GetID().c_str(),
1189 comp = SC->ComponentDataType().c_str(),
1190 val = valSO->GetName().c_str();
1192 Handle( SALOME_InteractiveObject ) new_obj =
1193 new SALOME_InteractiveObject( id.latin1(), comp.latin1(), val.latin1() );
1194 to_process.Append( new_obj );
1201 to_process.Append( obj );
1205 SALOME_ListIteratorOfListIO It( to_process );
1206 for (; It.More(); It.Next()) {
1207 Handle(SALOME_InteractiveObject) IOS = It.Value();
1208 if (IOS->hasEntry()) {
1209 SMESH::UpdateView(anAction, IOS->getEntry());
1210 if (anAction == SMESH::eDisplayOnly)
1211 anAction = SMESH::eDisplay;
1216 if (anAction == SMESH::eErase) {
1218 aSel->setSelectedObjects( l1 );
1221 aSel->setSelectedObjects( to_process );
1227 if(checkLock(aStudy)) break;
1230 EmitSignalDeactivateDialog();
1232 new SMESHGUI_NodesDlg(this);
1235 SUIT_MessageBox::warn1(desktop(),
1236 tr("SMESH_WRN_WARNING"),
1237 tr("SMESH_WRN_VIEWER_VTK"),
1238 tr("SMESH_BUT_OK"));
1243 case 2151: // FILTER
1247 EmitSignalDeactivateDialog();
1248 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1253 case 406: // MOVE NODE
1257 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1258 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1262 if(checkLock(aStudy)) break;
1263 new SMESHGUI_MoveNodesDlg(this);
1267 case 701: // COMPUTE MESH
1269 if(checkLock(aStudy)) break;
1271 SalomeApp_SelectionMgr *Sel = selectionMgr();
1272 SALOME_ListIO selected; Sel->selectedObjects( selected );
1274 int nbSel = selected.Extent();
1279 SMESH::SMESH_Mesh_var aMesh;
1280 SMESH::SMESH_subMesh_var aSubMesh;
1281 Handle(SALOME_InteractiveObject) IObject = selected.First();
1282 if (IObject->hasEntry()){
1283 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1284 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1285 if ( aShapeObject->_is_nil() ) {
1290 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1291 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1293 if (!aMesh->_is_nil()){
1294 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1295 if (!refShapeObject->_is_nil()) {
1296 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1297 SUIT_MessageBox::warn1(desktop(),
1298 tr("SMESH_WRN_WARNING"),
1299 tr("SMESH_WRN_MISSING_PARAMETERS"),
1300 tr("SMESH_BUT_OK"));
1304 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1305 SMESH::ModifiedMesh(aMeshSObj,true);
1306 // TO Do : change icon of all submeshes
1308 SUIT_MessageBox::warn1(desktop(),
1309 tr("SMESH_WRN_WARNING"),
1310 tr("SMESH_WRN_COMPUTE_FAILED"),
1311 tr("SMESH_BUT_OK"));
1313 catch(const SALOME::SALOME_Exception & S_ex){
1314 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1317 }else if(!aSubMesh->_is_nil()){
1318 aMesh = aSubMesh->GetFather();
1319 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1320 if(!refShapeObject->_is_nil()){
1321 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1323 SUIT_MessageBox::warn1(desktop(),
1324 tr("SMESH_WRN_WARNING"),
1325 tr("SMESH_WRN_MISSING_PARAMETERS"),
1326 tr("SMESH_BUT_OK"));
1330 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1331 SMESH::ModifiedMesh(aMeshSObj,true);
1332 // TO Do : change icon of all submeshes
1334 SUIT_MessageBox::warn1(desktop(),
1335 tr("SMESH_WRN_WARNING"),
1336 tr("SMESH_WRN_COMPUTE_FAILED"),
1337 tr("SMESH_BUT_OK"));
1338 }catch(const SALOME::SALOME_Exception & S_ex){
1339 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1345 CORBA::Long anId = aStudy->StudyId();
1346 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1347 if ( automaticUpdate() && aVisualObj){
1348 aVisualObj->Update();
1349 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1351 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1353 SMESH::DisplayActor(view,anActor); //apo
1357 SMESH::RepaintCurrentView();
1360 SUIT_MessageBox::warn1(desktop(),
1361 tr("SMESH_WRN_WARNING"),
1362 tr("SMESH_WRN_VIEWER_VTK"),
1363 tr("SMESH_BUT_OK"));
1369 case 702: // Create mesh
1370 startOperation( 702 );
1372 case 703: // Create sub-mesh
1373 startOperation( 703 );
1375 case 704: // Edit mesh/sub-mesh
1376 startOperation( 704 );
1378 case 407: // DIAGONAL INVERSION
1379 case 408: // Delete diagonal
1383 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1384 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1388 if ( checkLock( aStudy ) )
1391 /*Standard_Boolean aRes;
1392 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1393 if ( aMesh->_is_nil() )
1395 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1396 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1400 EmitSignalDeactivateDialog();
1401 if ( theCommandID == 407 )
1402 new SMESHGUI_TrianglesInversionDlg(this);
1404 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1407 case 409: // Change orientation
1408 case 410: // Union of triangles
1409 case 411: // Cutting of quadrangles
1413 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1414 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1418 if ( checkLock( aStudy ) )
1421 EmitSignalDeactivateDialog();
1422 SMESHGUI_MultiEditDlg* aDlg = NULL;
1423 if ( theCommandID == 409 )
1424 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1425 else if ( theCommandID == 410 )
1426 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1428 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1431 DefineDlgPosition( aDlg, x, y );
1436 case 412: // Smoothing
1438 if(checkLock(aStudy)) break;
1440 EmitSignalDeactivateDialog();
1441 new SMESHGUI_SmoothingDlg( this );
1444 SUIT_MessageBox::warn1(desktop(),
1445 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1446 tr("SMESH_BUT_OK"));
1450 case 413: // Extrusion
1452 if (checkLock(aStudy)) break;
1454 EmitSignalDeactivateDialog();
1455 new SMESHGUI_ExtrusionDlg ( this );
1457 SUIT_MessageBox::warn1(desktop(),
1458 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1459 tr("SMESH_BUT_OK"));
1463 case 414: // Revolution
1465 if(checkLock(aStudy)) break;
1467 EmitSignalDeactivateDialog();
1468 new SMESHGUI_RevolutionDlg( this );
1471 SUIT_MessageBox::warn1(desktop(),
1472 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1473 tr("SMESH_BUT_OK"));
1477 case 415: // Pattern mapping
1479 if ( checkLock( aStudy ) )
1483 EmitSignalDeactivateDialog();
1484 new SMESHGUI_MeshPatternDlg( this );
1487 SUIT_MessageBox::warn1(desktop(),
1488 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1489 tr("SMESH_BUT_OK"));
1493 case 416: // Extrusion along a path
1495 if (checkLock(aStudy)) break;
1497 EmitSignalDeactivateDialog();
1498 new SMESHGUI_ExtrusionAlongPathDlg( this );
1500 SUIT_MessageBox::warn1(desktop(),
1501 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1502 tr("SMESH_BUT_OK"));
1506 case 801: // CREATE GROUP
1510 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1511 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1515 if(checkLock(aStudy)) break;
1516 EmitSignalDeactivateDialog();
1517 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1519 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1520 SALOME_ListIO selected;
1522 aSel->selectedObjects( selected );
1524 int nbSel = selected.Extent();
1526 // check if mesh is selected
1527 aMesh = SMESH::GetMeshByIO( selected.First() );
1529 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1534 case 802: // CONSTRUCT GROUP
1538 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1539 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1543 if(checkLock(aStudy)) break;
1544 EmitSignalDeactivateDialog();
1546 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1547 SALOME_ListIO selected;
1549 aSel->selectedObjects( selected );
1551 int nbSel = selected.Extent();
1553 // check if submesh is selected
1554 Handle(SALOME_InteractiveObject) IObject = selected.First();
1555 if (IObject->hasEntry()) {
1556 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1558 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1559 if (!aSubMesh->_is_nil()) {
1561 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1562 // get submesh elements list by types
1563 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1564 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1565 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1566 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1567 // create group for each type o elements
1568 QString aName = IObject->getName();
1569 if (aNodes->length() > 0) {
1570 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1571 aGroup->Add(aNodes.inout());
1573 if (aEdges->length() > 0) {
1574 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1575 aGroup->Add(aEdges.inout());
1577 if (aFaces->length() > 0) {
1578 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1579 aGroup->Add(aFaces.inout());
1581 if (aVolumes->length() > 0) {
1582 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1583 aGroup->Add(aVolumes.inout());
1587 }catch(const SALOME::SALOME_Exception & S_ex){
1588 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1597 case 803: // EDIT GROUP
1601 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1602 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1606 if(checkLock(aStudy)) break;
1607 EmitSignalDeactivateDialog();
1609 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1610 SALOME_ListIO selected;
1612 aSel->selectedObjects( selected );
1614 SALOME_ListIteratorOfListIO It (selected);
1615 int nbSelectedGroups = 0;
1616 for ( ; It.More(); It.Next() )
1618 SMESH::SMESH_Group_var aGroup =
1619 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1620 if (!aGroup->_is_nil()) {
1622 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1626 if (nbSelectedGroups == 0)
1628 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1634 case 804: // Add elements to group
1636 if(checkLock(aStudy)) break;
1637 if (myState == 800) {
1638 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1639 if (aDlg) aDlg->onAdd();
1644 case 805: // Remove elements from group
1646 if(checkLock(aStudy)) break;
1647 if (myState == 800) {
1648 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1649 if (aDlg) aDlg->onRemove();
1654 case 810: // Union Groups
1655 case 811: // Intersect groups
1656 case 812: // Cut groups
1660 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1661 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1665 if ( checkLock( aStudy ) )
1668 EmitSignalDeactivateDialog();
1671 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1672 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1673 else aMode = SMESHGUI_GroupOpDlg::CUT;
1675 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1679 case 813: // Delete groups with their contents
1683 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1684 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1688 if ( checkLock( aStudy ) )
1691 EmitSignalDeactivateDialog();
1693 new SMESHGUI_DeleteGroupDlg( this );
1697 case 900: // MESH INFOS
1699 EmitSignalDeactivateDialog();
1700 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1701 SALOME_ListIO selected;
1703 aSel->selectedObjects( selected );
1705 if ( selected.Extent() > 1 ) { // a dlg for each IO
1707 SALOME_ListIteratorOfListIO It (selected);
1708 for ( ; It.More(); It.Next() ) {
1709 IOs.Clear(); IOs.Append( It.Value() );
1710 aSel->setSelectedObjects( IOs );
1711 new SMESHGUI_MeshInfosDlg(this, "", false);
1713 // restore selection
1714 aSel->setSelectedObjects( selected );
1717 new SMESHGUI_MeshInfosDlg(this, "", false);
1721 case 902: // STANDARD MESH INFOS
1723 EmitSignalDeactivateDialog();
1724 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1725 SALOME_ListIO selected;
1727 aSel->selectedObjects( selected );
1729 if ( selected.Extent() > 1 ) { // a dlg for each IO
1731 SALOME_ListIteratorOfListIO It (selected);
1732 for ( ; It.More(); It.Next() ) {
1734 IOs.Append( It.Value() );
1735 aSel->setSelectedObjects( IOs );
1736 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1738 // restore selection
1739 aSel->setSelectedObjects( selected );
1742 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1746 case 1100: // EDIT HYPOTHESIS
1748 if(checkLock(aStudy)) break;
1750 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1751 SALOME_ListIO selected;
1753 aSel->selectedObjects( selected );
1755 int nbSel = selected.Extent();
1758 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1760 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1761 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1762 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1763 if ( !Hyp->_is_nil() )
1765 char* sName = Hyp->GetName();
1766 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1769 aCreator->EditHypothesis(Hyp);
1777 updateObjBrowser( true );
1781 case 1101: // RENAME
1783 if ( checkLock( aStudy ) )
1786 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1787 SALOME_ListIO selected;
1789 aSel->selectedObjects( selected );
1791 SALOME_ListIteratorOfListIO It( selected );
1792 for ( ; It.More(); It.Next() )
1794 Handle(SALOME_InteractiveObject) IObject = It.Value();
1795 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1796 _PTR(GenericAttribute) anAttr;
1797 _PTR(AttributeName) aName;
1800 if ( obj->FindAttribute(anAttr, "AttributeName") )
1803 QString newName = QString(aName->Value().c_str());
1804 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1805 if ( !newName.isEmpty() )
1807 //old source: aStudy->renameIObject( IObject, newName );
1808 aName->SetValue( newName.latin1() );
1810 // if current object is group update group's name
1811 SMESH::SMESH_GroupBase_var aGroup =
1812 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1813 if (!aGroup->_is_nil() )
1814 aGroup->SetName( newName.latin1() );
1824 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1826 if(checkLock(aStudy)) break;
1827 SUIT_OverrideCursor wc;
1829 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1830 SALOME_ListIO selected;
1832 aSel->selectedObjects( selected );
1834 SALOME_ListIteratorOfListIO It(selected);
1835 for (int i = 0; It.More(); It.Next(), i++) {
1836 Handle(SALOME_InteractiveObject) IObject = It.Value();
1837 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1840 aSel->setSelectedObjects( l1 );
1845 case 401: // GEOM::EDGE
1846 case 4021: // TRIANGLE
1848 case 4023: // POLYGON
1852 if(checkLock(aStudy)) break;
1854 EmitSignalDeactivateDialog();
1855 SMDSAbs_ElementType type = SMDSAbs_Edge;
1857 switch (theCommandID) {
1858 case 4021: // TRIANGLE
1859 type = SMDSAbs_Face; nbNodes = 3; break;
1861 type = SMDSAbs_Face; nbNodes = 4; break;
1863 type = SMDSAbs_Volume; nbNodes = 4; break;
1864 case 4023: // POLYGON
1865 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1867 type = SMDSAbs_Volume; nbNodes = 8; break;
1868 case 4033: // POLYHEDRE
1869 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1872 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1875 SUIT_MessageBox::warn1(desktop(),
1876 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1877 tr("SMESH_BUT_OK"));
1881 case 4033: // POLYHEDRON
1883 if(checkLock(aStudy)) break;
1885 EmitSignalDeactivateDialog();
1886 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1889 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1890 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1891 tr("SMESH_BUT_OK"));
1895 case 4041: // REMOVES NODES
1897 if(checkLock(aStudy)) break;
1899 EmitSignalDeactivateDialog();
1900 new SMESHGUI_RemoveNodesDlg(this);
1903 SUIT_MessageBox::warn1(desktop(),
1904 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1905 tr("SMESH_BUT_OK"));
1909 case 4042: // REMOVES ELEMENTS
1911 if(checkLock(aStudy)) break;
1913 EmitSignalDeactivateDialog();
1914 new SMESHGUI_RemoveElementsDlg(this);
1918 SUIT_MessageBox::warn1(desktop(),
1919 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1920 tr("SMESH_BUT_OK"));
1924 case 4051: // RENUMBERING NODES
1926 if(checkLock(aStudy)) break;
1928 EmitSignalDeactivateDialog();
1929 new SMESHGUI_RenumberingDlg( this, "", 0);
1933 SUIT_MessageBox::warn1(desktop(),
1934 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1935 tr("SMESH_BUT_OK"));
1939 case 4052: // RENUMBERING ELEMENTS
1941 if(checkLock(aStudy)) break;
1943 EmitSignalDeactivateDialog();
1944 new SMESHGUI_RenumberingDlg( this, "", 1);
1948 SUIT_MessageBox::warn1(desktop(),
1949 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1950 tr("SMESH_BUT_OK"));
1954 case 4061: // TRANSLATION
1956 if(checkLock(aStudy)) break;
1958 EmitSignalDeactivateDialog();
1959 new SMESHGUI_TranslationDlg( this );
1962 SUIT_MessageBox::warn1(desktop(),
1963 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1964 tr("SMESH_BUT_OK"));
1968 case 4062: // ROTATION
1970 if(checkLock(aStudy)) break;
1972 EmitSignalDeactivateDialog();
1973 new SMESHGUI_RotationDlg( this );
1976 SUIT_MessageBox::warn1(desktop(),
1977 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1978 tr("SMESH_BUT_OK"));
1982 case 4063: // SYMMETRY
1984 if(checkLock(aStudy)) break;
1986 EmitSignalDeactivateDialog();
1987 new SMESHGUI_SymmetryDlg( this );
1990 SUIT_MessageBox::warn1(desktop(),
1991 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1992 tr("SMESH_BUT_OK"));
1996 case 4064: // SEWING
1998 if(checkLock(aStudy)) break;
2000 EmitSignalDeactivateDialog();
2001 new SMESHGUI_SewingDlg( this );
2004 SUIT_MessageBox::warn1(desktop(),
2005 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2006 tr("SMESH_BUT_OK"));
2010 case 4065: // MERGE NODES
2012 if(checkLock(aStudy)) break;
2014 EmitSignalDeactivateDialog();
2015 new SMESHGUI_MergeNodesDlg( this );
2018 SUIT_MessageBox::warn1(desktop(),
2019 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2020 tr("SMESH_BUT_OK"));
2024 case 4066: // MERGE EQUAL ELEMENTS
2026 if (checkLock(aStudy)) break;
2028 EmitSignalDeactivateDialog();
2029 new SMESHGUI_EditMeshDlg(this,
2030 "SMESH_MERGE_ELEMENTS_TITLE",
2031 "ICON_DLG_MERGE_ELEMENTS",
2032 1); // MergeEqualElemets
2034 SUIT_MessageBox::warn1(desktop(),
2035 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2036 tr("SMESH_BUT_OK"));
2041 case 5105: // Library of selection filters
2043 static QValueList<int> aTypes;
2044 if ( aTypes.isEmpty() )
2046 aTypes.append( SMESH::NODE );
2047 aTypes.append( SMESH::EDGE );
2048 aTypes.append( SMESH::FACE );
2049 aTypes.append( SMESH::VOLUME );
2051 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2055 case 6017: // CONTROLS
2071 SalomeApp_SelectionMgr* mgr = selectionMgr();
2072 SALOME_ListIO selected; mgr->selectedObjects( selected );
2074 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2075 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2077 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2078 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2079 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2080 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2081 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2082 ::Control( theCommandID );
2087 SUIT_MessageBox::warn1(desktop(),
2088 tr( "SMESH_WRN_WARNING" ),
2089 tr( "SMESH_BAD_SELECTION" ),
2090 tr( "SMESH_BUT_OK" ) );
2094 SUIT_MessageBox::warn1(desktop(),
2095 tr( "SMESH_WRN_WARNING" ),
2096 tr( "NOT_A_VTK_VIEWER" ),
2097 tr( "SMESH_BUT_OK" ) );
2102 SalomeApp_SelectionMgr* mgr = selectionMgr();
2103 SALOME_ListIO selected; mgr->selectedObjects( selected );
2105 if (selected.Extent() == 1) {
2106 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2107 if(anIObject->hasEntry())
2108 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2109 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2116 SalomeApp_SelectionMgr* mgr = selectionMgr();
2117 SALOME_ListIO selected; mgr->selectedObjects( selected );
2119 if (selected.Extent() == 1) {
2120 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2121 if(anIObject->hasEntry())
2122 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2123 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2130 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2131 //updateObjBrowser();
2135 //=============================================================================
2139 //=============================================================================
2140 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2145 //=============================================================================
2149 //=============================================================================
2150 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2155 //=============================================================================
2159 //=============================================================================
2160 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2165 //=============================================================================
2166 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2167 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2169 //=============================================================================
2170 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2171 SUIT_ViewWindow* wnd )
2173 if(theIO->hasEntry()){
2174 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2175 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2179 //=======================================================================
2180 // function : createSMESHAction
2182 //=======================================================================
2183 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2186 QWidget* parent = application()->desktop();
2187 SUIT_ResourceMgr* resMgr = resourceMgr();
2189 if ( icon_id.length() )
2190 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2192 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2193 if ( !pix.isNull() )
2194 icon = QIconSet( pix );
2196 QString tooltip = tr( QString( "TOP_" )+po_id ),
2197 menu = tr( QString( "MEN_" )+po_id ),
2198 status_bar = tr( QString( "STB_" )+po_id );
2200 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2203 //=======================================================================
2204 // function : createPopupItem
2206 //=======================================================================
2207 void SMESHGUI::createPopupItem( const int id,
2208 const QString& clients,
2209 const QString& types,
2210 const QString& theRule,
2215 parentId = popupMgr()->actionId( action( pId ) );
2217 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2218 popupMgr()->insert( action( id ), parentId, 0 );
2220 QChar lc = QtxPopupMgr::Selection::defEquality();
2221 QString rule = "(%1) and (%2) and (%3)";
2222 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2223 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2224 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2227 bool cont = myRules.contains( id );
2229 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2231 popupMgr()->setRule( action( id ), rule, true );
2232 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2235 //=======================================================================
2236 // function : initialize
2238 //=======================================================================
2239 void SMESHGUI::initialize( CAM_Application* app )
2241 SalomeApp_Module::initialize( app );
2243 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2245 /* Automatic Update flag */
2246 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2248 // ----- create actions --------------
2250 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2251 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2252 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2253 createSMESHAction( 114, "NUM" );
2254 createSMESHAction( 121, "DAT" );
2255 createSMESHAction( 122, "MED" );
2256 createSMESHAction( 123, "UNV" );
2257 createSMESHAction( 124, "EXPORT_DAT" );
2258 createSMESHAction( 125, "EXPORT_MED" );
2259 createSMESHAction( 126, "EXPORT_UNV" );
2260 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2261 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2262 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2263 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2264 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2265 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2266 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2267 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2268 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2269 createSMESHAction( 804, "ADD" );
2270 createSMESHAction( 805, "REMOVE" );
2271 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2272 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2273 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2274 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2275 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2276 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2277 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2278 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2279 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2280 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2281 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2282 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2283 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2284 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2285 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2286 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2287 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2288 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2289 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2290 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2291 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2292 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2293 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2294 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2295 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2296 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2297 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2298 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2299 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2300 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2301 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2302 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2303 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2304 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2305 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2306 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2307 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2308 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2309 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2310 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2311 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2312 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2313 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2314 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2315 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2316 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2317 createSMESHAction( 415, "MAP", "ICON_MAP" );
2318 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2319 createSMESHAction( 200, "RESET" );
2320 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2321 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2322 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2323 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2324 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2325 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2326 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2327 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2328 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2329 createSMESHAction( 220, "ALL" );
2330 createSMESHAction( 1100, "EDIT_HYPO" );
2331 createSMESHAction( 1101, "RENAME" );
2332 createSMESHAction( 1102, "UNASSIGN" );
2333 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2334 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2335 createSMESHAction( 1131, "DISPMODE" );
2336 createSMESHAction( 1132, "COLORS" );
2337 createSMESHAction( 1133, "TRANSP" );
2338 createSMESHAction( 1134, "CLIP" );
2339 createSMESHAction( 1135, "DISP_ENT" );
2340 createSMESHAction( 2000, "CTRL" );
2342 createSMESHAction( 300, "ERASE" );
2343 createSMESHAction( 301, "DISPLAY" );
2344 createSMESHAction( 302, "DISPLAY_ONLY" );
2345 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2347 // ----- create menu --------------
2348 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2349 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2350 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2351 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2352 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2353 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2354 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2356 createMenu( separator(), fileId );
2358 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2359 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2360 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2361 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2362 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2363 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2365 createMenu( 111, importId, -1 );
2366 createMenu( 112, importId, -1 );
2367 createMenu( 113, importId, -1 );
2369 createMenu( 121, exportId, -1 );
2370 createMenu( 122, exportId, -1 );
2371 createMenu( 123, exportId, -1 );
2373 createMenu( separator(), fileId, 10 );
2375 createMenu( 33, editId, -1 );
2377 createMenu( 5105, toolsId, -1 );
2379 createMenu( 702, meshId, -1 );
2380 createMenu( 703, meshId, -1 );
2381 createMenu( 704, meshId, -1 );
2382 createMenu( separator(), meshId, -1 );
2383 createMenu( 701, meshId, -1 );
2384 createMenu( separator(), meshId, -1 );
2385 createMenu( 801, meshId, -1 );
2386 createMenu( 802, meshId, -1 );
2387 createMenu( 803, meshId, -1 );
2388 createMenu( separator(), meshId, -1 );
2389 createMenu( 810, meshId, -1 );
2390 createMenu( 811, meshId, -1 );
2391 createMenu( 812, meshId, -1 );
2392 createMenu( separator(), meshId, -1 );
2393 createMenu( 813, meshId, -1 );
2394 createMenu( separator(), meshId, -1 );
2395 createMenu( 900, meshId, -1 );
2396 createMenu( 902, meshId, -1 );
2397 createMenu( separator(), meshId, -1 );
2399 createMenu( 6003, ctrlId, -1 );
2400 createMenu( 6001, ctrlId, -1 );
2401 createMenu( 6004, ctrlId, -1 );
2402 createMenu( separator(), ctrlId, -1 );
2403 createMenu( 6002, ctrlId, -1 );
2404 createMenu( 6018, ctrlId, -1 );
2405 createMenu( 6019, ctrlId, -1 );
2406 createMenu( 6011, ctrlId, -1 );
2407 createMenu( 6012, ctrlId, -1 );
2408 createMenu( 6013, ctrlId, -1 );
2409 createMenu( 6014, ctrlId, -1 );
2410 createMenu( 6015, ctrlId, -1 );
2411 createMenu( 6016, ctrlId, -1 );
2412 createMenu( separator(), ctrlId, -1 );
2413 createMenu( 6017, ctrlId, -1 );
2414 createMenu( 6009, ctrlId, -1 );
2415 createMenu( separator(), ctrlId, -1 );
2417 createMenu( 400, addId, -1 );
2418 createMenu( 401, addId, -1 );
2419 createMenu( 4021, addId, -1 );
2420 createMenu( 4022, addId, -1 );
2421 createMenu( 4023, addId, -1 );
2422 createMenu( 4031, addId, -1 );
2423 createMenu( 4032, addId, -1 );
2424 createMenu( 4033, addId, -1 );
2426 createMenu( 4041, removeId, -1 );
2427 createMenu( 4042, removeId, -1 );
2429 createMenu( 4051, renumId, -1 );
2430 createMenu( 4052, renumId, -1 );
2432 createMenu( 4061, transfId, -1 );
2433 createMenu( 4062, transfId, -1 );
2434 createMenu( 4063, transfId, -1 );
2435 createMenu( 4064, transfId, -1 );
2436 createMenu( 4065, transfId, -1 );
2437 createMenu( 4066, transfId, -1 );
2439 createMenu( 406, modifyId, -1 );
2440 createMenu( 407, modifyId, -1 );
2441 createMenu( 408, modifyId, -1 );
2442 createMenu( 409, modifyId, -1 );
2443 createMenu( 410, modifyId, -1 );
2444 createMenu( 411, modifyId, -1 );
2445 createMenu( 412, modifyId, -1 );
2446 createMenu( 413, modifyId, -1 );
2447 createMenu( 416, modifyId, -1 );
2448 createMenu( 414, modifyId, -1 );
2449 createMenu( 415, modifyId, -1 );
2451 createMenu( 214, viewId, -1 );
2453 // ----- create toolbars --------------
2454 int meshTb = createTool( tr( "TB_MESH" ) ),
2455 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2456 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2457 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2458 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2460 createTool( 702, meshTb );
2461 createTool( 703, meshTb );
2462 createTool( 704, meshTb );
2463 createTool( separator(), meshTb );
2464 createTool( 701, meshTb );
2465 createTool( separator(), meshTb );
2466 createTool( 801, meshTb );
2467 createTool( 802, meshTb );
2468 createTool( 803, meshTb );
2469 createTool( separator(), meshTb );
2470 createTool( 900, meshTb );
2471 createTool( 902, meshTb );
2472 createTool( separator(), meshTb );
2474 createTool( 6001, ctrlTb );
2475 createTool( 6003, ctrlTb );
2476 createTool( 6004, ctrlTb );
2477 createTool( separator(), ctrlTb );
2478 createTool( 6002, ctrlTb );
2479 createTool( 6018, ctrlTb );
2480 createTool( 6019, ctrlTb );
2481 createTool( 6011, ctrlTb );
2482 createTool( 6012, ctrlTb );
2483 createTool( 6013, ctrlTb );
2484 createTool( 6014, ctrlTb );
2485 createTool( 6015, ctrlTb );
2486 createTool( 6016, ctrlTb );
2487 createTool( separator(), ctrlTb );
2488 createTool( 6017, ctrlTb );
2489 createTool( 6009, ctrlTb );
2490 createTool( separator(), ctrlTb );
2492 createTool( 400, addRemTb );
2493 createTool( 401, addRemTb );
2494 createTool( 4021, addRemTb );
2495 createTool( 4022, addRemTb );
2496 createTool( 4023, addRemTb );
2497 createTool( 4031, addRemTb );
2498 createTool( 4032, addRemTb );
2499 createTool( 4033, addRemTb );
2500 createTool( separator(), addRemTb );
2501 createTool( 4041, addRemTb );
2502 createTool( 4042, addRemTb );
2503 createTool( separator(), addRemTb );
2504 createTool( 4051, addRemTb );
2505 createTool( 4052, addRemTb );
2506 createTool( separator(), addRemTb );
2507 createTool( 4061, addRemTb );
2508 createTool( 4062, addRemTb );
2509 createTool( 4063, addRemTb );
2510 createTool( 4064, addRemTb );
2511 createTool( 4065, addRemTb );
2512 createTool( 4066, addRemTb );
2513 createTool( separator(), addRemTb );
2515 createTool( 406, modifyTb );
2516 createTool( 407, modifyTb );
2517 createTool( 408, modifyTb );
2518 createTool( 409, modifyTb );
2519 createTool( 410, modifyTb );
2520 createTool( 411, modifyTb );
2521 createTool( 412, modifyTb );
2522 createTool( 413, modifyTb );
2523 createTool( 416, modifyTb );
2524 createTool( 414, modifyTb );
2525 createTool( 415, modifyTb );
2527 createTool( 214, dispModeTb );
2531 QString OB = "'ObjectBrowser'",
2532 View = "'" + SVTK_Viewer::Type() + "'",
2534 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2535 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2536 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2537 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2538 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2539 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2540 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2541 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2542 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2543 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2545 mesh_group = mesh + " " + subMesh + " " + group,
2546 hyp_alg = hypo + " " + algo;
2548 // popup for object browser
2550 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2551 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2552 createPopupItem( 803, OB, group ); // EDIT_GROUP
2553 popupMgr()->insert( separator(), -1, 0 );
2554 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2555 createPopupItem( 214, OB, mesh_group ); // UPDATE
2556 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2557 createPopupItem( 902, OB, mesh ); // STD_INFO
2558 popupMgr()->insert( separator(), -1, 0 );
2559 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2560 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2561 popupMgr()->insert( separator(), -1, 0 );
2562 createPopupItem( 1100, OB, hypo, "&& $hasReference={false}" ); // EDIT HYPOTHESIS
2563 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2564 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "&& $hasReference={false}" ); // RENAME
2565 popupMgr()->insert( separator(), -1, 0 );
2566 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2567 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2568 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2569 popupMgr()->insert( separator(), -1, 0 );
2572 createPopupItem( 803, View, group ); // EDIT_GROUP
2573 createPopupItem( 804, View, elems ); // ADD
2574 createPopupItem( 805, View, elems ); // REMOVE
2575 popupMgr()->insert( separator(), -1, 0 );
2576 createPopupItem( 214, View, mesh_group ); // UPDATE
2577 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2578 createPopupItem( 902, View, mesh ); // STD_INFO
2579 popupMgr()->insert( separator(), -1, 0 );
2583 isInvisible("not( isVisible )"),
2584 isEmpty("numberOfNodes = 0"),
2585 isNotEmpty("numberOfNodes <> 0"),
2587 // has nodes, edges, etc in VISIBLE! actor
2588 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2589 hasElems("(count( elemTypes ) > 0)"),
2590 hasDifferentElems("(count( elemTypes ) > 1)"),
2591 hasEdges("({'Edge'} in elemTypes)"),
2592 hasFaces("({'Face'} in elemTypes)"),
2593 hasVolumes("({'Volume'} in elemTypes)");
2595 QString lc = QtxPopupMgr::Selection::defEquality();
2596 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2597 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2598 aType = aType.arg( mesh_group );
2599 QString aMeshInVTK = aClient + "&&" + aType;
2601 //-------------------------------------------------
2603 //-------------------------------------------------
2604 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2606 popupMgr()->insert( action( 9010 ), anId, -1 );
2607 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2608 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2610 popupMgr()->insert( action( 9011 ), anId, -1 );
2611 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2612 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2614 popupMgr()->insert( separator(), -1, -1 );
2616 //-------------------------------------------------
2618 //-------------------------------------------------
2619 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2621 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2622 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2623 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2625 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2626 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2627 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2629 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2630 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2631 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2633 popupMgr()->insert( separator(), anId, -1 );
2635 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2636 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2637 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2639 //-------------------------------------------------
2641 //-------------------------------------------------
2642 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2644 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2646 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2647 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2648 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2650 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2651 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2652 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2654 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2655 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2656 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2658 popupMgr()->insert( separator(), anId, -1 );
2660 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2661 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2663 //-------------------------------------------------
2665 //-------------------------------------------------
2666 popupMgr()->insert( action( 1132 ), -1, -1 );
2667 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2669 //-------------------------------------------------
2671 //-------------------------------------------------
2672 popupMgr()->insert( action( 1133 ), -1, -1 );
2673 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2675 //-------------------------------------------------
2677 //-------------------------------------------------
2678 popupMgr()->insert( action( 1134 ), -1, -1 );
2679 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2681 popupMgr()->insert( separator(), -1, -1 );
2683 //-------------------------------------------------
2685 //-------------------------------------------------
2687 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2688 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2689 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2691 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2693 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2694 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2696 popupMgr()->insert( separator(), anId, -1 );
2698 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2699 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2700 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2702 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2703 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2704 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2706 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2707 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2708 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2710 popupMgr()->insert( separator(), anId, -1 );
2712 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2713 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2714 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2716 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2717 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2718 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2720 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2721 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2722 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2724 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2725 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2726 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2728 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2729 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2730 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2732 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2733 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2734 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2736 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2737 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2738 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2740 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2741 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2742 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2744 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2745 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2746 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2748 popupMgr()->insert( separator(), anId, -1 );
2750 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2751 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2752 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2754 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2755 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2756 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2758 popupMgr()->insert( separator(), anId, -1 );
2760 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2761 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2763 popupMgr()->insert( separator(), -1, -1 );
2765 //-------------------------------------------------
2767 //-------------------------------------------------
2768 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2769 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2770 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2772 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2773 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2774 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2775 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2777 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2778 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2780 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2781 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2783 popupMgr()->insert( separator(), -1, -1 );
2785 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2786 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2789 bool SMESHGUI::activateModule( SUIT_Study* study )
2791 bool res = SalomeApp_Module::activateModule( study );
2793 setMenuShown( true );
2794 setToolShown( true );
2799 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2801 setMenuShown( false );
2802 setToolShown( false );
2804 EmitSignalCloseAllDialogs();
2806 return SalomeApp_Module::deactivateModule( study );
2809 void SMESHGUI::OnGUIEvent()
2811 const QObject* obj = sender();
2812 if ( !obj || !obj->inherits( "QAction" ) )
2814 int id = actionId((QAction*)obj);
2819 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2821 if ( CORBA::is_nil( myComponentSMESH ) )
2823 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2824 return aGUI.myComponentSMESH;
2826 return myComponentSMESH;
2829 QString SMESHGUI::engineIOR() const
2831 CORBA::ORB_var anORB = getApp()->orb();
2832 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2836 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2838 SMESHGUI_Selection sel;
2839 sel.init( client, selectionMgr() );
2840 popupMgr()->updatePopup( menu, &sel );
2843 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2845 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2846 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2849 void SMESHGUI::viewManagers( QStringList& list ) const
2851 list.append( SVTK_Viewer::Type() );
2854 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
2856 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
2857 SMESH::UpdateSelectionProp( this );
2860 void SMESHGUI::createPreferences()
2862 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2864 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2865 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, SalomeApp_Preferences::Bool, "SMESH", "auto_update" );
2867 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2868 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "display_entity" );
2869 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "use_precision" );
2871 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2872 setPreferenceProperty( precGroup, "columns", 1 );
2874 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2876 setPreferenceProperty( prec, "min", 0 );
2877 setPreferenceProperty( prec, "max", 16 );
2879 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2880 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, SalomeApp_Preferences::Selector, "SMESH", "display_mode" );
2882 modes.append( "Wireframe" );
2883 modes.append( "Shading" );
2884 modes.append( "Nodes" );
2885 modes.append( "Shrink" );
2886 QValueList<QVariant> indices;
2887 indices.append( 0 );
2888 indices.append( 1 );
2889 indices.append( 2 );
2890 indices.append( 3 );
2891 setPreferenceProperty( dispmode, "strings", modes );
2892 setPreferenceProperty( dispmode, "indexes", indices );
2894 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2895 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2897 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
2898 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
2900 setPreferenceProperty( nodeSz, "min", 1 );
2901 setPreferenceProperty( nodeSz, "max", 5 );
2903 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2905 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
2906 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
2907 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
2908 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
2910 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
2911 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2913 setPreferenceProperty( elemW, "min", 1 );
2914 setPreferenceProperty( elemW, "max", 5 );
2916 setPreferenceProperty( shrink, "min", 0 );
2917 setPreferenceProperty( shrink, "max", 100 );
2919 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2921 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2923 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
2924 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
2925 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
2927 setPreferenceProperty( selW, "min", 1 );
2928 setPreferenceProperty( selW, "max", 5 );
2930 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2932 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
2933 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2935 setPreferenceProperty( preW, "min", 1 );
2936 setPreferenceProperty( preW, "max", 5 );
2938 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2940 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
2941 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
2943 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2944 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2946 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2947 addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2948 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2949 addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
2952 fam.append( tr( "SMESH_FONT_ARIAL" ) );
2953 fam.append( tr( "SMESH_FONT_COURIER" ) );
2954 fam.append( tr( "SMESH_FONT_TIMES" ) );
2955 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2957 setPreferenceProperty( tfont, "families", fam );
2958 setPreferenceProperty( tfont, "system", false );
2959 setPreferenceProperty( tfont, "widget_flags", wflag );
2960 setPreferenceProperty( lfont, "families", fam );
2961 setPreferenceProperty( lfont, "system", false );
2962 setPreferenceProperty( lfont, "widget_flags", wflag );
2964 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
2966 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
2967 setPreferenceProperty( numcol, "min", 2 );
2968 setPreferenceProperty( numcol, "max", 256 );
2970 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
2971 setPreferenceProperty( numlab, "min", 2 );
2972 setPreferenceProperty( numlab, "max", 65 );
2974 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
2975 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2976 QStringList orients;
2977 orients.append( tr( "SMESH_VERTICAL" ) );
2978 orients.append( tr( "SMESH_HORIZONTAL" ) );
2979 indices.clear(); indices.append( 0 ); indices.append( 1 );
2980 setPreferenceProperty( orient, "strings", orients );
2981 setPreferenceProperty( orient, "indexes", indices );
2983 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
2984 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2985 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2986 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2987 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
2988 setPreferenceProperty( xv, "step", 0.1 );
2989 setPreferenceProperty( xv, "min", 0.0 );
2990 setPreferenceProperty( xv, "max", 1.0 );
2991 setPreferenceProperty( yv, "step", 0.1 );
2992 setPreferenceProperty( yv, "min", 0.0 );
2993 setPreferenceProperty( yv, "max", 1.0 );
2994 setPreferenceProperty( wv, "step", 0.1 );
2995 setPreferenceProperty( wv, "min", 0.0 );
2996 setPreferenceProperty( wv, "max", 1.0 );
2997 setPreferenceProperty( hv, "min", 0.0 );
2998 setPreferenceProperty( hv, "max", 1.0 );
2999 setPreferenceProperty( hv, "step", 0.1 );
3001 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3002 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3003 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3004 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3005 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3006 setPreferenceProperty( xv, "min", 0.0 );
3007 setPreferenceProperty( xv, "max", 1.0 );
3008 setPreferenceProperty( xv, "step", 0.1 );
3009 setPreferenceProperty( xh, "min", 0.0 );
3010 setPreferenceProperty( xh, "max", 1.0 );
3011 setPreferenceProperty( xh, "step", 0.1 );
3012 setPreferenceProperty( yh, "min", 0.0 );
3013 setPreferenceProperty( yh, "max", 1.0 );
3014 setPreferenceProperty( yh, "step", 0.1 );
3015 setPreferenceProperty( wh, "min", 0.0 );
3016 setPreferenceProperty( wh, "max", 1.0 );
3017 setPreferenceProperty( wh, "step", 0.1 );
3018 setPreferenceProperty( hh, "min", 0.0 );
3019 setPreferenceProperty( hh, "max", 1.0 );
3020 setPreferenceProperty( hh, "step", 0.1 );
3023 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3026 if( name=="selection_object_color" || name=="selection_element_color" ||
3027 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3028 name=="selection_precision_node" || name=="selection_precision_element" )
3029 SMESH::UpdateSelectionProp( this );
3032 //================================================================================
3034 * \brief Update something in accordance with update flags
3035 * \param theFlags - update flags
3037 * Update viewer or/and object browser etc. in accordance with update flags ( see
3038 * SalomeApp_UpdateFlags enumeration ).
3040 //================================================================================
3041 void SMESHGUI::update( const int flags )
3043 if ( flags & UF_Viewer | flags & UF_Forced )
3044 SMESH::UpdateView();
3046 SalomeApp_Module::update( flags );
3049 //================================================================================
3051 * \brief Set default selection mode
3053 * SLOT called when operation commited. Sets default selection mode
3055 //================================================================================
3056 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3058 SVTK_ViewWindow* vtkWnd =
3059 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3061 vtkWnd->SetSelectionMode( ActorSelection );
3064 //================================================================================
3066 * \brief Set default selection mode
3068 * SLOT called when operation aborted. Sets default selection mode
3070 //================================================================================
3071 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3073 SVTK_ViewWindow* vtkWnd =
3074 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3076 vtkWnd->SetSelectionMode( ActorSelection );
3079 //================================================================================
3081 * \brief Creates operation with given identifier
3082 * \param id - identifier of operation to be started
3083 * \return Pointer on created operation or NULL if operation is not created
3085 * Virtual method redefined from the base class creates operation with given id.
3086 * It is called called automatically from startOperation method of base class.
3088 //================================================================================
3089 SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
3091 SalomeApp_Operation* op = 0;
3092 // to do : create operation here
3095 case 702: // Create mesh
3096 op = new SMESHGUI_MeshOp( true, true );
3098 case 703: // Create sub-mesh
3099 op = new SMESHGUI_MeshOp( true, false );
3101 case 704: // Edit mesh/sub-mesh
3102 op = new SMESHGUI_MeshOp( false );
3109 op = SalomeApp_Module::createOperation( id );
3113 SalomeApp_Displayer* SMESHGUI::displayer()
3116 myDisplayer = new SMESHGUI_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );