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 aSel->setSelectedObjects( l1 );
1180 if(checkLock(aStudy)) break;
1183 EmitSignalDeactivateDialog();
1185 new SMESHGUI_NodesDlg(this);
1188 SUIT_MessageBox::warn1(desktop(),
1189 tr("SMESH_WRN_WARNING"),
1190 tr("SMESH_WRN_VIEWER_VTK"),
1191 tr("SMESH_BUT_OK"));
1196 case 2151: // FILTER
1200 EmitSignalDeactivateDialog();
1201 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1206 case 406: // MOVE NODE
1210 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1211 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1215 if(checkLock(aStudy)) break;
1216 new SMESHGUI_MoveNodesDlg(this);
1220 case 701: // COMPUTE MESH
1222 if(checkLock(aStudy)) break;
1224 SalomeApp_SelectionMgr *Sel = selectionMgr();
1225 SALOME_ListIO selected; Sel->selectedObjects( selected );
1227 int nbSel = selected.Extent();
1232 SMESH::SMESH_Mesh_var aMesh;
1233 SMESH::SMESH_subMesh_var aSubMesh;
1234 Handle(SALOME_InteractiveObject) IObject = selected.First();
1235 if (IObject->hasEntry()){
1236 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1237 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1238 if ( aShapeObject->_is_nil() ) {
1243 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1244 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1246 if (!aMesh->_is_nil()){
1247 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1248 if (!refShapeObject->_is_nil()) {
1249 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1250 SUIT_MessageBox::warn1(desktop(),
1251 tr("SMESH_WRN_WARNING"),
1252 tr("SMESH_WRN_MISSING_PARAMETERS"),
1253 tr("SMESH_BUT_OK"));
1257 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1258 SMESH::ModifiedMesh(aMeshSObj,true);
1259 // TO Do : change icon of all submeshes
1261 SUIT_MessageBox::warn1(desktop(),
1262 tr("SMESH_WRN_WARNING"),
1263 tr("SMESH_WRN_COMPUTE_FAILED"),
1264 tr("SMESH_BUT_OK"));
1266 catch(const SALOME::SALOME_Exception & S_ex){
1267 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1270 }else if(!aSubMesh->_is_nil()){
1271 aMesh = aSubMesh->GetFather();
1272 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1273 if(!refShapeObject->_is_nil()){
1274 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1276 SUIT_MessageBox::warn1(desktop(),
1277 tr("SMESH_WRN_WARNING"),
1278 tr("SMESH_WRN_MISSING_PARAMETERS"),
1279 tr("SMESH_BUT_OK"));
1283 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1284 SMESH::ModifiedMesh(aMeshSObj,true);
1285 // TO Do : change icon of all submeshes
1287 SUIT_MessageBox::warn1(desktop(),
1288 tr("SMESH_WRN_WARNING"),
1289 tr("SMESH_WRN_COMPUTE_FAILED"),
1290 tr("SMESH_BUT_OK"));
1291 }catch(const SALOME::SALOME_Exception & S_ex){
1292 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1298 CORBA::Long anId = aStudy->StudyId();
1299 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1300 if ( automaticUpdate() && aVisualObj){
1301 aVisualObj->Update();
1302 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1304 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1306 SMESH::DisplayActor(view,anActor); //apo
1310 SMESH::RepaintCurrentView();
1313 SUIT_MessageBox::warn1(desktop(),
1314 tr("SMESH_WRN_WARNING"),
1315 tr("SMESH_WRN_VIEWER_VTK"),
1316 tr("SMESH_BUT_OK"));
1322 case 702: // Create mesh
1323 startOperation( 702 );
1325 case 703: // Create sub-mesh
1326 startOperation( 703 );
1328 case 704: // Edit mesh/sub-mesh
1329 startOperation( 704 );
1331 case 407: // DIAGONAL INVERSION
1332 case 408: // Delete diagonal
1336 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1337 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1341 if ( checkLock( aStudy ) )
1344 /*Standard_Boolean aRes;
1345 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1346 if ( aMesh->_is_nil() )
1348 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1349 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1353 EmitSignalDeactivateDialog();
1354 if ( theCommandID == 407 )
1355 new SMESHGUI_TrianglesInversionDlg(this);
1357 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1360 case 409: // Change orientation
1361 case 410: // Union of triangles
1362 case 411: // Cutting of quadrangles
1366 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1367 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1371 if ( checkLock( aStudy ) )
1374 EmitSignalDeactivateDialog();
1375 SMESHGUI_MultiEditDlg* aDlg = NULL;
1376 if ( theCommandID == 409 )
1377 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1378 else if ( theCommandID == 410 )
1379 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1381 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1384 DefineDlgPosition( aDlg, x, y );
1389 case 412: // Smoothing
1391 if(checkLock(aStudy)) break;
1393 EmitSignalDeactivateDialog();
1394 new SMESHGUI_SmoothingDlg( this );
1397 SUIT_MessageBox::warn1(desktop(),
1398 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1399 tr("SMESH_BUT_OK"));
1403 case 413: // Extrusion
1405 if (checkLock(aStudy)) break;
1407 EmitSignalDeactivateDialog();
1408 new SMESHGUI_ExtrusionDlg ( this );
1410 SUIT_MessageBox::warn1(desktop(),
1411 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1412 tr("SMESH_BUT_OK"));
1416 case 414: // Revolution
1418 if(checkLock(aStudy)) break;
1420 EmitSignalDeactivateDialog();
1421 new SMESHGUI_RevolutionDlg( this );
1424 SUIT_MessageBox::warn1(desktop(),
1425 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1426 tr("SMESH_BUT_OK"));
1430 case 415: // Pattern mapping
1432 if ( checkLock( aStudy ) )
1436 EmitSignalDeactivateDialog();
1437 new SMESHGUI_MeshPatternDlg( this );
1440 SUIT_MessageBox::warn1(desktop(),
1441 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1442 tr("SMESH_BUT_OK"));
1446 case 416: // Extrusion along a path
1448 if (checkLock(aStudy)) break;
1450 EmitSignalDeactivateDialog();
1451 new SMESHGUI_ExtrusionAlongPathDlg( this );
1453 SUIT_MessageBox::warn1(desktop(),
1454 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1455 tr("SMESH_BUT_OK"));
1459 case 801: // CREATE GROUP
1463 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1464 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1468 if(checkLock(aStudy)) break;
1469 EmitSignalDeactivateDialog();
1470 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1472 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1473 SALOME_ListIO selected;
1475 aSel->selectedObjects( selected );
1477 int nbSel = selected.Extent();
1479 // check if mesh is selected
1480 aMesh = SMESH::GetMeshByIO( selected.First() );
1482 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1487 case 802: // CONSTRUCT GROUP
1491 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1492 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1496 if(checkLock(aStudy)) break;
1497 EmitSignalDeactivateDialog();
1499 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1500 SALOME_ListIO selected;
1502 aSel->selectedObjects( selected );
1504 int nbSel = selected.Extent();
1506 // check if submesh is selected
1507 Handle(SALOME_InteractiveObject) IObject = selected.First();
1508 if (IObject->hasEntry()) {
1509 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1511 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1512 if (!aSubMesh->_is_nil()) {
1514 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1515 // get submesh elements list by types
1516 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1517 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1518 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1519 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1520 // create group for each type o elements
1521 QString aName = IObject->getName();
1522 if (aNodes->length() > 0) {
1523 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1524 aGroup->Add(aNodes.inout());
1526 if (aEdges->length() > 0) {
1527 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1528 aGroup->Add(aEdges.inout());
1530 if (aFaces->length() > 0) {
1531 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1532 aGroup->Add(aFaces.inout());
1534 if (aVolumes->length() > 0) {
1535 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1536 aGroup->Add(aVolumes.inout());
1540 }catch(const SALOME::SALOME_Exception & S_ex){
1541 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1550 case 803: // EDIT GROUP
1554 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1555 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1559 if(checkLock(aStudy)) break;
1560 EmitSignalDeactivateDialog();
1562 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1563 SALOME_ListIO selected;
1565 aSel->selectedObjects( selected );
1567 SALOME_ListIteratorOfListIO It (selected);
1568 int nbSelectedGroups = 0;
1569 for ( ; It.More(); It.Next() )
1571 SMESH::SMESH_Group_var aGroup =
1572 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1573 if (!aGroup->_is_nil()) {
1575 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1579 if (nbSelectedGroups == 0)
1581 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1587 case 804: // Add elements to group
1589 if(checkLock(aStudy)) break;
1590 if (myState == 800) {
1591 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1592 if (aDlg) aDlg->onAdd();
1597 case 805: // Remove elements from group
1599 if(checkLock(aStudy)) break;
1600 if (myState == 800) {
1601 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1602 if (aDlg) aDlg->onRemove();
1607 case 810: // Union Groups
1608 case 811: // Intersect groups
1609 case 812: // Cut groups
1613 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1614 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1618 if ( checkLock( aStudy ) )
1621 EmitSignalDeactivateDialog();
1624 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1625 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1626 else aMode = SMESHGUI_GroupOpDlg::CUT;
1628 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1632 case 813: // Delete groups with their contents
1636 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1637 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1641 if ( checkLock( aStudy ) )
1644 EmitSignalDeactivateDialog();
1646 new SMESHGUI_DeleteGroupDlg( this );
1650 case 900: // MESH INFOS
1652 EmitSignalDeactivateDialog();
1653 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1654 SALOME_ListIO selected;
1656 aSel->selectedObjects( selected );
1658 if ( selected.Extent() > 1 ) { // a dlg for each IO
1660 SALOME_ListIteratorOfListIO It (selected);
1661 for ( ; It.More(); It.Next() ) {
1662 IOs.Clear(); IOs.Append( It.Value() );
1663 aSel->setSelectedObjects( IOs );
1664 new SMESHGUI_MeshInfosDlg(this, "", false);
1666 // restore selection
1667 aSel->setSelectedObjects( selected );
1670 new SMESHGUI_MeshInfosDlg(this, "", false);
1674 case 902: // STANDARD 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() ) {
1687 IOs.Append( It.Value() );
1688 aSel->setSelectedObjects( IOs );
1689 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1691 // restore selection
1692 aSel->setSelectedObjects( selected );
1695 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1699 case 1100: // EDIT HYPOTHESIS
1701 if(checkLock(aStudy)) break;
1703 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1704 SALOME_ListIO selected;
1706 aSel->selectedObjects( selected );
1708 int nbSel = selected.Extent();
1711 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1713 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1714 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1715 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1716 if ( !Hyp->_is_nil() )
1718 char* sName = Hyp->GetName();
1719 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1722 aCreator->EditHypothesis(Hyp);
1730 updateObjBrowser( true );
1734 case 1101: // RENAME
1736 if ( checkLock( aStudy ) )
1739 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1740 SALOME_ListIO selected;
1742 aSel->selectedObjects( selected );
1744 SALOME_ListIteratorOfListIO It( selected );
1745 for ( ; It.More(); It.Next() )
1747 Handle(SALOME_InteractiveObject) IObject = It.Value();
1748 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1749 _PTR(GenericAttribute) anAttr;
1750 _PTR(AttributeName) aName;
1753 if ( obj->FindAttribute(anAttr, "AttributeName") )
1756 QString newName = QString(aName->Value().c_str());
1757 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1758 if ( !newName.isEmpty() )
1760 //old source: aStudy->renameIObject( IObject, newName );
1761 aName->SetValue( newName.latin1() );
1763 // if current object is group update group's name
1764 SMESH::SMESH_GroupBase_var aGroup =
1765 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1766 if (!aGroup->_is_nil() )
1767 aGroup->SetName( newName.latin1() );
1777 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1779 if(checkLock(aStudy)) break;
1780 SUIT_OverrideCursor wc;
1782 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1783 SALOME_ListIO selected;
1785 aSel->selectedObjects( selected );
1787 SALOME_ListIteratorOfListIO It(selected);
1788 for (int i = 0; It.More(); It.Next(), i++) {
1789 Handle(SALOME_InteractiveObject) IObject = It.Value();
1790 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1793 aSel->setSelectedObjects( l1 );
1798 case 401: // GEOM::EDGE
1799 case 4021: // TRIANGLE
1801 case 4023: // POLYGON
1805 if(checkLock(aStudy)) break;
1807 EmitSignalDeactivateDialog();
1808 SMDSAbs_ElementType type = SMDSAbs_Edge;
1810 switch (theCommandID) {
1811 case 4021: // TRIANGLE
1812 type = SMDSAbs_Face; nbNodes = 3; break;
1814 type = SMDSAbs_Face; nbNodes = 4; break;
1816 type = SMDSAbs_Volume; nbNodes = 4; break;
1817 case 4023: // POLYGON
1818 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1820 type = SMDSAbs_Volume; nbNodes = 8; break;
1821 case 4033: // POLYHEDRE
1822 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1825 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1828 SUIT_MessageBox::warn1(desktop(),
1829 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1830 tr("SMESH_BUT_OK"));
1834 case 4033: // POLYHEDRON
1836 if(checkLock(aStudy)) break;
1838 EmitSignalDeactivateDialog();
1839 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1842 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1843 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1844 tr("SMESH_BUT_OK"));
1848 case 4041: // REMOVES NODES
1850 if(checkLock(aStudy)) break;
1852 EmitSignalDeactivateDialog();
1853 new SMESHGUI_RemoveNodesDlg(this);
1856 SUIT_MessageBox::warn1(desktop(),
1857 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1858 tr("SMESH_BUT_OK"));
1862 case 4042: // REMOVES ELEMENTS
1864 if(checkLock(aStudy)) break;
1866 EmitSignalDeactivateDialog();
1867 new SMESHGUI_RemoveElementsDlg(this);
1871 SUIT_MessageBox::warn1(desktop(),
1872 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1873 tr("SMESH_BUT_OK"));
1877 case 4051: // RENUMBERING NODES
1879 if(checkLock(aStudy)) break;
1881 EmitSignalDeactivateDialog();
1882 new SMESHGUI_RenumberingDlg( this, "", 0);
1886 SUIT_MessageBox::warn1(desktop(),
1887 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1888 tr("SMESH_BUT_OK"));
1892 case 4052: // RENUMBERING ELEMENTS
1894 if(checkLock(aStudy)) break;
1896 EmitSignalDeactivateDialog();
1897 new SMESHGUI_RenumberingDlg( this, "", 1);
1901 SUIT_MessageBox::warn1(desktop(),
1902 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1903 tr("SMESH_BUT_OK"));
1907 case 4061: // TRANSLATION
1909 if(checkLock(aStudy)) break;
1911 EmitSignalDeactivateDialog();
1912 new SMESHGUI_TranslationDlg( this );
1915 SUIT_MessageBox::warn1(desktop(),
1916 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1917 tr("SMESH_BUT_OK"));
1921 case 4062: // ROTATION
1923 if(checkLock(aStudy)) break;
1925 EmitSignalDeactivateDialog();
1926 new SMESHGUI_RotationDlg( this );
1929 SUIT_MessageBox::warn1(desktop(),
1930 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1931 tr("SMESH_BUT_OK"));
1935 case 4063: // SYMMETRY
1937 if(checkLock(aStudy)) break;
1939 EmitSignalDeactivateDialog();
1940 new SMESHGUI_SymmetryDlg( this );
1943 SUIT_MessageBox::warn1(desktop(),
1944 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1945 tr("SMESH_BUT_OK"));
1949 case 4064: // SEWING
1951 if(checkLock(aStudy)) break;
1953 EmitSignalDeactivateDialog();
1954 new SMESHGUI_SewingDlg( this );
1957 SUIT_MessageBox::warn1(desktop(),
1958 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1959 tr("SMESH_BUT_OK"));
1963 case 4065: // MERGE NODES
1965 if(checkLock(aStudy)) break;
1967 EmitSignalDeactivateDialog();
1968 new SMESHGUI_MergeNodesDlg( this );
1971 SUIT_MessageBox::warn1(desktop(),
1972 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1973 tr("SMESH_BUT_OK"));
1977 case 4066: // MERGE EQUAL ELEMENTS
1979 if (checkLock(aStudy)) break;
1981 EmitSignalDeactivateDialog();
1982 new SMESHGUI_EditMeshDlg(this,
1983 "SMESH_MERGE_ELEMENTS_TITLE",
1984 "ICON_DLG_MERGE_ELEMENTS",
1985 1); // MergeEqualElemets
1987 SUIT_MessageBox::warn1(desktop(),
1988 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1989 tr("SMESH_BUT_OK"));
1994 case 5105: // Library of selection filters
1996 static QValueList<int> aTypes;
1997 if ( aTypes.isEmpty() )
1999 aTypes.append( SMESH::NODE );
2000 aTypes.append( SMESH::EDGE );
2001 aTypes.append( SMESH::FACE );
2002 aTypes.append( SMESH::VOLUME );
2004 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2008 case 6017: // CONTROLS
2023 SalomeApp_SelectionMgr* mgr = selectionMgr();
2024 SALOME_ListIO selected; mgr->selectedObjects( selected );
2026 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2027 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2029 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2030 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2031 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2032 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2033 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2034 ::Control( theCommandID );
2039 SUIT_MessageBox::warn1(desktop(),
2040 tr( "SMESH_WRN_WARNING" ),
2041 tr( "SMESH_BAD_SELECTION" ),
2042 tr( "SMESH_BUT_OK" ) );
2046 SUIT_MessageBox::warn1(desktop(),
2047 tr( "SMESH_WRN_WARNING" ),
2048 tr( "NOT_A_VTK_VIEWER" ),
2049 tr( "SMESH_BUT_OK" ) );
2054 SalomeApp_SelectionMgr* mgr = selectionMgr();
2055 SALOME_ListIO selected; mgr->selectedObjects( selected );
2057 if (selected.Extent() == 1) {
2058 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2059 if(anIObject->hasEntry())
2060 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2061 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2068 SalomeApp_SelectionMgr* mgr = selectionMgr();
2069 SALOME_ListIO selected; mgr->selectedObjects( selected );
2071 if (selected.Extent() == 1) {
2072 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2073 if(anIObject->hasEntry())
2074 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2075 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2082 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2083 //updateObjBrowser();
2087 //=============================================================================
2091 //=============================================================================
2092 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2097 //=============================================================================
2101 //=============================================================================
2102 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2107 //=============================================================================
2111 //=============================================================================
2112 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2117 //=============================================================================
2118 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2119 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2121 //=============================================================================
2122 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2123 SUIT_ViewWindow* wnd )
2125 if(theIO->hasEntry()){
2126 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2127 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2131 //=======================================================================
2132 // function : createSMESHAction
2134 //=======================================================================
2135 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2138 QWidget* parent = application()->desktop();
2139 SUIT_ResourceMgr* resMgr = resourceMgr();
2141 if ( icon_id.length() )
2142 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2144 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2145 if ( !pix.isNull() )
2146 icon = QIconSet( pix );
2148 QString tooltip = tr( QString( "TOP_" )+po_id ),
2149 menu = tr( QString( "MEN_" )+po_id ),
2150 status_bar = tr( QString( "STB_" )+po_id );
2152 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2155 //=======================================================================
2156 // function : createPopupItem
2158 //=======================================================================
2159 void SMESHGUI::createPopupItem( const int id,
2160 const QString& clients,
2161 const QString& types,
2162 const QString& theRule,
2167 parentId = popupMgr()->actionId( action( pId ) );
2169 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2170 popupMgr()->insert( action( id ), parentId, 0 );
2172 QChar lc = QtxPopupMgr::Selection::defEquality();
2173 QString rule = "(%1) and (%2) and (%3)";
2174 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2175 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2176 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2179 bool cont = myRules.contains( id );
2181 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2183 popupMgr()->setRule( action( id ), rule, true );
2184 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2187 //=======================================================================
2188 // function : initialize
2190 //=======================================================================
2191 void SMESHGUI::initialize( CAM_Application* app )
2193 SalomeApp_Module::initialize( app );
2195 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2197 /* Automatic Update flag */
2198 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2200 // ----- create actions --------------
2202 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2203 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2204 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2205 createSMESHAction( 114, "NUM" );
2206 createSMESHAction( 121, "DAT" );
2207 createSMESHAction( 122, "MED" );
2208 createSMESHAction( 123, "UNV" );
2209 createSMESHAction( 124, "EXPORT_DAT" );
2210 createSMESHAction( 125, "EXPORT_MED" );
2211 createSMESHAction( 126, "EXPORT_UNV" );
2212 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2213 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2214 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2215 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2216 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2217 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2218 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2219 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2220 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2221 createSMESHAction( 804, "ADD" );
2222 createSMESHAction( 805, "REMOVE" );
2223 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2224 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2225 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2226 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2227 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2228 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2229 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2230 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2231 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2232 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2233 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2234 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2235 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2236 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2237 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2238 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2239 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2240 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2241 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2242 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2243 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2244 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2245 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2246 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2247 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2248 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2249 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2250 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2251 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2252 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2253 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2254 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2255 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2256 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2257 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2258 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2259 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2260 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2261 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2262 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2263 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2264 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2265 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2266 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2267 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2268 createSMESHAction( 415, "MAP", "ICON_MAP" );
2269 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2270 createSMESHAction( 200, "RESET" );
2271 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2272 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2273 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2274 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2275 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2276 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2277 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2278 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2279 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2280 createSMESHAction( 220, "ALL" );
2281 createSMESHAction( 1100, "EDIT_HYPO" );
2282 createSMESHAction( 1101, "RENAME" );
2283 createSMESHAction( 1102, "UNASSIGN" );
2284 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2285 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2286 createSMESHAction( 1131, "DISPMODE" );
2287 createSMESHAction( 1132, "COLORS" );
2288 createSMESHAction( 1133, "TRANSP" );
2289 createSMESHAction( 1134, "CLIP" );
2290 createSMESHAction( 1135, "DISP_ENT" );
2291 createSMESHAction( 2000, "CTRL" );
2293 createSMESHAction( 300, "ERASE" );
2294 createSMESHAction( 301, "DISPLAY" );
2295 createSMESHAction( 302, "DISPLAY_ONLY" );
2296 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2298 // ----- create menu --------------
2299 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2300 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2301 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2302 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2303 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2304 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2305 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2307 createMenu( separator(), fileId );
2309 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2310 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2311 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2312 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2313 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2314 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2316 createMenu( 111, importId, -1 );
2317 createMenu( 112, importId, -1 );
2318 createMenu( 113, importId, -1 );
2320 createMenu( 121, exportId, -1 );
2321 createMenu( 122, exportId, -1 );
2322 createMenu( 123, exportId, -1 );
2324 createMenu( separator(), fileId, 10 );
2326 createMenu( 33, editId, -1 );
2328 createMenu( 5105, toolsId, -1 );
2330 createMenu( 702, meshId, -1 );
2331 createMenu( 703, meshId, -1 );
2332 createMenu( 704, meshId, -1 );
2333 createMenu( separator(), meshId, -1 );
2334 createMenu( 701, meshId, -1 );
2335 createMenu( separator(), meshId, -1 );
2336 createMenu( 801, meshId, -1 );
2337 createMenu( 802, meshId, -1 );
2338 createMenu( 803, meshId, -1 );
2339 createMenu( separator(), meshId, -1 );
2340 createMenu( 810, meshId, -1 );
2341 createMenu( 811, meshId, -1 );
2342 createMenu( 812, meshId, -1 );
2343 createMenu( separator(), meshId, -1 );
2344 createMenu( 813, meshId, -1 );
2345 createMenu( separator(), meshId, -1 );
2346 createMenu( 900, meshId, -1 );
2347 createMenu( 902, meshId, -1 );
2348 createMenu( separator(), meshId, -1 );
2350 createMenu( 6003, ctrlId, -1 );
2351 createMenu( 6001, ctrlId, -1 );
2352 createMenu( 6004, ctrlId, -1 );
2353 createMenu( separator(), ctrlId, -1 );
2354 createMenu( 6002, ctrlId, -1 );
2355 createMenu( 6018, ctrlId, -1 );
2356 createMenu( 6019, ctrlId, -1 );
2357 createMenu( 6011, ctrlId, -1 );
2358 createMenu( 6012, ctrlId, -1 );
2359 createMenu( 6013, ctrlId, -1 );
2360 createMenu( 6014, ctrlId, -1 );
2361 createMenu( 6015, ctrlId, -1 );
2362 createMenu( 6016, ctrlId, -1 );
2363 createMenu( separator(), ctrlId, -1 );
2364 createMenu( 6017, ctrlId, -1 );
2365 createMenu( separator(), ctrlId, -1 );
2367 createMenu( 400, addId, -1 );
2368 createMenu( 401, addId, -1 );
2369 createMenu( 4021, addId, -1 );
2370 createMenu( 4022, addId, -1 );
2371 createMenu( 4023, addId, -1 );
2372 createMenu( 4031, addId, -1 );
2373 createMenu( 4032, addId, -1 );
2374 createMenu( 4033, addId, -1 );
2376 createMenu( 4041, removeId, -1 );
2377 createMenu( 4042, removeId, -1 );
2379 createMenu( 4051, renumId, -1 );
2380 createMenu( 4052, renumId, -1 );
2382 createMenu( 4061, transfId, -1 );
2383 createMenu( 4062, transfId, -1 );
2384 createMenu( 4063, transfId, -1 );
2385 createMenu( 4064, transfId, -1 );
2386 createMenu( 4065, transfId, -1 );
2387 createMenu( 4066, transfId, -1 );
2389 createMenu( 406, modifyId, -1 );
2390 createMenu( 407, modifyId, -1 );
2391 createMenu( 408, modifyId, -1 );
2392 createMenu( 409, modifyId, -1 );
2393 createMenu( 410, modifyId, -1 );
2394 createMenu( 411, modifyId, -1 );
2395 createMenu( 412, modifyId, -1 );
2396 createMenu( 413, modifyId, -1 );
2397 createMenu( 416, modifyId, -1 );
2398 createMenu( 414, modifyId, -1 );
2399 createMenu( 415, modifyId, -1 );
2401 createMenu( 214, viewId, -1 );
2403 // ----- create toolbars --------------
2404 int meshTb = createTool( tr( "TB_MESH" ) ),
2405 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2406 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2407 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2408 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2410 createTool( 702, meshTb );
2411 createTool( 703, meshTb );
2412 createTool( 704, meshTb );
2413 createTool( separator(), meshTb );
2414 createTool( 701, meshTb );
2415 createTool( separator(), meshTb );
2416 createTool( 801, meshTb );
2417 createTool( 802, meshTb );
2418 createTool( 803, meshTb );
2419 createTool( separator(), meshTb );
2420 createTool( 900, meshTb );
2421 createTool( 902, meshTb );
2422 createTool( separator(), meshTb );
2424 createTool( 6001, ctrlTb );
2425 createTool( 6003, ctrlTb );
2426 createTool( 6004, ctrlTb );
2427 createTool( separator(), ctrlTb );
2428 createTool( 6002, ctrlTb );
2429 createTool( 6018, ctrlTb );
2430 createTool( 6019, ctrlTb );
2431 createTool( 6011, ctrlTb );
2432 createTool( 6012, ctrlTb );
2433 createTool( 6013, ctrlTb );
2434 createTool( 6014, ctrlTb );
2435 createTool( 6015, ctrlTb );
2436 createTool( 6016, ctrlTb );
2437 createTool( separator(), ctrlTb );
2438 createTool( 6017, ctrlTb );
2439 createTool( separator(), ctrlTb );
2441 createTool( 400, addRemTb );
2442 createTool( 401, addRemTb );
2443 createTool( 4021, addRemTb );
2444 createTool( 4022, addRemTb );
2445 createTool( 4023, addRemTb );
2446 createTool( 4031, addRemTb );
2447 createTool( 4032, addRemTb );
2448 createTool( 4033, addRemTb );
2449 createTool( separator(), addRemTb );
2450 createTool( 4041, addRemTb );
2451 createTool( 4042, addRemTb );
2452 createTool( separator(), addRemTb );
2453 createTool( 4051, addRemTb );
2454 createTool( 4052, addRemTb );
2455 createTool( separator(), addRemTb );
2456 createTool( 4061, addRemTb );
2457 createTool( 4062, addRemTb );
2458 createTool( 4063, addRemTb );
2459 createTool( 4064, addRemTb );
2460 createTool( 4065, addRemTb );
2461 createTool( 4066, addRemTb );
2462 createTool( separator(), addRemTb );
2464 createTool( 406, modifyTb );
2465 createTool( 407, modifyTb );
2466 createTool( 408, modifyTb );
2467 createTool( 409, modifyTb );
2468 createTool( 410, modifyTb );
2469 createTool( 411, modifyTb );
2470 createTool( 412, modifyTb );
2471 createTool( 413, modifyTb );
2472 createTool( 416, modifyTb );
2473 createTool( 414, modifyTb );
2474 createTool( 415, modifyTb );
2476 createTool( 214, dispModeTb );
2480 QString OB = "'ObjectBrowser'",
2481 View = "'" + SVTK_Viewer::Type() + "'",
2483 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2484 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2485 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2486 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2487 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2488 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2489 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2490 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2491 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2492 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2494 mesh_group = mesh + " " + subMesh + " " + group,
2495 hyp_alg = hypo + " " + algo;
2497 // popup for object browser
2499 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2500 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2501 createPopupItem( 803, OB, group ); // EDIT_GROUP
2502 popupMgr()->insert( separator(), -1, 0 );
2503 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2504 createPopupItem( 214, OB, mesh_group ); // UPDATE
2505 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2506 createPopupItem( 902, OB, mesh ); // STD_INFO
2507 popupMgr()->insert( separator(), -1, 0 );
2508 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2509 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2510 popupMgr()->insert( separator(), -1, 0 );
2511 createPopupItem( 1100, OB, hypo, "&& $hasReference={false}" ); // EDIT HYPOTHESIS
2512 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2513 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "&& $hasReference={false}" ); // RENAME
2514 popupMgr()->insert( separator(), -1, 0 );
2515 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2516 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2517 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2518 popupMgr()->insert( separator(), -1, 0 );
2521 createPopupItem( 803, View, group ); // EDIT_GROUP
2522 createPopupItem( 804, View, elems ); // ADD
2523 createPopupItem( 805, View, elems ); // REMOVE
2524 popupMgr()->insert( separator(), -1, 0 );
2525 createPopupItem( 214, View, mesh_group ); // UPDATE
2526 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2527 createPopupItem( 902, View, mesh ); // STD_INFO
2528 popupMgr()->insert( separator(), -1, 0 );
2532 isInvisible("not( isVisible )"),
2533 isEmpty("numberOfNodes = 0"),
2534 isNotEmpty("numberOfNodes <> 0"),
2536 // has nodes, edges, etc in VISIBLE! actor
2537 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2538 hasElems("(count( elemTypes ) > 0)"),
2539 hasDifferentElems("(count( elemTypes ) > 1)"),
2540 hasEdges("({'Edge'} in elemTypes)"),
2541 hasFaces("({'Face'} in elemTypes)"),
2542 hasVolumes("({'Volume'} in elemTypes)");
2544 QString lc = QtxPopupMgr::Selection::defEquality();
2545 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2546 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2547 QString aMeshInVTK = aClient + "&&" + aType;
2549 //-------------------------------------------------
2551 //-------------------------------------------------
2552 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2554 popupMgr()->insert( action( 9010 ), anId, -1 );
2555 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2556 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2558 popupMgr()->insert( action( 9011 ), anId, -1 );
2559 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2560 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2562 popupMgr()->insert( separator(), -1, -1 );
2564 //-------------------------------------------------
2566 //-------------------------------------------------
2567 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2569 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2570 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2571 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2573 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2574 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2575 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2577 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2578 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2579 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2581 popupMgr()->insert( separator(), anId, -1 );
2583 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2584 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2585 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2587 //-------------------------------------------------
2589 //-------------------------------------------------
2590 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2592 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2594 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2595 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2596 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2598 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2599 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2600 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2602 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2603 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2604 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2606 popupMgr()->insert( separator(), anId, -1 );
2608 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2609 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2611 //-------------------------------------------------
2613 //-------------------------------------------------
2614 popupMgr()->insert( action( 1132 ), -1, -1 );
2615 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2617 //-------------------------------------------------
2619 //-------------------------------------------------
2620 popupMgr()->insert( action( 1133 ), -1, -1 );
2621 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2623 //-------------------------------------------------
2625 //-------------------------------------------------
2626 popupMgr()->insert( action( 1134 ), -1, -1 );
2627 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2629 popupMgr()->insert( separator(), -1, -1 );
2631 //-------------------------------------------------
2633 //-------------------------------------------------
2635 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2636 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2637 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2639 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2641 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2642 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2644 popupMgr()->insert( separator(), anId, -1 );
2646 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2647 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2648 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2650 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2651 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2652 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2654 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2655 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2656 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2658 popupMgr()->insert( separator(), anId, -1 );
2660 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2661 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2662 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2664 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2665 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2666 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2668 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2669 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2670 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2672 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2673 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2674 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2676 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2677 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2678 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2680 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2681 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2682 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2684 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2685 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2686 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2688 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2689 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2690 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2692 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2693 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2694 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2696 popupMgr()->insert( separator(), anId, -1 );
2698 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2699 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2700 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2702 popupMgr()->insert( separator(), anId, -1 );
2704 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2705 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2707 popupMgr()->insert( separator(), -1, -1 );
2709 //-------------------------------------------------
2711 //-------------------------------------------------
2712 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2713 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
2714 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2715 QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
2716 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2717 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
2719 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2720 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
2722 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2723 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
2725 popupMgr()->insert( separator(), -1, -1 );
2727 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
2728 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
2731 bool SMESHGUI::activateModule( SUIT_Study* study )
2733 bool res = SalomeApp_Module::activateModule( study );
2735 setMenuShown( true );
2736 setToolShown( true );
2741 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2743 setMenuShown( false );
2744 setToolShown( false );
2746 EmitSignalCloseAllDialogs();
2748 return SalomeApp_Module::deactivateModule( study );
2751 void SMESHGUI::OnGUIEvent()
2753 const QObject* obj = sender();
2754 if ( !obj || !obj->inherits( "QAction" ) )
2756 int id = actionId((QAction*)obj);
2761 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2763 if ( CORBA::is_nil( myComponentSMESH ) )
2765 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2766 return aGUI.myComponentSMESH;
2768 return myComponentSMESH;
2771 QString SMESHGUI::engineIOR() const
2773 CORBA::ORB_var anORB = getApp()->orb();
2774 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2778 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2780 SMESHGUI_Selection sel;
2781 sel.init( client, selectionMgr() );
2782 popupMgr()->updatePopup( menu, &sel );
2785 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2787 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2788 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2791 void SMESHGUI::viewManagers( QStringList& list ) const
2793 list.append( SVTK_Viewer::Type() );
2796 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
2798 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
2799 SMESH::UpdateSelectionProp( this );
2802 void SMESHGUI::createPreferences()
2804 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2806 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2807 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, SalomeApp_Preferences::Bool, "SMESH", "auto_update" );
2809 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2810 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "display_entity" );
2811 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "use_precision" );
2813 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2814 setPreferenceProperty( precGroup, "columns", 1 );
2816 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2818 setPreferenceProperty( prec, "min", 0 );
2819 setPreferenceProperty( prec, "max", 16 );
2821 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2822 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, SalomeApp_Preferences::Selector, "SMESH", "display_mode" );
2824 modes.append( "Wireframe" );
2825 modes.append( "Shading" );
2826 modes.append( "Shrink" );
2827 modes.append( "Nodes" );
2828 QValueList<QVariant> indices;
2829 indices.append( 0 );
2830 indices.append( 1 );
2831 indices.append( 2 );
2832 indices.append( 3 );
2833 setPreferenceProperty( dispmode, "strings", modes );
2834 setPreferenceProperty( dispmode, "indexes", indices );
2836 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2837 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2839 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
2840 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
2842 setPreferenceProperty( nodeSz, "min", 1 );
2843 setPreferenceProperty( nodeSz, "max", 5 );
2845 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2847 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
2848 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
2849 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
2850 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
2852 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
2853 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2855 setPreferenceProperty( elemW, "min", 1 );
2856 setPreferenceProperty( elemW, "max", 5 );
2858 setPreferenceProperty( shrink, "min", 0 );
2859 setPreferenceProperty( shrink, "max", 100 );
2861 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2863 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2865 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
2866 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
2867 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
2869 setPreferenceProperty( selW, "min", 1 );
2870 setPreferenceProperty( selW, "max", 5 );
2872 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2874 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
2875 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2877 setPreferenceProperty( preW, "min", 1 );
2878 setPreferenceProperty( preW, "max", 5 );
2880 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2882 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
2883 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
2885 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2886 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2888 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2889 addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2890 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2891 addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
2894 fam.append( tr( "SMESH_FONT_ARIAL" ) );
2895 fam.append( tr( "SMESH_FONT_COURIER" ) );
2896 fam.append( tr( "SMESH_FONT_TIMES" ) );
2897 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2899 setPreferenceProperty( tfont, "families", fam );
2900 setPreferenceProperty( tfont, "system", false );
2901 setPreferenceProperty( tfont, "widget_flags", wflag );
2902 setPreferenceProperty( lfont, "families", fam );
2903 setPreferenceProperty( lfont, "system", false );
2904 setPreferenceProperty( lfont, "widget_flags", wflag );
2906 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
2908 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
2909 setPreferenceProperty( numcol, "min", 2 );
2910 setPreferenceProperty( numcol, "max", 256 );
2912 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
2913 setPreferenceProperty( numlab, "min", 2 );
2914 setPreferenceProperty( numlab, "max", 65 );
2916 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
2917 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2918 QStringList orients;
2919 orients.append( tr( "SMESH_VERTICAL" ) );
2920 orients.append( tr( "SMESH_HORIZONTAL" ) );
2921 indices.clear(); indices.append( 0 ); indices.append( 1 );
2922 setPreferenceProperty( orient, "strings", orients );
2923 setPreferenceProperty( orient, "indexes", indices );
2925 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
2926 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2927 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2928 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2929 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
2930 setPreferenceProperty( xv, "step", 0.1 );
2931 setPreferenceProperty( xv, "min", 0.0 );
2932 setPreferenceProperty( xv, "max", 1.0 );
2933 setPreferenceProperty( yv, "step", 0.1 );
2934 setPreferenceProperty( yv, "min", 0.0 );
2935 setPreferenceProperty( yv, "max", 1.0 );
2936 setPreferenceProperty( wv, "step", 0.1 );
2937 setPreferenceProperty( wv, "min", 0.0 );
2938 setPreferenceProperty( wv, "max", 1.0 );
2939 setPreferenceProperty( hv, "min", 0.0 );
2940 setPreferenceProperty( hv, "max", 1.0 );
2941 setPreferenceProperty( hv, "step", 0.1 );
2943 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
2944 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
2945 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
2946 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
2947 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
2948 setPreferenceProperty( xv, "min", 0.0 );
2949 setPreferenceProperty( xv, "max", 1.0 );
2950 setPreferenceProperty( xv, "step", 0.1 );
2951 setPreferenceProperty( xh, "min", 0.0 );
2952 setPreferenceProperty( xh, "max", 1.0 );
2953 setPreferenceProperty( xh, "step", 0.1 );
2954 setPreferenceProperty( yh, "min", 0.0 );
2955 setPreferenceProperty( yh, "max", 1.0 );
2956 setPreferenceProperty( yh, "step", 0.1 );
2957 setPreferenceProperty( wh, "min", 0.0 );
2958 setPreferenceProperty( wh, "max", 1.0 );
2959 setPreferenceProperty( wh, "step", 0.1 );
2960 setPreferenceProperty( hh, "min", 0.0 );
2961 setPreferenceProperty( hh, "max", 1.0 );
2962 setPreferenceProperty( hh, "step", 0.1 );
2965 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
2969 //================================================================================
2971 * \brief Update something in accordance with update flags
2972 * \param theFlags - update flags
2974 * Update viewer or/and object browser etc. in accordance with update flags ( see
2975 * SalomeApp_UpdateFlags enumeration ).
2977 //================================================================================
2978 void SMESHGUI::update( const int flags )
2980 if ( flags & UF_Viewer | flags & UF_Forced )
2981 SMESH::UpdateView();
2983 SalomeApp_Module::update( flags );
2986 //================================================================================
2988 * \brief Set default selection mode
2990 * SLOT called when operation commited. Sets default selection mode
2992 //================================================================================
2993 void SMESHGUI::onOperationCommited( SUIT_Operation* )
2995 SVTK_ViewWindow* vtkWnd =
2996 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
2998 vtkWnd->SetSelectionMode( ActorSelection );
3001 //================================================================================
3003 * \brief Set default selection mode
3005 * SLOT called when operation aborted. Sets default selection mode
3007 //================================================================================
3008 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3010 SVTK_ViewWindow* vtkWnd =
3011 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3013 vtkWnd->SetSelectionMode( ActorSelection );
3016 //================================================================================
3018 * \brief Creates operation with given identifier
3019 * \param id - identifier of operation to be started
3020 * \return Pointer on created operation or NULL if operation is not created
3022 * Virtual method redefined from the base class creates operation with given id.
3023 * It is called called automatically from startOperation method of base class.
3025 //================================================================================
3026 SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
3028 SalomeApp_Operation* op = 0;
3029 // to do : create operation here
3032 case 702: // Create mesh
3033 op = new SMESHGUI_MeshOp( true, true );
3035 case 703: // Create sub-mesh
3036 op = new SMESHGUI_MeshOp( true, false );
3038 case 704: // Edit mesh/sub-mesh
3039 op = new SMESHGUI_MeshOp( false );