1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESHGUI_InitMeshDlg.h"
30 #include "SMESHGUI_AddSubMeshDlg.h"
31 #include "SMESHGUI_NodesDlg.h"
32 #include "SMESHGUI_TransparencyDlg.h"
33 #include "SMESHGUI_ClippingDlg.h"
34 #include "SMESHGUI_GroupDlg.h"
35 #include "SMESHGUI_RemoveNodesDlg.h"
36 #include "SMESHGUI_RemoveElementsDlg.h"
37 #include "SMESHGUI_MeshInfosDlg.h"
38 #include "SMESHGUI_StandardMeshInfosDlg.h"
39 #include "SMESHGUI_Preferences_ColorDlg.h"
40 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
41 #include "SMESHGUI_Preferences_SelectionDlg.h"
42 #include "SMESHGUI_Hypotheses.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_EditHypothesesDlg.h"
46 #include "SMESHGUI_CreateHypothesesDlg.h"
47 #include "SMESHGUI_FilterDlg.h"
48 #include "SMESHGUI_FilterLibraryDlg.h"
49 #include "SMESHGUI_SingleEditDlg.h"
50 #include "SMESHGUI_MultiEditDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_DeleteGroupDlg.h"
53 #include "SMESHGUI_SmoothingDlg.h"
54 #include "SMESHGUI_RenumberingDlg.h"
55 #include "SMESHGUI_ExtrusionDlg.h"
56 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
57 #include "SMESHGUI_RevolutionDlg.h"
58 #include "SMESHGUI_TranslationDlg.h"
59 #include "SMESHGUI_RotationDlg.h"
60 #include "SMESHGUI_SymmetryDlg.h"
61 #include "SMESHGUI_SewingDlg.h"
62 #include "SMESHGUI_MergeNodesDlg.h"
63 #include "SMESHGUI_EditMeshDlg.h"
64 #include "SMESHGUI_MeshPatternDlg.h"
65 #include "SMESHGUI_PrecisionDlg.h"
66 #include "SMESHGUI_Selection.h"
67 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
69 #include "SMESHGUI_Utils.h"
70 #include "SMESHGUI_GEOMGenUtils.h"
71 #include "SMESHGUI_MeshUtils.h"
72 #include "SMESHGUI_GroupUtils.h"
73 #include "SMESHGUI_FilterUtils.h"
74 #include "SMESHGUI_PatternUtils.h"
75 #include "SMESHGUI_VTKUtils.h"
76 #include "SMESHGUI_HypothesesUtils.h"
78 #include "SMESH_Actor.h"
79 #include "SMESH_Object.h"
80 #include "SMESH_TypeFilter.hxx"
82 #include "SalomeApp_Tools.h"
83 #include "SalomeApp_Study.h"
84 #include "SalomeApp_NameDlg.h"
85 #include "SalomeApp_DataOwner.h"
86 #include "SalomeApp_Application.h"
87 #include "SalomeApp_Preferences.h"
88 #include "SalomeApp_VTKSelector.h"
89 #include "SalomeApp_ImportOperation.h"
91 #include <SVTK_ViewWindow.h>
92 #include <SVTK_ViewModel.h>
93 #include <SVTK_InteractorStyle.h>
94 #include <SVTK_RenderWindowInteractor.h>
96 #include <VTKViewer_ViewManager.h>
98 #include "OB_Browser.h"
100 #include "SUIT_Tools.h"
101 #include "SUIT_MessageBox.h"
102 #include "SUIT_ResourceMgr.h"
103 #include "SUIT_FileDlg.h"
104 #include "SUIT_Desktop.h"
105 #include "SUIT_ResourceMgr.h"
106 #include "SUIT_OverrideCursor.h"
107 #include "SUIT_Study.h"
108 #include "SUIT_Session.h"
110 #include "QtxPopupMgr.h"
112 #include "SALOME_ListIO.hxx"
113 #include "SALOME_ListIteratorOfListIO.hxx"
114 #include "SALOME_InteractiveObject.hxx"
115 #include "SALOME_NamingService.hxx"
116 #include "SALOME_LifeCycleCORBA.hxx"
118 #include "SALOMEconfig.h"
119 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
122 #define INCLUDE_MENUITEM_DEF
123 #include <qpopupmenu.h>
129 #include <boost/shared_ptr.hpp>
132 #include <vtkRenderer.h>
133 #include <vtkRenderWindow.h>
134 #include <vtkActorCollection.h>
135 #include <vtkScalarBarActor.h>
136 #include <vtkUnstructuredGrid.h>
138 #include "utilities.h"
140 #include "SALOMEDS_Study.hxx"
141 #include "SALOMEDSClient_StudyBuilder.hxx"
142 #include "SALOMEDSClient_SComponent.hxx"
148 //=============================================================
149 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
152 void ExportMeshToFile(int theCommandID);
154 void SetDisplayMode(int theCommandID);
156 void SetDisplayEntity(int theCommandID);
158 void Control( int theCommandID );
162 //=============================================================
163 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
169 if(theCommandID == 113){
170 filter.append(QObject::tr("MED files (*.med)"));
171 filter.append(QObject::tr("All files (*)"));
172 }else if (theCommandID == 112){
173 filter.append(QObject::tr("IDEAS files (*.unv)"));
174 }else if (theCommandID == 111){
175 filter.append(QObject::tr("DAT files (*.dat)"));
177 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
180 QObject::tr("Import mesh"),
182 if(!filename.isEmpty()) {
183 SUIT_OverrideCursor wc;
184 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
185 theComponentMesh->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
188 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
189 switch ( theCommandID ) {
192 aMeshes->length( 1 );
193 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
198 SMESH::DriverMED_ReadStatus res;
199 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
200 if ( res != SMESH::DRS_OK ) {
202 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
203 QObject::tr("SMESH_WRN_WARNING"),
204 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
205 QObject::tr("SMESH_BUT_OK"));
206 aMeshes->length( 0 );
213 bool isEmpty = false;
214 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
215 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
217 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
218 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
219 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
220 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
221 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
228 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
229 QObject::tr("SMESH_WRN_WARNING"),
230 QObject::tr("SMESH_DRS_EMPTY"),
231 QObject::tr("SMESH_BUT_OK"));
235 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
237 catch (const SALOME::SALOME_Exception& S_ex){
239 SalomeApp_Tools::QtCatchCorbaException(S_ex);
246 void ExportMeshToFile( int theCommandID )
248 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
249 SALOME_ListIO selected;
251 aSel->selectedObjects( selected );
253 if(selected.Extent()){
254 Handle(SALOME_InteractiveObject) anIObject = selected.First();
255 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
256 if ( !aMesh->_is_nil() ) {
257 QString aFilter, aTitle = QObject::tr("Export mesh");
258 QMap<QString, SMESH::MED_VERSION> aFilterMap;
259 switch ( theCommandID ) {
262 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
263 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
267 aFilter = QObject::tr("DAT files (*.dat)");
271 if(aMesh->NbPyramids()){
272 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
273 QObject::tr("SMESH_WRN_WARNING"),
274 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
275 QObject::tr("SMESH_BUT_YES"),
276 QObject::tr("SMESH_BUT_NO"),
281 aFilter = QObject::tr("IDEAS files (*.unv)");
288 SMESH::MED_VERSION aFormat;
290 if ( theCommandID != 122 && theCommandID != 125 )
291 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
295 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
296 filters.push_back( it.key() );
298 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
299 fd->setCaption( aTitle );
300 fd->setFilters( filters );
304 aFilename = fd->selectedFile();
305 aFormat = aFilterMap[fd->selectedFilter()];
307 if( !aFilename.isEmpty()
308 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
309 && aFormat==SMESH::MED_V2_1){
310 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
311 QObject::tr("SMESH_WRN_WARNING"),
312 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
313 QObject::tr("SMESH_BUT_YES"),
314 QObject::tr("SMESH_BUT_NO"),
323 if ( !aFilename.isEmpty() ) {
324 // Check whether the file already exists and delete it if yes
325 QFile aFile( aFilename );
326 if ( aFile.exists() )
328 SUIT_OverrideCursor wc;
329 switch ( theCommandID ) {
332 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
336 aMesh->ExportDAT( aFilename.latin1() );
340 aMesh->ExportUNV( aFilename.latin1() );
350 inline void InverseEntityMode(unsigned int& theOutputMode,
351 unsigned int theMode)
353 bool anIsNotPresent = ~theOutputMode & theMode;
355 theOutputMode |= theMode;
357 theOutputMode &= ~theMode;
360 void SetDisplayEntity(int theCommandID){
361 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
362 SALOME_ListIO selected;
364 aSel->selectedObjects( selected );
366 if(selected.Extent() >= 1){
367 SALOME_ListIteratorOfListIO It( selected );
368 for(; It.More(); It.Next()){
369 Handle(SALOME_InteractiveObject) IObject = It.Value();
370 if(IObject->hasEntry()){
371 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
372 unsigned int aMode = anActor->GetEntityMode();
373 switch(theCommandID){
375 InverseEntityMode(aMode,SMESH_Actor::eEdges);
378 InverseEntityMode(aMode,SMESH_Actor::eFaces);
381 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
384 aMode = SMESH_Actor::eAllEntity;
388 anActor->SetEntityMode(aMode);
395 void SetDisplayMode(int theCommandID){
396 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
397 SALOME_ListIO selected;
399 aSel->selectedObjects( selected );
401 if(selected.Extent() >= 1){
402 switch(theCommandID){
404 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
405 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
409 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
410 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
413 SALOME_ListIteratorOfListIO It( selected );
414 for(; It.More(); It.Next()){
415 Handle(SALOME_InteractiveObject) IObject = It.Value();
416 if(IObject->hasEntry()){
417 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
418 switch(theCommandID){
420 anActor->SetRepresentation(SMESH_Actor::eEdge);
423 anActor->SetRepresentation(SMESH_Actor::eSurface);
426 if(anActor->IsShrunk())
429 anActor->SetShrink();
432 anActor->SetRepresentation(SMESH_Actor::ePoint);
436 anActor->GetSufaceColor(color[0], color[1], color[2]);
437 int c0 = int (color[0] * 255);
438 int c1 = int (color[1] * 255);
439 int c2 = int (color[2] * 255);
440 QColor c(c0, c1, c2);
443 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
444 c0 = int (edgecolor[0] * 255);
445 c1 = int (edgecolor[1] * 255);
446 c2 = int (edgecolor[2] * 255);
447 QColor e(c0, c1, c2);
449 float backfacecolor[3];
450 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
451 c0 = int (backfacecolor[0] * 255);
452 c1 = int (backfacecolor[1] * 255);
453 c2 = int (backfacecolor[2] * 255);
454 QColor b(c0, c1, c2);
457 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
458 c0 = int (nodecolor[0] * 255);
459 c1 = int (nodecolor[1] * 255);
460 c2 = int (nodecolor[2] * 255);
461 QColor n(c0, c1, c2);
463 int Edgewidth = (int)anActor->GetLineWidth();
466 int intValue = int(anActor->GetNodeSize());
467 float Shrink = anActor->GetShrinkFactor();
469 SMESHGUI_Preferences_ColorDlg *aDlg =
470 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
471 aDlg->SetColor(1, c);
472 aDlg->SetColor(2, e);
473 aDlg->SetColor(3, n);
474 aDlg->SetColor(4, b);
475 aDlg->SetIntValue(1, Edgewidth);
476 aDlg->SetIntValue(2, intValue);
477 aDlg->SetIntValue(3, int(Shrink*100.));
479 QColor color = aDlg->GetColor(1);
480 QColor edgecolor = aDlg->GetColor(2);
481 QColor nodecolor = aDlg->GetColor(3);
482 QColor backfacecolor = aDlg->GetColor(4);
483 /* actor color and backface color */
484 anActor->SetSufaceColor(float (color.red()) / 255.,
485 float (color.green()) / 255.,
486 float (color.blue()) / 255.);
487 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
488 float (backfacecolor.green()) / 255.,
489 float (backfacecolor.blue()) / 255.);
492 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
493 float (edgecolor.green()) / 255.,
494 float (edgecolor.blue()) / 255.);
496 /* Shrink factor and size edges */
497 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
498 anActor->SetLineWidth(aDlg->GetIntValue(1));
500 /* Nodes color and size */
501 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
502 float (nodecolor.green()) / 255.,
503 float (nodecolor.blue()) / 255.);
504 anActor->SetNodeSize(aDlg->GetIntValue(2));
513 SMESH::RepaintCurrentView();
517 void Control( int theCommandID )
519 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
520 SALOME_ListIO selected;
522 aSel->selectedObjects( selected );
524 if( !selected.IsEmpty() ){
525 Handle(SALOME_InteractiveObject) anIO = selected.First();
528 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
529 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
530 switch ( theCommandID ){
532 aTitle = QObject::tr( "LENGTH_EDGES" );
533 aControl = SMESH_Actor::eLength;
536 aTitle = QObject::tr( "LENGTH2D_EDGES" );
537 aControl = SMESH_Actor::eLength2D;
540 aTitle = QObject::tr( "FREE_EDGES" );
541 aControl = SMESH_Actor::eFreeEdges;
544 aTitle = QObject::tr( "FREE_BORDERS" );
545 aControl = SMESH_Actor::eFreeBorders;
548 aTitle = QObject::tr( "MULTI_BORDERS" );
549 aControl = SMESH_Actor::eMultiConnection;
552 aTitle = QObject::tr( "MULTI2D_BORDERS" );
553 aControl = SMESH_Actor::eMultiConnection2D;
556 aTitle = QObject::tr( "AREA_ELEMENTS" );
557 aControl = SMESH_Actor::eArea;
560 aTitle = QObject::tr( "TAPER_ELEMENTS" );
561 aControl = SMESH_Actor::eTaper;
564 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
565 aControl = SMESH_Actor::eAspectRatio;
568 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
569 aControl = SMESH_Actor::eAspectRatio3D;
572 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
573 aControl = SMESH_Actor::eMinimumAngle;
576 aTitle = QObject::tr( "WARP_ELEMENTS" );
577 aControl = SMESH_Actor::eWarping;
580 aTitle = QObject::tr( "SKEW_ELEMENTS" );
581 aControl = SMESH_Actor::eSkew;
584 anActor->SetControlMode(aControl);
585 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
592 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
593 MeshObjectType theType,
594 const QString theInTypeName,
595 QString & theOutTypeName)
597 SMESH_TypeFilter aTypeFilter( theType );
599 if( !theIO.IsNull() )
601 entry = theIO->getEntry();
602 SalomeApp_DataOwner owner( entry );
603 if ( aTypeFilter.isOk( &owner )) {
604 theOutTypeName = theInTypeName;
612 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
614 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
615 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
617 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
618 CORBA::String_var anID = aSComp->GetID().c_str();
619 if (!strcmp(anID.in(),theIO->getEntry()))
625 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
626 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
627 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
628 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
629 CheckOIType ( theIO, GROUP, "Group", aTypeName )
637 QString CheckHomogeneousSelection()
639 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
640 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
641 SALOME_ListIO selected;
643 aSel->selectedObjects( selected );
645 QString RefType = CheckTypeObject(selected.First());
646 SALOME_ListIteratorOfListIO It(selected);
647 for (; It.More(); It.Next())
649 Handle(SALOME_InteractiveObject) IObject = It.Value();
650 QString Type = CheckTypeObject(IObject);
651 if (Type.compare(RefType) != 0)
652 return "Heterogeneous Selection";
659 void SMESHGUI::OnEditDelete()
661 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
662 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
663 SALOME_ListIO selected; aSel->selectedObjects( selected );
665 QString aParentComponent = QString::null;
666 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
668 QString cur = anIt.Value()->getComponentDataType();
669 if( aParentComponent.isNull() )
670 aParentComponent = cur;
671 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
672 aParentComponent = "";
675 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
676 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
677 QObject::tr("ERR_ERROR"),
678 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
679 QObject::tr("BUT_OK") );
682 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
683 if (SUIT_MessageBox::warn2
684 (SMESHGUI::desktop(),
685 QObject::tr("SMESH_WRN_WARNING"),
686 QObject::tr("SMESH_REALLY_DELETE"),
687 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
690 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
691 SUIT_ViewManager* vm = anApp->activeViewManager();
692 int nbSf = vm->getViewsCount();
694 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
695 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
696 _PTR(GenericAttribute) anAttr;
697 _PTR(AttributeIOR) anIOR;
699 SALOME_ListIteratorOfListIO It(selected);
701 aStudyBuilder->NewCommand(); // There is a transaction
702 for(; It.More(); It.Next()){
703 Handle(SALOME_InteractiveObject) IObject = It.Value();
704 if(IObject->hasEntry()){
705 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
707 // disable removal of "SMESH" component object
708 if(SO->FindAttribute(anAttr, "AttributeIOR")){
710 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
714 /* Erase child graphical objects */
715 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
716 for(it->InitEx(true); it->More(); it->Next()){
717 _PTR(SObject) CSO = it->Value();
718 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
721 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
722 for(int i = 0; i < nbSf; i++){
723 SUIT_ViewWindow *sf = aViews[i];
724 CORBA::String_var anEntry = CSO->GetID().c_str();
725 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
726 SMESH::RemoveActor(sf,anActor);
732 /* Erase main graphical object */
733 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
734 for(int i = 0; i < nbSf; i++){
735 SUIT_ViewWindow *sf = aViews[i];
736 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
737 SMESH::RemoveActor(sf,anActor);
741 // Remove object(s) from data structures
742 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
744 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
745 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
746 QString objType = CheckTypeObject(IObject);
747 if ( !aGroup->_is_nil() ) { // DELETE GROUP
748 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
749 aMesh->RemoveGroup( aGroup );
751 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
752 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
753 aMesh->RemoveSubMesh( aSubMesh );
755 else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
756 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
757 aStudyBuilder->RemoveObjectWithChildren( obj );
759 else {// default action: remove SObject from the study
760 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
761 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
763 aStudyBuilder->RemoveObjectWithChildren( obj );
768 } /* IObject->hasEntry() */
770 aStudyBuilder->CommitCommand();
772 /* Clear any previous selection */
774 aSel->setSelectedObjects( l1 );
776 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
781 Standard_EXPORT CAM_Module* createModule()
783 return new SMESHGUI();
787 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
789 //=============================================================================
793 //=============================================================================
794 SMESHGUI::SMESHGUI() :
795 SalomeApp_Module( "SMESH" )
797 if ( CORBA::is_nil( myComponentSMESH ) )
799 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
800 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
801 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
804 myActiveDialogBox = 0 ;
807 SMESH::GetFilterManager();
810 /* load resources for all available meshers */
811 SMESH::InitAvailableHypotheses();
814 //=============================================================================
818 //=============================================================================
819 SMESHGUI::~SMESHGUI()
821 SMESH::GetFilterManager()->Destroy();
824 //=============================================================================
828 //=============================================================================
829 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
831 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
833 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
838 bool SMESHGUI::automaticUpdate()
840 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
844 return resMgr->booleanValue( "SMESH", "auto_update", false );
847 //=============================================================================
851 //=============================================================================
852 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
854 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
857 //=============================================================================
861 //=============================================================================
862 SMESHGUI* SMESHGUI::GetSMESHGUI()
864 SMESHGUI* smeshMod = 0;
865 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
868 CAM_Module* module = app->module( "Mesh" );
869 smeshMod = dynamic_cast<SMESHGUI*>( module );
872 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
874 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
877 _PTR(Study) aStudy = study->studyDS();
879 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
888 Standard_EXPORT SMESHGUI* GetComponentGUI()
890 return SMESHGUI::GetSMESHGUI();
894 //=============================================================================
898 //=============================================================================
899 void SMESHGUI::SetState(int aState)
904 //=============================================================================
908 //=============================================================================
909 void SMESHGUI::ResetState()
914 //=============================================================================
918 //=============================================================================
919 void SMESHGUI::EmitSignalDeactivateDialog()
921 emit SignalDeactivateActiveDialog();
924 //=============================================================================
928 //=============================================================================
929 void SMESHGUI::EmitSignalStudyFrameChanged()
931 emit SignalStudyFrameChanged();
934 //=============================================================================
938 //=============================================================================
939 void SMESHGUI::EmitSignalCloseAllDialogs()
941 emit SignalCloseAllDialogs();
944 //=============================================================================
948 //=============================================================================
949 QDialog *SMESHGUI::GetActiveDialogBox()
951 return myActiveDialogBox;
954 //=============================================================================
958 //=============================================================================
959 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
961 myActiveDialogBox = (QDialog *) aDlg;
965 //=============================================================================
969 //=============================================================================
970 SUIT_Desktop* SMESHGUI::desktop()
972 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
974 return app->desktop();
979 //=============================================================================
983 //=============================================================================
984 SalomeApp_Study* SMESHGUI::activeStudy()
986 SUIT_Application* app = SUIT_Session::session()->activeApplication();
988 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
993 //=============================================================================
997 //=============================================================================
998 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1000 /* Here the position is on the bottom right corner - 10 */
1001 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1003 SUIT_Desktop *PP = desktop();
1004 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1005 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1009 //=============================================================================
1013 //=============================================================================
1014 static int isStudyLocked(_PTR(Study) theStudy){
1015 return theStudy->GetProperties()->IsLocked();
1018 static bool checkLock(_PTR(Study) theStudy) {
1019 if (isStudyLocked(theStudy)) {
1020 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1021 QObject::tr("WRN_WARNING"),
1022 QObject::tr("WRN_STUDY_LOCKED"),
1023 QObject::tr("BUT_OK") );
1029 //=======================================================================
1030 //function : CheckActiveStudyLocked
1032 //=======================================================================
1034 bool SMESHGUI::isActiveStudyLocked()
1036 _PTR(Study) aStudy = activeStudy()->studyDS();
1037 return checkLock( aStudy );
1040 //=============================================================================
1044 //=============================================================================
1045 bool SMESHGUI::OnGUIEvent( int theCommandID )
1047 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1051 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1052 SUIT_ResourceMgr* mgr = resourceMgr();
1056 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1057 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1059 //QAction* act = action( theCommandID );
1061 switch (theCommandID) {
1063 if(checkLock(aStudy)) break;
1071 if(checkLock(aStudy)) break;
1072 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1076 case 122: // EXPORT MED
1083 ::ExportMeshToFile(theCommandID);
1087 case 200: // SCALAR BAR
1089 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1090 SALOME_ListIO selected;
1092 aSel->selectedObjects( selected );
1094 if( selected.Extent() ) {
1095 Handle(SALOME_InteractiveObject) anIO = selected.First();
1096 if( anIO->hasEntry() ) {
1097 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1098 anActor->SetControlMode( SMESH_Actor::eNone );
1106 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1110 case 1134: // Clipping
1111 case 1133: // Tranparency
1112 case 1132: // Colors / Size
1119 ::SetDisplayMode(theCommandID);
1125 case 219: // Volumes
1126 case 220: // All Entity
1127 ::SetDisplayEntity(theCommandID);
1132 if(checkLock(aStudy)) break;
1133 SMESH::UpdateView();
1136 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1137 aSel->setSelectedObjects( l );
1142 case 301: // DISPLAY
1143 case 302: // DISPLAY ONLY
1145 SMESH::EDisplaing anAction;
1146 switch (theCommandID) {
1147 case 300: anAction = SMESH::eErase; break;
1148 case 301: anAction = SMESH::eDisplay; break;
1149 case 302: anAction = SMESH::eDisplayOnly; break;
1152 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1153 SALOME_ListIO selected;
1155 aSel->selectedObjects( selected );
1158 SALOME_ListIteratorOfListIO It (selected);
1159 for (; It.More(); It.Next()) {
1160 Handle(SALOME_InteractiveObject) IOS = It.Value();
1161 if (IOS->hasEntry()) {
1162 SMESH::UpdateView(anAction, IOS->getEntry());
1163 if (anAction == SMESH::eDisplayOnly)
1164 anAction = SMESH::eDisplay;
1169 aSel->setSelectedObjects( l1 );
1175 if(checkLock(aStudy)) break;
1178 EmitSignalDeactivateDialog();
1180 new SMESHGUI_NodesDlg(this);
1183 SUIT_MessageBox::warn1(desktop(),
1184 tr("SMESH_WRN_WARNING"),
1185 tr("SMESH_WRN_VIEWER_VTK"),
1186 tr("SMESH_BUT_OK"));
1191 case 2151: // FILTER
1195 EmitSignalDeactivateDialog();
1196 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1201 case 406: // MOVE NODE
1205 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1206 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1210 if(checkLock(aStudy)) break;
1211 new SMESHGUI_MoveNodesDlg(this);
1215 case 701: // COMPUTE MESH
1217 if(checkLock(aStudy)) break;
1219 SalomeApp_SelectionMgr *Sel = selectionMgr();
1220 SALOME_ListIO selected; Sel->selectedObjects( selected );
1222 int nbSel = selected.Extent();
1227 SMESH::SMESH_Mesh_var aMesh;
1228 SMESH::SMESH_subMesh_var aSubMesh;
1229 Handle(SALOME_InteractiveObject) IObject = selected.First();
1230 if (IObject->hasEntry()){
1231 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1232 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1233 if ( aShapeObject->_is_nil() ) {
1238 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1239 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1241 if (!aMesh->_is_nil()){
1242 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1243 if (!refShapeObject->_is_nil()) {
1244 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1245 SUIT_MessageBox::warn1(desktop(),
1246 tr("SMESH_WRN_WARNING"),
1247 tr("SMESH_WRN_MISSING_PARAMETERS"),
1248 tr("SMESH_BUT_OK"));
1252 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1253 SMESH::ModifiedMesh(aMeshSObj,true);
1254 // TO Do : change icon of all submeshes
1256 SUIT_MessageBox::warn1(desktop(),
1257 tr("SMESH_WRN_WARNING"),
1258 tr("SMESH_WRN_COMPUTE_FAILED"),
1259 tr("SMESH_BUT_OK"));
1261 catch(const SALOME::SALOME_Exception & S_ex){
1262 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1265 }else if(!aSubMesh->_is_nil()){
1266 aMesh = aSubMesh->GetFather();
1267 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1268 if(!refShapeObject->_is_nil()){
1269 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1271 SUIT_MessageBox::warn1(desktop(),
1272 tr("SMESH_WRN_WARNING"),
1273 tr("SMESH_WRN_MISSING_PARAMETERS"),
1274 tr("SMESH_BUT_OK"));
1278 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1279 SMESH::ModifiedMesh(aMeshSObj,true);
1280 // TO Do : change icon of all submeshes
1282 SUIT_MessageBox::warn1(desktop(),
1283 tr("SMESH_WRN_WARNING"),
1284 tr("SMESH_WRN_COMPUTE_FAILED"),
1285 tr("SMESH_BUT_OK"));
1286 }catch(const SALOME::SALOME_Exception & S_ex){
1287 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1293 CORBA::Long anId = aStudy->StudyId();
1294 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1295 if ( automaticUpdate() && aVisualObj){
1296 aVisualObj->Update();
1297 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1299 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1301 SMESH::DisplayActor(view,anActor); //apo
1307 SUIT_MessageBox::warn1(desktop(),
1308 tr("SMESH_WRN_WARNING"),
1309 tr("SMESH_WRN_VIEWER_VTK"),
1310 tr("SMESH_BUT_OK"));
1316 case 702: // ADD SUB MESH
1318 if(checkLock(aStudy)) break;
1320 EmitSignalDeactivateDialog();
1321 new SMESHGUI_AddSubMeshDlg( this );
1324 SUIT_MessageBox::warn1(desktop(),
1325 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1326 tr("SMESH_BUT_OK"));
1331 case 703: // INIT MESH
1333 if(checkLock(aStudy)) break;
1334 EmitSignalDeactivateDialog();
1335 new SMESHGUI_InitMeshDlg( this );
1339 case 704: // EDIT Hypothesis
1341 if(checkLock(aStudy)) break;
1342 EmitSignalDeactivateDialog();
1343 new SMESHGUI_EditHypothesesDlg( this );
1347 case 705: // EDIT Global Hypothesis
1349 if(checkLock(aStudy)) break;
1350 EmitSignalDeactivateDialog();
1351 new SMESHGUI_EditHypothesesDlg( this );
1355 case 706: // EDIT Local Hypothesis
1357 if(checkLock(aStudy)) break;
1358 EmitSignalDeactivateDialog();
1359 new SMESHGUI_EditHypothesesDlg( this );
1363 case 407: // DIAGONAL INVERSION
1364 case 408: // Delete diagonal
1368 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1369 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1373 if ( checkLock( aStudy ) )
1376 /*Standard_Boolean aRes;
1377 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1378 if ( aMesh->_is_nil() )
1380 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1381 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1385 EmitSignalDeactivateDialog();
1386 if ( theCommandID == 407 )
1387 new SMESHGUI_TrianglesInversionDlg(this);
1389 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1392 case 409: // Change orientation
1393 case 410: // Union of triangles
1394 case 411: // Cutting of quadrangles
1398 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1399 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1403 if ( checkLock( aStudy ) )
1406 EmitSignalDeactivateDialog();
1407 SMESHGUI_MultiEditDlg* aDlg = NULL;
1408 if ( theCommandID == 409 )
1409 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1410 else if ( theCommandID == 410 )
1411 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1413 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1416 DefineDlgPosition( aDlg, x, y );
1421 case 412: // Smoothing
1423 if(checkLock(aStudy)) break;
1425 EmitSignalDeactivateDialog();
1426 new SMESHGUI_SmoothingDlg( this );
1429 SUIT_MessageBox::warn1(desktop(),
1430 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1431 tr("SMESH_BUT_OK"));
1435 case 413: // Extrusion
1437 if (checkLock(aStudy)) break;
1439 EmitSignalDeactivateDialog();
1440 new SMESHGUI_ExtrusionDlg ( this );
1442 SUIT_MessageBox::warn1(desktop(),
1443 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1444 tr("SMESH_BUT_OK"));
1448 case 414: // Revolution
1450 if(checkLock(aStudy)) break;
1452 EmitSignalDeactivateDialog();
1453 new SMESHGUI_RevolutionDlg( this );
1456 SUIT_MessageBox::warn1(desktop(),
1457 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1458 tr("SMESH_BUT_OK"));
1462 case 415: // Pattern mapping
1464 if ( checkLock( aStudy ) )
1468 EmitSignalDeactivateDialog();
1469 new SMESHGUI_MeshPatternDlg( this );
1472 SUIT_MessageBox::warn1(desktop(),
1473 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1474 tr("SMESH_BUT_OK"));
1478 case 416: // Extrusion along a path
1480 if (checkLock(aStudy)) break;
1482 EmitSignalDeactivateDialog();
1483 new SMESHGUI_ExtrusionAlongPathDlg( this );
1485 SUIT_MessageBox::warn1(desktop(),
1486 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1487 tr("SMESH_BUT_OK"));
1491 case 801: // CREATE GROUP
1495 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1496 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1500 if(checkLock(aStudy)) break;
1501 EmitSignalDeactivateDialog();
1502 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1504 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1505 SALOME_ListIO selected;
1507 aSel->selectedObjects( selected );
1509 int nbSel = selected.Extent();
1511 // check if mesh is selected
1512 aMesh = SMESH::GetMeshByIO( selected.First() );
1514 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1519 case 802: // CONSTRUCT GROUP
1523 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1524 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1528 if(checkLock(aStudy)) break;
1529 EmitSignalDeactivateDialog();
1531 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1532 SALOME_ListIO selected;
1534 aSel->selectedObjects( selected );
1536 int nbSel = selected.Extent();
1538 // check if submesh is selected
1539 Handle(SALOME_InteractiveObject) IObject = selected.First();
1540 if (IObject->hasEntry()) {
1541 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1543 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1544 if (!aSubMesh->_is_nil()) {
1546 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1547 // get submesh elements list by types
1548 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1549 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1550 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1551 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1552 // create group for each type o elements
1553 QString aName = IObject->getName();
1554 if (aNodes->length() > 0) {
1555 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1556 aGroup->Add(aNodes.inout());
1558 if (aEdges->length() > 0) {
1559 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1560 aGroup->Add(aEdges.inout());
1562 if (aFaces->length() > 0) {
1563 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1564 aGroup->Add(aFaces.inout());
1566 if (aVolumes->length() > 0) {
1567 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1568 aGroup->Add(aVolumes.inout());
1572 }catch(const SALOME::SALOME_Exception & S_ex){
1573 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1582 case 803: // EDIT GROUP
1586 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1587 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1591 if(checkLock(aStudy)) break;
1592 EmitSignalDeactivateDialog();
1594 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1595 SALOME_ListIO selected;
1597 aSel->selectedObjects( selected );
1599 SALOME_ListIteratorOfListIO It (selected);
1600 int nbSelectedGroups = 0;
1601 for ( ; It.More(); It.Next() )
1603 SMESH::SMESH_Group_var aGroup =
1604 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1605 if (!aGroup->_is_nil()) {
1607 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1611 if (nbSelectedGroups == 0)
1613 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1619 case 804: // Add elements to group
1621 if(checkLock(aStudy)) break;
1622 if (myState == 800) {
1623 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1624 if (aDlg) aDlg->onAdd();
1629 case 805: // Remove elements from group
1631 if(checkLock(aStudy)) break;
1632 if (myState == 800) {
1633 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1634 if (aDlg) aDlg->onRemove();
1639 case 810: // Union Groups
1640 case 811: // Intersect groups
1641 case 812: // Cut groups
1645 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1646 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1650 if ( checkLock( aStudy ) )
1653 EmitSignalDeactivateDialog();
1656 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1657 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1658 else aMode = SMESHGUI_GroupOpDlg::CUT;
1660 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1664 case 813: // Delete groups with their contents
1668 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1669 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1673 if ( checkLock( aStudy ) )
1676 EmitSignalDeactivateDialog();
1678 new SMESHGUI_DeleteGroupDlg( this );
1682 case 900: // MESH INFOS
1684 EmitSignalDeactivateDialog();
1685 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1686 SALOME_ListIO selected;
1688 aSel->selectedObjects( selected );
1690 if ( selected.Extent() > 1 ) { // a dlg for each IO
1692 SALOME_ListIteratorOfListIO It (selected);
1693 for ( ; It.More(); It.Next() ) {
1694 IOs.Clear(); IOs.Append( It.Value() );
1695 aSel->setSelectedObjects( IOs );
1696 new SMESHGUI_MeshInfosDlg(this, "", false);
1698 // restore selection
1699 aSel->setSelectedObjects( selected );
1702 new SMESHGUI_MeshInfosDlg(this, "", false);
1706 case 902: // STANDARD MESH INFOS
1708 EmitSignalDeactivateDialog();
1709 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1710 SALOME_ListIO selected;
1712 aSel->selectedObjects( selected );
1714 if ( selected.Extent() > 1 ) { // a dlg for each IO
1716 SALOME_ListIteratorOfListIO It (selected);
1717 for ( ; It.More(); It.Next() ) {
1719 IOs.Append( It.Value() );
1720 aSel->setSelectedObjects( IOs );
1721 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1723 // restore selection
1724 aSel->setSelectedObjects( selected );
1727 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1731 case 1100: // EDIT HYPOTHESIS
1733 if(checkLock(aStudy)) break;
1735 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1736 SALOME_ListIO selected;
1738 aSel->selectedObjects( selected );
1740 int nbSel = selected.Extent();
1743 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1745 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1746 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1747 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1748 if ( !Hyp->_is_nil() )
1750 char* sName = Hyp->GetName();
1751 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1754 aCreator->EditHypothesis(Hyp);
1762 updateObjBrowser( true );
1766 case 1101: // RENAME
1768 if ( checkLock( aStudy ) )
1771 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1772 SALOME_ListIO selected;
1774 aSel->selectedObjects( selected );
1776 SALOME_ListIteratorOfListIO It( selected );
1777 for ( ; It.More(); It.Next() )
1779 Handle(SALOME_InteractiveObject) IObject = It.Value();
1780 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1781 _PTR(GenericAttribute) anAttr;
1782 _PTR(AttributeName) aName;
1785 if ( obj->FindAttribute(anAttr, "AttributeName") )
1788 QString newName = QString(aName->Value().c_str());
1789 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1790 if ( !newName.isEmpty() )
1792 //old source: aStudy->renameIObject( IObject, newName );
1793 aName->SetValue( newName.latin1() );
1795 // if current object is group update group's name
1796 SMESH::SMESH_GroupBase_var aGroup =
1797 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1798 if (!aGroup->_is_nil() )
1799 aGroup->SetName( newName.latin1() );
1809 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1811 if(checkLock(aStudy)) break;
1812 SUIT_OverrideCursor wc;
1814 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1815 SALOME_ListIO selected;
1817 aSel->selectedObjects( selected );
1819 SALOME_ListIteratorOfListIO It(selected);
1820 for (int i = 0; It.More(); It.Next(), i++) {
1821 Handle(SALOME_InteractiveObject) IObject = It.Value();
1822 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1825 aSel->setSelectedObjects( l1 );
1830 case 401: // GEOM::EDGE
1831 case 4021: // TRIANGLE
1833 case 4023: // POLYGON
1837 if(checkLock(aStudy)) break;
1839 EmitSignalDeactivateDialog();
1840 SMDSAbs_ElementType type = SMDSAbs_Edge;
1842 switch (theCommandID) {
1843 case 4021: // TRIANGLE
1844 type = SMDSAbs_Face; nbNodes = 3; break;
1846 type = SMDSAbs_Face; nbNodes = 4; break;
1848 type = SMDSAbs_Volume; nbNodes = 4; break;
1849 case 4023: // POLYGON
1850 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1852 type = SMDSAbs_Volume; nbNodes = 8; break;
1853 case 4033: // POLYHEDRE
1854 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1857 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1860 SUIT_MessageBox::warn1(desktop(),
1861 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1862 tr("SMESH_BUT_OK"));
1866 case 4033: // POLYHEDRON
1868 if(checkLock(aStudy)) break;
1870 EmitSignalDeactivateDialog();
1871 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1874 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1875 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1876 tr("SMESH_BUT_OK"));
1880 case 4041: // REMOVES NODES
1882 if(checkLock(aStudy)) break;
1884 EmitSignalDeactivateDialog();
1885 new SMESHGUI_RemoveNodesDlg(this);
1888 SUIT_MessageBox::warn1(desktop(),
1889 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1890 tr("SMESH_BUT_OK"));
1894 case 4042: // REMOVES ELEMENTS
1896 if(checkLock(aStudy)) break;
1898 EmitSignalDeactivateDialog();
1899 new SMESHGUI_RemoveElementsDlg(this);
1903 SUIT_MessageBox::warn1(desktop(),
1904 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1905 tr("SMESH_BUT_OK"));
1909 case 4051: // RENUMBERING NODES
1911 if(checkLock(aStudy)) break;
1913 EmitSignalDeactivateDialog();
1914 new SMESHGUI_RenumberingDlg( this, "", 0);
1918 SUIT_MessageBox::warn1(desktop(),
1919 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1920 tr("SMESH_BUT_OK"));
1924 case 4052: // RENUMBERING ELEMENTS
1926 if(checkLock(aStudy)) break;
1928 EmitSignalDeactivateDialog();
1929 new SMESHGUI_RenumberingDlg( this, "", 1);
1933 SUIT_MessageBox::warn1(desktop(),
1934 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1935 tr("SMESH_BUT_OK"));
1939 case 4061: // TRANSLATION
1941 if(checkLock(aStudy)) break;
1943 EmitSignalDeactivateDialog();
1944 new SMESHGUI_TranslationDlg( this );
1947 SUIT_MessageBox::warn1(desktop(),
1948 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1949 tr("SMESH_BUT_OK"));
1953 case 4062: // ROTATION
1955 if(checkLock(aStudy)) break;
1957 EmitSignalDeactivateDialog();
1958 new SMESHGUI_RotationDlg( this );
1961 SUIT_MessageBox::warn1(desktop(),
1962 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1963 tr("SMESH_BUT_OK"));
1967 case 4063: // SYMMETRY
1969 if(checkLock(aStudy)) break;
1971 EmitSignalDeactivateDialog();
1972 new SMESHGUI_SymmetryDlg( this );
1975 SUIT_MessageBox::warn1(desktop(),
1976 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1977 tr("SMESH_BUT_OK"));
1981 case 4064: // SEWING
1983 if(checkLock(aStudy)) break;
1985 EmitSignalDeactivateDialog();
1986 new SMESHGUI_SewingDlg( this );
1989 SUIT_MessageBox::warn1(desktop(),
1990 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1991 tr("SMESH_BUT_OK"));
1995 case 4065: // MERGE NODES
1997 if(checkLock(aStudy)) break;
1999 EmitSignalDeactivateDialog();
2000 new SMESHGUI_MergeNodesDlg( this );
2003 SUIT_MessageBox::warn1(desktop(),
2004 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2005 tr("SMESH_BUT_OK"));
2009 case 4066: // MERGE EQUAL ELEMENTS
2011 if (checkLock(aStudy)) break;
2013 EmitSignalDeactivateDialog();
2014 new SMESHGUI_EditMeshDlg(this,
2015 "SMESH_MERGE_ELEMENTS_TITLE",
2016 "ICON_DLG_MERGE_ELEMENTS",
2017 1); // MergeEqualElemets
2019 SUIT_MessageBox::warn1(desktop(),
2020 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2021 tr("SMESH_BUT_OK"));
2027 case 5000: // HYPOTHESIS
2029 if(checkLock(aStudy)) break;
2030 EmitSignalDeactivateDialog();
2031 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2036 if(checkLock(aStudy)) break;
2037 EmitSignalDeactivateDialog();
2038 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2042 case 5105: // Library of selection filters
2044 static QValueList<int> aTypes;
2045 if ( aTypes.isEmpty() )
2047 aTypes.append( SMESH::NODE );
2048 aTypes.append( SMESH::EDGE );
2049 aTypes.append( SMESH::FACE );
2050 aTypes.append( SMESH::VOLUME );
2052 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2056 case 6017: // CONTROLS
2071 SalomeApp_SelectionMgr* mgr = selectionMgr();
2072 SALOME_ListIO selected; mgr->selectedObjects( selected );
2074 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2075 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2077 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2078 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2079 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2080 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2081 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2082 ::Control( theCommandID );
2087 SUIT_MessageBox::warn1(desktop(),
2088 tr( "SMESH_WRN_WARNING" ),
2089 tr( "SMESH_BAD_SELECTION" ),
2090 tr( "SMESH_BUT_OK" ) );
2094 SUIT_MessageBox::warn1(desktop(),
2095 tr( "SMESH_WRN_WARNING" ),
2096 tr( "NOT_A_VTK_VIEWER" ),
2097 tr( "SMESH_BUT_OK" ) );
2102 SalomeApp_SelectionMgr* mgr = selectionMgr();
2103 SALOME_ListIO selected; mgr->selectedObjects( selected );
2105 if (selected.Extent() == 1) {
2106 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2107 if(anIObject->hasEntry())
2108 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2109 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2116 SalomeApp_SelectionMgr* mgr = selectionMgr();
2117 SALOME_ListIO selected; mgr->selectedObjects( selected );
2119 if (selected.Extent() == 1) {
2120 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2121 if(anIObject->hasEntry())
2122 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2123 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2129 //updateObjBrowser();
2133 //=============================================================================
2137 //=============================================================================
2138 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2143 //=============================================================================
2147 //=============================================================================
2148 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2153 //=============================================================================
2157 //=============================================================================
2158 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2163 //=============================================================================
2164 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2165 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2167 //=============================================================================
2168 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2169 SUIT_ViewWindow* wnd )
2171 if(theIO->hasEntry()){
2172 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2173 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2177 //=======================================================================
2178 // function : createSMESHAction
2180 //=======================================================================
2181 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2184 QWidget* parent = application()->desktop();
2185 SUIT_ResourceMgr* resMgr = resourceMgr();
2187 if ( icon_id.length() )
2188 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2190 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2191 if ( !pix.isNull() )
2192 icon = QIconSet( pix );
2194 QString tooltip = tr( QString( "TOP_" )+po_id ),
2195 menu = tr( QString( "MEN_" )+po_id ),
2196 status_bar = tr( QString( "STB_" )+po_id );
2198 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2201 //=======================================================================
2202 // function : createPopupItem
2204 //=======================================================================
2205 void SMESHGUI::createPopupItem( const int id,
2206 const QString& clients,
2207 const QString& types,
2208 const QString& theRule,
2213 parentId = popupMgr()->actionId( action( pId ) );
2215 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2216 popupMgr()->insert( action( id ), parentId, 0 );
2218 QChar lc = QtxPopupMgr::Selection::defEquality();
2219 QString rule = "(%1) and (%2) and (%3)";
2220 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2221 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2222 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2225 bool cont = myRules.contains( id );
2227 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2229 popupMgr()->setRule( action( id ), rule, true );
2230 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2233 //=======================================================================
2234 // function : initialize
2236 //=======================================================================
2237 void SMESHGUI::initialize( CAM_Application* app )
2239 SalomeApp_Module::initialize( app );
2241 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2243 /* Automatic Update flag */
2244 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2246 // ----- create actions --------------
2248 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2249 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2250 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2251 createSMESHAction( 114, "NUM" );
2252 createSMESHAction( 121, "DAT" );
2253 createSMESHAction( 122, "MED" );
2254 createSMESHAction( 123, "UNV" );
2255 createSMESHAction( 124, "EXPORT_DAT" );
2256 createSMESHAction( 125, "EXPORT_MED" );
2257 createSMESHAction( 126, "EXPORT_UNV" );
2258 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2259 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2260 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2261 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2262 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2263 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2264 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2265 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2266 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2267 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2268 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2269 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2270 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2271 createSMESHAction( 804, "ADD" );
2272 createSMESHAction( 805, "REMOVE" );
2273 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2274 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2275 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2276 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2277 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2278 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2279 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2280 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2281 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2282 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2283 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2284 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2285 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2286 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2287 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2288 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2289 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2290 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2291 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2292 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2293 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2294 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2295 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2296 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2297 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2298 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2299 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2300 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2301 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2302 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2303 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2304 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2305 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2306 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2307 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2308 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2309 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2310 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2311 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2312 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2313 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2314 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2315 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2316 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2317 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2318 createSMESHAction( 415, "MAP", "ICON_MAP" );
2319 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2320 createSMESHAction( 200, "RESET" );
2321 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2322 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2323 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2324 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2325 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2326 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2327 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2328 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2329 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2330 createSMESHAction( 220, "ALL" );
2331 createSMESHAction( 1100, "EDIT_HYPO" );
2332 createSMESHAction( 1101, "RENAME" );
2333 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2334 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2335 createSMESHAction( 1131, "DISPMODE" );
2336 createSMESHAction( 1132, "COLORS" );
2337 createSMESHAction( 1133, "TRANSP" );
2338 createSMESHAction( 1134, "CLIP" );
2339 createSMESHAction( 1135, "DISP_ENT" );
2340 createSMESHAction( 2000, "CTRL" );
2342 createSMESHAction( 300, "ERASE" );
2343 createSMESHAction( 301, "DISPLAY" );
2344 createSMESHAction( 302, "DISPLAY_ONLY" );
2345 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2347 // ----- create menu --------------
2348 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2349 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2350 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2351 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2352 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2353 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2354 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2355 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2357 createMenu( separator(), fileId );
2359 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2360 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2361 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2362 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2363 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2364 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2366 createMenu( 111, importId, -1 );
2367 createMenu( 112, importId, -1 );
2368 createMenu( 113, importId, -1 );
2370 createMenu( 121, exportId, -1 );
2371 createMenu( 122, exportId, -1 );
2372 createMenu( 123, exportId, -1 );
2374 createMenu( separator(), fileId, 10 );
2376 createMenu( 33, editId, -1 );
2378 createMenu( 5105, toolsId, -1 );
2380 createMenu( 5000, hypoId, -1 );
2381 createMenu( 5010, hypoId, -1 );
2383 createMenu( 703, meshId, -1 );
2384 createMenu( 702, meshId, -1 );
2385 createMenu( 704, meshId, -1 );
2386 createMenu( separator(), meshId, -1 );
2387 createMenu( 701, meshId, -1 );
2388 createMenu( separator(), meshId, -1 );
2389 createMenu( 801, meshId, -1 );
2390 createMenu( 802, meshId, -1 );
2391 createMenu( 803, meshId, -1 );
2392 createMenu( separator(), meshId, -1 );
2393 createMenu( 810, meshId, -1 );
2394 createMenu( 811, meshId, -1 );
2395 createMenu( 812, meshId, -1 );
2396 createMenu( separator(), meshId, -1 );
2397 createMenu( 813, meshId, -1 );
2398 createMenu( separator(), meshId, -1 );
2399 createMenu( 900, meshId, -1 );
2400 createMenu( 902, meshId, -1 );
2401 createMenu( separator(), meshId, -1 );
2403 createMenu( 6003, ctrlId, -1 );
2404 createMenu( 6001, ctrlId, -1 );
2405 createMenu( 6004, ctrlId, -1 );
2406 createMenu( separator(), ctrlId, -1 );
2407 createMenu( 6002, ctrlId, -1 );
2408 createMenu( 6018, ctrlId, -1 );
2409 createMenu( 6019, ctrlId, -1 );
2410 createMenu( 6011, ctrlId, -1 );
2411 createMenu( 6012, ctrlId, -1 );
2412 createMenu( 6013, ctrlId, -1 );
2413 createMenu( 6014, ctrlId, -1 );
2414 createMenu( 6015, ctrlId, -1 );
2415 createMenu( 6016, ctrlId, -1 );
2416 createMenu( separator(), ctrlId, -1 );
2417 createMenu( 6017, ctrlId, -1 );
2418 createMenu( separator(), ctrlId, -1 );
2420 createMenu( 400, addId, -1 );
2421 createMenu( 401, addId, -1 );
2422 createMenu( 4021, addId, -1 );
2423 createMenu( 4022, addId, -1 );
2424 createMenu( 4023, addId, -1 );
2425 createMenu( 4031, addId, -1 );
2426 createMenu( 4032, addId, -1 );
2427 createMenu( 4033, addId, -1 );
2429 createMenu( 4041, removeId, -1 );
2430 createMenu( 4042, removeId, -1 );
2432 createMenu( 4051, renumId, -1 );
2433 createMenu( 4052, renumId, -1 );
2435 createMenu( 4061, transfId, -1 );
2436 createMenu( 4062, transfId, -1 );
2437 createMenu( 4063, transfId, -1 );
2438 createMenu( 4064, transfId, -1 );
2439 createMenu( 4065, transfId, -1 );
2440 createMenu( 4066, transfId, -1 );
2442 createMenu( 406, modifyId, -1 );
2443 createMenu( 407, modifyId, -1 );
2444 createMenu( 408, modifyId, -1 );
2445 createMenu( 409, modifyId, -1 );
2446 createMenu( 410, modifyId, -1 );
2447 createMenu( 411, modifyId, -1 );
2448 createMenu( 412, modifyId, -1 );
2449 createMenu( 413, modifyId, -1 );
2450 createMenu( 416, modifyId, -1 );
2451 createMenu( 414, modifyId, -1 );
2452 createMenu( 415, modifyId, -1 );
2454 createMenu( 214, viewId, -1 );
2456 // ----- create toolbars --------------
2457 int meshTb = createTool( tr( "TB_MESH" ) ),
2458 hypoTb = createTool( tr( "TB_HYPO" ) ),
2459 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2460 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2461 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2462 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2464 createTool( 703, meshTb );
2465 createTool( 702, meshTb );
2466 createTool( 704, meshTb );
2467 createTool( separator(), meshTb );
2468 createTool( 701, meshTb );
2469 createTool( separator(), meshTb );
2470 createTool( 801, meshTb );
2471 createTool( 802, meshTb );
2472 createTool( 803, meshTb );
2473 createTool( separator(), meshTb );
2474 createTool( 900, meshTb );
2475 createTool( 902, meshTb );
2476 createTool( separator(), meshTb );
2478 createTool( 5000, hypoTb );
2479 createTool( 5010, hypoTb );
2481 createTool( 6001, ctrlTb );
2482 createTool( 6003, ctrlTb );
2483 createTool( 6004, ctrlTb );
2484 createTool( separator(), ctrlTb );
2485 createTool( 6002, ctrlTb );
2486 createTool( 6018, ctrlTb );
2487 createTool( 6019, ctrlTb );
2488 createTool( 6011, ctrlTb );
2489 createTool( 6012, ctrlTb );
2490 createTool( 6013, ctrlTb );
2491 createTool( 6014, ctrlTb );
2492 createTool( 6015, ctrlTb );
2493 createTool( 6016, ctrlTb );
2494 createTool( separator(), ctrlTb );
2495 createTool( 6017, ctrlTb );
2496 createTool( separator(), ctrlTb );
2498 createTool( 400, addRemTb );
2499 createTool( 401, addRemTb );
2500 createTool( 4021, addRemTb );
2501 createTool( 4022, addRemTb );
2502 createTool( 4023, addRemTb );
2503 createTool( 4031, addRemTb );
2504 createTool( 4032, addRemTb );
2505 createTool( 4033, addRemTb );
2506 createTool( separator(), addRemTb );
2507 createTool( 4041, addRemTb );
2508 createTool( 4042, addRemTb );
2509 createTool( separator(), addRemTb );
2510 createTool( 4051, addRemTb );
2511 createTool( 4052, addRemTb );
2512 createTool( separator(), addRemTb );
2513 createTool( 4061, addRemTb );
2514 createTool( 4062, addRemTb );
2515 createTool( 4063, addRemTb );
2516 createTool( 4064, addRemTb );
2517 createTool( 4065, addRemTb );
2518 createTool( 4066, addRemTb );
2519 createTool( separator(), addRemTb );
2521 createTool( 406, modifyTb );
2522 createTool( 407, modifyTb );
2523 createTool( 408, modifyTb );
2524 createTool( 409, modifyTb );
2525 createTool( 410, modifyTb );
2526 createTool( 411, modifyTb );
2527 createTool( 412, modifyTb );
2528 createTool( 413, modifyTb );
2529 createTool( 416, modifyTb );
2530 createTool( 414, modifyTb );
2531 createTool( 415, modifyTb );
2533 createTool( 214, dispModeTb );
2537 QString OB = "'ObjectBrowser'",
2538 View = "'" + SVTK_Viewer::Type() + "'",
2540 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2541 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2542 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2543 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2544 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2545 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2546 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2547 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2548 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2549 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2551 mesh_group = mesh + " " + subMesh + " " + group,
2552 hyp_alg = hypo + " " + algo;
2554 // popup for object browser
2556 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2557 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2558 createPopupItem( 803, OB, group ); // EDIT_GROUP
2559 popupMgr()->insert( separator(), -1, 0 );
2560 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2561 createPopupItem( 214, OB, mesh_group ); // UPDATE
2562 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2563 createPopupItem( 902, OB, mesh ); // STD_INFO
2564 popupMgr()->insert( separator(), -1, 0 );
2565 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2566 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2567 popupMgr()->insert( separator(), -1, 0 );
2568 createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS
2569 createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS
2570 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2571 popupMgr()->insert( separator(), -1, 0 );
2572 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2573 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2574 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2575 popupMgr()->insert( separator(), -1, 0 );
2578 createPopupItem( 803, View, group ); // EDIT_GROUP
2579 createPopupItem( 804, View, elems ); // ADD
2580 createPopupItem( 805, View, elems ); // REMOVE
2581 popupMgr()->insert( separator(), -1, 0 );
2582 createPopupItem( 214, View, mesh_group ); // UPDATE
2583 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2584 createPopupItem( 902, View, mesh ); // STD_INFO
2585 popupMgr()->insert( separator(), -1, 0 );
2589 isInvisible("not( isVisible )"),
2590 isEmpty("numberOfNodes = 0"),
2591 isNotEmpty("numberOfNodes <> 0"),
2593 // has nodes, edges, etc in VISIBLE! actor
2594 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2595 hasElems("(count( elemTypes ) > 0)"),
2596 hasDifferentElems("(count( elemTypes ) > 1)"),
2597 hasEdges("({'Edge'} in elemTypes)"),
2598 hasFaces("({'Face'} in elemTypes)"),
2599 hasVolumes("({'Volume'} in elemTypes)");
2601 QString lc = QtxPopupMgr::Selection::defEquality();
2602 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2603 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2604 QString aMeshInVTK = aClient + "&&" + aType;
2606 //-------------------------------------------------
2608 //-------------------------------------------------
2609 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2611 popupMgr()->insert( action( 9010 ), anId, -1 );
2612 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2613 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2615 popupMgr()->insert( action( 9011 ), anId, -1 );
2616 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2617 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2619 popupMgr()->insert( separator(), -1, -1 );
2621 //-------------------------------------------------
2623 //-------------------------------------------------
2624 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2626 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2627 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2628 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2630 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2631 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2632 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2634 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2635 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2636 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2638 popupMgr()->insert( separator(), anId, -1 );
2640 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2641 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2642 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2644 //-------------------------------------------------
2646 //-------------------------------------------------
2647 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2649 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2651 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2652 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2653 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2655 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2656 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2657 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2659 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2660 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2661 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2663 popupMgr()->insert( separator(), anId, -1 );
2665 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2666 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2668 //-------------------------------------------------
2670 //-------------------------------------------------
2671 popupMgr()->insert( action( 1132 ), -1, -1 );
2672 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2674 //-------------------------------------------------
2676 //-------------------------------------------------
2677 popupMgr()->insert( action( 1133 ), -1, -1 );
2678 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2680 //-------------------------------------------------
2682 //-------------------------------------------------
2683 popupMgr()->insert( action( 1134 ), -1, -1 );
2684 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2686 popupMgr()->insert( separator(), -1, -1 );
2688 //-------------------------------------------------
2690 //-------------------------------------------------
2692 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2693 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2694 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2696 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2698 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2699 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2701 popupMgr()->insert( separator(), anId, -1 );
2703 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2704 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2705 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2707 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2708 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2709 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2711 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2712 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2713 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2715 popupMgr()->insert( separator(), anId, -1 );
2717 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2718 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2719 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2721 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2722 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2723 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2725 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2726 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2727 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2729 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2730 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2731 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2733 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2734 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2735 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2737 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2738 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2739 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2741 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2742 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2743 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2745 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2746 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2747 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2749 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2750 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2751 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2753 popupMgr()->insert( separator(), anId, -1 );
2755 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2756 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2757 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2759 popupMgr()->insert( separator(), anId, -1 );
2761 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2762 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2764 popupMgr()->insert( separator(), -1, -1 );
2766 //-------------------------------------------------
2768 //-------------------------------------------------
2769 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2770 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
2771 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2772 QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
2773 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2774 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
2776 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2777 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
2779 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2780 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
2782 popupMgr()->insert( separator(), -1, -1 );
2784 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
2785 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
2788 bool SMESHGUI::activateModule( SUIT_Study* study )
2790 bool res = SalomeApp_Module::activateModule( study );
2792 setMenuShown( true );
2793 setToolShown( true );
2798 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2800 setMenuShown( false );
2801 setToolShown( false );
2803 EmitSignalCloseAllDialogs();
2805 return SalomeApp_Module::deactivateModule( study );
2808 void SMESHGUI::OnGUIEvent()
2810 const QObject* obj = sender();
2811 if ( !obj || !obj->inherits( "QAction" ) )
2813 int id = actionId((QAction*)obj);
2818 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2820 if ( CORBA::is_nil( myComponentSMESH ) )
2822 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2823 return aGUI.myComponentSMESH;
2825 return myComponentSMESH;
2828 QString SMESHGUI::engineIOR() const
2830 CORBA::ORB_var anORB = getApp()->orb();
2831 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2835 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2837 SMESHGUI_Selection sel;
2838 sel.init( client, selectionMgr() );
2839 popupMgr()->updatePopup( menu, &sel );
2842 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2844 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2845 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2848 void SMESHGUI::viewManagers( QStringList& list ) const
2850 list.append( SVTK_Viewer::Type() );
2853 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
2855 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
2856 SMESH::UpdateSelectionProp( this );
2859 void SMESHGUI::createPreferences()
2861 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2863 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2864 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "display_entity" );
2865 addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "auto_update" );
2867 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2868 setPreferenceProperty( precGroup, "columns", 1 );
2870 addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool );
2871 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2873 setPreferenceProperty( prec, "min", 0 );
2874 setPreferenceProperty( prec, "max", 16 );
2876 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2877 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, SalomeApp_Preferences::Selector, "SMESH", "display_mode" );
2879 modes.append( "Wireframe" );
2880 modes.append( "Shading" );
2881 modes.append( "Shrink" );
2882 modes.append( "Nodes" );
2883 setPreferenceProperty( dispmode, "strings", modes );
2885 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2886 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2888 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
2889 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
2891 setPreferenceProperty( nodeSz, "min", 1 );
2892 setPreferenceProperty( nodeSz, "max", 5 );
2894 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2896 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
2897 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
2898 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
2899 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
2901 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
2902 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2904 setPreferenceProperty( elemW, "min", 1 );
2905 setPreferenceProperty( elemW, "max", 5 );
2907 setPreferenceProperty( shrink, "min", 0 );
2908 setPreferenceProperty( shrink, "max", 100 );
2910 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2912 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2914 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
2915 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
2916 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
2918 setPreferenceProperty( selW, "min", 1 );
2919 setPreferenceProperty( selW, "max", 5 );
2921 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2923 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
2924 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2926 setPreferenceProperty( preW, "min", 1 );
2927 setPreferenceProperty( preW, "max", 5 );
2929 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2931 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
2932 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
2934 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2935 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2937 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2938 addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2939 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2940 addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
2943 fam.append( tr( "SMESH_FONT_ARIAL" ) );
2944 fam.append( tr( "SMESH_FONT_COURIER" ) );
2945 fam.append( tr( "SMESH_FONT_TIMES" ) );
2946 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2948 setPreferenceProperty( tfont, "families", fam );
2949 setPreferenceProperty( tfont, "system", false );
2950 setPreferenceProperty( tfont, "widget_flags", wflag );
2951 setPreferenceProperty( lfont, "families", fam );
2952 setPreferenceProperty( lfont, "system", false );
2953 setPreferenceProperty( lfont, "widget_flags", wflag );
2955 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
2957 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
2958 setPreferenceProperty( numcol, "min", 2 );
2959 setPreferenceProperty( numcol, "max", 256 );
2961 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
2962 setPreferenceProperty( numlab, "min", 2 );
2963 setPreferenceProperty( numlab, "max", 65 );
2965 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
2966 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2967 QStringList orients;
2968 orients.append( tr( "SMESH_VERTICAL" ) );
2969 orients.append( tr( "SMESH_HORIZONTAL" ) );
2970 QValueList<QVariant> indices; indices.append( 0 ); indices.append( 1 );
2971 setPreferenceProperty( orient, "strings", orients );
2972 setPreferenceProperty( orient, "indexes", indices );
2974 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
2975 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2976 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2977 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2978 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
2979 setPreferenceProperty( xv, "step", 0.1 );
2980 setPreferenceProperty( xv, "min", 0.0 );
2981 setPreferenceProperty( xv, "max", 1.0 );
2982 setPreferenceProperty( yv, "step", 0.1 );
2983 setPreferenceProperty( yv, "min", 0.0 );
2984 setPreferenceProperty( yv, "max", 1.0 );
2985 setPreferenceProperty( wv, "step", 0.1 );
2986 setPreferenceProperty( wv, "min", 0.0 );
2987 setPreferenceProperty( wv, "max", 1.0 );
2988 setPreferenceProperty( hv, "min", 0.0 );
2989 setPreferenceProperty( hv, "max", 1.0 );
2990 setPreferenceProperty( hv, "step", 0.1 );
2992 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
2993 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
2994 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
2995 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
2996 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
2997 setPreferenceProperty( xv, "min", 0.0 );
2998 setPreferenceProperty( xv, "max", 1.0 );
2999 setPreferenceProperty( xv, "step", 0.1 );
3000 setPreferenceProperty( xh, "min", 0.0 );
3001 setPreferenceProperty( xh, "max", 1.0 );
3002 setPreferenceProperty( xh, "step", 0.1 );
3003 setPreferenceProperty( yh, "min", 0.0 );
3004 setPreferenceProperty( yh, "max", 1.0 );
3005 setPreferenceProperty( yh, "step", 0.1 );
3006 setPreferenceProperty( wh, "min", 0.0 );
3007 setPreferenceProperty( wh, "max", 1.0 );
3008 setPreferenceProperty( wh, "step", 0.1 );
3009 setPreferenceProperty( hh, "min", 0.0 );
3010 setPreferenceProperty( hh, "max", 1.0 );
3011 setPreferenceProperty( hh, "step", 0.1 );
3014 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )