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
1305 SMESH::RepaintCurrentView();
1308 SUIT_MessageBox::warn1(desktop(),
1309 tr("SMESH_WRN_WARNING"),
1310 tr("SMESH_WRN_VIEWER_VTK"),
1311 tr("SMESH_BUT_OK"));
1317 case 702: // ADD SUB MESH
1319 if(checkLock(aStudy)) break;
1321 EmitSignalDeactivateDialog();
1322 new SMESHGUI_AddSubMeshDlg( this );
1325 SUIT_MessageBox::warn1(desktop(),
1326 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1327 tr("SMESH_BUT_OK"));
1332 case 703: // INIT MESH
1334 if(checkLock(aStudy)) break;
1335 EmitSignalDeactivateDialog();
1336 new SMESHGUI_InitMeshDlg( this );
1340 case 704: // EDIT Hypothesis
1342 if(checkLock(aStudy)) break;
1343 EmitSignalDeactivateDialog();
1344 new SMESHGUI_EditHypothesesDlg( this );
1348 case 705: // EDIT Global Hypothesis
1350 if(checkLock(aStudy)) break;
1351 EmitSignalDeactivateDialog();
1352 new SMESHGUI_EditHypothesesDlg( this );
1356 case 706: // EDIT Local Hypothesis
1358 if(checkLock(aStudy)) break;
1359 EmitSignalDeactivateDialog();
1360 new SMESHGUI_EditHypothesesDlg( this );
1364 case 407: // DIAGONAL INVERSION
1365 case 408: // Delete diagonal
1369 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1370 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1374 if ( checkLock( aStudy ) )
1377 /*Standard_Boolean aRes;
1378 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1379 if ( aMesh->_is_nil() )
1381 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1382 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1386 EmitSignalDeactivateDialog();
1387 if ( theCommandID == 407 )
1388 new SMESHGUI_TrianglesInversionDlg(this);
1390 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1393 case 409: // Change orientation
1394 case 410: // Union of triangles
1395 case 411: // Cutting of quadrangles
1399 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1400 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1404 if ( checkLock( aStudy ) )
1407 EmitSignalDeactivateDialog();
1408 SMESHGUI_MultiEditDlg* aDlg = NULL;
1409 if ( theCommandID == 409 )
1410 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1411 else if ( theCommandID == 410 )
1412 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1414 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1417 DefineDlgPosition( aDlg, x, y );
1422 case 412: // Smoothing
1424 if(checkLock(aStudy)) break;
1426 EmitSignalDeactivateDialog();
1427 new SMESHGUI_SmoothingDlg( this );
1430 SUIT_MessageBox::warn1(desktop(),
1431 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1432 tr("SMESH_BUT_OK"));
1436 case 413: // Extrusion
1438 if (checkLock(aStudy)) break;
1440 EmitSignalDeactivateDialog();
1441 new SMESHGUI_ExtrusionDlg ( this );
1443 SUIT_MessageBox::warn1(desktop(),
1444 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1445 tr("SMESH_BUT_OK"));
1449 case 414: // Revolution
1451 if(checkLock(aStudy)) break;
1453 EmitSignalDeactivateDialog();
1454 new SMESHGUI_RevolutionDlg( this );
1457 SUIT_MessageBox::warn1(desktop(),
1458 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1459 tr("SMESH_BUT_OK"));
1463 case 415: // Pattern mapping
1465 if ( checkLock( aStudy ) )
1469 EmitSignalDeactivateDialog();
1470 new SMESHGUI_MeshPatternDlg( this );
1473 SUIT_MessageBox::warn1(desktop(),
1474 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1475 tr("SMESH_BUT_OK"));
1479 case 416: // Extrusion along a path
1481 if (checkLock(aStudy)) break;
1483 EmitSignalDeactivateDialog();
1484 new SMESHGUI_ExtrusionAlongPathDlg( this );
1486 SUIT_MessageBox::warn1(desktop(),
1487 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1488 tr("SMESH_BUT_OK"));
1492 case 801: // CREATE GROUP
1496 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1497 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1501 if(checkLock(aStudy)) break;
1502 EmitSignalDeactivateDialog();
1503 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1505 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1506 SALOME_ListIO selected;
1508 aSel->selectedObjects( selected );
1510 int nbSel = selected.Extent();
1512 // check if mesh is selected
1513 aMesh = SMESH::GetMeshByIO( selected.First() );
1515 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1520 case 802: // CONSTRUCT GROUP
1524 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1525 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1529 if(checkLock(aStudy)) break;
1530 EmitSignalDeactivateDialog();
1532 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1533 SALOME_ListIO selected;
1535 aSel->selectedObjects( selected );
1537 int nbSel = selected.Extent();
1539 // check if submesh is selected
1540 Handle(SALOME_InteractiveObject) IObject = selected.First();
1541 if (IObject->hasEntry()) {
1542 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1544 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1545 if (!aSubMesh->_is_nil()) {
1547 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1548 // get submesh elements list by types
1549 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1550 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1551 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1552 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1553 // create group for each type o elements
1554 QString aName = IObject->getName();
1555 if (aNodes->length() > 0) {
1556 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1557 aGroup->Add(aNodes.inout());
1559 if (aEdges->length() > 0) {
1560 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1561 aGroup->Add(aEdges.inout());
1563 if (aFaces->length() > 0) {
1564 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1565 aGroup->Add(aFaces.inout());
1567 if (aVolumes->length() > 0) {
1568 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1569 aGroup->Add(aVolumes.inout());
1573 }catch(const SALOME::SALOME_Exception & S_ex){
1574 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1583 case 803: // EDIT GROUP
1587 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1588 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1592 if(checkLock(aStudy)) break;
1593 EmitSignalDeactivateDialog();
1595 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1596 SALOME_ListIO selected;
1598 aSel->selectedObjects( selected );
1600 SALOME_ListIteratorOfListIO It (selected);
1601 int nbSelectedGroups = 0;
1602 for ( ; It.More(); It.Next() )
1604 SMESH::SMESH_Group_var aGroup =
1605 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1606 if (!aGroup->_is_nil()) {
1608 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1612 if (nbSelectedGroups == 0)
1614 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1620 case 804: // Add elements to group
1622 if(checkLock(aStudy)) break;
1623 if (myState == 800) {
1624 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1625 if (aDlg) aDlg->onAdd();
1630 case 805: // Remove elements from group
1632 if(checkLock(aStudy)) break;
1633 if (myState == 800) {
1634 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1635 if (aDlg) aDlg->onRemove();
1640 case 810: // Union Groups
1641 case 811: // Intersect groups
1642 case 812: // Cut groups
1646 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1647 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1651 if ( checkLock( aStudy ) )
1654 EmitSignalDeactivateDialog();
1657 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1658 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1659 else aMode = SMESHGUI_GroupOpDlg::CUT;
1661 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1665 case 813: // Delete groups with their contents
1669 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1670 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1674 if ( checkLock( aStudy ) )
1677 EmitSignalDeactivateDialog();
1679 new SMESHGUI_DeleteGroupDlg( this );
1683 case 900: // MESH INFOS
1685 EmitSignalDeactivateDialog();
1686 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1687 SALOME_ListIO selected;
1689 aSel->selectedObjects( selected );
1691 if ( selected.Extent() > 1 ) { // a dlg for each IO
1693 SALOME_ListIteratorOfListIO It (selected);
1694 for ( ; It.More(); It.Next() ) {
1695 IOs.Clear(); IOs.Append( It.Value() );
1696 aSel->setSelectedObjects( IOs );
1697 new SMESHGUI_MeshInfosDlg(this, "", false);
1699 // restore selection
1700 aSel->setSelectedObjects( selected );
1703 new SMESHGUI_MeshInfosDlg(this, "", false);
1707 case 902: // STANDARD MESH INFOS
1709 EmitSignalDeactivateDialog();
1710 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1711 SALOME_ListIO selected;
1713 aSel->selectedObjects( selected );
1715 if ( selected.Extent() > 1 ) { // a dlg for each IO
1717 SALOME_ListIteratorOfListIO It (selected);
1718 for ( ; It.More(); It.Next() ) {
1720 IOs.Append( It.Value() );
1721 aSel->setSelectedObjects( IOs );
1722 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1724 // restore selection
1725 aSel->setSelectedObjects( selected );
1728 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1732 case 1100: // EDIT HYPOTHESIS
1734 if(checkLock(aStudy)) break;
1736 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1737 SALOME_ListIO selected;
1739 aSel->selectedObjects( selected );
1741 int nbSel = selected.Extent();
1744 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1746 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1747 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1748 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1749 if ( !Hyp->_is_nil() )
1751 char* sName = Hyp->GetName();
1752 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1755 aCreator->EditHypothesis(Hyp);
1763 updateObjBrowser( true );
1767 case 1101: // RENAME
1769 if ( checkLock( aStudy ) )
1772 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1773 SALOME_ListIO selected;
1775 aSel->selectedObjects( selected );
1777 SALOME_ListIteratorOfListIO It( selected );
1778 for ( ; It.More(); It.Next() )
1780 Handle(SALOME_InteractiveObject) IObject = It.Value();
1781 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1782 _PTR(GenericAttribute) anAttr;
1783 _PTR(AttributeName) aName;
1786 if ( obj->FindAttribute(anAttr, "AttributeName") )
1789 QString newName = QString(aName->Value().c_str());
1790 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1791 if ( !newName.isEmpty() )
1793 //old source: aStudy->renameIObject( IObject, newName );
1794 aName->SetValue( newName.latin1() );
1796 // if current object is group update group's name
1797 SMESH::SMESH_GroupBase_var aGroup =
1798 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1799 if (!aGroup->_is_nil() )
1800 aGroup->SetName( newName.latin1() );
1810 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1812 if(checkLock(aStudy)) break;
1813 SUIT_OverrideCursor wc;
1815 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1816 SALOME_ListIO selected;
1818 aSel->selectedObjects( selected );
1820 SALOME_ListIteratorOfListIO It(selected);
1821 for (int i = 0; It.More(); It.Next(), i++) {
1822 Handle(SALOME_InteractiveObject) IObject = It.Value();
1823 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1826 aSel->setSelectedObjects( l1 );
1831 case 401: // GEOM::EDGE
1832 case 4021: // TRIANGLE
1834 case 4023: // POLYGON
1838 if(checkLock(aStudy)) break;
1840 EmitSignalDeactivateDialog();
1841 SMDSAbs_ElementType type = SMDSAbs_Edge;
1843 switch (theCommandID) {
1844 case 4021: // TRIANGLE
1845 type = SMDSAbs_Face; nbNodes = 3; break;
1847 type = SMDSAbs_Face; nbNodes = 4; break;
1849 type = SMDSAbs_Volume; nbNodes = 4; break;
1850 case 4023: // POLYGON
1851 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1853 type = SMDSAbs_Volume; nbNodes = 8; break;
1854 case 4033: // POLYHEDRE
1855 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1858 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1861 SUIT_MessageBox::warn1(desktop(),
1862 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1863 tr("SMESH_BUT_OK"));
1867 case 4033: // POLYHEDRON
1869 if(checkLock(aStudy)) break;
1871 EmitSignalDeactivateDialog();
1872 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1875 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1876 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1877 tr("SMESH_BUT_OK"));
1881 case 4041: // REMOVES NODES
1883 if(checkLock(aStudy)) break;
1885 EmitSignalDeactivateDialog();
1886 new SMESHGUI_RemoveNodesDlg(this);
1889 SUIT_MessageBox::warn1(desktop(),
1890 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1891 tr("SMESH_BUT_OK"));
1895 case 4042: // REMOVES ELEMENTS
1897 if(checkLock(aStudy)) break;
1899 EmitSignalDeactivateDialog();
1900 new SMESHGUI_RemoveElementsDlg(this);
1904 SUIT_MessageBox::warn1(desktop(),
1905 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1906 tr("SMESH_BUT_OK"));
1910 case 4051: // RENUMBERING NODES
1912 if(checkLock(aStudy)) break;
1914 EmitSignalDeactivateDialog();
1915 new SMESHGUI_RenumberingDlg( this, "", 0);
1919 SUIT_MessageBox::warn1(desktop(),
1920 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1921 tr("SMESH_BUT_OK"));
1925 case 4052: // RENUMBERING ELEMENTS
1927 if(checkLock(aStudy)) break;
1929 EmitSignalDeactivateDialog();
1930 new SMESHGUI_RenumberingDlg( this, "", 1);
1934 SUIT_MessageBox::warn1(desktop(),
1935 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1936 tr("SMESH_BUT_OK"));
1940 case 4061: // TRANSLATION
1942 if(checkLock(aStudy)) break;
1944 EmitSignalDeactivateDialog();
1945 new SMESHGUI_TranslationDlg( this );
1948 SUIT_MessageBox::warn1(desktop(),
1949 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1950 tr("SMESH_BUT_OK"));
1954 case 4062: // ROTATION
1956 if(checkLock(aStudy)) break;
1958 EmitSignalDeactivateDialog();
1959 new SMESHGUI_RotationDlg( this );
1962 SUIT_MessageBox::warn1(desktop(),
1963 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1964 tr("SMESH_BUT_OK"));
1968 case 4063: // SYMMETRY
1970 if(checkLock(aStudy)) break;
1972 EmitSignalDeactivateDialog();
1973 new SMESHGUI_SymmetryDlg( this );
1976 SUIT_MessageBox::warn1(desktop(),
1977 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1978 tr("SMESH_BUT_OK"));
1982 case 4064: // SEWING
1984 if(checkLock(aStudy)) break;
1986 EmitSignalDeactivateDialog();
1987 new SMESHGUI_SewingDlg( this );
1990 SUIT_MessageBox::warn1(desktop(),
1991 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1992 tr("SMESH_BUT_OK"));
1996 case 4065: // MERGE NODES
1998 if(checkLock(aStudy)) break;
2000 EmitSignalDeactivateDialog();
2001 new SMESHGUI_MergeNodesDlg( this );
2004 SUIT_MessageBox::warn1(desktop(),
2005 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2006 tr("SMESH_BUT_OK"));
2010 case 4066: // MERGE EQUAL ELEMENTS
2012 if (checkLock(aStudy)) break;
2014 EmitSignalDeactivateDialog();
2015 new SMESHGUI_EditMeshDlg(this,
2016 "SMESH_MERGE_ELEMENTS_TITLE",
2017 "ICON_DLG_MERGE_ELEMENTS",
2018 1); // MergeEqualElemets
2020 SUIT_MessageBox::warn1(desktop(),
2021 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2022 tr("SMESH_BUT_OK"));
2028 case 5000: // HYPOTHESIS
2030 if(checkLock(aStudy)) break;
2031 EmitSignalDeactivateDialog();
2032 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
2037 if(checkLock(aStudy)) break;
2038 EmitSignalDeactivateDialog();
2039 new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
2043 case 5105: // Library of selection filters
2045 static QValueList<int> aTypes;
2046 if ( aTypes.isEmpty() )
2048 aTypes.append( SMESH::NODE );
2049 aTypes.append( SMESH::EDGE );
2050 aTypes.append( SMESH::FACE );
2051 aTypes.append( SMESH::VOLUME );
2053 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2057 case 6017: // CONTROLS
2072 SalomeApp_SelectionMgr* mgr = selectionMgr();
2073 SALOME_ListIO selected; mgr->selectedObjects( selected );
2075 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2076 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2078 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2079 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2080 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2081 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2082 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2083 ::Control( theCommandID );
2088 SUIT_MessageBox::warn1(desktop(),
2089 tr( "SMESH_WRN_WARNING" ),
2090 tr( "SMESH_BAD_SELECTION" ),
2091 tr( "SMESH_BUT_OK" ) );
2095 SUIT_MessageBox::warn1(desktop(),
2096 tr( "SMESH_WRN_WARNING" ),
2097 tr( "NOT_A_VTK_VIEWER" ),
2098 tr( "SMESH_BUT_OK" ) );
2103 SalomeApp_SelectionMgr* mgr = selectionMgr();
2104 SALOME_ListIO selected; mgr->selectedObjects( selected );
2106 if (selected.Extent() == 1) {
2107 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2108 if(anIObject->hasEntry())
2109 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2110 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2117 SalomeApp_SelectionMgr* mgr = selectionMgr();
2118 SALOME_ListIO selected; mgr->selectedObjects( selected );
2120 if (selected.Extent() == 1) {
2121 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2122 if(anIObject->hasEntry())
2123 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2124 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2130 //updateObjBrowser();
2134 //=============================================================================
2138 //=============================================================================
2139 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2144 //=============================================================================
2148 //=============================================================================
2149 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2154 //=============================================================================
2158 //=============================================================================
2159 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2164 //=============================================================================
2165 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2166 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2168 //=============================================================================
2169 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2170 SUIT_ViewWindow* wnd )
2172 if(theIO->hasEntry()){
2173 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2174 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2178 //=======================================================================
2179 // function : createSMESHAction
2181 //=======================================================================
2182 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2185 QWidget* parent = application()->desktop();
2186 SUIT_ResourceMgr* resMgr = resourceMgr();
2188 if ( icon_id.length() )
2189 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2191 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2192 if ( !pix.isNull() )
2193 icon = QIconSet( pix );
2195 QString tooltip = tr( QString( "TOP_" )+po_id ),
2196 menu = tr( QString( "MEN_" )+po_id ),
2197 status_bar = tr( QString( "STB_" )+po_id );
2199 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2202 //=======================================================================
2203 // function : createPopupItem
2205 //=======================================================================
2206 void SMESHGUI::createPopupItem( const int id,
2207 const QString& clients,
2208 const QString& types,
2209 const QString& theRule,
2214 parentId = popupMgr()->actionId( action( pId ) );
2216 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2217 popupMgr()->insert( action( id ), parentId, 0 );
2219 QChar lc = QtxPopupMgr::Selection::defEquality();
2220 QString rule = "(%1) and (%2) and (%3)";
2221 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2222 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2223 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2226 bool cont = myRules.contains( id );
2228 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2230 popupMgr()->setRule( action( id ), rule, true );
2231 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2234 //=======================================================================
2235 // function : initialize
2237 //=======================================================================
2238 void SMESHGUI::initialize( CAM_Application* app )
2240 SalomeApp_Module::initialize( app );
2242 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2244 /* Automatic Update flag */
2245 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2247 // ----- create actions --------------
2249 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2250 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2251 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2252 createSMESHAction( 114, "NUM" );
2253 createSMESHAction( 121, "DAT" );
2254 createSMESHAction( 122, "MED" );
2255 createSMESHAction( 123, "UNV" );
2256 createSMESHAction( 124, "EXPORT_DAT" );
2257 createSMESHAction( 125, "EXPORT_MED" );
2258 createSMESHAction( 126, "EXPORT_UNV" );
2259 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2260 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2261 createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" );
2262 createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" );
2263 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2264 createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" );
2265 createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" );
2266 createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" );
2267 createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" );
2268 createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" );
2269 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2270 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2271 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2272 createSMESHAction( 804, "ADD" );
2273 createSMESHAction( 805, "REMOVE" );
2274 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2275 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2276 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2277 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2278 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2279 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2280 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2281 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2282 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2283 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2284 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2285 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2286 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2287 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2288 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2289 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2290 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2291 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2292 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2293 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2294 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2295 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2296 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2297 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2298 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2299 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2300 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2301 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2302 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2303 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2304 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2305 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2306 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2307 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2308 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2309 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2310 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2311 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2312 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2313 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2314 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2315 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2316 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2317 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2318 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2319 createSMESHAction( 415, "MAP", "ICON_MAP" );
2320 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2321 createSMESHAction( 200, "RESET" );
2322 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2323 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2324 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2325 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2326 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2327 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2328 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2329 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2330 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2331 createSMESHAction( 220, "ALL" );
2332 createSMESHAction( 1100, "EDIT_HYPO" );
2333 createSMESHAction( 1101, "RENAME" );
2334 createSMESHAction( 1102, "UNASSIGN" );
2335 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2336 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2337 createSMESHAction( 1131, "DISPMODE" );
2338 createSMESHAction( 1132, "COLORS" );
2339 createSMESHAction( 1133, "TRANSP" );
2340 createSMESHAction( 1134, "CLIP" );
2341 createSMESHAction( 1135, "DISP_ENT" );
2342 createSMESHAction( 2000, "CTRL" );
2344 createSMESHAction( 300, "ERASE" );
2345 createSMESHAction( 301, "DISPLAY" );
2346 createSMESHAction( 302, "DISPLAY_ONLY" );
2347 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2349 // ----- create menu --------------
2350 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2351 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2352 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2353 hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ),
2354 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2355 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2356 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2357 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2359 createMenu( separator(), fileId );
2361 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2362 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2363 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2364 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2365 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2366 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2368 createMenu( 111, importId, -1 );
2369 createMenu( 112, importId, -1 );
2370 createMenu( 113, importId, -1 );
2372 createMenu( 121, exportId, -1 );
2373 createMenu( 122, exportId, -1 );
2374 createMenu( 123, exportId, -1 );
2376 createMenu( separator(), fileId, 10 );
2378 createMenu( 33, editId, -1 );
2380 createMenu( 5105, toolsId, -1 );
2382 createMenu( 5000, hypoId, -1 );
2383 createMenu( 5010, hypoId, -1 );
2385 createMenu( 703, meshId, -1 );
2386 createMenu( 702, meshId, -1 );
2387 createMenu( 704, meshId, -1 );
2388 createMenu( separator(), meshId, -1 );
2389 createMenu( 701, meshId, -1 );
2390 createMenu( separator(), meshId, -1 );
2391 createMenu( 801, meshId, -1 );
2392 createMenu( 802, meshId, -1 );
2393 createMenu( 803, meshId, -1 );
2394 createMenu( separator(), meshId, -1 );
2395 createMenu( 810, meshId, -1 );
2396 createMenu( 811, meshId, -1 );
2397 createMenu( 812, meshId, -1 );
2398 createMenu( separator(), meshId, -1 );
2399 createMenu( 813, meshId, -1 );
2400 createMenu( separator(), meshId, -1 );
2401 createMenu( 900, meshId, -1 );
2402 createMenu( 902, meshId, -1 );
2403 createMenu( separator(), meshId, -1 );
2405 createMenu( 6003, ctrlId, -1 );
2406 createMenu( 6001, ctrlId, -1 );
2407 createMenu( 6004, ctrlId, -1 );
2408 createMenu( separator(), ctrlId, -1 );
2409 createMenu( 6002, ctrlId, -1 );
2410 createMenu( 6018, ctrlId, -1 );
2411 createMenu( 6019, ctrlId, -1 );
2412 createMenu( 6011, ctrlId, -1 );
2413 createMenu( 6012, ctrlId, -1 );
2414 createMenu( 6013, ctrlId, -1 );
2415 createMenu( 6014, ctrlId, -1 );
2416 createMenu( 6015, ctrlId, -1 );
2417 createMenu( 6016, ctrlId, -1 );
2418 createMenu( separator(), ctrlId, -1 );
2419 createMenu( 6017, ctrlId, -1 );
2420 createMenu( separator(), ctrlId, -1 );
2422 createMenu( 400, addId, -1 );
2423 createMenu( 401, addId, -1 );
2424 createMenu( 4021, addId, -1 );
2425 createMenu( 4022, addId, -1 );
2426 createMenu( 4023, addId, -1 );
2427 createMenu( 4031, addId, -1 );
2428 createMenu( 4032, addId, -1 );
2429 createMenu( 4033, addId, -1 );
2431 createMenu( 4041, removeId, -1 );
2432 createMenu( 4042, removeId, -1 );
2434 createMenu( 4051, renumId, -1 );
2435 createMenu( 4052, renumId, -1 );
2437 createMenu( 4061, transfId, -1 );
2438 createMenu( 4062, transfId, -1 );
2439 createMenu( 4063, transfId, -1 );
2440 createMenu( 4064, transfId, -1 );
2441 createMenu( 4065, transfId, -1 );
2442 createMenu( 4066, transfId, -1 );
2444 createMenu( 406, modifyId, -1 );
2445 createMenu( 407, modifyId, -1 );
2446 createMenu( 408, modifyId, -1 );
2447 createMenu( 409, modifyId, -1 );
2448 createMenu( 410, modifyId, -1 );
2449 createMenu( 411, modifyId, -1 );
2450 createMenu( 412, modifyId, -1 );
2451 createMenu( 413, modifyId, -1 );
2452 createMenu( 416, modifyId, -1 );
2453 createMenu( 414, modifyId, -1 );
2454 createMenu( 415, modifyId, -1 );
2456 createMenu( 214, viewId, -1 );
2458 // ----- create toolbars --------------
2459 int meshTb = createTool( tr( "TB_MESH" ) ),
2460 hypoTb = createTool( tr( "TB_HYPO" ) ),
2461 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2462 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2463 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2464 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2466 createTool( 703, meshTb );
2467 createTool( 702, meshTb );
2468 createTool( 704, meshTb );
2469 createTool( separator(), meshTb );
2470 createTool( 701, meshTb );
2471 createTool( separator(), meshTb );
2472 createTool( 801, meshTb );
2473 createTool( 802, meshTb );
2474 createTool( 803, meshTb );
2475 createTool( separator(), meshTb );
2476 createTool( 900, meshTb );
2477 createTool( 902, meshTb );
2478 createTool( separator(), meshTb );
2480 createTool( 5000, hypoTb );
2481 createTool( 5010, hypoTb );
2483 createTool( 6001, ctrlTb );
2484 createTool( 6003, ctrlTb );
2485 createTool( 6004, ctrlTb );
2486 createTool( separator(), ctrlTb );
2487 createTool( 6002, ctrlTb );
2488 createTool( 6018, ctrlTb );
2489 createTool( 6019, ctrlTb );
2490 createTool( 6011, ctrlTb );
2491 createTool( 6012, ctrlTb );
2492 createTool( 6013, ctrlTb );
2493 createTool( 6014, ctrlTb );
2494 createTool( 6015, ctrlTb );
2495 createTool( 6016, ctrlTb );
2496 createTool( separator(), ctrlTb );
2497 createTool( 6017, ctrlTb );
2498 createTool( separator(), ctrlTb );
2500 createTool( 400, addRemTb );
2501 createTool( 401, addRemTb );
2502 createTool( 4021, addRemTb );
2503 createTool( 4022, addRemTb );
2504 createTool( 4023, addRemTb );
2505 createTool( 4031, addRemTb );
2506 createTool( 4032, addRemTb );
2507 createTool( 4033, addRemTb );
2508 createTool( separator(), addRemTb );
2509 createTool( 4041, addRemTb );
2510 createTool( 4042, addRemTb );
2511 createTool( separator(), addRemTb );
2512 createTool( 4051, addRemTb );
2513 createTool( 4052, addRemTb );
2514 createTool( separator(), addRemTb );
2515 createTool( 4061, addRemTb );
2516 createTool( 4062, addRemTb );
2517 createTool( 4063, addRemTb );
2518 createTool( 4064, addRemTb );
2519 createTool( 4065, addRemTb );
2520 createTool( 4066, addRemTb );
2521 createTool( separator(), addRemTb );
2523 createTool( 406, modifyTb );
2524 createTool( 407, modifyTb );
2525 createTool( 408, modifyTb );
2526 createTool( 409, modifyTb );
2527 createTool( 410, modifyTb );
2528 createTool( 411, modifyTb );
2529 createTool( 412, modifyTb );
2530 createTool( 413, modifyTb );
2531 createTool( 416, modifyTb );
2532 createTool( 414, modifyTb );
2533 createTool( 415, modifyTb );
2535 createTool( 214, dispModeTb );
2539 QString OB = "'ObjectBrowser'",
2540 View = "'" + SVTK_Viewer::Type() + "'",
2542 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2543 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2544 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2545 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2546 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2547 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2548 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2549 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2550 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2551 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2553 mesh_group = mesh + " " + subMesh + " " + group,
2554 hyp_alg = hypo + " " + algo;
2556 // popup for object browser
2558 createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO
2559 createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO
2560 createPopupItem( 803, OB, group ); // EDIT_GROUP
2561 popupMgr()->insert( separator(), -1, 0 );
2562 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2563 createPopupItem( 214, OB, mesh_group ); // UPDATE
2564 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2565 createPopupItem( 902, OB, mesh ); // STD_INFO
2566 popupMgr()->insert( separator(), -1, 0 );
2567 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2568 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2569 popupMgr()->insert( separator(), -1, 0 );
2570 createPopupItem( 1100, OB, hypo, "&& $hasReference={false}" ); // EDIT HYPOTHESIS
2571 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2572 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "&& $hasReference={false}" ); // RENAME
2573 popupMgr()->insert( separator(), -1, 0 );
2574 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2575 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2576 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2577 popupMgr()->insert( separator(), -1, 0 );
2580 createPopupItem( 803, View, group ); // EDIT_GROUP
2581 createPopupItem( 804, View, elems ); // ADD
2582 createPopupItem( 805, View, elems ); // REMOVE
2583 popupMgr()->insert( separator(), -1, 0 );
2584 createPopupItem( 214, View, mesh_group ); // UPDATE
2585 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2586 createPopupItem( 902, View, mesh ); // STD_INFO
2587 popupMgr()->insert( separator(), -1, 0 );
2591 isInvisible("not( isVisible )"),
2592 isEmpty("numberOfNodes = 0"),
2593 isNotEmpty("numberOfNodes <> 0"),
2595 // has nodes, edges, etc in VISIBLE! actor
2596 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2597 hasElems("(count( elemTypes ) > 0)"),
2598 hasDifferentElems("(count( elemTypes ) > 1)"),
2599 hasEdges("({'Edge'} in elemTypes)"),
2600 hasFaces("({'Face'} in elemTypes)"),
2601 hasVolumes("({'Volume'} in elemTypes)");
2603 QString lc = QtxPopupMgr::Selection::defEquality();
2604 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2605 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
2606 QString aMeshInVTK = aClient + "&&" + aType;
2608 //-------------------------------------------------
2610 //-------------------------------------------------
2611 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2613 popupMgr()->insert( action( 9010 ), anId, -1 );
2614 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2615 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2617 popupMgr()->insert( action( 9011 ), anId, -1 );
2618 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2619 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2621 popupMgr()->insert( separator(), -1, -1 );
2623 //-------------------------------------------------
2625 //-------------------------------------------------
2626 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2628 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2629 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2630 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2632 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2633 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2634 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2636 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2637 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2638 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2640 popupMgr()->insert( separator(), anId, -1 );
2642 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2643 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2644 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2646 //-------------------------------------------------
2648 //-------------------------------------------------
2649 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2651 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2653 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2654 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2655 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2657 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2658 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2659 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2661 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2662 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2663 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2665 popupMgr()->insert( separator(), anId, -1 );
2667 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2668 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2670 //-------------------------------------------------
2672 //-------------------------------------------------
2673 popupMgr()->insert( action( 1132 ), -1, -1 );
2674 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2676 //-------------------------------------------------
2678 //-------------------------------------------------
2679 popupMgr()->insert( action( 1133 ), -1, -1 );
2680 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2682 //-------------------------------------------------
2684 //-------------------------------------------------
2685 popupMgr()->insert( action( 1134 ), -1, -1 );
2686 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2688 popupMgr()->insert( separator(), -1, -1 );
2690 //-------------------------------------------------
2692 //-------------------------------------------------
2694 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2695 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2696 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2698 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2700 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2701 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2703 popupMgr()->insert( separator(), anId, -1 );
2705 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2706 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2707 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2709 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2710 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2711 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2713 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2714 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2715 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2717 popupMgr()->insert( separator(), anId, -1 );
2719 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2720 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2721 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2723 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2724 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2725 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2727 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2728 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2729 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2731 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2732 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2733 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2735 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2736 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2737 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2739 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2740 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2741 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2743 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2744 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2745 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2747 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2748 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2749 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2751 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2752 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2753 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2755 popupMgr()->insert( separator(), anId, -1 );
2757 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2758 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2759 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2761 popupMgr()->insert( separator(), anId, -1 );
2763 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2764 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2766 popupMgr()->insert( separator(), -1, -1 );
2768 //-------------------------------------------------
2770 //-------------------------------------------------
2771 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2772 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
2773 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2774 QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
2775 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2776 popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
2778 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2779 popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
2781 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2782 popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
2784 popupMgr()->insert( separator(), -1, -1 );
2786 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
2787 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
2790 bool SMESHGUI::activateModule( SUIT_Study* study )
2792 bool res = SalomeApp_Module::activateModule( study );
2794 setMenuShown( true );
2795 setToolShown( true );
2800 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2802 setMenuShown( false );
2803 setToolShown( false );
2805 EmitSignalCloseAllDialogs();
2807 return SalomeApp_Module::deactivateModule( study );
2810 void SMESHGUI::OnGUIEvent()
2812 const QObject* obj = sender();
2813 if ( !obj || !obj->inherits( "QAction" ) )
2815 int id = actionId((QAction*)obj);
2820 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2822 if ( CORBA::is_nil( myComponentSMESH ) )
2824 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2825 return aGUI.myComponentSMESH;
2827 return myComponentSMESH;
2830 QString SMESHGUI::engineIOR() const
2832 CORBA::ORB_var anORB = getApp()->orb();
2833 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2837 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2839 SMESHGUI_Selection sel;
2840 sel.init( client, selectionMgr() );
2841 popupMgr()->updatePopup( menu, &sel );
2844 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2846 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2847 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2850 void SMESHGUI::viewManagers( QStringList& list ) const
2852 list.append( SVTK_Viewer::Type() );
2855 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
2857 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
2858 SMESH::UpdateSelectionProp( this );
2861 void SMESHGUI::createPreferences()
2863 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2865 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2866 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "display_entity" );
2867 addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "auto_update" );
2869 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2870 setPreferenceProperty( precGroup, "columns", 1 );
2872 addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool );
2873 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2875 setPreferenceProperty( prec, "min", 0 );
2876 setPreferenceProperty( prec, "max", 16 );
2878 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2879 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, SalomeApp_Preferences::Selector, "SMESH", "display_mode" );
2881 modes.append( "Wireframe" );
2882 modes.append( "Shading" );
2883 modes.append( "Shrink" );
2884 modes.append( "Nodes" );
2885 setPreferenceProperty( dispmode, "strings", modes );
2887 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2888 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2890 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
2891 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
2893 setPreferenceProperty( nodeSz, "min", 1 );
2894 setPreferenceProperty( nodeSz, "max", 5 );
2896 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2898 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
2899 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
2900 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
2901 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
2903 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
2904 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2906 setPreferenceProperty( elemW, "min", 1 );
2907 setPreferenceProperty( elemW, "max", 5 );
2909 setPreferenceProperty( shrink, "min", 0 );
2910 setPreferenceProperty( shrink, "max", 100 );
2912 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2914 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2916 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
2917 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
2918 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
2920 setPreferenceProperty( selW, "min", 1 );
2921 setPreferenceProperty( selW, "max", 5 );
2923 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2925 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
2926 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2928 setPreferenceProperty( preW, "min", 1 );
2929 setPreferenceProperty( preW, "max", 5 );
2931 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2933 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
2934 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
2936 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2937 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2939 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2940 addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2941 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2942 addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
2945 fam.append( tr( "SMESH_FONT_ARIAL" ) );
2946 fam.append( tr( "SMESH_FONT_COURIER" ) );
2947 fam.append( tr( "SMESH_FONT_TIMES" ) );
2948 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2950 setPreferenceProperty( tfont, "families", fam );
2951 setPreferenceProperty( tfont, "system", false );
2952 setPreferenceProperty( tfont, "widget_flags", wflag );
2953 setPreferenceProperty( lfont, "families", fam );
2954 setPreferenceProperty( lfont, "system", false );
2955 setPreferenceProperty( lfont, "widget_flags", wflag );
2957 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
2959 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
2960 setPreferenceProperty( numcol, "min", 2 );
2961 setPreferenceProperty( numcol, "max", 256 );
2963 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
2964 setPreferenceProperty( numlab, "min", 2 );
2965 setPreferenceProperty( numlab, "max", 65 );
2967 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
2968 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2969 QStringList orients;
2970 orients.append( tr( "SMESH_VERTICAL" ) );
2971 orients.append( tr( "SMESH_HORIZONTAL" ) );
2972 QValueList<QVariant> indices; indices.append( 0 ); indices.append( 1 );
2973 setPreferenceProperty( orient, "strings", orients );
2974 setPreferenceProperty( orient, "indexes", indices );
2976 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
2977 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2978 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2979 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2980 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
2981 setPreferenceProperty( xv, "step", 0.1 );
2982 setPreferenceProperty( xv, "min", 0.0 );
2983 setPreferenceProperty( xv, "max", 1.0 );
2984 setPreferenceProperty( yv, "step", 0.1 );
2985 setPreferenceProperty( yv, "min", 0.0 );
2986 setPreferenceProperty( yv, "max", 1.0 );
2987 setPreferenceProperty( wv, "step", 0.1 );
2988 setPreferenceProperty( wv, "min", 0.0 );
2989 setPreferenceProperty( wv, "max", 1.0 );
2990 setPreferenceProperty( hv, "min", 0.0 );
2991 setPreferenceProperty( hv, "max", 1.0 );
2992 setPreferenceProperty( hv, "step", 0.1 );
2994 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
2995 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
2996 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
2997 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
2998 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
2999 setPreferenceProperty( xv, "min", 0.0 );
3000 setPreferenceProperty( xv, "max", 1.0 );
3001 setPreferenceProperty( xv, "step", 0.1 );
3002 setPreferenceProperty( xh, "min", 0.0 );
3003 setPreferenceProperty( xh, "max", 1.0 );
3004 setPreferenceProperty( xh, "step", 0.1 );
3005 setPreferenceProperty( yh, "min", 0.0 );
3006 setPreferenceProperty( yh, "max", 1.0 );
3007 setPreferenceProperty( yh, "step", 0.1 );
3008 setPreferenceProperty( wh, "min", 0.0 );
3009 setPreferenceProperty( wh, "max", 1.0 );
3010 setPreferenceProperty( wh, "step", 0.1 );
3011 setPreferenceProperty( hh, "min", 0.0 );
3012 setPreferenceProperty( hh, "max", 1.0 );
3013 setPreferenceProperty( hh, "step", 0.1 );
3016 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )