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());
590 SMESH::RepaintCurrentView();
597 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
598 MeshObjectType theType,
599 const QString theInTypeName,
600 QString & theOutTypeName)
602 SMESH_TypeFilter aTypeFilter( theType );
604 if( !theIO.IsNull() )
606 entry = theIO->getEntry();
607 SalomeApp_DataOwner owner( entry );
608 if ( aTypeFilter.isOk( &owner )) {
609 theOutTypeName = theInTypeName;
617 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
619 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
620 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
622 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
623 CORBA::String_var anID = aSComp->GetID().c_str();
624 if (!strcmp(anID.in(),theIO->getEntry()))
630 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
631 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
632 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
633 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
634 CheckOIType ( theIO, GROUP, "Group", aTypeName )
642 QString CheckHomogeneousSelection()
644 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
645 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
646 SALOME_ListIO selected;
648 aSel->selectedObjects( selected );
650 QString RefType = CheckTypeObject(selected.First());
651 SALOME_ListIteratorOfListIO It(selected);
652 for (; It.More(); It.Next())
654 Handle(SALOME_InteractiveObject) IObject = It.Value();
655 QString Type = CheckTypeObject(IObject);
656 if (Type.compare(RefType) != 0)
657 return "Heterogeneous Selection";
664 void SMESHGUI::OnEditDelete()
666 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
667 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
668 SALOME_ListIO selected; aSel->selectedObjects( selected );
670 QString aParentComponent = QString::null;
671 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
673 QString cur = anIt.Value()->getComponentDataType();
674 if( aParentComponent.isNull() )
675 aParentComponent = cur;
676 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
677 aParentComponent = "";
680 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
681 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
682 QObject::tr("ERR_ERROR"),
683 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
684 QObject::tr("BUT_OK") );
687 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
688 if (SUIT_MessageBox::warn2
689 (SMESHGUI::desktop(),
690 QObject::tr("SMESH_WRN_WARNING"),
691 QObject::tr("SMESH_REALLY_DELETE"),
692 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
695 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
696 SUIT_ViewManager* vm = anApp->activeViewManager();
697 int nbSf = vm->getViewsCount();
699 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
700 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
701 _PTR(GenericAttribute) anAttr;
702 _PTR(AttributeIOR) anIOR;
704 SALOME_ListIteratorOfListIO It(selected);
706 aStudyBuilder->NewCommand(); // There is a transaction
707 for(; It.More(); It.Next()){
708 Handle(SALOME_InteractiveObject) IObject = It.Value();
709 if(IObject->hasEntry()){
710 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
712 // disable removal of "SMESH" component object
713 if(SO->FindAttribute(anAttr, "AttributeIOR")){
715 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
719 /* Erase child graphical objects */
720 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
721 for(it->InitEx(true); it->More(); it->Next()){
722 _PTR(SObject) CSO = it->Value();
723 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
726 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
727 for(int i = 0; i < nbSf; i++){
728 SUIT_ViewWindow *sf = aViews[i];
729 CORBA::String_var anEntry = CSO->GetID().c_str();
730 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
731 SMESH::RemoveActor(sf,anActor);
737 /* Erase main graphical object */
738 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
739 for(int i = 0; i < nbSf; i++){
740 SUIT_ViewWindow *sf = aViews[i];
741 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
742 SMESH::RemoveActor(sf,anActor);
746 // Remove object(s) from data structures
747 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
749 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
750 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
751 QString objType = CheckTypeObject(IObject);
752 if ( !aGroup->_is_nil() ) { // DELETE GROUP
753 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
754 aMesh->RemoveGroup( aGroup );
756 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
757 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
758 aMesh->RemoveSubMesh( aSubMesh );
760 else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
761 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
762 aStudyBuilder->RemoveObjectWithChildren( obj );
764 else {// default action: remove SObject from the study
765 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
766 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
768 aStudyBuilder->RemoveObjectWithChildren( obj );
773 } /* IObject->hasEntry() */
775 aStudyBuilder->CommitCommand();
777 /* Clear any previous selection */
779 aSel->setSelectedObjects( l1 );
781 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
786 Standard_EXPORT CAM_Module* createModule()
788 return new SMESHGUI();
792 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
794 //=============================================================================
798 //=============================================================================
799 SMESHGUI::SMESHGUI() :
800 SalomeApp_Module( "SMESH" )
802 if ( CORBA::is_nil( myComponentSMESH ) )
804 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
805 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
806 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
809 myActiveDialogBox = 0 ;
812 SMESH::GetFilterManager();
815 /* load resources for all available meshers */
816 SMESH::InitAvailableHypotheses();
819 //=============================================================================
823 //=============================================================================
824 SMESHGUI::~SMESHGUI()
826 SMESH::GetFilterManager()->Destroy();
829 //=============================================================================
833 //=============================================================================
834 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
836 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
838 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
843 bool SMESHGUI::automaticUpdate()
845 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
849 return resMgr->booleanValue( "SMESH", "auto_update", false );
852 //=============================================================================
856 //=============================================================================
857 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
859 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
862 //=============================================================================
866 //=============================================================================
867 SMESHGUI* SMESHGUI::GetSMESHGUI()
869 SMESHGUI* smeshMod = 0;
870 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
873 CAM_Module* module = app->module( "Mesh" );
874 smeshMod = dynamic_cast<SMESHGUI*>( module );
877 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
879 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
882 _PTR(Study) aStudy = study->studyDS();
884 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
893 Standard_EXPORT SMESHGUI* GetComponentGUI()
895 return SMESHGUI::GetSMESHGUI();
899 //=============================================================================
903 //=============================================================================
904 void SMESHGUI::SetState(int aState)
909 //=============================================================================
913 //=============================================================================
914 void SMESHGUI::ResetState()
919 //=============================================================================
923 //=============================================================================
924 void SMESHGUI::EmitSignalDeactivateDialog()
926 emit SignalDeactivateActiveDialog();
929 //=============================================================================
933 //=============================================================================
934 void SMESHGUI::EmitSignalStudyFrameChanged()
936 emit SignalStudyFrameChanged();
939 //=============================================================================
943 //=============================================================================
944 void SMESHGUI::EmitSignalCloseAllDialogs()
946 emit SignalCloseAllDialogs();
949 //=============================================================================
953 //=============================================================================
954 QDialog *SMESHGUI::GetActiveDialogBox()
956 return myActiveDialogBox;
959 //=============================================================================
963 //=============================================================================
964 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
966 myActiveDialogBox = (QDialog *) aDlg;
970 //=============================================================================
974 //=============================================================================
975 SUIT_Desktop* SMESHGUI::desktop()
977 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
979 return app->desktop();
984 //=============================================================================
988 //=============================================================================
989 SalomeApp_Study* SMESHGUI::activeStudy()
991 SUIT_Application* app = SUIT_Session::session()->activeApplication();
993 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
998 //=============================================================================
1002 //=============================================================================
1003 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1005 /* Here the position is on the bottom right corner - 10 */
1006 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1008 SUIT_Desktop *PP = desktop();
1009 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1010 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1014 //=============================================================================
1018 //=============================================================================
1019 static int isStudyLocked(_PTR(Study) theStudy){
1020 return theStudy->GetProperties()->IsLocked();
1023 static bool checkLock(_PTR(Study) theStudy) {
1024 if (isStudyLocked(theStudy)) {
1025 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1026 QObject::tr("WRN_WARNING"),
1027 QObject::tr("WRN_STUDY_LOCKED"),
1028 QObject::tr("BUT_OK") );
1034 //=======================================================================
1035 //function : CheckActiveStudyLocked
1037 //=======================================================================
1039 bool SMESHGUI::isActiveStudyLocked()
1041 _PTR(Study) aStudy = activeStudy()->studyDS();
1042 return checkLock( aStudy );
1045 //=============================================================================
1049 //=============================================================================
1050 bool SMESHGUI::OnGUIEvent( int theCommandID )
1052 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1056 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1057 SUIT_ResourceMgr* mgr = resourceMgr();
1061 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1062 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1064 //QAction* act = action( theCommandID );
1066 switch (theCommandID) {
1068 if(checkLock(aStudy)) break;
1076 if(checkLock(aStudy)) break;
1077 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1081 case 122: // EXPORT MED
1088 ::ExportMeshToFile(theCommandID);
1092 case 200: // SCALAR BAR
1094 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1095 SALOME_ListIO selected;
1097 aSel->selectedObjects( selected );
1099 if( selected.Extent() ) {
1100 Handle(SALOME_InteractiveObject) anIO = selected.First();
1101 if( anIO->hasEntry() ) {
1102 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1103 anActor->SetControlMode( SMESH_Actor::eNone );
1111 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1115 case 1134: // Clipping
1116 case 1133: // Tranparency
1117 case 1132: // Colors / Size
1124 ::SetDisplayMode(theCommandID);
1130 case 219: // Volumes
1131 case 220: // All Entity
1132 ::SetDisplayEntity(theCommandID);
1137 if(checkLock(aStudy)) break;
1138 SMESH::UpdateView();
1141 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1142 aSel->setSelectedObjects( l );
1147 case 301: // DISPLAY
1148 case 302: // DISPLAY ONLY
1150 SMESH::EDisplaing anAction;
1151 switch (theCommandID) {
1152 case 300: anAction = SMESH::eErase; break;
1153 case 301: anAction = SMESH::eDisplay; break;
1154 case 302: anAction = SMESH::eDisplayOnly; break;
1157 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1158 SALOME_ListIO selected;
1160 aSel->selectedObjects( selected );
1163 SALOME_ListIteratorOfListIO It (selected);
1164 for (; It.More(); It.Next()) {
1165 Handle(SALOME_InteractiveObject) IOS = It.Value();
1166 if (IOS->hasEntry()) {
1167 SMESH::UpdateView(anAction, IOS->getEntry());
1168 if (anAction == SMESH::eDisplayOnly)
1169 anAction = SMESH::eDisplay;
1174 if (anAction == SMESH::eErase) {
1176 aSel->setSelectedObjects( l1 );
1179 aSel->setSelectedObjects( selected );
1185 if(checkLock(aStudy)) break;
1188 EmitSignalDeactivateDialog();
1190 new SMESHGUI_NodesDlg(this);
1193 SUIT_MessageBox::warn1(desktop(),
1194 tr("SMESH_WRN_WARNING"),
1195 tr("SMESH_WRN_VIEWER_VTK"),
1196 tr("SMESH_BUT_OK"));
1201 case 2151: // FILTER
1205 EmitSignalDeactivateDialog();
1206 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1211 case 406: // MOVE NODE
1215 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1216 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1220 if(checkLock(aStudy)) break;
1221 new SMESHGUI_MoveNodesDlg(this);
1225 case 701: // COMPUTE MESH
1227 if(checkLock(aStudy)) break;
1229 SalomeApp_SelectionMgr *Sel = selectionMgr();
1230 SALOME_ListIO selected; Sel->selectedObjects( selected );
1232 int nbSel = selected.Extent();
1237 SMESH::SMESH_Mesh_var aMesh;
1238 SMESH::SMESH_subMesh_var aSubMesh;
1239 Handle(SALOME_InteractiveObject) IObject = selected.First();
1240 if (IObject->hasEntry()){
1241 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1242 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1243 if ( aShapeObject->_is_nil() ) {
1248 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1249 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1251 if (!aMesh->_is_nil()){
1252 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1253 if (!refShapeObject->_is_nil()) {
1254 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1255 SUIT_MessageBox::warn1(desktop(),
1256 tr("SMESH_WRN_WARNING"),
1257 tr("SMESH_WRN_MISSING_PARAMETERS"),
1258 tr("SMESH_BUT_OK"));
1262 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1263 SMESH::ModifiedMesh(aMeshSObj,true);
1264 // TO Do : change icon of all submeshes
1266 SUIT_MessageBox::warn1(desktop(),
1267 tr("SMESH_WRN_WARNING"),
1268 tr("SMESH_WRN_COMPUTE_FAILED"),
1269 tr("SMESH_BUT_OK"));
1271 catch(const SALOME::SALOME_Exception & S_ex){
1272 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1275 }else if(!aSubMesh->_is_nil()){
1276 aMesh = aSubMesh->GetFather();
1277 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1278 if(!refShapeObject->_is_nil()){
1279 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1281 SUIT_MessageBox::warn1(desktop(),
1282 tr("SMESH_WRN_WARNING"),
1283 tr("SMESH_WRN_MISSING_PARAMETERS"),
1284 tr("SMESH_BUT_OK"));
1288 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1289 SMESH::ModifiedMesh(aMeshSObj,true);
1290 // TO Do : change icon of all submeshes
1292 SUIT_MessageBox::warn1(desktop(),
1293 tr("SMESH_WRN_WARNING"),
1294 tr("SMESH_WRN_COMPUTE_FAILED"),
1295 tr("SMESH_BUT_OK"));
1296 }catch(const SALOME::SALOME_Exception & S_ex){
1297 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1303 CORBA::Long anId = aStudy->StudyId();
1304 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1305 if ( automaticUpdate() && aVisualObj){
1306 aVisualObj->Update();
1307 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1309 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1311 SMESH::DisplayActor(view,anActor); //apo
1315 SMESH::RepaintCurrentView();
1318 SUIT_MessageBox::warn1(desktop(),
1319 tr("SMESH_WRN_WARNING"),
1320 tr("SMESH_WRN_VIEWER_VTK"),
1321 tr("SMESH_BUT_OK"));
1327 case 702: // Create mesh
1328 startOperation( 702 );
1330 case 703: // Create sub-mesh
1331 startOperation( 703 );
1333 case 704: // Edit mesh/sub-mesh
1334 startOperation( 704 );
1336 case 407: // DIAGONAL INVERSION
1337 case 408: // Delete diagonal
1341 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1342 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1346 if ( checkLock( aStudy ) )
1349 /*Standard_Boolean aRes;
1350 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1351 if ( aMesh->_is_nil() )
1353 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1354 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1358 EmitSignalDeactivateDialog();
1359 if ( theCommandID == 407 )
1360 new SMESHGUI_TrianglesInversionDlg(this);
1362 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1365 case 409: // Change orientation
1366 case 410: // Union of triangles
1367 case 411: // Cutting of quadrangles
1371 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1372 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1376 if ( checkLock( aStudy ) )
1379 EmitSignalDeactivateDialog();
1380 SMESHGUI_MultiEditDlg* aDlg = NULL;
1381 if ( theCommandID == 409 )
1382 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1383 else if ( theCommandID == 410 )
1384 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1386 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1389 DefineDlgPosition( aDlg, x, y );
1394 case 412: // Smoothing
1396 if(checkLock(aStudy)) break;
1398 EmitSignalDeactivateDialog();
1399 new SMESHGUI_SmoothingDlg( this );
1402 SUIT_MessageBox::warn1(desktop(),
1403 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1404 tr("SMESH_BUT_OK"));
1408 case 413: // Extrusion
1410 if (checkLock(aStudy)) break;
1412 EmitSignalDeactivateDialog();
1413 new SMESHGUI_ExtrusionDlg ( this );
1415 SUIT_MessageBox::warn1(desktop(),
1416 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1417 tr("SMESH_BUT_OK"));
1421 case 414: // Revolution
1423 if(checkLock(aStudy)) break;
1425 EmitSignalDeactivateDialog();
1426 new SMESHGUI_RevolutionDlg( this );
1429 SUIT_MessageBox::warn1(desktop(),
1430 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1431 tr("SMESH_BUT_OK"));
1435 case 415: // Pattern mapping
1437 if ( checkLock( aStudy ) )
1441 EmitSignalDeactivateDialog();
1442 new SMESHGUI_MeshPatternDlg( this );
1445 SUIT_MessageBox::warn1(desktop(),
1446 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1447 tr("SMESH_BUT_OK"));
1451 case 416: // Extrusion along a path
1453 if (checkLock(aStudy)) break;
1455 EmitSignalDeactivateDialog();
1456 new SMESHGUI_ExtrusionAlongPathDlg( this );
1458 SUIT_MessageBox::warn1(desktop(),
1459 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1460 tr("SMESH_BUT_OK"));
1464 case 801: // CREATE GROUP
1468 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1469 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1473 if(checkLock(aStudy)) break;
1474 EmitSignalDeactivateDialog();
1475 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1477 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1478 SALOME_ListIO selected;
1480 aSel->selectedObjects( selected );
1482 int nbSel = selected.Extent();
1484 // check if mesh is selected
1485 aMesh = SMESH::GetMeshByIO( selected.First() );
1487 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1492 case 802: // CONSTRUCT GROUP
1496 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1497 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1501 if(checkLock(aStudy)) break;
1502 EmitSignalDeactivateDialog();
1504 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1505 SALOME_ListIO selected;
1507 aSel->selectedObjects( selected );
1509 int nbSel = selected.Extent();
1511 // check if submesh is selected
1512 Handle(SALOME_InteractiveObject) IObject = selected.First();
1513 if (IObject->hasEntry()) {
1514 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1516 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1517 if (!aSubMesh->_is_nil()) {
1519 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1520 // get submesh elements list by types
1521 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1522 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1523 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1524 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1525 // create group for each type o elements
1526 QString aName = IObject->getName();
1527 if (aNodes->length() > 0) {
1528 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1529 aGroup->Add(aNodes.inout());
1531 if (aEdges->length() > 0) {
1532 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1533 aGroup->Add(aEdges.inout());
1535 if (aFaces->length() > 0) {
1536 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1537 aGroup->Add(aFaces.inout());
1539 if (aVolumes->length() > 0) {
1540 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1541 aGroup->Add(aVolumes.inout());
1545 }catch(const SALOME::SALOME_Exception & S_ex){
1546 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1555 case 803: // EDIT GROUP
1559 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1560 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1564 if(checkLock(aStudy)) break;
1565 EmitSignalDeactivateDialog();
1567 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1568 SALOME_ListIO selected;
1570 aSel->selectedObjects( selected );
1572 SALOME_ListIteratorOfListIO It (selected);
1573 int nbSelectedGroups = 0;
1574 for ( ; It.More(); It.Next() )
1576 SMESH::SMESH_Group_var aGroup =
1577 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1578 if (!aGroup->_is_nil()) {
1580 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1584 if (nbSelectedGroups == 0)
1586 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1592 case 804: // Add elements to group
1594 if(checkLock(aStudy)) break;
1595 if (myState == 800) {
1596 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1597 if (aDlg) aDlg->onAdd();
1602 case 805: // Remove elements from group
1604 if(checkLock(aStudy)) break;
1605 if (myState == 800) {
1606 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1607 if (aDlg) aDlg->onRemove();
1612 case 810: // Union Groups
1613 case 811: // Intersect groups
1614 case 812: // Cut groups
1618 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1619 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1623 if ( checkLock( aStudy ) )
1626 EmitSignalDeactivateDialog();
1629 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1630 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1631 else aMode = SMESHGUI_GroupOpDlg::CUT;
1633 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1637 case 813: // Delete groups with their contents
1641 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1642 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1646 if ( checkLock( aStudy ) )
1649 EmitSignalDeactivateDialog();
1651 new SMESHGUI_DeleteGroupDlg( this );
1655 case 900: // MESH INFOS
1657 EmitSignalDeactivateDialog();
1658 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1659 SALOME_ListIO selected;
1661 aSel->selectedObjects( selected );
1663 if ( selected.Extent() > 1 ) { // a dlg for each IO
1665 SALOME_ListIteratorOfListIO It (selected);
1666 for ( ; It.More(); It.Next() ) {
1667 IOs.Clear(); IOs.Append( It.Value() );
1668 aSel->setSelectedObjects( IOs );
1669 new SMESHGUI_MeshInfosDlg(this, "", false);
1671 // restore selection
1672 aSel->setSelectedObjects( selected );
1675 new SMESHGUI_MeshInfosDlg(this, "", false);
1679 case 902: // STANDARD MESH INFOS
1681 EmitSignalDeactivateDialog();
1682 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1683 SALOME_ListIO selected;
1685 aSel->selectedObjects( selected );
1687 if ( selected.Extent() > 1 ) { // a dlg for each IO
1689 SALOME_ListIteratorOfListIO It (selected);
1690 for ( ; It.More(); It.Next() ) {
1692 IOs.Append( It.Value() );
1693 aSel->setSelectedObjects( IOs );
1694 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1696 // restore selection
1697 aSel->setSelectedObjects( selected );
1700 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1704 case 1100: // EDIT HYPOTHESIS
1706 if(checkLock(aStudy)) break;
1708 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1709 SALOME_ListIO selected;
1711 aSel->selectedObjects( selected );
1713 int nbSel = selected.Extent();
1716 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1718 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1719 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1720 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1721 if ( !Hyp->_is_nil() )
1723 char* sName = Hyp->GetName();
1724 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1727 aCreator->EditHypothesis(Hyp);
1735 updateObjBrowser( true );
1739 case 1101: // RENAME
1741 if ( checkLock( aStudy ) )
1744 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1745 SALOME_ListIO selected;
1747 aSel->selectedObjects( selected );
1749 SALOME_ListIteratorOfListIO It( selected );
1750 for ( ; It.More(); It.Next() )
1752 Handle(SALOME_InteractiveObject) IObject = It.Value();
1753 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1754 _PTR(GenericAttribute) anAttr;
1755 _PTR(AttributeName) aName;
1758 if ( obj->FindAttribute(anAttr, "AttributeName") )
1761 QString newName = QString(aName->Value().c_str());
1762 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1763 if ( !newName.isEmpty() )
1765 //old source: aStudy->renameIObject( IObject, newName );
1766 aName->SetValue( newName.latin1() );
1768 // if current object is group update group's name
1769 SMESH::SMESH_GroupBase_var aGroup =
1770 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1771 if (!aGroup->_is_nil() )
1772 aGroup->SetName( newName.latin1() );
1782 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1784 if(checkLock(aStudy)) break;
1785 SUIT_OverrideCursor wc;
1787 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1788 SALOME_ListIO selected;
1790 aSel->selectedObjects( selected );
1792 SALOME_ListIteratorOfListIO It(selected);
1793 for (int i = 0; It.More(); It.Next(), i++) {
1794 Handle(SALOME_InteractiveObject) IObject = It.Value();
1795 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1798 aSel->setSelectedObjects( l1 );
1803 case 401: // GEOM::EDGE
1804 case 4021: // TRIANGLE
1806 case 4023: // POLYGON
1810 if(checkLock(aStudy)) break;
1812 EmitSignalDeactivateDialog();
1813 SMDSAbs_ElementType type = SMDSAbs_Edge;
1815 switch (theCommandID) {
1816 case 4021: // TRIANGLE
1817 type = SMDSAbs_Face; nbNodes = 3; break;
1819 type = SMDSAbs_Face; nbNodes = 4; break;
1821 type = SMDSAbs_Volume; nbNodes = 4; break;
1822 case 4023: // POLYGON
1823 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1825 type = SMDSAbs_Volume; nbNodes = 8; break;
1826 case 4033: // POLYHEDRE
1827 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1830 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1833 SUIT_MessageBox::warn1(desktop(),
1834 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1835 tr("SMESH_BUT_OK"));
1839 case 4033: // POLYHEDRON
1841 if(checkLock(aStudy)) break;
1843 EmitSignalDeactivateDialog();
1844 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1847 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1848 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1849 tr("SMESH_BUT_OK"));
1853 case 4041: // REMOVES NODES
1855 if(checkLock(aStudy)) break;
1857 EmitSignalDeactivateDialog();
1858 new SMESHGUI_RemoveNodesDlg(this);
1861 SUIT_MessageBox::warn1(desktop(),
1862 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1863 tr("SMESH_BUT_OK"));
1867 case 4042: // REMOVES ELEMENTS
1869 if(checkLock(aStudy)) break;
1871 EmitSignalDeactivateDialog();
1872 new SMESHGUI_RemoveElementsDlg(this);
1876 SUIT_MessageBox::warn1(desktop(),
1877 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1878 tr("SMESH_BUT_OK"));
1882 case 4051: // RENUMBERING NODES
1884 if(checkLock(aStudy)) break;
1886 EmitSignalDeactivateDialog();
1887 new SMESHGUI_RenumberingDlg( this, "", 0);
1891 SUIT_MessageBox::warn1(desktop(),
1892 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1893 tr("SMESH_BUT_OK"));
1897 case 4052: // RENUMBERING ELEMENTS
1899 if(checkLock(aStudy)) break;
1901 EmitSignalDeactivateDialog();
1902 new SMESHGUI_RenumberingDlg( this, "", 1);
1906 SUIT_MessageBox::warn1(desktop(),
1907 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1908 tr("SMESH_BUT_OK"));
1912 case 4061: // TRANSLATION
1914 if(checkLock(aStudy)) break;
1916 EmitSignalDeactivateDialog();
1917 new SMESHGUI_TranslationDlg( this );
1920 SUIT_MessageBox::warn1(desktop(),
1921 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1922 tr("SMESH_BUT_OK"));
1926 case 4062: // ROTATION
1928 if(checkLock(aStudy)) break;
1930 EmitSignalDeactivateDialog();
1931 new SMESHGUI_RotationDlg( this );
1934 SUIT_MessageBox::warn1(desktop(),
1935 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1936 tr("SMESH_BUT_OK"));
1940 case 4063: // SYMMETRY
1942 if(checkLock(aStudy)) break;
1944 EmitSignalDeactivateDialog();
1945 new SMESHGUI_SymmetryDlg( this );
1948 SUIT_MessageBox::warn1(desktop(),
1949 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1950 tr("SMESH_BUT_OK"));
1954 case 4064: // SEWING
1956 if(checkLock(aStudy)) break;
1958 EmitSignalDeactivateDialog();
1959 new SMESHGUI_SewingDlg( this );
1962 SUIT_MessageBox::warn1(desktop(),
1963 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1964 tr("SMESH_BUT_OK"));
1968 case 4065: // MERGE NODES
1970 if(checkLock(aStudy)) break;
1972 EmitSignalDeactivateDialog();
1973 new SMESHGUI_MergeNodesDlg( this );
1976 SUIT_MessageBox::warn1(desktop(),
1977 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1978 tr("SMESH_BUT_OK"));
1982 case 4066: // MERGE EQUAL ELEMENTS
1984 if (checkLock(aStudy)) break;
1986 EmitSignalDeactivateDialog();
1987 new SMESHGUI_EditMeshDlg(this,
1988 "SMESH_MERGE_ELEMENTS_TITLE",
1989 "ICON_DLG_MERGE_ELEMENTS",
1990 1); // MergeEqualElemets
1992 SUIT_MessageBox::warn1(desktop(),
1993 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1994 tr("SMESH_BUT_OK"));
1999 case 5105: // Library of selection filters
2001 static QValueList<int> aTypes;
2002 if ( aTypes.isEmpty() )
2004 aTypes.append( SMESH::NODE );
2005 aTypes.append( SMESH::EDGE );
2006 aTypes.append( SMESH::FACE );
2007 aTypes.append( SMESH::VOLUME );
2009 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2013 case 6017: // CONTROLS
2028 SalomeApp_SelectionMgr* mgr = selectionMgr();
2029 SALOME_ListIO selected; mgr->selectedObjects( selected );
2031 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2032 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2034 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2035 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2036 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2037 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2038 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2039 ::Control( theCommandID );
2044 SUIT_MessageBox::warn1(desktop(),
2045 tr( "SMESH_WRN_WARNING" ),
2046 tr( "SMESH_BAD_SELECTION" ),
2047 tr( "SMESH_BUT_OK" ) );
2051 SUIT_MessageBox::warn1(desktop(),
2052 tr( "SMESH_WRN_WARNING" ),
2053 tr( "NOT_A_VTK_VIEWER" ),
2054 tr( "SMESH_BUT_OK" ) );
2059 SalomeApp_SelectionMgr* mgr = selectionMgr();
2060 SALOME_ListIO selected; mgr->selectedObjects( selected );
2062 if (selected.Extent() == 1) {
2063 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2064 if(anIObject->hasEntry())
2065 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2066 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2073 SalomeApp_SelectionMgr* mgr = selectionMgr();
2074 SALOME_ListIO selected; mgr->selectedObjects( selected );
2076 if (selected.Extent() == 1) {
2077 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2078 if(anIObject->hasEntry())
2079 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2080 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2087 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2088 //updateObjBrowser();
2092 //=============================================================================
2096 //=============================================================================
2097 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2102 //=============================================================================
2106 //=============================================================================
2107 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2112 //=============================================================================
2116 //=============================================================================
2117 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2122 //=============================================================================
2123 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2124 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2126 //=============================================================================
2127 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2128 SUIT_ViewWindow* wnd )
2130 if(theIO->hasEntry()){
2131 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2132 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2136 //=======================================================================
2137 // function : createSMESHAction
2139 //=======================================================================
2140 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2143 QWidget* parent = application()->desktop();
2144 SUIT_ResourceMgr* resMgr = resourceMgr();
2146 if ( icon_id.length() )
2147 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2149 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2150 if ( !pix.isNull() )
2151 icon = QIconSet( pix );
2153 QString tooltip = tr( QString( "TOP_" )+po_id ),
2154 menu = tr( QString( "MEN_" )+po_id ),
2155 status_bar = tr( QString( "STB_" )+po_id );
2157 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2160 //=======================================================================
2161 // function : createPopupItem
2163 //=======================================================================
2164 void SMESHGUI::createPopupItem( const int id,
2165 const QString& clients,
2166 const QString& types,
2167 const QString& theRule,
2172 parentId = popupMgr()->actionId( action( pId ) );
2174 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2175 popupMgr()->insert( action( id ), parentId, 0 );
2177 QChar lc = QtxPopupMgr::Selection::defEquality();
2178 QString rule = "(%1) and (%2) and (%3)";
2179 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2180 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2181 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2184 bool cont = myRules.contains( id );
2186 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2188 popupMgr()->setRule( action( id ), rule, true );
2189 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2192 //=======================================================================
2193 // function : initialize
2195 //=======================================================================
2196 void SMESHGUI::initialize( CAM_Application* app )
2198 SalomeApp_Module::initialize( app );
2200 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2202 /* Automatic Update flag */
2203 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2205 // ----- create actions --------------
2207 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2208 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2209 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2210 createSMESHAction( 114, "NUM" );
2211 createSMESHAction( 121, "DAT" );
2212 createSMESHAction( 122, "MED" );
2213 createSMESHAction( 123, "UNV" );
2214 createSMESHAction( 124, "EXPORT_DAT" );
2215 createSMESHAction( 125, "EXPORT_MED" );
2216 createSMESHAction( 126, "EXPORT_UNV" );
2217 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2218 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2219 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2220 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2221 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2222 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2223 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2224 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2225 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2226 createSMESHAction( 804, "ADD" );
2227 createSMESHAction( 805, "REMOVE" );
2228 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2229 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2230 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2231 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2232 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2233 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2234 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2235 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2236 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2237 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2238 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2239 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2240 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2241 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2242 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2243 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2244 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2245 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2246 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2247 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2248 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2249 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2250 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2251 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2252 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2253 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2254 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2255 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2256 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2257 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2258 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2259 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2260 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2261 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2262 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2263 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2264 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2265 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2266 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2267 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2268 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2269 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2270 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2271 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2272 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2273 createSMESHAction( 415, "MAP", "ICON_MAP" );
2274 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2275 createSMESHAction( 200, "RESET" );
2276 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2277 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2278 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2279 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2280 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2281 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2282 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2283 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2284 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2285 createSMESHAction( 220, "ALL" );
2286 createSMESHAction( 1100, "EDIT_HYPO" );
2287 createSMESHAction( 1101, "RENAME" );
2288 createSMESHAction( 1102, "UNASSIGN" );
2289 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2290 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2291 createSMESHAction( 1131, "DISPMODE" );
2292 createSMESHAction( 1132, "COLORS" );
2293 createSMESHAction( 1133, "TRANSP" );
2294 createSMESHAction( 1134, "CLIP" );
2295 createSMESHAction( 1135, "DISP_ENT" );
2296 createSMESHAction( 2000, "CTRL" );
2298 createSMESHAction( 300, "ERASE" );
2299 createSMESHAction( 301, "DISPLAY" );
2300 createSMESHAction( 302, "DISPLAY_ONLY" );
2301 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2303 // ----- create menu --------------
2304 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2305 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2306 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2307 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2308 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2309 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2310 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2312 createMenu( separator(), fileId );
2314 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2315 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2316 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2317 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2318 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2319 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2321 createMenu( 111, importId, -1 );
2322 createMenu( 112, importId, -1 );
2323 createMenu( 113, importId, -1 );
2325 createMenu( 121, exportId, -1 );
2326 createMenu( 122, exportId, -1 );
2327 createMenu( 123, exportId, -1 );
2329 createMenu( separator(), fileId, 10 );
2331 createMenu( 33, editId, -1 );
2333 createMenu( 5105, toolsId, -1 );
2335 createMenu( 702, meshId, -1 );
2336 createMenu( 703, meshId, -1 );
2337 createMenu( 704, meshId, -1 );
2338 createMenu( separator(), meshId, -1 );
2339 createMenu( 701, meshId, -1 );
2340 createMenu( separator(), meshId, -1 );
2341 createMenu( 801, meshId, -1 );
2342 createMenu( 802, meshId, -1 );
2343 createMenu( 803, meshId, -1 );
2344 createMenu( separator(), meshId, -1 );
2345 createMenu( 810, meshId, -1 );
2346 createMenu( 811, meshId, -1 );
2347 createMenu( 812, meshId, -1 );
2348 createMenu( separator(), meshId, -1 );
2349 createMenu( 813, meshId, -1 );
2350 createMenu( separator(), meshId, -1 );
2351 createMenu( 900, meshId, -1 );
2352 createMenu( 902, meshId, -1 );
2353 createMenu( separator(), meshId, -1 );
2355 createMenu( 6003, ctrlId, -1 );
2356 createMenu( 6001, ctrlId, -1 );
2357 createMenu( 6004, ctrlId, -1 );
2358 createMenu( separator(), ctrlId, -1 );
2359 createMenu( 6002, ctrlId, -1 );
2360 createMenu( 6018, ctrlId, -1 );
2361 createMenu( 6019, ctrlId, -1 );
2362 createMenu( 6011, ctrlId, -1 );
2363 createMenu( 6012, ctrlId, -1 );
2364 createMenu( 6013, ctrlId, -1 );
2365 createMenu( 6014, ctrlId, -1 );
2366 createMenu( 6015, ctrlId, -1 );
2367 createMenu( 6016, ctrlId, -1 );
2368 createMenu( separator(), ctrlId, -1 );
2369 createMenu( 6017, ctrlId, -1 );
2370 createMenu( separator(), ctrlId, -1 );
2372 createMenu( 400, addId, -1 );
2373 createMenu( 401, addId, -1 );
2374 createMenu( 4021, addId, -1 );
2375 createMenu( 4022, addId, -1 );
2376 createMenu( 4023, addId, -1 );
2377 createMenu( 4031, addId, -1 );
2378 createMenu( 4032, addId, -1 );
2379 createMenu( 4033, addId, -1 );
2381 createMenu( 4041, removeId, -1 );
2382 createMenu( 4042, removeId, -1 );
2384 createMenu( 4051, renumId, -1 );
2385 createMenu( 4052, renumId, -1 );
2387 createMenu( 4061, transfId, -1 );
2388 createMenu( 4062, transfId, -1 );
2389 createMenu( 4063, transfId, -1 );
2390 createMenu( 4064, transfId, -1 );
2391 createMenu( 4065, transfId, -1 );
2392 createMenu( 4066, transfId, -1 );
2394 createMenu( 406, modifyId, -1 );
2395 createMenu( 407, modifyId, -1 );
2396 createMenu( 408, modifyId, -1 );
2397 createMenu( 409, modifyId, -1 );
2398 createMenu( 410, modifyId, -1 );
2399 createMenu( 411, modifyId, -1 );
2400 createMenu( 412, modifyId, -1 );
2401 createMenu( 413, modifyId, -1 );
2402 createMenu( 416, modifyId, -1 );
2403 createMenu( 414, modifyId, -1 );
2404 createMenu( 415, modifyId, -1 );
2406 createMenu( 214, viewId, -1 );
2408 // ----- create toolbars --------------
2409 int meshTb = createTool( tr( "TB_MESH" ) ),
2410 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2411 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2412 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2413 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2415 createTool( 702, meshTb );
2416 createTool( 703, meshTb );
2417 createTool( 704, meshTb );
2418 createTool( separator(), meshTb );
2419 createTool( 701, meshTb );
2420 createTool( separator(), meshTb );
2421 createTool( 801, meshTb );
2422 createTool( 802, meshTb );
2423 createTool( 803, meshTb );
2424 createTool( separator(), meshTb );
2425 createTool( 900, meshTb );
2426 createTool( 902, meshTb );
2427 createTool( separator(), meshTb );
2429 createTool( 6001, ctrlTb );
2430 createTool( 6003, ctrlTb );
2431 createTool( 6004, ctrlTb );
2432 createTool( separator(), ctrlTb );
2433 createTool( 6002, ctrlTb );
2434 createTool( 6018, ctrlTb );
2435 createTool( 6019, ctrlTb );
2436 createTool( 6011, ctrlTb );
2437 createTool( 6012, ctrlTb );
2438 createTool( 6013, ctrlTb );
2439 createTool( 6014, ctrlTb );
2440 createTool( 6015, ctrlTb );
2441 createTool( 6016, ctrlTb );
2442 createTool( separator(), ctrlTb );
2443 createTool( 6017, ctrlTb );
2444 createTool( separator(), ctrlTb );
2446 createTool( 400, addRemTb );
2447 createTool( 401, addRemTb );
2448 createTool( 4021, addRemTb );
2449 createTool( 4022, addRemTb );
2450 createTool( 4023, addRemTb );
2451 createTool( 4031, addRemTb );
2452 createTool( 4032, addRemTb );
2453 createTool( 4033, addRemTb );
2454 createTool( separator(), addRemTb );
2455 createTool( 4041, addRemTb );
2456 createTool( 4042, addRemTb );
2457 createTool( separator(), addRemTb );
2458 createTool( 4051, addRemTb );
2459 createTool( 4052, addRemTb );
2460 createTool( separator(), addRemTb );
2461 createTool( 4061, addRemTb );
2462 createTool( 4062, addRemTb );
2463 createTool( 4063, addRemTb );
2464 createTool( 4064, addRemTb );
2465 createTool( 4065, addRemTb );
2466 createTool( 4066, addRemTb );
2467 createTool( separator(), addRemTb );
2469 createTool( 406, modifyTb );
2470 createTool( 407, modifyTb );
2471 createTool( 408, modifyTb );
2472 createTool( 409, modifyTb );
2473 createTool( 410, modifyTb );
2474 createTool( 411, modifyTb );
2475 createTool( 412, modifyTb );
2476 createTool( 413, modifyTb );
2477 createTool( 416, modifyTb );
2478 createTool( 414, modifyTb );
2479 createTool( 415, modifyTb );
2481 createTool( 214, dispModeTb );
2485 QString OB = "'ObjectBrowser'",
2486 View = "'" + SVTK_Viewer::Type() + "'",
2488 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2489 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2490 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2491 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2492 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2493 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2494 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2495 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2496 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2497 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2499 mesh_group = mesh + " " + subMesh + " " + group,
2500 hyp_alg = hypo + " " + algo;
2502 // popup for object browser
2504 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2505 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2506 createPopupItem( 803, OB, group ); // EDIT_GROUP
2507 popupMgr()->insert( separator(), -1, 0 );
2508 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2509 createPopupItem( 214, OB, mesh_group ); // UPDATE
2510 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2511 createPopupItem( 902, OB, mesh ); // STD_INFO
2512 popupMgr()->insert( separator(), -1, 0 );
2513 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2514 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2515 popupMgr()->insert( separator(), -1, 0 );
2516 createPopupItem( 1100, OB, hypo, "&& $hasReference={false}" ); // EDIT HYPOTHESIS
2517 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2518 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "&& $hasReference={false}" ); // RENAME
2519 popupMgr()->insert( separator(), -1, 0 );
2520 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2521 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2522 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2523 popupMgr()->insert( separator(), -1, 0 );
2526 createPopupItem( 803, View, group ); // EDIT_GROUP
2527 createPopupItem( 804, View, elems ); // ADD
2528 createPopupItem( 805, View, elems ); // REMOVE
2529 popupMgr()->insert( separator(), -1, 0 );
2530 createPopupItem( 214, View, mesh_group ); // UPDATE
2531 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2532 createPopupItem( 902, View, mesh ); // STD_INFO
2533 popupMgr()->insert( separator(), -1, 0 );
2537 isInvisible("not( isVisible )"),
2538 isEmpty("numberOfNodes = 0"),
2539 isNotEmpty("numberOfNodes <> 0"),
2541 // has nodes, edges, etc in VISIBLE! actor
2542 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2543 hasElems("(count( elemTypes ) > 0)"),
2544 hasDifferentElems("(count( elemTypes ) > 1)"),
2545 hasEdges("({'Edge'} in elemTypes)"),
2546 hasFaces("({'Face'} in elemTypes)"),
2547 hasVolumes("({'Volume'} in elemTypes)");
2549 QString lc = QtxPopupMgr::Selection::defEquality();
2550 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2551 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2552 QString aMeshInVTK = aClient + "&&" + aType;
2554 //-------------------------------------------------
2556 //-------------------------------------------------
2557 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2559 popupMgr()->insert( action( 9010 ), anId, -1 );
2560 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2561 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2563 popupMgr()->insert( action( 9011 ), anId, -1 );
2564 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2565 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2567 popupMgr()->insert( separator(), -1, -1 );
2569 //-------------------------------------------------
2571 //-------------------------------------------------
2572 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2574 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2575 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2576 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2578 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2579 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2580 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2582 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2583 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2584 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2586 popupMgr()->insert( separator(), anId, -1 );
2588 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2589 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2590 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2592 //-------------------------------------------------
2594 //-------------------------------------------------
2595 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2597 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2599 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2600 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2601 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2603 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2604 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2605 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2607 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2608 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2609 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2611 popupMgr()->insert( separator(), anId, -1 );
2613 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2614 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2616 //-------------------------------------------------
2618 //-------------------------------------------------
2619 popupMgr()->insert( action( 1132 ), -1, -1 );
2620 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2622 //-------------------------------------------------
2624 //-------------------------------------------------
2625 popupMgr()->insert( action( 1133 ), -1, -1 );
2626 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2628 //-------------------------------------------------
2630 //-------------------------------------------------
2631 popupMgr()->insert( action( 1134 ), -1, -1 );
2632 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2634 popupMgr()->insert( separator(), -1, -1 );
2636 //-------------------------------------------------
2638 //-------------------------------------------------
2640 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2641 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2642 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2644 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2646 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2647 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2649 popupMgr()->insert( separator(), anId, -1 );
2651 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2652 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2653 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2655 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2656 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2657 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2659 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2660 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2661 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2663 popupMgr()->insert( separator(), anId, -1 );
2665 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2666 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2667 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2669 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2670 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2671 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2673 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2674 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2675 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2677 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2678 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2679 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2681 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2682 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2683 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2685 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2686 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2687 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2689 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2690 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2691 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2693 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2694 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2695 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2697 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2698 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2699 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2701 popupMgr()->insert( separator(), anId, -1 );
2703 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2704 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2705 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2707 popupMgr()->insert( separator(), anId, -1 );
2709 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2710 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2712 popupMgr()->insert( separator(), -1, -1 );
2714 //-------------------------------------------------
2716 //-------------------------------------------------
2717 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2718 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
2719 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2720 QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
2721 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2722 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
2724 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2725 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
2727 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2728 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
2730 popupMgr()->insert( separator(), -1, -1 );
2732 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
2733 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
2736 bool SMESHGUI::activateModule( SUIT_Study* study )
2738 bool res = SalomeApp_Module::activateModule( study );
2740 setMenuShown( true );
2741 setToolShown( true );
2746 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2748 setMenuShown( false );
2749 setToolShown( false );
2751 EmitSignalCloseAllDialogs();
2753 return SalomeApp_Module::deactivateModule( study );
2756 void SMESHGUI::OnGUIEvent()
2758 const QObject* obj = sender();
2759 if ( !obj || !obj->inherits( "QAction" ) )
2761 int id = actionId((QAction*)obj);
2766 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2768 if ( CORBA::is_nil( myComponentSMESH ) )
2770 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2771 return aGUI.myComponentSMESH;
2773 return myComponentSMESH;
2776 QString SMESHGUI::engineIOR() const
2778 CORBA::ORB_var anORB = getApp()->orb();
2779 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2783 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2785 SMESHGUI_Selection sel;
2786 sel.init( client, selectionMgr() );
2787 popupMgr()->updatePopup( menu, &sel );
2790 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2792 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2793 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2796 void SMESHGUI::viewManagers( QStringList& list ) const
2798 list.append( SVTK_Viewer::Type() );
2801 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
2803 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
2804 SMESH::UpdateSelectionProp( this );
2807 void SMESHGUI::createPreferences()
2809 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2811 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2812 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, SalomeApp_Preferences::Bool, "SMESH", "auto_update" );
2814 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2815 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "display_entity" );
2816 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "use_precision" );
2818 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2819 setPreferenceProperty( precGroup, "columns", 1 );
2821 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2823 setPreferenceProperty( prec, "min", 0 );
2824 setPreferenceProperty( prec, "max", 16 );
2826 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2827 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, SalomeApp_Preferences::Selector, "SMESH", "display_mode" );
2829 modes.append( "Wireframe" );
2830 modes.append( "Shading" );
2831 modes.append( "Nodes" );
2832 modes.append( "Shrink" );
2833 QValueList<QVariant> indices;
2834 indices.append( 0 );
2835 indices.append( 1 );
2836 indices.append( 2 );
2837 indices.append( 3 );
2838 setPreferenceProperty( dispmode, "strings", modes );
2839 setPreferenceProperty( dispmode, "indexes", indices );
2841 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2842 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2844 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
2845 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
2847 setPreferenceProperty( nodeSz, "min", 1 );
2848 setPreferenceProperty( nodeSz, "max", 5 );
2850 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2852 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
2853 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
2854 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
2855 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
2857 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
2858 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2860 setPreferenceProperty( elemW, "min", 1 );
2861 setPreferenceProperty( elemW, "max", 5 );
2863 setPreferenceProperty( shrink, "min", 0 );
2864 setPreferenceProperty( shrink, "max", 100 );
2866 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2868 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2870 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
2871 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
2872 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
2874 setPreferenceProperty( selW, "min", 1 );
2875 setPreferenceProperty( selW, "max", 5 );
2877 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2879 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
2880 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2882 setPreferenceProperty( preW, "min", 1 );
2883 setPreferenceProperty( preW, "max", 5 );
2885 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2887 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
2888 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
2890 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2891 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2893 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2894 addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2895 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2896 addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
2899 fam.append( tr( "SMESH_FONT_ARIAL" ) );
2900 fam.append( tr( "SMESH_FONT_COURIER" ) );
2901 fam.append( tr( "SMESH_FONT_TIMES" ) );
2902 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2904 setPreferenceProperty( tfont, "families", fam );
2905 setPreferenceProperty( tfont, "system", false );
2906 setPreferenceProperty( tfont, "widget_flags", wflag );
2907 setPreferenceProperty( lfont, "families", fam );
2908 setPreferenceProperty( lfont, "system", false );
2909 setPreferenceProperty( lfont, "widget_flags", wflag );
2911 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
2913 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
2914 setPreferenceProperty( numcol, "min", 2 );
2915 setPreferenceProperty( numcol, "max", 256 );
2917 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
2918 setPreferenceProperty( numlab, "min", 2 );
2919 setPreferenceProperty( numlab, "max", 65 );
2921 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
2922 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2923 QStringList orients;
2924 orients.append( tr( "SMESH_VERTICAL" ) );
2925 orients.append( tr( "SMESH_HORIZONTAL" ) );
2926 indices.clear(); indices.append( 0 ); indices.append( 1 );
2927 setPreferenceProperty( orient, "strings", orients );
2928 setPreferenceProperty( orient, "indexes", indices );
2930 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
2931 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2932 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2933 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2934 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
2935 setPreferenceProperty( xv, "step", 0.1 );
2936 setPreferenceProperty( xv, "min", 0.0 );
2937 setPreferenceProperty( xv, "max", 1.0 );
2938 setPreferenceProperty( yv, "step", 0.1 );
2939 setPreferenceProperty( yv, "min", 0.0 );
2940 setPreferenceProperty( yv, "max", 1.0 );
2941 setPreferenceProperty( wv, "step", 0.1 );
2942 setPreferenceProperty( wv, "min", 0.0 );
2943 setPreferenceProperty( wv, "max", 1.0 );
2944 setPreferenceProperty( hv, "min", 0.0 );
2945 setPreferenceProperty( hv, "max", 1.0 );
2946 setPreferenceProperty( hv, "step", 0.1 );
2948 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
2949 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
2950 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
2951 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
2952 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
2953 setPreferenceProperty( xv, "min", 0.0 );
2954 setPreferenceProperty( xv, "max", 1.0 );
2955 setPreferenceProperty( xv, "step", 0.1 );
2956 setPreferenceProperty( xh, "min", 0.0 );
2957 setPreferenceProperty( xh, "max", 1.0 );
2958 setPreferenceProperty( xh, "step", 0.1 );
2959 setPreferenceProperty( yh, "min", 0.0 );
2960 setPreferenceProperty( yh, "max", 1.0 );
2961 setPreferenceProperty( yh, "step", 0.1 );
2962 setPreferenceProperty( wh, "min", 0.0 );
2963 setPreferenceProperty( wh, "max", 1.0 );
2964 setPreferenceProperty( wh, "step", 0.1 );
2965 setPreferenceProperty( hh, "min", 0.0 );
2966 setPreferenceProperty( hh, "max", 1.0 );
2967 setPreferenceProperty( hh, "step", 0.1 );
2970 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
2974 //================================================================================
2976 * \brief Update something in accordance with update flags
2977 * \param theFlags - update flags
2979 * Update viewer or/and object browser etc. in accordance with update flags ( see
2980 * SalomeApp_UpdateFlags enumeration ).
2982 //================================================================================
2983 void SMESHGUI::update( const int flags )
2985 if ( flags & UF_Viewer | flags & UF_Forced )
2986 SMESH::UpdateView();
2988 SalomeApp_Module::update( flags );
2991 //================================================================================
2993 * \brief Set default selection mode
2995 * SLOT called when operation commited. Sets default selection mode
2997 //================================================================================
2998 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3000 SVTK_ViewWindow* vtkWnd =
3001 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3003 vtkWnd->SetSelectionMode( ActorSelection );
3006 //================================================================================
3008 * \brief Set default selection mode
3010 * SLOT called when operation aborted. Sets default selection mode
3012 //================================================================================
3013 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3015 SVTK_ViewWindow* vtkWnd =
3016 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3018 vtkWnd->SetSelectionMode( ActorSelection );
3021 //================================================================================
3023 * \brief Creates operation with given identifier
3024 * \param id - identifier of operation to be started
3025 * \return Pointer on created operation or NULL if operation is not created
3027 * Virtual method redefined from the base class creates operation with given id.
3028 * It is called called automatically from startOperation method of base class.
3030 //================================================================================
3031 SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
3033 SalomeApp_Operation* op = 0;
3034 // to do : create operation here
3037 case 702: // Create mesh
3038 op = new SMESHGUI_MeshOp( true, true );
3040 case 703: // Create sub-mesh
3041 op = new SMESHGUI_MeshOp( true, false );
3043 case 704: // Edit mesh/sub-mesh
3044 op = new SMESHGUI_MeshOp( false );