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_InitMeshDlg.h"
30 #include "SMESHGUI_AddSubMeshDlg.h"
31 #include "SMESHGUI_NodesDlg.h"
32 #include "SMESHGUI_TransparencyDlg.h"
33 #include "SMESHGUI_ClippingDlg.h"
34 #include "SMESHGUI_GroupDlg.h"
35 #include "SMESHGUI_RemoveNodesDlg.h"
36 #include "SMESHGUI_RemoveElementsDlg.h"
37 #include "SMESHGUI_MeshInfosDlg.h"
38 #include "SMESHGUI_StandardMeshInfosDlg.h"
39 #include "SMESHGUI_Preferences_ColorDlg.h"
40 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
41 #include "SMESHGUI_Preferences_SelectionDlg.h"
42 #include "SMESHGUI_Hypotheses.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_EditHypothesesDlg.h"
46 #include "SMESHGUI_CreateHypothesesDlg.h"
47 #include "SMESHGUI_FilterDlg.h"
48 #include "SMESHGUI_FilterLibraryDlg.h"
49 #include "SMESHGUI_SingleEditDlg.h"
50 #include "SMESHGUI_MultiEditDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_DeleteGroupDlg.h"
53 #include "SMESHGUI_SmoothingDlg.h"
54 #include "SMESHGUI_RenumberingDlg.h"
55 #include "SMESHGUI_ExtrusionDlg.h"
56 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
57 #include "SMESHGUI_RevolutionDlg.h"
58 #include "SMESHGUI_TranslationDlg.h"
59 #include "SMESHGUI_RotationDlg.h"
60 #include "SMESHGUI_SymmetryDlg.h"
61 #include "SMESHGUI_SewingDlg.h"
62 #include "SMESHGUI_MergeNodesDlg.h"
63 #include "SMESHGUI_EditMeshDlg.h"
64 #include "SMESHGUI_MeshPatternDlg.h"
65 #include "SMESHGUI_PrecisionDlg.h"
66 #include "SMESHGUI_Selection.h"
67 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
68 #include "SMESHGUI_MeshOp.h"
70 #include "SMESHGUI_Utils.h"
71 #include "SMESHGUI_GEOMGenUtils.h"
72 #include "SMESHGUI_MeshUtils.h"
73 #include "SMESHGUI_GroupUtils.h"
74 #include "SMESHGUI_FilterUtils.h"
75 #include "SMESHGUI_PatternUtils.h"
76 #include "SMESHGUI_VTKUtils.h"
77 #include "SMESHGUI_HypothesesUtils.h"
79 #include "SMESH_Actor.h"
80 #include "SMESH_Object.h"
81 #include "SMESH_TypeFilter.hxx"
83 #include "SalomeApp_Tools.h"
84 #include "SalomeApp_Study.h"
85 #include "SalomeApp_NameDlg.h"
86 #include "SalomeApp_DataOwner.h"
87 #include "SalomeApp_Application.h"
88 #include "SalomeApp_Preferences.h"
89 #include "SalomeApp_VTKSelector.h"
90 #include "SalomeApp_Operation.h"
91 #include "SalomeApp_UpdateFlags.h"
93 #include "SalomeApp_ImportOperation.h"
95 #include <SVTK_ViewWindow.h>
96 #include <SVTK_ViewModel.h>
97 #include <SVTK_InteractorStyle.h>
98 #include <SVTK_RenderWindowInteractor.h>
100 #include <VTKViewer_ViewManager.h>
102 #include "OB_Browser.h"
104 #include "SUIT_Tools.h"
105 #include "SUIT_MessageBox.h"
106 #include "SUIT_ResourceMgr.h"
107 #include "SUIT_FileDlg.h"
108 #include "SUIT_Desktop.h"
109 #include "SUIT_ResourceMgr.h"
110 #include "SUIT_OverrideCursor.h"
111 #include "SUIT_Study.h"
112 #include "SUIT_Session.h"
114 #include "QtxPopupMgr.h"
116 #include "SALOME_ListIO.hxx"
117 #include "SALOME_ListIteratorOfListIO.hxx"
118 #include "SALOME_InteractiveObject.hxx"
119 #include "SALOME_NamingService.hxx"
120 #include "SALOME_LifeCycleCORBA.hxx"
122 #include "SALOMEconfig.h"
123 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
126 #define INCLUDE_MENUITEM_DEF
127 #include <qpopupmenu.h>
133 #include <boost/shared_ptr.hpp>
136 #include <vtkRenderer.h>
137 #include <vtkRenderWindow.h>
138 #include <vtkActorCollection.h>
139 #include <vtkScalarBarActor.h>
140 #include <vtkUnstructuredGrid.h>
142 #include "utilities.h"
144 #include "SALOMEDS_Study.hxx"
145 #include "SALOMEDSClient_StudyBuilder.hxx"
146 #include "SALOMEDSClient_SComponent.hxx"
152 //=============================================================
153 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
156 void ExportMeshToFile(int theCommandID);
158 void SetDisplayMode(int theCommandID);
160 void SetDisplayEntity(int theCommandID);
162 void Control( int theCommandID );
166 //=============================================================
167 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
173 if(theCommandID == 113){
174 filter.append(QObject::tr("MED files (*.med)"));
175 filter.append(QObject::tr("All files (*)"));
176 }else if (theCommandID == 112){
177 filter.append(QObject::tr("IDEAS files (*.unv)"));
178 }else if (theCommandID == 111){
179 filter.append(QObject::tr("DAT files (*.dat)"));
181 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
184 QObject::tr("Import mesh"),
186 if(!filename.isEmpty()) {
187 SUIT_OverrideCursor wc;
188 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
189 theComponentMesh->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
192 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
193 switch ( theCommandID ) {
196 aMeshes->length( 1 );
197 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
202 SMESH::DriverMED_ReadStatus res;
203 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
204 if ( res != SMESH::DRS_OK ) {
206 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
207 QObject::tr("SMESH_WRN_WARNING"),
208 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
209 QObject::tr("SMESH_BUT_OK"));
210 aMeshes->length( 0 );
217 bool isEmpty = false;
218 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
219 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
221 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
222 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
223 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
224 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
225 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
232 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
233 QObject::tr("SMESH_WRN_WARNING"),
234 QObject::tr("SMESH_DRS_EMPTY"),
235 QObject::tr("SMESH_BUT_OK"));
239 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
241 catch (const SALOME::SALOME_Exception& S_ex){
243 SalomeApp_Tools::QtCatchCorbaException(S_ex);
250 void ExportMeshToFile( int theCommandID )
252 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
253 SALOME_ListIO selected;
255 aSel->selectedObjects( selected );
257 if(selected.Extent()){
258 Handle(SALOME_InteractiveObject) anIObject = selected.First();
259 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
260 if ( !aMesh->_is_nil() ) {
261 QString aFilter, aTitle = QObject::tr("Export mesh");
262 QMap<QString, SMESH::MED_VERSION> aFilterMap;
263 switch ( theCommandID ) {
266 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
267 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
271 aFilter = QObject::tr("DAT files (*.dat)");
275 if(aMesh->NbPyramids()){
276 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
277 QObject::tr("SMESH_WRN_WARNING"),
278 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
279 QObject::tr("SMESH_BUT_YES"),
280 QObject::tr("SMESH_BUT_NO"),
285 aFilter = QObject::tr("IDEAS files (*.unv)");
292 SMESH::MED_VERSION aFormat;
294 if ( theCommandID != 122 && theCommandID != 125 )
295 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
299 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
300 filters.push_back( it.key() );
302 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
303 fd->setCaption( aTitle );
304 fd->setFilters( filters );
308 aFilename = fd->selectedFile();
309 aFormat = aFilterMap[fd->selectedFilter()];
311 if( !aFilename.isEmpty()
312 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
313 && aFormat==SMESH::MED_V2_1){
314 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
315 QObject::tr("SMESH_WRN_WARNING"),
316 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
317 QObject::tr("SMESH_BUT_YES"),
318 QObject::tr("SMESH_BUT_NO"),
327 if ( !aFilename.isEmpty() ) {
328 // Check whether the file already exists and delete it if yes
329 QFile aFile( aFilename );
330 if ( aFile.exists() )
332 SUIT_OverrideCursor wc;
333 switch ( theCommandID ) {
336 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
340 aMesh->ExportDAT( aFilename.latin1() );
344 aMesh->ExportUNV( aFilename.latin1() );
354 inline void InverseEntityMode(unsigned int& theOutputMode,
355 unsigned int theMode)
357 bool anIsNotPresent = ~theOutputMode & theMode;
359 theOutputMode |= theMode;
361 theOutputMode &= ~theMode;
364 void SetDisplayEntity(int theCommandID){
365 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
366 SALOME_ListIO selected;
368 aSel->selectedObjects( selected );
370 if(selected.Extent() >= 1){
371 SALOME_ListIteratorOfListIO It( selected );
372 for(; It.More(); It.Next()){
373 Handle(SALOME_InteractiveObject) IObject = It.Value();
374 if(IObject->hasEntry()){
375 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
376 unsigned int aMode = anActor->GetEntityMode();
377 switch(theCommandID){
379 InverseEntityMode(aMode,SMESH_Actor::eEdges);
382 InverseEntityMode(aMode,SMESH_Actor::eFaces);
385 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
388 aMode = SMESH_Actor::eAllEntity;
392 anActor->SetEntityMode(aMode);
399 void SetDisplayMode(int theCommandID){
400 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
401 SALOME_ListIO selected;
403 aSel->selectedObjects( selected );
405 if(selected.Extent() >= 1){
406 switch(theCommandID){
408 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
409 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
413 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
414 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
417 SALOME_ListIteratorOfListIO It( selected );
418 for(; It.More(); It.Next()){
419 Handle(SALOME_InteractiveObject) IObject = It.Value();
420 if(IObject->hasEntry()){
421 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
422 switch(theCommandID){
424 anActor->SetRepresentation(SMESH_Actor::eEdge);
427 anActor->SetRepresentation(SMESH_Actor::eSurface);
430 if(anActor->IsShrunk())
433 anActor->SetShrink();
436 anActor->SetRepresentation(SMESH_Actor::ePoint);
440 anActor->GetSufaceColor(color[0], color[1], color[2]);
441 int c0 = int (color[0] * 255);
442 int c1 = int (color[1] * 255);
443 int c2 = int (color[2] * 255);
444 QColor c(c0, c1, c2);
447 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
448 c0 = int (edgecolor[0] * 255);
449 c1 = int (edgecolor[1] * 255);
450 c2 = int (edgecolor[2] * 255);
451 QColor e(c0, c1, c2);
453 float backfacecolor[3];
454 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
455 c0 = int (backfacecolor[0] * 255);
456 c1 = int (backfacecolor[1] * 255);
457 c2 = int (backfacecolor[2] * 255);
458 QColor b(c0, c1, c2);
461 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
462 c0 = int (nodecolor[0] * 255);
463 c1 = int (nodecolor[1] * 255);
464 c2 = int (nodecolor[2] * 255);
465 QColor n(c0, c1, c2);
467 int Edgewidth = (int)anActor->GetLineWidth();
470 int intValue = int(anActor->GetNodeSize());
471 float Shrink = anActor->GetShrinkFactor();
473 SMESHGUI_Preferences_ColorDlg *aDlg =
474 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
475 aDlg->SetColor(1, c);
476 aDlg->SetColor(2, e);
477 aDlg->SetColor(3, n);
478 aDlg->SetColor(4, b);
479 aDlg->SetIntValue(1, Edgewidth);
480 aDlg->SetIntValue(2, intValue);
481 aDlg->SetIntValue(3, int(Shrink*100.));
483 QColor color = aDlg->GetColor(1);
484 QColor edgecolor = aDlg->GetColor(2);
485 QColor nodecolor = aDlg->GetColor(3);
486 QColor backfacecolor = aDlg->GetColor(4);
487 /* actor color and backface color */
488 anActor->SetSufaceColor(float (color.red()) / 255.,
489 float (color.green()) / 255.,
490 float (color.blue()) / 255.);
491 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
492 float (backfacecolor.green()) / 255.,
493 float (backfacecolor.blue()) / 255.);
496 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
497 float (edgecolor.green()) / 255.,
498 float (edgecolor.blue()) / 255.);
500 /* Shrink factor and size edges */
501 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
502 anActor->SetLineWidth(aDlg->GetIntValue(1));
504 /* Nodes color and size */
505 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
506 float (nodecolor.green()) / 255.,
507 float (nodecolor.blue()) / 255.);
508 anActor->SetNodeSize(aDlg->GetIntValue(2));
517 SMESH::RepaintCurrentView();
521 void Control( int theCommandID )
523 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
524 SALOME_ListIO selected;
526 aSel->selectedObjects( selected );
528 if( !selected.IsEmpty() ){
529 Handle(SALOME_InteractiveObject) anIO = selected.First();
532 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
533 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
534 switch ( theCommandID ){
536 aTitle = QObject::tr( "LENGTH_EDGES" );
537 aControl = SMESH_Actor::eLength;
540 aTitle = QObject::tr( "LENGTH2D_EDGES" );
541 aControl = SMESH_Actor::eLength2D;
544 aTitle = QObject::tr( "FREE_EDGES" );
545 aControl = SMESH_Actor::eFreeEdges;
548 aTitle = QObject::tr( "FREE_BORDERS" );
549 aControl = SMESH_Actor::eFreeBorders;
552 aTitle = QObject::tr( "MULTI_BORDERS" );
553 aControl = SMESH_Actor::eMultiConnection;
556 aTitle = QObject::tr( "MULTI2D_BORDERS" );
557 aControl = SMESH_Actor::eMultiConnection2D;
560 aTitle = QObject::tr( "AREA_ELEMENTS" );
561 aControl = SMESH_Actor::eArea;
564 aTitle = QObject::tr( "TAPER_ELEMENTS" );
565 aControl = SMESH_Actor::eTaper;
568 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
569 aControl = SMESH_Actor::eAspectRatio;
572 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
573 aControl = SMESH_Actor::eAspectRatio3D;
576 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
577 aControl = SMESH_Actor::eMinimumAngle;
580 aTitle = QObject::tr( "WARP_ELEMENTS" );
581 aControl = SMESH_Actor::eWarping;
584 aTitle = QObject::tr( "SKEW_ELEMENTS" );
585 aControl = SMESH_Actor::eSkew;
588 anActor->SetControlMode(aControl);
589 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
596 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
597 MeshObjectType theType,
598 const QString theInTypeName,
599 QString & theOutTypeName)
601 SMESH_TypeFilter aTypeFilter( theType );
603 if( !theIO.IsNull() )
605 entry = theIO->getEntry();
606 SalomeApp_DataOwner owner( entry );
607 if ( aTypeFilter.isOk( &owner )) {
608 theOutTypeName = theInTypeName;
616 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
618 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
619 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
621 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
622 CORBA::String_var anID = aSComp->GetID().c_str();
623 if (!strcmp(anID.in(),theIO->getEntry()))
629 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
630 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
631 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
632 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
633 CheckOIType ( theIO, GROUP, "Group", aTypeName )
641 QString CheckHomogeneousSelection()
643 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
644 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
645 SALOME_ListIO selected;
647 aSel->selectedObjects( selected );
649 QString RefType = CheckTypeObject(selected.First());
650 SALOME_ListIteratorOfListIO It(selected);
651 for (; It.More(); It.Next())
653 Handle(SALOME_InteractiveObject) IObject = It.Value();
654 QString Type = CheckTypeObject(IObject);
655 if (Type.compare(RefType) != 0)
656 return "Heterogeneous Selection";
663 void SMESHGUI::OnEditDelete()
665 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
666 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
667 SALOME_ListIO selected; aSel->selectedObjects( selected );
669 QString aParentComponent = QString::null;
670 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
672 QString cur = anIt.Value()->getComponentDataType();
673 if( aParentComponent.isNull() )
674 aParentComponent = cur;
675 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
676 aParentComponent = "";
679 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
680 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
681 QObject::tr("ERR_ERROR"),
682 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
683 QObject::tr("BUT_OK") );
686 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
687 if (SUIT_MessageBox::warn2
688 (SMESHGUI::desktop(),
689 QObject::tr("SMESH_WRN_WARNING"),
690 QObject::tr("SMESH_REALLY_DELETE"),
691 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
694 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
695 SUIT_ViewManager* vm = anApp->activeViewManager();
696 int nbSf = vm->getViewsCount();
698 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
699 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
700 _PTR(GenericAttribute) anAttr;
701 _PTR(AttributeIOR) anIOR;
703 SALOME_ListIteratorOfListIO It(selected);
705 aStudyBuilder->NewCommand(); // There is a transaction
706 for(; It.More(); It.Next()){
707 Handle(SALOME_InteractiveObject) IObject = It.Value();
708 if(IObject->hasEntry()){
709 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
711 // disable removal of "SMESH" component object
712 if(SO->FindAttribute(anAttr, "AttributeIOR")){
714 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
718 /* Erase child graphical objects */
719 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
720 for(it->InitEx(true); it->More(); it->Next()){
721 _PTR(SObject) CSO = it->Value();
722 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
725 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
726 for(int i = 0; i < nbSf; i++){
727 SUIT_ViewWindow *sf = aViews[i];
728 CORBA::String_var anEntry = CSO->GetID().c_str();
729 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
730 SMESH::RemoveActor(sf,anActor);
736 /* Erase main graphical object */
737 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
738 for(int i = 0; i < nbSf; i++){
739 SUIT_ViewWindow *sf = aViews[i];
740 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
741 SMESH::RemoveActor(sf,anActor);
745 // Remove object(s) from data structures
746 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
748 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
749 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
750 QString objType = CheckTypeObject(IObject);
751 if ( !aGroup->_is_nil() ) { // DELETE GROUP
752 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
753 aMesh->RemoveGroup( aGroup );
755 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
756 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
757 aMesh->RemoveSubMesh( aSubMesh );
759 else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
760 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
761 aStudyBuilder->RemoveObjectWithChildren( obj );
763 else {// default action: remove SObject from the study
764 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
765 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
767 aStudyBuilder->RemoveObjectWithChildren( obj );
772 } /* IObject->hasEntry() */
774 aStudyBuilder->CommitCommand();
776 /* Clear any previous selection */
778 aSel->setSelectedObjects( l1 );
780 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
785 Standard_EXPORT CAM_Module* createModule()
787 return new SMESHGUI();
791 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
793 //=============================================================================
797 //=============================================================================
798 SMESHGUI::SMESHGUI() :
799 SalomeApp_Module( "SMESH" )
801 if ( CORBA::is_nil( myComponentSMESH ) )
803 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
804 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
805 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
808 myActiveDialogBox = 0 ;
811 SMESH::GetFilterManager();
814 /* load resources for all available meshers */
815 SMESH::InitAvailableHypotheses();
818 //=============================================================================
822 //=============================================================================
823 SMESHGUI::~SMESHGUI()
825 SMESH::GetFilterManager()->Destroy();
828 //=============================================================================
832 //=============================================================================
833 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
835 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
837 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
842 bool SMESHGUI::automaticUpdate()
844 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
848 return resMgr->booleanValue( "SMESH", "auto_update", false );
851 //=============================================================================
855 //=============================================================================
856 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
858 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
861 //=============================================================================
865 //=============================================================================
866 SMESHGUI* SMESHGUI::GetSMESHGUI()
868 SMESHGUI* smeshMod = 0;
869 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
872 CAM_Module* module = app->module( "Mesh" );
873 smeshMod = dynamic_cast<SMESHGUI*>( module );
876 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
878 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
881 _PTR(Study) aStudy = study->studyDS();
883 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
892 Standard_EXPORT SMESHGUI* GetComponentGUI()
894 return SMESHGUI::GetSMESHGUI();
898 //=============================================================================
902 //=============================================================================
903 void SMESHGUI::SetState(int aState)
908 //=============================================================================
912 //=============================================================================
913 void SMESHGUI::ResetState()
918 //=============================================================================
922 //=============================================================================
923 void SMESHGUI::EmitSignalDeactivateDialog()
925 emit SignalDeactivateActiveDialog();
928 //=============================================================================
932 //=============================================================================
933 void SMESHGUI::EmitSignalStudyFrameChanged()
935 emit SignalStudyFrameChanged();
938 //=============================================================================
942 //=============================================================================
943 void SMESHGUI::EmitSignalCloseAllDialogs()
945 emit SignalCloseAllDialogs();
948 //=============================================================================
952 //=============================================================================
953 QDialog *SMESHGUI::GetActiveDialogBox()
955 return myActiveDialogBox;
958 //=============================================================================
962 //=============================================================================
963 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
965 myActiveDialogBox = (QDialog *) aDlg;
969 //=============================================================================
973 //=============================================================================
974 SUIT_Desktop* SMESHGUI::desktop()
976 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
978 return app->desktop();
983 //=============================================================================
987 //=============================================================================
988 SalomeApp_Study* SMESHGUI::activeStudy()
990 SUIT_Application* app = SUIT_Session::session()->activeApplication();
992 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
997 //=============================================================================
1001 //=============================================================================
1002 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1004 /* Here the position is on the bottom right corner - 10 */
1005 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1007 SUIT_Desktop *PP = desktop();
1008 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1009 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1013 //=============================================================================
1017 //=============================================================================
1018 static int isStudyLocked(_PTR(Study) theStudy){
1019 return theStudy->GetProperties()->IsLocked();
1022 static bool checkLock(_PTR(Study) theStudy) {
1023 if (isStudyLocked(theStudy)) {
1024 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1025 QObject::tr("WRN_WARNING"),
1026 QObject::tr("WRN_STUDY_LOCKED"),
1027 QObject::tr("BUT_OK") );
1033 //=======================================================================
1034 //function : CheckActiveStudyLocked
1036 //=======================================================================
1038 bool SMESHGUI::isActiveStudyLocked()
1040 _PTR(Study) aStudy = activeStudy()->studyDS();
1041 return checkLock( aStudy );
1044 //=============================================================================
1048 //=============================================================================
1049 bool SMESHGUI::OnGUIEvent( int theCommandID )
1051 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1055 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1056 SUIT_ResourceMgr* mgr = resourceMgr();
1060 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1061 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1063 //QAction* act = action( theCommandID );
1065 switch (theCommandID) {
1067 if(checkLock(aStudy)) break;
1075 if(checkLock(aStudy)) break;
1076 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1080 case 122: // EXPORT MED
1087 ::ExportMeshToFile(theCommandID);
1091 case 200: // SCALAR BAR
1093 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1094 SALOME_ListIO selected;
1096 aSel->selectedObjects( selected );
1098 if( selected.Extent() ) {
1099 Handle(SALOME_InteractiveObject) anIO = selected.First();
1100 if( anIO->hasEntry() ) {
1101 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1102 anActor->SetControlMode( SMESH_Actor::eNone );
1110 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1114 case 1134: // Clipping
1115 case 1133: // Tranparency
1116 case 1132: // Colors / Size
1123 ::SetDisplayMode(theCommandID);
1129 case 219: // Volumes
1130 case 220: // All Entity
1131 ::SetDisplayEntity(theCommandID);
1136 if(checkLock(aStudy)) break;
1137 SMESH::UpdateView();
1140 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1141 aSel->setSelectedObjects( l );
1146 case 301: // DISPLAY
1147 case 302: // DISPLAY ONLY
1149 SMESH::EDisplaing anAction;
1150 switch (theCommandID) {
1151 case 300: anAction = SMESH::eErase; break;
1152 case 301: anAction = SMESH::eDisplay; break;
1153 case 302: anAction = SMESH::eDisplayOnly; break;
1156 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1157 SALOME_ListIO selected;
1159 aSel->selectedObjects( selected );
1162 SALOME_ListIteratorOfListIO It (selected);
1163 for (; It.More(); It.Next()) {
1164 Handle(SALOME_InteractiveObject) IOS = It.Value();
1165 if (IOS->hasEntry()) {
1166 SMESH::UpdateView(anAction, IOS->getEntry());
1167 if (anAction == SMESH::eDisplayOnly)
1168 anAction = SMESH::eDisplay;
1173 aSel->setSelectedObjects( l1 );
1179 if(checkLock(aStudy)) break;
1182 EmitSignalDeactivateDialog();
1184 new SMESHGUI_NodesDlg(this);
1187 SUIT_MessageBox::warn1(desktop(),
1188 tr("SMESH_WRN_WARNING"),
1189 tr("SMESH_WRN_VIEWER_VTK"),
1190 tr("SMESH_BUT_OK"));
1195 case 2151: // FILTER
1199 EmitSignalDeactivateDialog();
1200 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1205 case 406: // MOVE NODE
1209 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1210 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1214 if(checkLock(aStudy)) break;
1215 new SMESHGUI_MoveNodesDlg(this);
1219 case 701: // COMPUTE MESH
1221 if(checkLock(aStudy)) break;
1223 SalomeApp_SelectionMgr *Sel = selectionMgr();
1224 SALOME_ListIO selected; Sel->selectedObjects( selected );
1226 int nbSel = selected.Extent();
1231 SMESH::SMESH_Mesh_var aMesh;
1232 SMESH::SMESH_subMesh_var aSubMesh;
1233 Handle(SALOME_InteractiveObject) IObject = selected.First();
1234 if (IObject->hasEntry()){
1235 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1236 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1237 if ( aShapeObject->_is_nil() ) {
1242 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1243 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1245 if (!aMesh->_is_nil()){
1246 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1247 if (!refShapeObject->_is_nil()) {
1248 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1249 SUIT_MessageBox::warn1(desktop(),
1250 tr("SMESH_WRN_WARNING"),
1251 tr("SMESH_WRN_MISSING_PARAMETERS"),
1252 tr("SMESH_BUT_OK"));
1256 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1257 SMESH::ModifiedMesh(aMeshSObj,true);
1258 // TO Do : change icon of all submeshes
1260 SUIT_MessageBox::warn1(desktop(),
1261 tr("SMESH_WRN_WARNING"),
1262 tr("SMESH_WRN_COMPUTE_FAILED"),
1263 tr("SMESH_BUT_OK"));
1265 catch(const SALOME::SALOME_Exception & S_ex){
1266 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1269 }else if(!aSubMesh->_is_nil()){
1270 aMesh = aSubMesh->GetFather();
1271 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1272 if(!refShapeObject->_is_nil()){
1273 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1275 SUIT_MessageBox::warn1(desktop(),
1276 tr("SMESH_WRN_WARNING"),
1277 tr("SMESH_WRN_MISSING_PARAMETERS"),
1278 tr("SMESH_BUT_OK"));
1282 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1283 SMESH::ModifiedMesh(aMeshSObj,true);
1284 // TO Do : change icon of all submeshes
1286 SUIT_MessageBox::warn1(desktop(),
1287 tr("SMESH_WRN_WARNING"),
1288 tr("SMESH_WRN_COMPUTE_FAILED"),
1289 tr("SMESH_BUT_OK"));
1290 }catch(const SALOME::SALOME_Exception & S_ex){
1291 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1297 CORBA::Long anId = aStudy->StudyId();
1298 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1299 if ( automaticUpdate() && aVisualObj){
1300 aVisualObj->Update();
1301 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1303 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1305 SMESH::DisplayActor(view,anActor); //apo
1309 SMESH::RepaintCurrentView();
1312 SUIT_MessageBox::warn1(desktop(),
1313 tr("SMESH_WRN_WARNING"),
1314 tr("SMESH_WRN_VIEWER_VTK"),
1315 tr("SMESH_BUT_OK"));
1321 case 702: // Create mesh
1322 startOperation( 702 );
1324 case 703: // Create sub-mesh
1325 startOperation( 703 );
1327 case 704: // Edit mesh/sub-mesh
1328 startOperation( 704 );
1330 case 407: // DIAGONAL INVERSION
1331 case 408: // Delete diagonal
1335 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1336 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1340 if ( checkLock( aStudy ) )
1343 /*Standard_Boolean aRes;
1344 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1345 if ( aMesh->_is_nil() )
1347 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1348 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1352 EmitSignalDeactivateDialog();
1353 if ( theCommandID == 407 )
1354 new SMESHGUI_TrianglesInversionDlg(this);
1356 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1359 case 409: // Change orientation
1360 case 410: // Union of triangles
1361 case 411: // Cutting of quadrangles
1365 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1366 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1370 if ( checkLock( aStudy ) )
1373 EmitSignalDeactivateDialog();
1374 SMESHGUI_MultiEditDlg* aDlg = NULL;
1375 if ( theCommandID == 409 )
1376 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1377 else if ( theCommandID == 410 )
1378 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1380 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1383 DefineDlgPosition( aDlg, x, y );
1388 case 412: // Smoothing
1390 if(checkLock(aStudy)) break;
1392 EmitSignalDeactivateDialog();
1393 new SMESHGUI_SmoothingDlg( this );
1396 SUIT_MessageBox::warn1(desktop(),
1397 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1398 tr("SMESH_BUT_OK"));
1402 case 413: // Extrusion
1404 if (checkLock(aStudy)) break;
1406 EmitSignalDeactivateDialog();
1407 new SMESHGUI_ExtrusionDlg ( this );
1409 SUIT_MessageBox::warn1(desktop(),
1410 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1411 tr("SMESH_BUT_OK"));
1415 case 414: // Revolution
1417 if(checkLock(aStudy)) break;
1419 EmitSignalDeactivateDialog();
1420 new SMESHGUI_RevolutionDlg( this );
1423 SUIT_MessageBox::warn1(desktop(),
1424 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1425 tr("SMESH_BUT_OK"));
1429 case 415: // Pattern mapping
1431 if ( checkLock( aStudy ) )
1435 EmitSignalDeactivateDialog();
1436 new SMESHGUI_MeshPatternDlg( this );
1439 SUIT_MessageBox::warn1(desktop(),
1440 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1441 tr("SMESH_BUT_OK"));
1445 case 416: // Extrusion along a path
1447 if (checkLock(aStudy)) break;
1449 EmitSignalDeactivateDialog();
1450 new SMESHGUI_ExtrusionAlongPathDlg( this );
1452 SUIT_MessageBox::warn1(desktop(),
1453 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1454 tr("SMESH_BUT_OK"));
1458 case 801: // CREATE GROUP
1462 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1463 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1467 if(checkLock(aStudy)) break;
1468 EmitSignalDeactivateDialog();
1469 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1471 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1472 SALOME_ListIO selected;
1474 aSel->selectedObjects( selected );
1476 int nbSel = selected.Extent();
1478 // check if mesh is selected
1479 aMesh = SMESH::GetMeshByIO( selected.First() );
1481 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1486 case 802: // CONSTRUCT GROUP
1490 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1491 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1495 if(checkLock(aStudy)) break;
1496 EmitSignalDeactivateDialog();
1498 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1499 SALOME_ListIO selected;
1501 aSel->selectedObjects( selected );
1503 int nbSel = selected.Extent();
1505 // check if submesh is selected
1506 Handle(SALOME_InteractiveObject) IObject = selected.First();
1507 if (IObject->hasEntry()) {
1508 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1510 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1511 if (!aSubMesh->_is_nil()) {
1513 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1514 // get submesh elements list by types
1515 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1516 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1517 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1518 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1519 // create group for each type o elements
1520 QString aName = IObject->getName();
1521 if (aNodes->length() > 0) {
1522 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1523 aGroup->Add(aNodes.inout());
1525 if (aEdges->length() > 0) {
1526 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1527 aGroup->Add(aEdges.inout());
1529 if (aFaces->length() > 0) {
1530 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1531 aGroup->Add(aFaces.inout());
1533 if (aVolumes->length() > 0) {
1534 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1535 aGroup->Add(aVolumes.inout());
1539 }catch(const SALOME::SALOME_Exception & S_ex){
1540 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1549 case 803: // EDIT GROUP
1553 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1554 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1558 if(checkLock(aStudy)) break;
1559 EmitSignalDeactivateDialog();
1561 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1562 SALOME_ListIO selected;
1564 aSel->selectedObjects( selected );
1566 SALOME_ListIteratorOfListIO It (selected);
1567 int nbSelectedGroups = 0;
1568 for ( ; It.More(); It.Next() )
1570 SMESH::SMESH_Group_var aGroup =
1571 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1572 if (!aGroup->_is_nil()) {
1574 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1578 if (nbSelectedGroups == 0)
1580 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1586 case 804: // Add elements to group
1588 if(checkLock(aStudy)) break;
1589 if (myState == 800) {
1590 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1591 if (aDlg) aDlg->onAdd();
1596 case 805: // Remove elements from group
1598 if(checkLock(aStudy)) break;
1599 if (myState == 800) {
1600 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1601 if (aDlg) aDlg->onRemove();
1606 case 810: // Union Groups
1607 case 811: // Intersect groups
1608 case 812: // Cut groups
1612 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1613 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1617 if ( checkLock( aStudy ) )
1620 EmitSignalDeactivateDialog();
1623 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1624 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1625 else aMode = SMESHGUI_GroupOpDlg::CUT;
1627 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1631 case 813: // Delete groups with their contents
1635 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1636 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1640 if ( checkLock( aStudy ) )
1643 EmitSignalDeactivateDialog();
1645 new SMESHGUI_DeleteGroupDlg( this );
1649 case 900: // MESH INFOS
1651 EmitSignalDeactivateDialog();
1652 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1653 SALOME_ListIO selected;
1655 aSel->selectedObjects( selected );
1657 if ( selected.Extent() > 1 ) { // a dlg for each IO
1659 SALOME_ListIteratorOfListIO It (selected);
1660 for ( ; It.More(); It.Next() ) {
1661 IOs.Clear(); IOs.Append( It.Value() );
1662 aSel->setSelectedObjects( IOs );
1663 new SMESHGUI_MeshInfosDlg(this, "", false);
1665 // restore selection
1666 aSel->setSelectedObjects( selected );
1669 new SMESHGUI_MeshInfosDlg(this, "", false);
1673 case 902: // STANDARD MESH INFOS
1675 EmitSignalDeactivateDialog();
1676 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1677 SALOME_ListIO selected;
1679 aSel->selectedObjects( selected );
1681 if ( selected.Extent() > 1 ) { // a dlg for each IO
1683 SALOME_ListIteratorOfListIO It (selected);
1684 for ( ; It.More(); It.Next() ) {
1686 IOs.Append( It.Value() );
1687 aSel->setSelectedObjects( IOs );
1688 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1690 // restore selection
1691 aSel->setSelectedObjects( selected );
1694 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1698 case 1100: // EDIT HYPOTHESIS
1700 if(checkLock(aStudy)) break;
1702 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1703 SALOME_ListIO selected;
1705 aSel->selectedObjects( selected );
1707 int nbSel = selected.Extent();
1710 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1712 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1713 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1714 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1715 if ( !Hyp->_is_nil() )
1717 char* sName = Hyp->GetName();
1718 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1721 aCreator->EditHypothesis(Hyp);
1729 updateObjBrowser( true );
1733 case 1101: // RENAME
1735 if ( checkLock( aStudy ) )
1738 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1739 SALOME_ListIO selected;
1741 aSel->selectedObjects( selected );
1743 SALOME_ListIteratorOfListIO It( selected );
1744 for ( ; It.More(); It.Next() )
1746 Handle(SALOME_InteractiveObject) IObject = It.Value();
1747 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1748 _PTR(GenericAttribute) anAttr;
1749 _PTR(AttributeName) aName;
1752 if ( obj->FindAttribute(anAttr, "AttributeName") )
1755 QString newName = QString(aName->Value().c_str());
1756 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1757 if ( !newName.isEmpty() )
1759 //old source: aStudy->renameIObject( IObject, newName );
1760 aName->SetValue( newName.latin1() );
1762 // if current object is group update group's name
1763 SMESH::SMESH_GroupBase_var aGroup =
1764 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1765 if (!aGroup->_is_nil() )
1766 aGroup->SetName( newName.latin1() );
1776 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1778 if(checkLock(aStudy)) break;
1779 SUIT_OverrideCursor wc;
1781 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1782 SALOME_ListIO selected;
1784 aSel->selectedObjects( selected );
1786 SALOME_ListIteratorOfListIO It(selected);
1787 for (int i = 0; It.More(); It.Next(), i++) {
1788 Handle(SALOME_InteractiveObject) IObject = It.Value();
1789 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1792 aSel->setSelectedObjects( l1 );
1797 case 401: // GEOM::EDGE
1798 case 4021: // TRIANGLE
1800 case 4023: // POLYGON
1804 if(checkLock(aStudy)) break;
1806 EmitSignalDeactivateDialog();
1807 SMDSAbs_ElementType type = SMDSAbs_Edge;
1809 switch (theCommandID) {
1810 case 4021: // TRIANGLE
1811 type = SMDSAbs_Face; nbNodes = 3; break;
1813 type = SMDSAbs_Face; nbNodes = 4; break;
1815 type = SMDSAbs_Volume; nbNodes = 4; break;
1816 case 4023: // POLYGON
1817 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1819 type = SMDSAbs_Volume; nbNodes = 8; break;
1820 case 4033: // POLYHEDRE
1821 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1824 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1827 SUIT_MessageBox::warn1(desktop(),
1828 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1829 tr("SMESH_BUT_OK"));
1833 case 4033: // POLYHEDRON
1835 if(checkLock(aStudy)) break;
1837 EmitSignalDeactivateDialog();
1838 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1841 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1842 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1843 tr("SMESH_BUT_OK"));
1847 case 4041: // REMOVES NODES
1849 if(checkLock(aStudy)) break;
1851 EmitSignalDeactivateDialog();
1852 new SMESHGUI_RemoveNodesDlg(this);
1855 SUIT_MessageBox::warn1(desktop(),
1856 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1857 tr("SMESH_BUT_OK"));
1861 case 4042: // REMOVES ELEMENTS
1863 if(checkLock(aStudy)) break;
1865 EmitSignalDeactivateDialog();
1866 new SMESHGUI_RemoveElementsDlg(this);
1870 SUIT_MessageBox::warn1(desktop(),
1871 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1872 tr("SMESH_BUT_OK"));
1876 case 4051: // RENUMBERING NODES
1878 if(checkLock(aStudy)) break;
1880 EmitSignalDeactivateDialog();
1881 new SMESHGUI_RenumberingDlg( this, "", 0);
1885 SUIT_MessageBox::warn1(desktop(),
1886 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1887 tr("SMESH_BUT_OK"));
1891 case 4052: // RENUMBERING ELEMENTS
1893 if(checkLock(aStudy)) break;
1895 EmitSignalDeactivateDialog();
1896 new SMESHGUI_RenumberingDlg( this, "", 1);
1900 SUIT_MessageBox::warn1(desktop(),
1901 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1902 tr("SMESH_BUT_OK"));
1906 case 4061: // TRANSLATION
1908 if(checkLock(aStudy)) break;
1910 EmitSignalDeactivateDialog();
1911 new SMESHGUI_TranslationDlg( this );
1914 SUIT_MessageBox::warn1(desktop(),
1915 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1916 tr("SMESH_BUT_OK"));
1920 case 4062: // ROTATION
1922 if(checkLock(aStudy)) break;
1924 EmitSignalDeactivateDialog();
1925 new SMESHGUI_RotationDlg( this );
1928 SUIT_MessageBox::warn1(desktop(),
1929 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1930 tr("SMESH_BUT_OK"));
1934 case 4063: // SYMMETRY
1936 if(checkLock(aStudy)) break;
1938 EmitSignalDeactivateDialog();
1939 new SMESHGUI_SymmetryDlg( this );
1942 SUIT_MessageBox::warn1(desktop(),
1943 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1944 tr("SMESH_BUT_OK"));
1948 case 4064: // SEWING
1950 if(checkLock(aStudy)) break;
1952 EmitSignalDeactivateDialog();
1953 new SMESHGUI_SewingDlg( this );
1956 SUIT_MessageBox::warn1(desktop(),
1957 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1958 tr("SMESH_BUT_OK"));
1962 case 4065: // MERGE NODES
1964 if(checkLock(aStudy)) break;
1966 EmitSignalDeactivateDialog();
1967 new SMESHGUI_MergeNodesDlg( this );
1970 SUIT_MessageBox::warn1(desktop(),
1971 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1972 tr("SMESH_BUT_OK"));
1976 case 4066: // MERGE EQUAL ELEMENTS
1978 if (checkLock(aStudy)) break;
1980 EmitSignalDeactivateDialog();
1981 new SMESHGUI_EditMeshDlg(this,
1982 "SMESH_MERGE_ELEMENTS_TITLE",
1983 "ICON_DLG_MERGE_ELEMENTS",
1984 1); // MergeEqualElemets
1986 SUIT_MessageBox::warn1(desktop(),
1987 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1988 tr("SMESH_BUT_OK"));
1993 case 5105: // Library of selection filters
1995 static QValueList<int> aTypes;
1996 if ( aTypes.isEmpty() )
1998 aTypes.append( SMESH::NODE );
1999 aTypes.append( SMESH::EDGE );
2000 aTypes.append( SMESH::FACE );
2001 aTypes.append( SMESH::VOLUME );
2003 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2007 case 6017: // CONTROLS
2022 SalomeApp_SelectionMgr* mgr = selectionMgr();
2023 SALOME_ListIO selected; mgr->selectedObjects( selected );
2025 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2026 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2028 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2029 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2030 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2031 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2032 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2033 ::Control( theCommandID );
2038 SUIT_MessageBox::warn1(desktop(),
2039 tr( "SMESH_WRN_WARNING" ),
2040 tr( "SMESH_BAD_SELECTION" ),
2041 tr( "SMESH_BUT_OK" ) );
2045 SUIT_MessageBox::warn1(desktop(),
2046 tr( "SMESH_WRN_WARNING" ),
2047 tr( "NOT_A_VTK_VIEWER" ),
2048 tr( "SMESH_BUT_OK" ) );
2053 SalomeApp_SelectionMgr* mgr = selectionMgr();
2054 SALOME_ListIO selected; mgr->selectedObjects( selected );
2056 if (selected.Extent() == 1) {
2057 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2058 if(anIObject->hasEntry())
2059 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2060 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2067 SalomeApp_SelectionMgr* mgr = selectionMgr();
2068 SALOME_ListIO selected; mgr->selectedObjects( selected );
2070 if (selected.Extent() == 1) {
2071 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2072 if(anIObject->hasEntry())
2073 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2074 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2080 //updateObjBrowser();
2084 //=============================================================================
2088 //=============================================================================
2089 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2094 //=============================================================================
2098 //=============================================================================
2099 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2104 //=============================================================================
2108 //=============================================================================
2109 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2114 //=============================================================================
2115 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2116 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2118 //=============================================================================
2119 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2120 SUIT_ViewWindow* wnd )
2122 if(theIO->hasEntry()){
2123 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2124 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2128 //=======================================================================
2129 // function : createSMESHAction
2131 //=======================================================================
2132 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2135 QWidget* parent = application()->desktop();
2136 SUIT_ResourceMgr* resMgr = resourceMgr();
2138 if ( icon_id.length() )
2139 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2141 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2142 if ( !pix.isNull() )
2143 icon = QIconSet( pix );
2145 QString tooltip = tr( QString( "TOP_" )+po_id ),
2146 menu = tr( QString( "MEN_" )+po_id ),
2147 status_bar = tr( QString( "STB_" )+po_id );
2149 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2152 //=======================================================================
2153 // function : createPopupItem
2155 //=======================================================================
2156 void SMESHGUI::createPopupItem( const int id,
2157 const QString& clients,
2158 const QString& types,
2159 const QString& theRule,
2164 parentId = popupMgr()->actionId( action( pId ) );
2166 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2167 popupMgr()->insert( action( id ), parentId, 0 );
2169 QChar lc = QtxPopupMgr::Selection::defEquality();
2170 QString rule = "(%1) and (%2) and (%3)";
2171 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2172 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2173 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2176 bool cont = myRules.contains( id );
2178 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2180 popupMgr()->setRule( action( id ), rule, true );
2181 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2184 //=======================================================================
2185 // function : initialize
2187 //=======================================================================
2188 void SMESHGUI::initialize( CAM_Application* app )
2190 SalomeApp_Module::initialize( app );
2192 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2194 /* Automatic Update flag */
2195 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2197 // ----- create actions --------------
2199 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2200 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2201 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2202 createSMESHAction( 114, "NUM" );
2203 createSMESHAction( 121, "DAT" );
2204 createSMESHAction( 122, "MED" );
2205 createSMESHAction( 123, "UNV" );
2206 createSMESHAction( 124, "EXPORT_DAT" );
2207 createSMESHAction( 125, "EXPORT_MED" );
2208 createSMESHAction( 126, "EXPORT_UNV" );
2209 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2210 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2211 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2212 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2213 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2214 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2215 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2216 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2217 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2218 createSMESHAction( 804, "ADD" );
2219 createSMESHAction( 805, "REMOVE" );
2220 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2221 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2222 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2223 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2224 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2225 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2226 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2227 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2228 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2229 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2230 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2231 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2232 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2233 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2234 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2235 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2236 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2237 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2238 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2239 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2240 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2241 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2242 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2243 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2244 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2245 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2246 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2247 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2248 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2249 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2250 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2251 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2252 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2253 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2254 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2255 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2256 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2257 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2258 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2259 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2260 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2261 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2262 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2263 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2264 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2265 createSMESHAction( 415, "MAP", "ICON_MAP" );
2266 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2267 createSMESHAction( 200, "RESET" );
2268 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2269 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2270 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2271 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2272 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2273 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2274 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2275 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2276 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2277 createSMESHAction( 220, "ALL" );
2278 createSMESHAction( 1100, "EDIT_HYPO" );
2279 createSMESHAction( 1101, "RENAME" );
2280 createSMESHAction( 1102, "UNASSIGN" );
2281 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2282 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2283 createSMESHAction( 1131, "DISPMODE" );
2284 createSMESHAction( 1132, "COLORS" );
2285 createSMESHAction( 1133, "TRANSP" );
2286 createSMESHAction( 1134, "CLIP" );
2287 createSMESHAction( 1135, "DISP_ENT" );
2288 createSMESHAction( 2000, "CTRL" );
2290 createSMESHAction( 300, "ERASE" );
2291 createSMESHAction( 301, "DISPLAY" );
2292 createSMESHAction( 302, "DISPLAY_ONLY" );
2293 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2295 // ----- create menu --------------
2296 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2297 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2298 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2299 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2300 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2301 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2302 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2304 createMenu( separator(), fileId );
2306 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2307 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2308 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2309 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2310 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2311 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2313 createMenu( 111, importId, -1 );
2314 createMenu( 112, importId, -1 );
2315 createMenu( 113, importId, -1 );
2317 createMenu( 121, exportId, -1 );
2318 createMenu( 122, exportId, -1 );
2319 createMenu( 123, exportId, -1 );
2321 createMenu( separator(), fileId, 10 );
2323 createMenu( 33, editId, -1 );
2325 createMenu( 5105, toolsId, -1 );
2327 createMenu( 702, meshId, -1 );
2328 createMenu( 703, meshId, -1 );
2329 createMenu( 704, meshId, -1 );
2330 createMenu( separator(), meshId, -1 );
2331 createMenu( 701, meshId, -1 );
2332 createMenu( separator(), meshId, -1 );
2333 createMenu( 801, meshId, -1 );
2334 createMenu( 802, meshId, -1 );
2335 createMenu( 803, meshId, -1 );
2336 createMenu( separator(), meshId, -1 );
2337 createMenu( 810, meshId, -1 );
2338 createMenu( 811, meshId, -1 );
2339 createMenu( 812, meshId, -1 );
2340 createMenu( separator(), meshId, -1 );
2341 createMenu( 813, meshId, -1 );
2342 createMenu( separator(), meshId, -1 );
2343 createMenu( 900, meshId, -1 );
2344 createMenu( 902, meshId, -1 );
2345 createMenu( separator(), meshId, -1 );
2347 createMenu( 6003, ctrlId, -1 );
2348 createMenu( 6001, ctrlId, -1 );
2349 createMenu( 6004, ctrlId, -1 );
2350 createMenu( separator(), ctrlId, -1 );
2351 createMenu( 6002, ctrlId, -1 );
2352 createMenu( 6018, ctrlId, -1 );
2353 createMenu( 6019, ctrlId, -1 );
2354 createMenu( 6011, ctrlId, -1 );
2355 createMenu( 6012, ctrlId, -1 );
2356 createMenu( 6013, ctrlId, -1 );
2357 createMenu( 6014, ctrlId, -1 );
2358 createMenu( 6015, ctrlId, -1 );
2359 createMenu( 6016, ctrlId, -1 );
2360 createMenu( separator(), ctrlId, -1 );
2361 createMenu( 6017, ctrlId, -1 );
2362 createMenu( separator(), ctrlId, -1 );
2364 createMenu( 400, addId, -1 );
2365 createMenu( 401, addId, -1 );
2366 createMenu( 4021, addId, -1 );
2367 createMenu( 4022, addId, -1 );
2368 createMenu( 4023, addId, -1 );
2369 createMenu( 4031, addId, -1 );
2370 createMenu( 4032, addId, -1 );
2371 createMenu( 4033, addId, -1 );
2373 createMenu( 4041, removeId, -1 );
2374 createMenu( 4042, removeId, -1 );
2376 createMenu( 4051, renumId, -1 );
2377 createMenu( 4052, renumId, -1 );
2379 createMenu( 4061, transfId, -1 );
2380 createMenu( 4062, transfId, -1 );
2381 createMenu( 4063, transfId, -1 );
2382 createMenu( 4064, transfId, -1 );
2383 createMenu( 4065, transfId, -1 );
2384 createMenu( 4066, transfId, -1 );
2386 createMenu( 406, modifyId, -1 );
2387 createMenu( 407, modifyId, -1 );
2388 createMenu( 408, modifyId, -1 );
2389 createMenu( 409, modifyId, -1 );
2390 createMenu( 410, modifyId, -1 );
2391 createMenu( 411, modifyId, -1 );
2392 createMenu( 412, modifyId, -1 );
2393 createMenu( 413, modifyId, -1 );
2394 createMenu( 416, modifyId, -1 );
2395 createMenu( 414, modifyId, -1 );
2396 createMenu( 415, modifyId, -1 );
2398 createMenu( 214, viewId, -1 );
2400 // ----- create toolbars --------------
2401 int meshTb = createTool( tr( "TB_MESH" ) ),
2402 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2403 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2404 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2405 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2407 createTool( 702, meshTb );
2408 createTool( 703, meshTb );
2409 createTool( 704, meshTb );
2410 createTool( separator(), meshTb );
2411 createTool( 701, meshTb );
2412 createTool( separator(), meshTb );
2413 createTool( 801, meshTb );
2414 createTool( 802, meshTb );
2415 createTool( 803, meshTb );
2416 createTool( separator(), meshTb );
2417 createTool( 900, meshTb );
2418 createTool( 902, meshTb );
2419 createTool( separator(), meshTb );
2421 createTool( 6001, ctrlTb );
2422 createTool( 6003, ctrlTb );
2423 createTool( 6004, ctrlTb );
2424 createTool( separator(), ctrlTb );
2425 createTool( 6002, ctrlTb );
2426 createTool( 6018, ctrlTb );
2427 createTool( 6019, ctrlTb );
2428 createTool( 6011, ctrlTb );
2429 createTool( 6012, ctrlTb );
2430 createTool( 6013, ctrlTb );
2431 createTool( 6014, ctrlTb );
2432 createTool( 6015, ctrlTb );
2433 createTool( 6016, ctrlTb );
2434 createTool( separator(), ctrlTb );
2435 createTool( 6017, ctrlTb );
2436 createTool( separator(), ctrlTb );
2438 createTool( 400, addRemTb );
2439 createTool( 401, addRemTb );
2440 createTool( 4021, addRemTb );
2441 createTool( 4022, addRemTb );
2442 createTool( 4023, addRemTb );
2443 createTool( 4031, addRemTb );
2444 createTool( 4032, addRemTb );
2445 createTool( 4033, addRemTb );
2446 createTool( separator(), addRemTb );
2447 createTool( 4041, addRemTb );
2448 createTool( 4042, addRemTb );
2449 createTool( separator(), addRemTb );
2450 createTool( 4051, addRemTb );
2451 createTool( 4052, addRemTb );
2452 createTool( separator(), addRemTb );
2453 createTool( 4061, addRemTb );
2454 createTool( 4062, addRemTb );
2455 createTool( 4063, addRemTb );
2456 createTool( 4064, addRemTb );
2457 createTool( 4065, addRemTb );
2458 createTool( 4066, addRemTb );
2459 createTool( separator(), addRemTb );
2461 createTool( 406, modifyTb );
2462 createTool( 407, modifyTb );
2463 createTool( 408, modifyTb );
2464 createTool( 409, modifyTb );
2465 createTool( 410, modifyTb );
2466 createTool( 411, modifyTb );
2467 createTool( 412, modifyTb );
2468 createTool( 413, modifyTb );
2469 createTool( 416, modifyTb );
2470 createTool( 414, modifyTb );
2471 createTool( 415, modifyTb );
2473 createTool( 214, dispModeTb );
2477 QString OB = "'ObjectBrowser'",
2478 View = "'" + SVTK_Viewer::Type() + "'",
2480 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2481 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2482 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2483 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2484 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2485 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2486 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2487 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2488 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2489 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2491 mesh_group = mesh + " " + subMesh + " " + group,
2492 hyp_alg = hypo + " " + algo;
2494 // popup for object browser
2496 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2497 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2498 createPopupItem( 803, OB, group ); // EDIT_GROUP
2499 popupMgr()->insert( separator(), -1, 0 );
2500 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2501 createPopupItem( 214, OB, mesh_group ); // UPDATE
2502 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2503 createPopupItem( 902, OB, mesh ); // STD_INFO
2504 popupMgr()->insert( separator(), -1, 0 );
2505 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2506 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2507 popupMgr()->insert( separator(), -1, 0 );
2508 createPopupItem( 1100, OB, hypo, "&& $hasReference={false}" ); // EDIT HYPOTHESIS
2509 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2510 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "&& $hasReference={false}" ); // RENAME
2511 popupMgr()->insert( separator(), -1, 0 );
2512 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2513 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2514 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2515 popupMgr()->insert( separator(), -1, 0 );
2518 createPopupItem( 803, View, group ); // EDIT_GROUP
2519 createPopupItem( 804, View, elems ); // ADD
2520 createPopupItem( 805, View, elems ); // REMOVE
2521 popupMgr()->insert( separator(), -1, 0 );
2522 createPopupItem( 214, View, mesh_group ); // UPDATE
2523 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2524 createPopupItem( 902, View, mesh ); // STD_INFO
2525 popupMgr()->insert( separator(), -1, 0 );
2529 isInvisible("not( isVisible )"),
2530 isEmpty("numberOfNodes = 0"),
2531 isNotEmpty("numberOfNodes <> 0"),
2533 // has nodes, edges, etc in VISIBLE! actor
2534 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2535 hasElems("(count( elemTypes ) > 0)"),
2536 hasDifferentElems("(count( elemTypes ) > 1)"),
2537 hasEdges("({'Edge'} in elemTypes)"),
2538 hasFaces("({'Face'} in elemTypes)"),
2539 hasVolumes("({'Volume'} in elemTypes)");
2541 QString lc = QtxPopupMgr::Selection::defEquality();
2542 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2543 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2544 QString aMeshInVTK = aClient + "&&" + aType;
2546 //-------------------------------------------------
2548 //-------------------------------------------------
2549 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2551 popupMgr()->insert( action( 9010 ), anId, -1 );
2552 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2553 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2555 popupMgr()->insert( action( 9011 ), anId, -1 );
2556 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2557 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2559 popupMgr()->insert( separator(), -1, -1 );
2561 //-------------------------------------------------
2563 //-------------------------------------------------
2564 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2566 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2567 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2568 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2570 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2571 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2572 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2574 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2575 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2576 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2578 popupMgr()->insert( separator(), anId, -1 );
2580 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2581 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2582 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2584 //-------------------------------------------------
2586 //-------------------------------------------------
2587 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2589 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2591 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2592 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2593 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2595 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2596 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2597 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2599 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2600 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2601 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2603 popupMgr()->insert( separator(), anId, -1 );
2605 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2606 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2608 //-------------------------------------------------
2610 //-------------------------------------------------
2611 popupMgr()->insert( action( 1132 ), -1, -1 );
2612 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2614 //-------------------------------------------------
2616 //-------------------------------------------------
2617 popupMgr()->insert( action( 1133 ), -1, -1 );
2618 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2620 //-------------------------------------------------
2622 //-------------------------------------------------
2623 popupMgr()->insert( action( 1134 ), -1, -1 );
2624 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2626 popupMgr()->insert( separator(), -1, -1 );
2628 //-------------------------------------------------
2630 //-------------------------------------------------
2632 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2633 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2634 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2636 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2638 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2639 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2641 popupMgr()->insert( separator(), anId, -1 );
2643 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2644 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2645 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2647 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2648 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2649 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2651 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2652 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2653 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2655 popupMgr()->insert( separator(), anId, -1 );
2657 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2658 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2659 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2661 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2662 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2663 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2665 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2666 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2667 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2669 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2670 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2671 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2673 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2674 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2675 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2677 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2678 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2679 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2681 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2682 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2683 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2685 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2686 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2687 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2689 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2690 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2691 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2693 popupMgr()->insert( separator(), anId, -1 );
2695 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2696 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2697 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2699 popupMgr()->insert( separator(), anId, -1 );
2701 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2702 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2704 popupMgr()->insert( separator(), -1, -1 );
2706 //-------------------------------------------------
2708 //-------------------------------------------------
2709 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2710 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
2711 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2712 QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
2713 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2714 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
2716 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2717 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
2719 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2720 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
2722 popupMgr()->insert( separator(), -1, -1 );
2724 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
2725 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
2728 bool SMESHGUI::activateModule( SUIT_Study* study )
2730 bool res = SalomeApp_Module::activateModule( study );
2732 setMenuShown( true );
2733 setToolShown( true );
2738 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2740 setMenuShown( false );
2741 setToolShown( false );
2743 EmitSignalCloseAllDialogs();
2745 return SalomeApp_Module::deactivateModule( study );
2748 void SMESHGUI::OnGUIEvent()
2750 const QObject* obj = sender();
2751 if ( !obj || !obj->inherits( "QAction" ) )
2753 int id = actionId((QAction*)obj);
2758 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2760 if ( CORBA::is_nil( myComponentSMESH ) )
2762 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2763 return aGUI.myComponentSMESH;
2765 return myComponentSMESH;
2768 QString SMESHGUI::engineIOR() const
2770 CORBA::ORB_var anORB = getApp()->orb();
2771 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2775 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2777 SMESHGUI_Selection sel;
2778 sel.init( client, selectionMgr() );
2779 popupMgr()->updatePopup( menu, &sel );
2782 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2784 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2785 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2788 void SMESHGUI::viewManagers( QStringList& list ) const
2790 list.append( SVTK_Viewer::Type() );
2793 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
2795 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
2796 SMESH::UpdateSelectionProp( this );
2799 void SMESHGUI::createPreferences()
2801 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2803 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2804 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "display_entity" );
2805 addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "auto_update" );
2807 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2808 setPreferenceProperty( precGroup, "columns", 1 );
2810 addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool );
2811 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2813 setPreferenceProperty( prec, "min", 0 );
2814 setPreferenceProperty( prec, "max", 16 );
2816 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2817 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, SalomeApp_Preferences::Selector, "SMESH", "display_mode" );
2819 modes.append( "Wireframe" );
2820 modes.append( "Shading" );
2821 modes.append( "Shrink" );
2822 modes.append( "Nodes" );
2823 setPreferenceProperty( dispmode, "strings", modes );
2825 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2826 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2828 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
2829 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
2831 setPreferenceProperty( nodeSz, "min", 1 );
2832 setPreferenceProperty( nodeSz, "max", 5 );
2834 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2836 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
2837 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
2838 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
2839 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
2841 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
2842 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2844 setPreferenceProperty( elemW, "min", 1 );
2845 setPreferenceProperty( elemW, "max", 5 );
2847 setPreferenceProperty( shrink, "min", 0 );
2848 setPreferenceProperty( shrink, "max", 100 );
2850 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2852 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2854 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
2855 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
2856 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
2858 setPreferenceProperty( selW, "min", 1 );
2859 setPreferenceProperty( selW, "max", 5 );
2861 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2863 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
2864 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2866 setPreferenceProperty( preW, "min", 1 );
2867 setPreferenceProperty( preW, "max", 5 );
2869 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2871 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
2872 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
2874 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2875 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2877 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2878 addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2879 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2880 addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
2883 fam.append( tr( "SMESH_FONT_ARIAL" ) );
2884 fam.append( tr( "SMESH_FONT_COURIER" ) );
2885 fam.append( tr( "SMESH_FONT_TIMES" ) );
2886 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2888 setPreferenceProperty( tfont, "families", fam );
2889 setPreferenceProperty( tfont, "system", false );
2890 setPreferenceProperty( tfont, "widget_flags", wflag );
2891 setPreferenceProperty( lfont, "families", fam );
2892 setPreferenceProperty( lfont, "system", false );
2893 setPreferenceProperty( lfont, "widget_flags", wflag );
2895 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
2897 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
2898 setPreferenceProperty( numcol, "min", 2 );
2899 setPreferenceProperty( numcol, "max", 256 );
2901 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
2902 setPreferenceProperty( numlab, "min", 2 );
2903 setPreferenceProperty( numlab, "max", 65 );
2905 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
2906 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2907 QStringList orients;
2908 orients.append( tr( "SMESH_VERTICAL" ) );
2909 orients.append( tr( "SMESH_HORIZONTAL" ) );
2910 QValueList<QVariant> indices; indices.append( 0 ); indices.append( 1 );
2911 setPreferenceProperty( orient, "strings", orients );
2912 setPreferenceProperty( orient, "indexes", indices );
2914 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
2915 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2916 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2917 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2918 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
2919 setPreferenceProperty( xv, "step", 0.1 );
2920 setPreferenceProperty( xv, "min", 0.0 );
2921 setPreferenceProperty( xv, "max", 1.0 );
2922 setPreferenceProperty( yv, "step", 0.1 );
2923 setPreferenceProperty( yv, "min", 0.0 );
2924 setPreferenceProperty( yv, "max", 1.0 );
2925 setPreferenceProperty( wv, "step", 0.1 );
2926 setPreferenceProperty( wv, "min", 0.0 );
2927 setPreferenceProperty( wv, "max", 1.0 );
2928 setPreferenceProperty( hv, "min", 0.0 );
2929 setPreferenceProperty( hv, "max", 1.0 );
2930 setPreferenceProperty( hv, "step", 0.1 );
2932 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
2933 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
2934 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
2935 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
2936 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
2937 setPreferenceProperty( xv, "min", 0.0 );
2938 setPreferenceProperty( xv, "max", 1.0 );
2939 setPreferenceProperty( xv, "step", 0.1 );
2940 setPreferenceProperty( xh, "min", 0.0 );
2941 setPreferenceProperty( xh, "max", 1.0 );
2942 setPreferenceProperty( xh, "step", 0.1 );
2943 setPreferenceProperty( yh, "min", 0.0 );
2944 setPreferenceProperty( yh, "max", 1.0 );
2945 setPreferenceProperty( yh, "step", 0.1 );
2946 setPreferenceProperty( wh, "min", 0.0 );
2947 setPreferenceProperty( wh, "max", 1.0 );
2948 setPreferenceProperty( wh, "step", 0.1 );
2949 setPreferenceProperty( hh, "min", 0.0 );
2950 setPreferenceProperty( hh, "max", 1.0 );
2951 setPreferenceProperty( hh, "step", 0.1 );
2954 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
2958 //================================================================================
2960 * \brief Update something in accordance with update flags
2961 * \param theFlags - update flags
2963 * Update viewer or/and object browser etc. in accordance with update flags ( see
2964 * SalomeApp_UpdateFlags enumeration ).
2966 //================================================================================
2967 void SMESHGUI::update( const int flags )
2969 if ( flags & UF_Viewer | flags & UF_Forced )
2970 SMESH::UpdateView();
2972 SalomeApp_Module::update( flags );
2975 //================================================================================
2977 * \brief Set default selection mode
2979 * SLOT called when operation commited. Sets default selection mode
2981 //================================================================================
2982 void SMESHGUI::onOperationCommited( SUIT_Operation* )
2984 SVTK_ViewWindow* vtkWnd =
2985 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
2987 vtkWnd->SetSelectionMode( ActorSelection );
2990 //================================================================================
2992 * \brief Set default selection mode
2994 * SLOT called when operation aborted. Sets default selection mode
2996 //================================================================================
2997 void SMESHGUI::onOperationAborted( SUIT_Operation* )
2999 SVTK_ViewWindow* vtkWnd =
3000 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3002 vtkWnd->SetSelectionMode( ActorSelection );
3005 //================================================================================
3007 * \brief Creates operation with given identifier
3008 * \param id - identifier of operation to be started
3009 * \return Pointer on created operation or NULL if operation is not created
3011 * Virtual method redefined from the base class creates operation with given id.
3012 * It is called called automatically from startOperation method of base class.
3014 //================================================================================
3015 SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
3017 SalomeApp_Operation* op = 0;
3018 // to do : create operation here
3021 case 702: // Create mesh
3022 op = new SMESHGUI_MeshOp( true, true );
3024 case 703: // Create sub-mesh
3025 op = new SMESHGUI_MeshOp( true, false );
3027 case 704: // Edit mesh/sub-mesh
3028 op = new SMESHGUI_MeshOp( false );