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"
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_ImportOperation.h"
91 #include <SVTK_ViewWindow.h>
92 #include <SVTK_ViewModel.h>
93 #include <SVTK_InteractorStyle.h>
94 #include <SVTK_RenderWindowInteractor.h>
96 #include <VTKViewer_ViewManager.h>
98 #include "OB_Browser.h"
100 #include "SUIT_Tools.h"
101 #include "SUIT_MessageBox.h"
102 #include "SUIT_ResourceMgr.h"
103 #include "SUIT_FileDlg.h"
104 #include "SUIT_Desktop.h"
105 #include "SUIT_ResourceMgr.h"
106 #include "SUIT_OverrideCursor.h"
107 #include "SUIT_Study.h"
108 #include "SUIT_Session.h"
110 #include "QtxPopupMgr.h"
112 #include "SALOME_ListIO.hxx"
113 #include "SALOME_ListIteratorOfListIO.hxx"
114 #include "SALOME_InteractiveObject.hxx"
115 #include "SALOME_NamingService.hxx"
116 #include "SALOME_LifeCycleCORBA.hxx"
118 #include "SALOMEconfig.h"
119 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
122 #define INCLUDE_MENUITEM_DEF
123 #include <qpopupmenu.h>
129 #include <boost/shared_ptr.hpp>
132 #include <vtkRenderer.h>
133 #include <vtkRenderWindow.h>
134 #include <vtkActorCollection.h>
135 #include <vtkScalarBarActor.h>
136 #include <vtkUnstructuredGrid.h>
138 #include "utilities.h"
140 #include "SALOMEDS_Study.hxx"
141 #include "SALOMEDSClient_StudyBuilder.hxx"
142 #include "SALOMEDSClient_SComponent.hxx"
148 //=============================================================
149 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
152 void ExportMeshToFile(int theCommandID);
154 void SetDisplayMode(int theCommandID);
156 void SetDisplayEntity(int theCommandID);
158 void Control( int theCommandID );
162 //=============================================================
163 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
169 if(theCommandID == 113){
170 filter.append(QObject::tr("MED files (*.med)"));
171 filter.append(QObject::tr("All files (*)"));
172 }else if (theCommandID == 112){
173 filter.append(QObject::tr("IDEAS files (*.unv)"));
174 }else if (theCommandID == 111){
175 filter.append(QObject::tr("DAT files (*.dat)"));
177 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
180 QObject::tr("Import mesh"),
182 if(!filename.isEmpty()) {
183 SUIT_OverrideCursor wc;
184 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
185 theComponentMesh->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
188 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
189 switch ( theCommandID ) {
192 aMeshes->length( 1 );
193 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
198 SMESH::DriverMED_ReadStatus res;
199 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
200 if ( res != SMESH::DRS_OK ) {
202 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
203 QObject::tr("SMESH_WRN_WARNING"),
204 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
205 QObject::tr("SMESH_BUT_OK"));
206 aMeshes->length( 0 );
213 bool isEmpty = false;
214 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
215 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
217 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
218 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
219 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
220 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
221 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
228 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
229 QObject::tr("SMESH_WRN_WARNING"),
230 QObject::tr("SMESH_DRS_EMPTY"),
231 QObject::tr("SMESH_BUT_OK"));
235 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
237 catch (const SALOME::SALOME_Exception& S_ex){
239 SalomeApp_Tools::QtCatchCorbaException(S_ex);
246 void ExportMeshToFile( int theCommandID )
248 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
249 SALOME_ListIO selected;
251 aSel->selectedObjects( selected );
253 if(selected.Extent()){
254 Handle(SALOME_InteractiveObject) anIObject = selected.First();
255 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
256 if ( !aMesh->_is_nil() ) {
257 QString aFilter, aTitle = QObject::tr("Export mesh");
258 QMap<QString, SMESH::MED_VERSION> aFilterMap;
259 switch ( theCommandID ) {
262 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
263 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
267 aFilter = QObject::tr("DAT files (*.dat)");
271 if(aMesh->NbPyramids()){
272 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
273 QObject::tr("SMESH_WRN_WARNING"),
274 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
275 QObject::tr("SMESH_BUT_YES"),
276 QObject::tr("SMESH_BUT_NO"),
281 aFilter = QObject::tr("IDEAS files (*.unv)");
288 SMESH::MED_VERSION aFormat;
290 if ( theCommandID != 122 && theCommandID != 125 )
291 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
295 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
296 filters.push_back( it.key() );
298 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
299 fd->setCaption( aTitle );
300 fd->setFilters( filters );
304 aFilename = fd->selectedFile();
305 aFormat = aFilterMap[fd->selectedFilter()];
307 if( !aFilename.isEmpty()
308 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
309 && aFormat==SMESH::MED_V2_1){
310 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
311 QObject::tr("SMESH_WRN_WARNING"),
312 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
313 QObject::tr("SMESH_BUT_YES"),
314 QObject::tr("SMESH_BUT_NO"),
323 if ( !aFilename.isEmpty() ) {
324 // Check whether the file already exists and delete it if yes
325 QFile aFile( aFilename );
326 if ( aFile.exists() )
328 SUIT_OverrideCursor wc;
329 switch ( theCommandID ) {
332 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
336 aMesh->ExportDAT( aFilename.latin1() );
340 aMesh->ExportUNV( aFilename.latin1() );
350 inline void InverseEntityMode(unsigned int& theOutputMode,
351 unsigned int theMode)
353 bool anIsNotPresent = ~theOutputMode & theMode;
355 theOutputMode |= theMode;
357 theOutputMode &= ~theMode;
360 void SetDisplayEntity(int theCommandID){
361 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
362 SALOME_ListIO selected;
364 aSel->selectedObjects( selected );
366 if(selected.Extent() >= 1){
367 SALOME_ListIteratorOfListIO It( selected );
368 for(; It.More(); It.Next()){
369 Handle(SALOME_InteractiveObject) IObject = It.Value();
370 if(IObject->hasEntry()){
371 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
372 unsigned int aMode = anActor->GetEntityMode();
373 switch(theCommandID){
375 InverseEntityMode(aMode,SMESH_Actor::eEdges);
378 InverseEntityMode(aMode,SMESH_Actor::eFaces);
381 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
384 aMode = SMESH_Actor::eAllEntity;
388 anActor->SetEntityMode(aMode);
395 void SetDisplayMode(int theCommandID){
396 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
397 SALOME_ListIO selected;
399 aSel->selectedObjects( selected );
401 if(selected.Extent() >= 1){
402 switch(theCommandID){
404 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
405 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
409 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
410 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
413 SALOME_ListIteratorOfListIO It( selected );
414 for(; It.More(); It.Next()){
415 Handle(SALOME_InteractiveObject) IObject = It.Value();
416 if(IObject->hasEntry()){
417 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
418 switch(theCommandID){
420 anActor->SetRepresentation(SMESH_Actor::eEdge);
423 anActor->SetRepresentation(SMESH_Actor::eSurface);
426 if(anActor->IsShrunk())
429 anActor->SetShrink();
432 anActor->SetRepresentation(SMESH_Actor::ePoint);
436 anActor->GetSufaceColor(color[0], color[1], color[2]);
437 int c0 = int (color[0] * 255);
438 int c1 = int (color[1] * 255);
439 int c2 = int (color[2] * 255);
440 QColor c(c0, c1, c2);
443 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
444 c0 = int (edgecolor[0] * 255);
445 c1 = int (edgecolor[1] * 255);
446 c2 = int (edgecolor[2] * 255);
447 QColor e(c0, c1, c2);
449 float backfacecolor[3];
450 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
451 c0 = int (backfacecolor[0] * 255);
452 c1 = int (backfacecolor[1] * 255);
453 c2 = int (backfacecolor[2] * 255);
454 QColor b(c0, c1, c2);
457 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
458 c0 = int (nodecolor[0] * 255);
459 c1 = int (nodecolor[1] * 255);
460 c2 = int (nodecolor[2] * 255);
461 QColor n(c0, c1, c2);
463 int Edgewidth = (int)anActor->GetLineWidth();
466 int intValue = int(anActor->GetNodeSize());
467 float Shrink = anActor->GetShrinkFactor();
469 SMESHGUI_Preferences_ColorDlg *aDlg =
470 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
471 aDlg->SetColor(1, c);
472 aDlg->SetColor(2, e);
473 aDlg->SetColor(3, n);
474 aDlg->SetColor(4, b);
475 aDlg->SetIntValue(1, Edgewidth);
476 aDlg->SetIntValue(2, intValue);
477 aDlg->SetIntValue(3, int(Shrink*100.));
479 QColor color = aDlg->GetColor(1);
480 QColor edgecolor = aDlg->GetColor(2);
481 QColor nodecolor = aDlg->GetColor(3);
482 QColor backfacecolor = aDlg->GetColor(4);
483 /* actor color and backface color */
484 anActor->SetSufaceColor(float (color.red()) / 255.,
485 float (color.green()) / 255.,
486 float (color.blue()) / 255.);
487 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
488 float (backfacecolor.green()) / 255.,
489 float (backfacecolor.blue()) / 255.);
492 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
493 float (edgecolor.green()) / 255.,
494 float (edgecolor.blue()) / 255.);
496 /* Shrink factor and size edges */
497 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
498 anActor->SetLineWidth(aDlg->GetIntValue(1));
500 /* Nodes color and size */
501 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
502 float (nodecolor.green()) / 255.,
503 float (nodecolor.blue()) / 255.);
504 anActor->SetNodeSize(aDlg->GetIntValue(2));
513 SMESH::RepaintCurrentView();
517 void Control( int theCommandID )
519 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
520 SALOME_ListIO selected;
522 aSel->selectedObjects( selected );
524 if( !selected.IsEmpty() ){
525 Handle(SALOME_InteractiveObject) anIO = selected.First();
528 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
529 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
530 switch ( theCommandID ){
532 aTitle = QObject::tr( "LENGTH_EDGES" );
533 aControl = SMESH_Actor::eLength;
536 aTitle = QObject::tr( "LENGTH2D_EDGES" );
537 aControl = SMESH_Actor::eLength2D;
540 aTitle = QObject::tr( "FREE_EDGES" );
541 aControl = SMESH_Actor::eFreeEdges;
544 aTitle = QObject::tr( "FREE_BORDERS" );
545 aControl = SMESH_Actor::eFreeBorders;
548 aTitle = QObject::tr( "MULTI_BORDERS" );
549 aControl = SMESH_Actor::eMultiConnection;
552 aTitle = QObject::tr( "MULTI2D_BORDERS" );
553 aControl = SMESH_Actor::eMultiConnection2D;
556 aTitle = QObject::tr( "AREA_ELEMENTS" );
557 aControl = SMESH_Actor::eArea;
560 aTitle = QObject::tr( "TAPER_ELEMENTS" );
561 aControl = SMESH_Actor::eTaper;
564 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
565 aControl = SMESH_Actor::eAspectRatio;
568 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
569 aControl = SMESH_Actor::eAspectRatio3D;
572 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
573 aControl = SMESH_Actor::eMinimumAngle;
576 aTitle = QObject::tr( "WARP_ELEMENTS" );
577 aControl = SMESH_Actor::eWarping;
580 aTitle = QObject::tr( "SKEW_ELEMENTS" );
581 aControl = SMESH_Actor::eSkew;
584 anActor->SetControlMode(aControl);
585 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
592 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
593 MeshObjectType theType,
594 const QString theInTypeName,
595 QString & theOutTypeName)
597 SMESH_TypeFilter aTypeFilter( theType );
599 if( !theIO.IsNull() )
601 entry = theIO->getEntry();
602 SalomeApp_DataOwner owner( entry );
603 if ( aTypeFilter.isOk( &owner )) {
604 theOutTypeName = theInTypeName;
612 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
614 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
615 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
617 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
618 CORBA::String_var anID = aSComp->GetID().c_str();
619 if (!strcmp(anID.in(),theIO->getEntry()))
625 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
626 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
627 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
628 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
629 CheckOIType ( theIO, GROUP, "Group", aTypeName )
637 QString CheckHomogeneousSelection()
639 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
640 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
641 SALOME_ListIO selected;
643 aSel->selectedObjects( selected );
645 QString RefType = CheckTypeObject(selected.First());
646 SALOME_ListIteratorOfListIO It(selected);
647 for (; It.More(); It.Next())
649 Handle(SALOME_InteractiveObject) IObject = It.Value();
650 QString Type = CheckTypeObject(IObject);
651 if (Type.compare(RefType) != 0)
652 return "Heterogeneous Selection";
660 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
661 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
662 SALOME_ListIO selected; aSel->selectedObjects( selected );
664 QString aParentComponent = QString::null;
665 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
667 QString cur = anIt.Value()->getComponentDataType();
668 if( aParentComponent.isNull() )
669 aParentComponent = cur;
670 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
671 aParentComponent = "";
674 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
675 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
676 QObject::tr("ERR_ERROR"),
677 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
678 QObject::tr("BUT_OK") );
681 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
682 if (SUIT_MessageBox::warn2
683 (SMESHGUI::desktop(),
684 QObject::tr("SMESH_WRN_WARNING"),
685 QObject::tr("SMESH_REALLY_DELETE"),
686 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
689 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
690 SUIT_ViewManager* vm = anApp->activeViewManager();
691 int nbSf = vm->getViewsCount();
693 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
694 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
695 _PTR(GenericAttribute) anAttr;
696 _PTR(AttributeIOR) anIOR;
698 SALOME_ListIteratorOfListIO It(selected);
700 aStudyBuilder->NewCommand(); // There is a transaction
701 for(; It.More(); It.Next()){
702 Handle(SALOME_InteractiveObject) IObject = It.Value();
703 if(IObject->hasEntry()){
704 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
706 /* Erase child graphical objects */
707 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
708 for(it->InitEx(true); it->More(); it->Next()){
709 _PTR(SObject) CSO = it->Value();
710 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
713 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
714 for(int i = 0; i < nbSf; i++){
715 SUIT_ViewWindow *sf = aViews[i];
716 CORBA::String_var anEntry = CSO->GetID().c_str();
717 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
718 SMESH::RemoveActor(sf,anActor);
724 /* Erase main graphical object */
725 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
726 for(int i = 0; i < nbSf; i++){
727 SUIT_ViewWindow *sf = aViews[i];
728 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
729 SMESH::RemoveActor(sf,anActor);
733 // Remove object(s) from data structures
734 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
736 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
737 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
738 QString objType = CheckTypeObject(IObject);
739 if ( !aGroup->_is_nil() ) { // DELETE GROUP
740 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
741 aMesh->RemoveGroup( aGroup );
743 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
744 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
745 aMesh->RemoveSubMesh( aSubMesh );
747 else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
748 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
749 aStudyBuilder->RemoveObjectWithChildren( obj );
751 else {// default action: remove SObject from the study
752 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
753 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
755 aStudyBuilder->RemoveObjectWithChildren( obj );
760 } /* IObject->hasEntry() */
762 aStudyBuilder->CommitCommand();
764 /* Clear any previous selection */
766 aSel->setSelectedObjects( l1 );
768 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
773 Standard_EXPORT CAM_Module* createModule()
775 return new SMESHGUI();
779 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
781 //=============================================================================
785 //=============================================================================
786 SMESHGUI::SMESHGUI() :
787 SalomeApp_Module( "SMESH" )
789 if ( CORBA::is_nil( myComponentSMESH ) )
791 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
792 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
793 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
796 myActiveDialogBox = 0 ;
799 SMESH::GetFilterManager();
802 /* load resources for all available meshers */
803 SMESH::InitAvailableHypotheses();
806 //=============================================================================
810 //=============================================================================
811 SMESHGUI::~SMESHGUI()
813 SMESH::GetFilterManager()->Destroy();
816 //=============================================================================
820 //=============================================================================
821 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
823 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
825 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
830 bool SMESHGUI::automaticUpdate()
832 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
836 return resMgr->booleanValue( "SMESH", "auto_update", false );
839 //=============================================================================
843 //=============================================================================
844 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
846 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
849 //=============================================================================
853 //=============================================================================
854 SMESHGUI* SMESHGUI::GetSMESHGUI()
856 SMESHGUI* smeshMod = 0;
857 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
860 CAM_Module* module = app->module( "Mesh" );
861 smeshMod = dynamic_cast<SMESHGUI*>( module );
864 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
866 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
869 _PTR(Study) aStudy = study->studyDS();
871 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
880 Standard_EXPORT SMESHGUI* GetComponentGUI()
882 return SMESHGUI::GetSMESHGUI();
886 //=============================================================================
890 //=============================================================================
891 void SMESHGUI::SetState(int aState)
896 //=============================================================================
900 //=============================================================================
901 void SMESHGUI::ResetState()
906 //=============================================================================
910 //=============================================================================
911 void SMESHGUI::EmitSignalDeactivateDialog()
913 emit SignalDeactivateActiveDialog();
916 //=============================================================================
920 //=============================================================================
921 void SMESHGUI::EmitSignalStudyFrameChanged()
923 emit SignalStudyFrameChanged();
926 //=============================================================================
930 //=============================================================================
931 void SMESHGUI::EmitSignalCloseAllDialogs()
933 emit SignalCloseAllDialogs();
936 //=============================================================================
940 //=============================================================================
941 QDialog *SMESHGUI::GetActiveDialogBox()
943 return myActiveDialogBox;
946 //=============================================================================
950 //=============================================================================
951 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
953 myActiveDialogBox = (QDialog *) aDlg;
957 //=============================================================================
961 //=============================================================================
962 SUIT_Desktop* SMESHGUI::desktop()
964 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
966 return app->desktop();
971 //=============================================================================
975 //=============================================================================
976 SalomeApp_Study* SMESHGUI::activeStudy()
978 SUIT_Application* app = SUIT_Session::session()->activeApplication();
980 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
985 //=============================================================================
989 //=============================================================================
990 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
992 /* Here the position is on the bottom right corner - 10 */
993 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
995 SUIT_Desktop *PP = desktop();
996 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
997 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1001 //=============================================================================
1005 //=============================================================================
1006 static int isStudyLocked(_PTR(Study) theStudy){
1007 return theStudy->GetProperties()->IsLocked();
1010 static bool checkLock(_PTR(Study) theStudy) {
1011 if (isStudyLocked(theStudy)) {
1012 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1013 QObject::tr("WRN_WARNING"),
1014 QObject::tr("WRN_STUDY_LOCKED"),
1015 QObject::tr("BUT_OK") );
1021 //=======================================================================
1022 //function : CheckActiveStudyLocked
1024 //=======================================================================
1026 bool SMESHGUI::isActiveStudyLocked()
1028 _PTR(Study) aStudy = activeStudy()->studyDS();
1029 return checkLock( aStudy );
1032 //=============================================================================
1036 //=============================================================================
1037 bool SMESHGUI::OnGUIEvent( int theCommandID )
1039 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1043 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1044 SUIT_ResourceMgr* mgr = resourceMgr();
1048 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1049 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1051 //QAction* act = action( theCommandID );
1053 switch (theCommandID) {
1055 if(checkLock(aStudy)) break;
1063 if(checkLock(aStudy)) break;
1064 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1068 case 122: // EXPORT MED
1075 ::ExportMeshToFile(theCommandID);
1079 case 200: // SCALAR BAR
1081 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1082 SALOME_ListIO selected;
1084 aSel->selectedObjects( selected );
1086 if( selected.Extent() ) {
1087 Handle(SALOME_InteractiveObject) anIO = selected.First();
1088 if( anIO->hasEntry() ) {
1089 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1090 anActor->SetControlMode( SMESH_Actor::eNone );
1098 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1102 case 1134: // Clipping
1103 case 1133: // Tranparency
1104 case 1132: // Colors / Size
1111 ::SetDisplayMode(theCommandID);
1117 case 219: // Volumes
1118 case 220: // All Entity
1119 ::SetDisplayEntity(theCommandID);
1124 if(checkLock(aStudy)) break;
1125 SMESH::UpdateView();
1128 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1129 aSel->setSelectedObjects( l );
1134 case 301: // DISPLAY
1135 case 302: // DISPLAY ONLY
1137 SMESH::EDisplaing anAction;
1138 switch (theCommandID) {
1139 case 300: anAction = SMESH::eErase; break;
1140 case 301: anAction = SMESH::eDisplay; break;
1141 case 302: anAction = SMESH::eDisplayOnly; break;
1144 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1145 SALOME_ListIO selected;
1147 aSel->selectedObjects( selected );
1150 SALOME_ListIteratorOfListIO It (selected);
1151 for (; It.More(); It.Next()) {
1152 Handle(SALOME_InteractiveObject) IOS = It.Value();
1153 if (IOS->hasEntry()) {
1154 SMESH::UpdateView(anAction, IOS->getEntry());
1155 if (anAction == SMESH::eDisplayOnly)
1156 anAction = SMESH::eDisplay;
1161 aSel->setSelectedObjects( l1 );
1167 if(checkLock(aStudy)) break;
1170 EmitSignalDeactivateDialog();
1172 new SMESHGUI_NodesDlg(this);
1175 SUIT_MessageBox::warn1(desktop(),
1176 tr("SMESH_WRN_WARNING"),
1177 tr("SMESH_WRN_VIEWER_VTK"),
1178 tr("SMESH_BUT_OK"));
1183 case 2151: // FILTER
1187 EmitSignalDeactivateDialog();
1188 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1193 case 406: // MOVE NODE
1197 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1198 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1202 if(checkLock(aStudy)) break;
1203 new SMESHGUI_MoveNodesDlg(this);
1207 case 701: // COMPUTE MESH
1209 if(checkLock(aStudy)) break;
1211 SalomeApp_SelectionMgr *Sel = selectionMgr();
1212 SALOME_ListIO selected; Sel->selectedObjects( selected );
1214 int nbSel = selected.Extent();
1219 SMESH::SMESH_Mesh_var aMesh;
1220 SMESH::SMESH_subMesh_var aSubMesh;
1221 Handle(SALOME_InteractiveObject) IObject = selected.First();
1222 if (IObject->hasEntry()){
1223 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1224 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1225 if ( aShapeObject->_is_nil() ) {
1230 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1231 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1233 if (!aMesh->_is_nil()){
1234 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1235 if (!refShapeObject->_is_nil()) {
1236 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1237 SUIT_MessageBox::warn1(desktop(),
1238 tr("SMESH_WRN_WARNING"),
1239 tr("SMESH_WRN_MISSING_PARAMETERS"),
1240 tr("SMESH_BUT_OK"));
1244 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1245 SMESH::ModifiedMesh(aMeshSObj,true);
1246 // TO Do : change icon of all submeshes
1248 SUIT_MessageBox::warn1(desktop(),
1249 tr("SMESH_WRN_WARNING"),
1250 tr("SMESH_WRN_COMPUTE_FAILED"),
1251 tr("SMESH_BUT_OK"));
1253 catch(const SALOME::SALOME_Exception & S_ex){
1254 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1257 }else if(!aSubMesh->_is_nil()){
1258 aMesh = aSubMesh->GetFather();
1259 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1260 if(!refShapeObject->_is_nil()){
1261 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1263 SUIT_MessageBox::warn1(desktop(),
1264 tr("SMESH_WRN_WARNING"),
1265 tr("SMESH_WRN_MISSING_PARAMETERS"),
1266 tr("SMESH_BUT_OK"));
1270 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1271 SMESH::ModifiedMesh(aMeshSObj,true);
1272 // TO Do : change icon of all submeshes
1274 SUIT_MessageBox::warn1(desktop(),
1275 tr("SMESH_WRN_WARNING"),
1276 tr("SMESH_WRN_COMPUTE_FAILED"),
1277 tr("SMESH_BUT_OK"));
1278 }catch(const SALOME::SALOME_Exception & S_ex){
1279 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1285 CORBA::Long anId = aStudy->StudyId();
1286 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1287 if ( automaticUpdate() && aVisualObj){
1288 aVisualObj->Update();
1289 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1291 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1293 SMESH::DisplayActor(view,anActor); //apo
1299 SUIT_MessageBox::warn1(desktop(),
1300 tr("SMESH_WRN_WARNING"),
1301 tr("SMESH_WRN_VIEWER_VTK"),
1302 tr("SMESH_BUT_OK"));
1308 case 702: // ADD SUB MESH
1310 if(checkLock(aStudy)) break;
1312 EmitSignalDeactivateDialog();
1313 new SMESHGUI_AddSubMeshDlg( this );
1316 SUIT_MessageBox::warn1(desktop(),
1317 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1318 tr("SMESH_BUT_OK"));
1323 case 703: // INIT MESH
1325 if(checkLock(aStudy)) break;
1326 EmitSignalDeactivateDialog();
1327 new SMESHGUI_InitMeshDlg( this );
1331 case 704: // EDIT Hypothesis
1333 if(checkLock(aStudy)) break;
1334 EmitSignalDeactivateDialog();
1335 new SMESHGUI_EditHypothesesDlg( this );
1339 case 705: // EDIT Global Hypothesis
1341 if(checkLock(aStudy)) break;
1342 EmitSignalDeactivateDialog();
1343 new SMESHGUI_EditHypothesesDlg( this );
1347 case 706: // EDIT Local Hypothesis
1349 if(checkLock(aStudy)) break;
1350 EmitSignalDeactivateDialog();
1351 new SMESHGUI_EditHypothesesDlg( this );
1355 case 407: // DIAGONAL INVERSION
1356 case 408: // Delete diagonal
1360 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1361 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1365 if ( checkLock( aStudy ) )
1368 /*Standard_Boolean aRes;
1369 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1370 if ( aMesh->_is_nil() )
1372 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1373 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1377 EmitSignalDeactivateDialog();
1378 if ( theCommandID == 407 )
1379 new SMESHGUI_TrianglesInversionDlg(this);
1381 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1384 case 409: // Change orientation
1385 case 410: // Union of triangles
1386 case 411: // Cutting of quadrangles
1390 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1391 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1395 if ( checkLock( aStudy ) )
1398 EmitSignalDeactivateDialog();
1399 SMESHGUI_MultiEditDlg* aDlg = NULL;
1400 if ( theCommandID == 409 )
1401 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1402 else if ( theCommandID == 410 )
1403 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1405 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1408 DefineDlgPosition( aDlg, x, y );
1413 case 412: // Smoothing
1415 if(checkLock(aStudy)) break;
1417 EmitSignalDeactivateDialog();
1418 new SMESHGUI_SmoothingDlg( this );
1421 SUIT_MessageBox::warn1(desktop(),
1422 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1423 tr("SMESH_BUT_OK"));
1427 case 413: // Extrusion
1429 if (checkLock(aStudy)) break;
1431 EmitSignalDeactivateDialog();
1432 new SMESHGUI_ExtrusionDlg ( this );
1434 SUIT_MessageBox::warn1(desktop(),
1435 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1436 tr("SMESH_BUT_OK"));
1440 case 414: // Revolution
1442 if(checkLock(aStudy)) break;
1444 EmitSignalDeactivateDialog();
1445 new SMESHGUI_RevolutionDlg( this );
1448 SUIT_MessageBox::warn1(desktop(),
1449 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1450 tr("SMESH_BUT_OK"));
1454 case 415: // Pattern mapping
1456 if ( checkLock( aStudy ) )
1460 EmitSignalDeactivateDialog();
1461 new SMESHGUI_MeshPatternDlg( this );
1464 SUIT_MessageBox::warn1(desktop(),
1465 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1466 tr("SMESH_BUT_OK"));
1470 case 416: // Extrusion along a path
1472 if (checkLock(aStudy)) break;
1474 EmitSignalDeactivateDialog();
1475 new SMESHGUI_ExtrusionAlongPathDlg( this );
1477 SUIT_MessageBox::warn1(desktop(),
1478 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1479 tr("SMESH_BUT_OK"));
1483 case 801: // CREATE GROUP
1487 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1488 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1492 if(checkLock(aStudy)) break;
1493 EmitSignalDeactivateDialog();
1494 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1496 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1497 SALOME_ListIO selected;
1499 aSel->selectedObjects( selected );
1501 int nbSel = selected.Extent();
1503 // check if mesh is selected
1504 aMesh = SMESH::GetMeshByIO( selected.First() );
1506 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1511 case 802: // CONSTRUCT GROUP
1515 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1516 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1520 if(checkLock(aStudy)) break;
1521 EmitSignalDeactivateDialog();
1523 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1524 SALOME_ListIO selected;
1526 aSel->selectedObjects( selected );
1528 int nbSel = selected.Extent();
1530 // check if submesh is selected
1531 Handle(SALOME_InteractiveObject) IObject = selected.First();
1532 if (IObject->hasEntry()) {
1533 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1535 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1536 if (!aSubMesh->_is_nil()) {
1538 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1539 // get submesh elements list by types
1540 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1541 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1542 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1543 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1544 // create group for each type o elements
1545 QString aName = IObject->getName();
1546 if (aNodes->length() > 0) {
1547 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1548 aGroup->Add(aNodes.inout());
1550 if (aEdges->length() > 0) {
1551 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1552 aGroup->Add(aEdges.inout());
1554 if (aFaces->length() > 0) {
1555 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1556 aGroup->Add(aFaces.inout());
1558 if (aVolumes->length() > 0) {
1559 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1560 aGroup->Add(aVolumes.inout());
1564 }catch(const SALOME::SALOME_Exception & S_ex){
1565 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1574 case 803: // EDIT GROUP
1578 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1579 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1583 if(checkLock(aStudy)) break;
1584 EmitSignalDeactivateDialog();
1586 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1587 SALOME_ListIO selected;
1589 aSel->selectedObjects( selected );
1591 SALOME_ListIteratorOfListIO It (selected);
1592 int nbSelectedGroups = 0;
1593 for ( ; It.More(); It.Next() )
1595 SMESH::SMESH_Group_var aGroup =
1596 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1597 if (!aGroup->_is_nil()) {
1599 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1603 if (nbSelectedGroups == 0)
1605 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1611 case 804: // Add elements to group
1613 if(checkLock(aStudy)) break;
1614 if (myState == 800) {
1615 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1616 if (aDlg) aDlg->onAdd();
1621 case 805: // Remove elements from group
1623 if(checkLock(aStudy)) break;
1624 if (myState == 800) {
1625 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1626 if (aDlg) aDlg->onRemove();
1631 case 810: // Union Groups
1632 case 811: // Intersect groups
1633 case 812: // Cut groups
1637 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1638 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1642 if ( checkLock( aStudy ) )
1645 EmitSignalDeactivateDialog();
1648 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1649 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1650 else aMode = SMESHGUI_GroupOpDlg::CUT;
1652 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1656 case 813: // Delete groups with their contents
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();
1670 new SMESHGUI_DeleteGroupDlg( this );
1674 case 900: // MESH INFOS
1676 EmitSignalDeactivateDialog();
1677 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1678 SALOME_ListIO selected;
1680 aSel->selectedObjects( selected );
1682 if ( selected.Extent() > 1 ) { // a dlg for each IO
1684 SALOME_ListIteratorOfListIO It (selected);
1685 for ( ; It.More(); It.Next() ) {
1686 IOs.Clear(); IOs.Append( It.Value() );
1687 aSel->setSelectedObjects( IOs );
1688 new SMESHGUI_MeshInfosDlg(this, "", false);
1690 // restore selection
1691 aSel->setSelectedObjects( selected );
1694 new SMESHGUI_MeshInfosDlg(this, "", false);
1698 case 902: // STANDARD MESH INFOS
1700 EmitSignalDeactivateDialog();
1701 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1702 SALOME_ListIO selected;
1704 aSel->selectedObjects( selected );
1706 if ( selected.Extent() > 1 ) { // a dlg for each IO
1708 SALOME_ListIteratorOfListIO It (selected);
1709 for ( ; It.More(); It.Next() ) {
1711 IOs.Append( It.Value() );
1712 aSel->setSelectedObjects( IOs );
1713 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1715 // restore selection
1716 aSel->setSelectedObjects( selected );
1719 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1723 case 1100: // EDIT HYPOTHESIS
1725 if(checkLock(aStudy)) break;
1727 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1728 SALOME_ListIO selected;
1730 aSel->selectedObjects( selected );
1732 int nbSel = selected.Extent();
1735 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1737 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1738 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1739 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1740 if ( !Hyp->_is_nil() )
1742 char* sName = Hyp->GetName();
1743 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1746 aCreator->EditHypothesis(Hyp);
1754 updateObjBrowser( true );
1758 case 1101: // RENAME
1760 if ( checkLock( aStudy ) )
1763 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1764 SALOME_ListIO selected;
1766 aSel->selectedObjects( selected );
1768 SALOME_ListIteratorOfListIO It( selected );
1769 for ( ; It.More(); It.Next() )
1771 Handle(SALOME_InteractiveObject) IObject = It.Value();
1772 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1773 _PTR(GenericAttribute) anAttr;
1774 _PTR(AttributeName) aName;
1777 if ( obj->FindAttribute(anAttr, "AttributeName") )
1780 QString newName = QString(aName->Value().c_str());
1781 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1782 if ( !newName.isEmpty() )
1784 //old source: aStudy->renameIObject( IObject, newName );
1785 aName->SetValue( newName.latin1() );
1787 // if current object is group update group's name
1788 SMESH::SMESH_GroupBase_var aGroup =
1789 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1790 if (!aGroup->_is_nil() )
1791 aGroup->SetName( newName.latin1() );
1801 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1803 if(checkLock(aStudy)) break;
1804 SUIT_OverrideCursor wc;
1806 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1807 SALOME_ListIO selected;
1809 aSel->selectedObjects( selected );
1811 SALOME_ListIteratorOfListIO It(selected);
1812 for (int i = 0; It.More(); It.Next(), i++) {
1813 Handle(SALOME_InteractiveObject) IObject = It.Value();
1814 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1817 aSel->setSelectedObjects( l1 );
1822 case 401: // GEOM::EDGE
1823 case 4021: // TRIANGLE
1825 case 4023: // POLYGON
1829 if(checkLock(aStudy)) break;
1831 EmitSignalDeactivateDialog();
1832 SMDSAbs_ElementType type = SMDSAbs_Edge;
1834 switch (theCommandID) {
1835 case 4021: // TRIANGLE
1836 type = SMDSAbs_Face; nbNodes = 3; break;
1838 type = SMDSAbs_Face; nbNodes = 4; break;
1840 type = SMDSAbs_Volume; nbNodes = 4; break;
1841 case 4023: // POLYGON
1842 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1844 type = SMDSAbs_Volume; nbNodes = 8; break;
1845 case 4033: // POLYHEDRE
1846 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1849 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1852 SUIT_MessageBox::warn1(desktop(),
1853 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1854 tr("SMESH_BUT_OK"));
1858 case 4033: // POLYHEDRON
1860 if(checkLock(aStudy)) break;
1862 EmitSignalDeactivateDialog();
1863 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1866 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1867 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1868 tr("SMESH_BUT_OK"));
1872 case 4041: // REMOVES NODES
1874 if(checkLock(aStudy)) break;
1876 EmitSignalDeactivateDialog();
1877 new SMESHGUI_RemoveNodesDlg(this);
1880 SUIT_MessageBox::warn1(desktop(),
1881 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1882 tr("SMESH_BUT_OK"));
1886 case 4042: // REMOVES ELEMENTS
1888 if(checkLock(aStudy)) break;
1890 EmitSignalDeactivateDialog();
1891 new SMESHGUI_RemoveElementsDlg(this);
1895 SUIT_MessageBox::warn1(desktop(),
1896 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1897 tr("SMESH_BUT_OK"));
1901 case 4051: // RENUMBERING NODES
1903 if(checkLock(aStudy)) break;
1905 EmitSignalDeactivateDialog();
1906 new SMESHGUI_RenumberingDlg( this, "", 0);
1910 SUIT_MessageBox::warn1(desktop(),
1911 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1912 tr("SMESH_BUT_OK"));
1916 case 4052: // RENUMBERING ELEMENTS
1918 if(checkLock(aStudy)) break;
1920 EmitSignalDeactivateDialog();
1921 new SMESHGUI_RenumberingDlg( this, "", 1);
1925 SUIT_MessageBox::warn1(desktop(),
1926 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1927 tr("SMESH_BUT_OK"));
1931 case 4061: // TRANSLATION
1933 if(checkLock(aStudy)) break;
1935 EmitSignalDeactivateDialog();
1936 new SMESHGUI_TranslationDlg( this );
1939 SUIT_MessageBox::warn1(desktop(),
1940 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1941 tr("SMESH_BUT_OK"));
1945 case 4062: // ROTATION
1947 if(checkLock(aStudy)) break;
1949 EmitSignalDeactivateDialog();
1950 new SMESHGUI_RotationDlg( this );
1953 SUIT_MessageBox::warn1(desktop(),
1954 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1955 tr("SMESH_BUT_OK"));
1959 case 4063: // SYMMETRY
1961 if(checkLock(aStudy)) break;
1963 EmitSignalDeactivateDialog();
1964 new SMESHGUI_SymmetryDlg( this );
1967 SUIT_MessageBox::warn1(desktop(),
1968 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1969 tr("SMESH_BUT_OK"));
1973 case 4064: // SEWING
1975 if(checkLock(aStudy)) break;
1977 EmitSignalDeactivateDialog();
1978 new SMESHGUI_SewingDlg( this );
1981 SUIT_MessageBox::warn1(desktop(),
1982 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1983 tr("SMESH_BUT_OK"));
1987 case 4065: // MERGE NODES
1989 if(checkLock(aStudy)) break;
1991 EmitSignalDeactivateDialog();
1992 new SMESHGUI_MergeNodesDlg( this );
1995 SUIT_MessageBox::warn1(desktop(),
1996 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1997 tr("SMESH_BUT_OK"));
2001 case 4066: // MERGE EQUAL ELEMENTS
2003 if (checkLock(aStudy)) break;
2005 EmitSignalDeactivateDialog();
2006 new SMESHGUI_EditMeshDlg(this,
2007 "SMESH_MERGE_ELEMENTS_TITLE",
2008 "ICON_DLG_MERGE_ELEMENTS",
2009 1); // MergeEqualElemets
2011 SUIT_MessageBox::warn1(desktop(),
2012 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2013 tr("SMESH_BUT_OK"));
2019 case 5000: // HYPOTHESIS
2021 if(checkLock(aStudy)) break;
2022 EmitSignalDeactivateDialog();
2023 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2028 if(checkLock(aStudy)) break;
2029 EmitSignalDeactivateDialog();
2030 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2034 case 5105: // Library of selection filters
2036 static QValueList<int> aTypes;
2037 if ( aTypes.isEmpty() )
2039 aTypes.append( SMESH::NODE );
2040 aTypes.append( SMESH::EDGE );
2041 aTypes.append( SMESH::FACE );
2042 aTypes.append( SMESH::VOLUME );
2044 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2048 case 6017: // CONTROLS
2063 SalomeApp_SelectionMgr* mgr = selectionMgr();
2064 SALOME_ListIO selected; mgr->selectedObjects( selected );
2066 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2067 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2069 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2070 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2071 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2072 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2073 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2074 ::Control( theCommandID );
2079 SUIT_MessageBox::warn1(desktop(),
2080 tr( "SMESH_WRN_WARNING" ),
2081 tr( "SMESH_BAD_SELECTION" ),
2082 tr( "SMESH_BUT_OK" ) );
2086 SUIT_MessageBox::warn1(desktop(),
2087 tr( "SMESH_WRN_WARNING" ),
2088 tr( "NOT_A_VTK_VIEWER" ),
2089 tr( "SMESH_BUT_OK" ) );
2094 SalomeApp_SelectionMgr* mgr = selectionMgr();
2095 SALOME_ListIO selected; mgr->selectedObjects( selected );
2097 if (selected.Extent() == 1) {
2098 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2099 if(anIObject->hasEntry())
2100 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2101 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2108 SalomeApp_SelectionMgr* mgr = selectionMgr();
2109 SALOME_ListIO selected; mgr->selectedObjects( selected );
2111 if (selected.Extent() == 1) {
2112 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2113 if(anIObject->hasEntry())
2114 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2115 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2121 //updateObjBrowser();
2125 //=============================================================================
2129 //=============================================================================
2130 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2135 //=============================================================================
2139 //=============================================================================
2140 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2145 //=============================================================================
2149 //=============================================================================
2150 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2155 //=============================================================================
2156 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2157 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2159 //=============================================================================
2160 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2161 SUIT_ViewWindow* wnd )
2163 if(theIO->hasEntry()){
2164 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2165 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2169 //=======================================================================
2170 // function : createSMESHAction
2172 //=======================================================================
2173 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2176 QWidget* parent = application()->desktop();
2177 SUIT_ResourceMgr* resMgr = resourceMgr();
2179 if ( icon_id.length() )
2180 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2182 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2183 if ( !pix.isNull() )
2184 icon = QIconSet( pix );
2186 QString tooltip = tr( QString( "TOP_" )+po_id ),
2187 menu = tr( QString( "MEN_" )+po_id ),
2188 status_bar = tr( QString( "STB_" )+po_id );
2190 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2193 //=======================================================================
2194 // function : createPopupItem
2196 //=======================================================================
2197 void SMESHGUI::createPopupItem( const int id,
2198 const QString& clients,
2199 const QString& types,
2200 const QString& theRule,
2205 parentId = popupMgr()->actionId( action( pId ) );
2207 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2208 popupMgr()->insert( action( id ), parentId, 0 );
2210 QChar lc = QtxPopupMgr::Selection::defEquality();
2211 QString rule = "(%1) and (%2) and (%3)";
2212 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2213 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2214 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2217 bool cont = myRules.contains( id );
2219 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2221 popupMgr()->setRule( action( id ), rule, true );
2222 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2225 //=======================================================================
2226 // function : initialize
2228 //=======================================================================
2229 void SMESHGUI::initialize( CAM_Application* app )
2231 SalomeApp_Module::initialize( app );
2233 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2235 /* Automatic Update flag */
2236 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2238 // ----- create actions --------------
2240 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2241 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2242 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2243 createSMESHAction( 114, "NUM" );
2244 createSMESHAction( 121, "DAT" );
2245 createSMESHAction( 122, "MED" );
2246 createSMESHAction( 123, "UNV" );
2247 createSMESHAction( 124, "EXPORT_DAT" );
2248 createSMESHAction( 125, "EXPORT_MED" );
2249 createSMESHAction( 126, "EXPORT_UNV" );
2250 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2251 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2252 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2253 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2254 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2255 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2256 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2257 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2258 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2259 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2260 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2261 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2262 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2263 createSMESHAction( 804, "ADD" );
2264 createSMESHAction( 805, "REMOVE" );
2265 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2266 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2267 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2268 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2269 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2270 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2271 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2272 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2273 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2274 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2275 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2276 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2277 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2278 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2279 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2280 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2281 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2282 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2283 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2284 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2285 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2286 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2287 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2288 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2289 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2290 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2291 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2292 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2293 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2294 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2295 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2296 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2297 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2298 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2299 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2300 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2301 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2302 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2303 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2304 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2305 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2306 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2307 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2308 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2309 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2310 createSMESHAction( 415, "MAP", "ICON_MAP" );
2311 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2312 createSMESHAction( 200, "RESET" );
2313 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2314 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2315 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2316 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2317 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2318 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2319 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2320 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2321 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2322 createSMESHAction( 220, "ALL" );
2323 createSMESHAction( 1100, "EDIT_HYPO" );
2324 createSMESHAction( 1101, "RENAME" );
2325 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2326 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2327 createSMESHAction( 1131, "DISPMODE" );
2328 createSMESHAction( 1132, "COLORS" );
2329 createSMESHAction( 1133, "TRANSP" );
2330 createSMESHAction( 1134, "CLIP" );
2331 createSMESHAction( 1135, "DISP_ENT" );
2332 createSMESHAction( 2000, "CTRL" );
2334 createSMESHAction( 300, "ERASE" );
2335 createSMESHAction( 301, "DISPLAY" );
2336 createSMESHAction( 302, "DISPLAY_ONLY" );
2337 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2339 // ----- create menu --------------
2340 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2341 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2342 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2343 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2344 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2345 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2346 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2347 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2349 createMenu( separator(), fileId );
2351 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2352 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2353 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2354 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2355 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2356 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2358 createMenu( 111, importId, -1 );
2359 createMenu( 112, importId, -1 );
2360 createMenu( 113, importId, -1 );
2362 createMenu( 121, exportId, -1 );
2363 createMenu( 122, exportId, -1 );
2364 createMenu( 123, exportId, -1 );
2366 createMenu( separator(), fileId, 10 );
2368 createMenu( 33, editId, -1 );
2370 createMenu( 5105, toolsId, -1 );
2372 createMenu( 5000, hypoId, -1 );
2373 createMenu( 5010, hypoId, -1 );
2375 createMenu( 703, meshId, -1 );
2376 createMenu( 702, meshId, -1 );
2377 createMenu( 704, meshId, -1 );
2378 createMenu( separator(), meshId, -1 );
2379 createMenu( 701, meshId, -1 );
2380 createMenu( separator(), meshId, -1 );
2381 createMenu( 801, meshId, -1 );
2382 createMenu( 802, meshId, -1 );
2383 createMenu( 803, meshId, -1 );
2384 createMenu( separator(), meshId, -1 );
2385 createMenu( 810, meshId, -1 );
2386 createMenu( 811, meshId, -1 );
2387 createMenu( 812, meshId, -1 );
2388 createMenu( separator(), meshId, -1 );
2389 createMenu( 813, meshId, -1 );
2390 createMenu( separator(), meshId, -1 );
2391 createMenu( 900, meshId, -1 );
2392 createMenu( 902, meshId, -1 );
2393 createMenu( separator(), meshId, -1 );
2395 createMenu( 6003, ctrlId, -1 );
2396 createMenu( 6001, ctrlId, -1 );
2397 createMenu( 6004, ctrlId, -1 );
2398 createMenu( separator(), ctrlId, -1 );
2399 createMenu( 6002, ctrlId, -1 );
2400 createMenu( 6018, ctrlId, -1 );
2401 createMenu( 6019, ctrlId, -1 );
2402 createMenu( 6011, ctrlId, -1 );
2403 createMenu( 6012, ctrlId, -1 );
2404 createMenu( 6013, ctrlId, -1 );
2405 createMenu( 6014, ctrlId, -1 );
2406 createMenu( 6015, ctrlId, -1 );
2407 createMenu( 6016, ctrlId, -1 );
2408 createMenu( separator(), ctrlId, -1 );
2409 createMenu( 6017, ctrlId, -1 );
2410 createMenu( separator(), ctrlId, -1 );
2412 createMenu( 400, addId, -1 );
2413 createMenu( 401, addId, -1 );
2414 createMenu( 4021, addId, -1 );
2415 createMenu( 4022, addId, -1 );
2416 createMenu( 4023, addId, -1 );
2417 createMenu( 4031, addId, -1 );
2418 createMenu( 4032, addId, -1 );
2419 createMenu( 4033, addId, -1 );
2421 createMenu( 4041, removeId, -1 );
2422 createMenu( 4042, removeId, -1 );
2424 createMenu( 4051, renumId, -1 );
2425 createMenu( 4052, renumId, -1 );
2427 createMenu( 4061, transfId, -1 );
2428 createMenu( 4062, transfId, -1 );
2429 createMenu( 4063, transfId, -1 );
2430 createMenu( 4064, transfId, -1 );
2431 createMenu( 4065, transfId, -1 );
2432 createMenu( 4066, transfId, -1 );
2434 createMenu( 406, modifyId, -1 );
2435 createMenu( 407, modifyId, -1 );
2436 createMenu( 408, modifyId, -1 );
2437 createMenu( 409, modifyId, -1 );
2438 createMenu( 410, modifyId, -1 );
2439 createMenu( 411, modifyId, -1 );
2440 createMenu( 412, modifyId, -1 );
2441 createMenu( 413, modifyId, -1 );
2442 createMenu( 416, modifyId, -1 );
2443 createMenu( 414, modifyId, -1 );
2444 createMenu( 415, modifyId, -1 );
2446 createMenu( 214, viewId, -1 );
2448 // ----- create toolbars --------------
2449 int meshTb = createTool( tr( "TB_MESH" ) ),
2450 hypoTb = createTool( tr( "TB_HYPO" ) ),
2451 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2452 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2453 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2454 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2456 createTool( 703, meshTb );
2457 createTool( 702, meshTb );
2458 createTool( 704, meshTb );
2459 createTool( separator(), meshTb );
2460 createTool( 701, meshTb );
2461 createTool( separator(), meshTb );
2462 createTool( 801, meshTb );
2463 createTool( 802, meshTb );
2464 createTool( 803, meshTb );
2465 createTool( separator(), meshTb );
2466 createTool( 900, meshTb );
2467 createTool( 902, meshTb );
2468 createTool( separator(), meshTb );
2470 createTool( 5000, hypoTb );
2471 createTool( 5010, hypoTb );
2473 createTool( 6001, ctrlTb );
2474 createTool( 6003, ctrlTb );
2475 createTool( 6004, ctrlTb );
2476 createTool( separator(), ctrlTb );
2477 createTool( 6002, ctrlTb );
2478 createTool( 6018, ctrlTb );
2479 createTool( 6019, ctrlTb );
2480 createTool( 6011, ctrlTb );
2481 createTool( 6012, ctrlTb );
2482 createTool( 6013, ctrlTb );
2483 createTool( 6014, ctrlTb );
2484 createTool( 6015, ctrlTb );
2485 createTool( 6016, ctrlTb );
2486 createTool( separator(), ctrlTb );
2487 createTool( 6017, ctrlTb );
2488 createTool( separator(), ctrlTb );
2490 createTool( 400, addRemTb );
2491 createTool( 401, addRemTb );
2492 createTool( 4021, addRemTb );
2493 createTool( 4022, addRemTb );
2494 createTool( 4023, addRemTb );
2495 createTool( 4031, addRemTb );
2496 createTool( 4032, addRemTb );
2497 createTool( 4033, addRemTb );
2498 createTool( separator(), addRemTb );
2499 createTool( 4041, addRemTb );
2500 createTool( 4042, addRemTb );
2501 createTool( separator(), addRemTb );
2502 createTool( 4051, addRemTb );
2503 createTool( 4052, addRemTb );
2504 createTool( separator(), addRemTb );
2505 createTool( 4061, addRemTb );
2506 createTool( 4062, addRemTb );
2507 createTool( 4063, addRemTb );
2508 createTool( 4064, addRemTb );
2509 createTool( 4065, addRemTb );
2510 createTool( 4066, addRemTb );
2511 createTool( separator(), addRemTb );
2513 createTool( 406, modifyTb );
2514 createTool( 407, modifyTb );
2515 createTool( 408, modifyTb );
2516 createTool( 409, modifyTb );
2517 createTool( 410, modifyTb );
2518 createTool( 411, modifyTb );
2519 createTool( 412, modifyTb );
2520 createTool( 413, modifyTb );
2521 createTool( 416, modifyTb );
2522 createTool( 414, modifyTb );
2523 createTool( 415, modifyTb );
2525 createTool( 214, dispModeTb );
2529 QString OB = "'ObjectBrowser'",
2530 View = "'" + SVTK_Viewer::Type() + "'",
2532 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2533 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2534 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2535 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2536 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2537 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2538 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2539 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2540 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2541 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2543 mesh_group = mesh + " " + subMesh + " " + group,
2544 hyp_alg = hypo + " " + algo;
2546 // popup for object browser
2548 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2549 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2550 createPopupItem( 803, OB, group ); // EDIT_GROUP
2551 popupMgr()->insert( separator(), -1, 0 );
2552 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2553 createPopupItem( 214, OB, mesh_group ); // UPDATE
2554 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2555 createPopupItem( 902, OB, mesh ); // STD_INFO
2556 popupMgr()->insert( separator(), -1, 0 );
2557 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2558 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2559 popupMgr()->insert( separator(), -1, 0 );
2560 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2561 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2562 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2563 popupMgr()->insert( separator(), -1, 0 );
2564 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2565 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2566 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2567 popupMgr()->insert( separator(), -1, 0 );
2570 createPopupItem( 803, View, group ); // EDIT_GROUP
2571 createPopupItem( 804, View, elems ); // ADD
2572 createPopupItem( 805, View, elems ); // REMOVE
2573 popupMgr()->insert( separator(), -1, 0 );
2574 createPopupItem( 214, View, mesh_group ); // UPDATE
2575 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2576 createPopupItem( 902, View, mesh ); // STD_INFO
2577 popupMgr()->insert( separator(), -1, 0 );
2581 isInvisible("not( isVisible )"),
2582 isEmpty("numberOfNodes = 0"),
2583 isNotEmpty("numberOfNodes <> 0"),
2585 // has nodes, edges, etc in VISIBLE! actor
2586 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2587 hasElems("(count( elemTypes ) > 0)"),
2588 hasDifferentElems("(count( elemTypes ) > 1)"),
2589 hasEdges("({'Edge'} in elemTypes)"),
2590 hasFaces("({'Face'} in elemTypes)"),
2591 hasVolumes("({'Volume'} in elemTypes)");
2593 QString lc = QtxPopupMgr::Selection::defEquality();
2594 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2595 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2596 QString aMeshInVTK = aClient + "&&" + aType;
2598 //-------------------------------------------------
2600 //-------------------------------------------------
2601 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2603 popupMgr()->insert( action( 9010 ), anId, -1 );
2604 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );//@
2605 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2607 popupMgr()->insert( action( 9011 ), anId, -1 );
2608 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2609 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2611 popupMgr()->insert( separator(), -1, -1 );
2613 //-------------------------------------------------
2615 //-------------------------------------------------
2616 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2618 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2619 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2620 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2622 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2623 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2624 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2626 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2627 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2628 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2630 popupMgr()->insert( separator(), anId, -1 );
2632 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2633 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2634 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2636 //-------------------------------------------------
2638 //-------------------------------------------------
2639 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2641 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2643 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2644 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2645 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2647 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2648 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2649 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2651 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2652 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2653 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2655 popupMgr()->insert( separator(), anId, -1 );
2657 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2658 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2660 //-------------------------------------------------
2662 //-------------------------------------------------
2663 popupMgr()->insert( action( 1132 ), -1, -1 );
2664 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2666 //-------------------------------------------------
2668 //-------------------------------------------------
2669 popupMgr()->insert( action( 1133 ), -1, -1 );
2670 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2672 //-------------------------------------------------
2674 //-------------------------------------------------
2675 popupMgr()->insert( action( 1134 ), -1, -1 );
2676 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2678 popupMgr()->insert( separator(), -1, -1 );
2680 //-------------------------------------------------
2682 //-------------------------------------------------
2684 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2685 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2686 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2688 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2690 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2691 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2693 popupMgr()->insert( separator(), anId, -1 );
2695 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2696 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2697 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2699 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2700 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2701 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2703 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2704 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2705 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2707 popupMgr()->insert( separator(), anId, -1 );
2709 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2710 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2711 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2713 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2714 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2715 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2717 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2718 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2719 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2721 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2722 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2723 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2725 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2726 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2727 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2729 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2730 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2731 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2733 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2734 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2735 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2737 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2738 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2739 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2741 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2742 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2743 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2745 popupMgr()->insert( separator(), anId, -1 );
2747 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2748 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2749 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2751 popupMgr()->insert( separator(), anId, -1 );
2753 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2754 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2756 popupMgr()->insert( separator(), -1, -1 );
2758 //-------------------------------------------------
2760 //-------------------------------------------------
2761 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2762 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
2763 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2764 QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
2765 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2766 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
2768 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2769 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
2771 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2772 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
2774 popupMgr()->insert( separator(), -1, -1 );
2776 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
2777 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
2780 bool SMESHGUI::activateModule( SUIT_Study* study )
2782 bool res = SalomeApp_Module::activateModule( study );
2784 setMenuShown( true );
2785 setToolShown( true );
2790 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2792 setMenuShown( false );
2793 setToolShown( false );
2795 EmitSignalCloseAllDialogs();
2797 return SalomeApp_Module::deactivateModule( study );
2800 void SMESHGUI::OnGUIEvent()
2802 const QObject* obj = sender();
2803 if ( !obj || !obj->inherits( "QAction" ) )
2805 int id = actionId((QAction*)obj);
2810 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2812 if ( CORBA::is_nil( myComponentSMESH ) )
2814 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2815 return aGUI.myComponentSMESH;
2817 return myComponentSMESH;
2820 QString SMESHGUI::engineIOR() const
2822 CORBA::ORB_var anORB = getApp()->orb();
2823 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2827 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2829 SMESHGUI_Selection sel;
2830 sel.init( client, selectionMgr() );
2831 popupMgr()->updatePopup( menu, &sel );
2834 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2836 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2837 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2840 void SMESHGUI::viewManagers( QStringList& list ) const
2842 list.append( SVTK_Viewer::Type() );
2845 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
2847 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
2848 SMESH::UpdateSelectionProp( this );
2851 void SMESHGUI::createPreferences()
2853 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2855 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2856 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "display_entity" );
2857 addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "auto_update" );
2859 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2860 setPreferenceProperty( precGroup, "columns", 1 );
2862 addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool );
2863 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2865 setPreferenceProperty( prec, "min", 0 );
2866 setPreferenceProperty( prec, "max", 16 );
2868 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2869 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, SalomeApp_Preferences::Selector, "SMESH", "display_mode" );
2871 modes.append( "Wireframe" );
2872 modes.append( "Shading" );
2873 modes.append( "Shrink" );
2874 modes.append( "Nodes" );
2875 setPreferenceProperty( dispmode, "strings", modes );
2877 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2878 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2880 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
2881 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
2883 setPreferenceProperty( nodeSz, "min", 1 );
2884 setPreferenceProperty( nodeSz, "max", 5 );
2886 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2888 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
2889 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
2890 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
2891 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
2893 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
2894 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2896 setPreferenceProperty( elemW, "min", 1 );
2897 setPreferenceProperty( elemW, "max", 5 );
2899 setPreferenceProperty( shrink, "min", 0 );
2900 setPreferenceProperty( shrink, "max", 100 );
2902 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2904 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2906 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
2907 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
2908 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
2910 setPreferenceProperty( selW, "min", 1 );
2911 setPreferenceProperty( selW, "max", 5 );
2913 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2915 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
2916 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2918 setPreferenceProperty( preW, "min", 1 );
2919 setPreferenceProperty( preW, "max", 5 );
2921 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2923 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
2924 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
2926 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2927 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2929 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2930 addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2931 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2932 addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
2935 fam.append( tr( "SMESH_FONT_ARIAL" ) );
2936 fam.append( tr( "SMESH_FONT_COURIER" ) );
2937 fam.append( tr( "SMESH_FONT_TIMES" ) );
2938 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2940 setPreferenceProperty( tfont, "families", fam );
2941 setPreferenceProperty( tfont, "system", false );
2942 setPreferenceProperty( tfont, "widget_flags", wflag );
2943 setPreferenceProperty( lfont, "families", fam );
2944 setPreferenceProperty( lfont, "system", false );
2945 setPreferenceProperty( lfont, "widget_flags", wflag );
2947 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
2949 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
2950 setPreferenceProperty( numcol, "min", 2 );
2951 setPreferenceProperty( numcol, "max", 256 );
2953 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
2954 setPreferenceProperty( numlab, "min", 2 );
2955 setPreferenceProperty( numlab, "max", 65 );
2957 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
2958 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2959 QStringList orients;
2960 orients.append( tr( "SMESH_VERTICAL" ) );
2961 orients.append( tr( "SMESH_HORIZONTAL" ) );
2962 QValueList<QVariant> indices; indices.append( 0 ); indices.append( 1 );
2963 setPreferenceProperty( orient, "strings", orients );
2964 setPreferenceProperty( orient, "indexes", indices );
2966 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
2967 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2968 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2969 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2970 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
2971 setPreferenceProperty( xv, "step", 0.1 );
2972 setPreferenceProperty( xv, "min", 0.0 );
2973 setPreferenceProperty( xv, "max", 1.0 );
2974 setPreferenceProperty( yv, "step", 0.1 );
2975 setPreferenceProperty( yv, "min", 0.0 );
2976 setPreferenceProperty( yv, "max", 1.0 );
2977 setPreferenceProperty( wv, "step", 0.1 );
2978 setPreferenceProperty( wv, "min", 0.0 );
2979 setPreferenceProperty( wv, "max", 1.0 );
2980 setPreferenceProperty( hv, "min", 0.0 );
2981 setPreferenceProperty( hv, "max", 1.0 );
2982 setPreferenceProperty( hv, "step", 0.1 );
2984 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
2985 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
2986 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
2987 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
2988 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
2989 setPreferenceProperty( xv, "min", 0.0 );
2990 setPreferenceProperty( xv, "max", 1.0 );
2991 setPreferenceProperty( xv, "step", 0.1 );
2992 setPreferenceProperty( xh, "min", 0.0 );
2993 setPreferenceProperty( xh, "max", 1.0 );
2994 setPreferenceProperty( xh, "step", 0.1 );
2995 setPreferenceProperty( yh, "min", 0.0 );
2996 setPreferenceProperty( yh, "max", 1.0 );
2997 setPreferenceProperty( yh, "step", 0.1 );
2998 setPreferenceProperty( wh, "min", 0.0 );
2999 setPreferenceProperty( wh, "max", 1.0 );
3000 setPreferenceProperty( wh, "step", 0.1 );
3001 setPreferenceProperty( hh, "min", 0.0 );
3002 setPreferenceProperty( hh, "max", 1.0 );
3003 setPreferenceProperty( hh, "step", 0.1 );
3006 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )