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_NodesDlg.h"
30 #include "SMESHGUI_TransparencyDlg.h"
31 #include "SMESHGUI_ClippingDlg.h"
32 #include "SMESHGUI_GroupDlg.h"
33 #include "SMESHGUI_RemoveNodesDlg.h"
34 #include "SMESHGUI_RemoveElementsDlg.h"
35 #include "SMESHGUI_MeshInfosDlg.h"
36 #include "SMESHGUI_StandardMeshInfosDlg.h"
37 #include "SMESHGUI_Preferences_ColorDlg.h"
38 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
39 #include "SMESHGUI_Preferences_SelectionDlg.h"
40 #include "SMESHGUI_Hypotheses.h"
41 #include "SMESHGUI_MoveNodesDlg.h"
42 #include "SMESHGUI_AddMeshElementDlg.h"
43 #include "SMESHGUI_EditHypothesesDlg.h"
44 #include "SMESHGUI_CreateHypothesesDlg.h"
45 #include "SMESHGUI_FilterDlg.h"
46 #include "SMESHGUI_FilterLibraryDlg.h"
47 #include "SMESHGUI_SingleEditDlg.h"
48 #include "SMESHGUI_MultiEditDlg.h"
49 #include "SMESHGUI_GroupOpDlg.h"
50 #include "SMESHGUI_DeleteGroupDlg.h"
51 #include "SMESHGUI_SmoothingDlg.h"
52 #include "SMESHGUI_RenumberingDlg.h"
53 #include "SMESHGUI_ExtrusionDlg.h"
54 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
55 #include "SMESHGUI_RevolutionDlg.h"
56 #include "SMESHGUI_TranslationDlg.h"
57 #include "SMESHGUI_RotationDlg.h"
58 #include "SMESHGUI_SymmetryDlg.h"
59 #include "SMESHGUI_SewingDlg.h"
60 #include "SMESHGUI_MergeNodesDlg.h"
61 #include "SMESHGUI_EditMeshDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_PrecisionDlg.h"
64 #include "SMESHGUI_Selection.h"
65 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
66 #include "SMESHGUI_MeshOp.h"
67 #include "SMESHGUI_Displayer.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_Operation.h"
90 #include "SalomeApp_UpdateFlags.h"
92 #include "SalomeApp_ImportOperation.h"
94 #include <SVTK_ViewWindow.h>
95 #include <SVTK_ViewModel.h>
96 #include <SVTK_InteractorStyle.h>
97 #include <SVTK_RenderWindowInteractor.h>
99 #include <VTKViewer_ViewManager.h>
101 #include "OB_Browser.h"
103 #include "SUIT_Tools.h"
104 #include "SUIT_MessageBox.h"
105 #include "SUIT_ResourceMgr.h"
106 #include "SUIT_FileDlg.h"
107 #include "SUIT_Desktop.h"
108 #include "SUIT_ResourceMgr.h"
109 #include "SUIT_OverrideCursor.h"
110 #include "SUIT_Study.h"
111 #include "SUIT_Session.h"
113 #include "QtxPopupMgr.h"
115 #include "SALOME_ListIO.hxx"
116 #include "SALOME_ListIteratorOfListIO.hxx"
117 #include "SALOME_InteractiveObject.hxx"
118 #include "SALOME_NamingService.hxx"
119 #include "SALOME_LifeCycleCORBA.hxx"
121 #include "SALOMEconfig.h"
122 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
125 #define INCLUDE_MENUITEM_DEF
126 #include <qpopupmenu.h>
132 #include <boost/shared_ptr.hpp>
135 #include <vtkRenderer.h>
136 #include <vtkRenderWindow.h>
137 #include <vtkActorCollection.h>
138 #include <vtkScalarBarActor.h>
139 #include <vtkUnstructuredGrid.h>
141 #include "utilities.h"
143 #include "SALOMEDS_Study.hxx"
144 #include "SALOMEDSClient_StudyBuilder.hxx"
145 #include "SALOMEDSClient_SComponent.hxx"
151 //=============================================================
152 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
155 void ExportMeshToFile(int theCommandID);
157 void SetDisplayMode(int theCommandID);
159 void SetDisplayEntity(int theCommandID);
161 void Control( int theCommandID );
165 //=============================================================
166 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
172 if(theCommandID == 113){
173 filter.append(QObject::tr("MED files (*.med)"));
174 filter.append(QObject::tr("All files (*)"));
175 }else if (theCommandID == 112){
176 filter.append(QObject::tr("IDEAS files (*.unv)"));
177 }else if (theCommandID == 111){
178 filter.append(QObject::tr("DAT files (*.dat)"));
180 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
183 QObject::tr("Import mesh"),
185 if(!filename.isEmpty()) {
186 SUIT_OverrideCursor wc;
187 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
188 theComponentMesh->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
191 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
192 switch ( theCommandID ) {
195 aMeshes->length( 1 );
196 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
201 SMESH::DriverMED_ReadStatus res;
202 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
203 if ( res != SMESH::DRS_OK ) {
205 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
206 QObject::tr("SMESH_WRN_WARNING"),
207 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
208 QObject::tr("SMESH_BUT_OK"));
209 aMeshes->length( 0 );
216 bool isEmpty = false;
217 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
218 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
220 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
221 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
222 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
223 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
224 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
231 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
232 QObject::tr("SMESH_WRN_WARNING"),
233 QObject::tr("SMESH_DRS_EMPTY"),
234 QObject::tr("SMESH_BUT_OK"));
238 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
240 catch (const SALOME::SALOME_Exception& S_ex){
242 SalomeApp_Tools::QtCatchCorbaException(S_ex);
249 void ExportMeshToFile( int theCommandID )
251 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
252 SALOME_ListIO selected;
254 aSel->selectedObjects( selected );
256 if(selected.Extent()){
257 Handle(SALOME_InteractiveObject) anIObject = selected.First();
258 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
259 if ( !aMesh->_is_nil() ) {
260 QString aFilter, aTitle = QObject::tr("Export mesh");
261 QMap<QString, SMESH::MED_VERSION> aFilterMap;
262 switch ( theCommandID ) {
265 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
266 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
270 aFilter = QObject::tr("DAT files (*.dat)");
274 if(aMesh->NbPyramids()){
275 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
276 QObject::tr("SMESH_WRN_WARNING"),
277 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
278 QObject::tr("SMESH_BUT_YES"),
279 QObject::tr("SMESH_BUT_NO"),
284 aFilter = QObject::tr("IDEAS files (*.unv)");
291 SMESH::MED_VERSION aFormat;
293 if ( theCommandID != 122 && theCommandID != 125 )
294 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
298 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
299 filters.push_back( it.key() );
301 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
302 fd->setCaption( aTitle );
303 fd->setFilters( filters );
307 aFilename = fd->selectedFile();
308 aFormat = aFilterMap[fd->selectedFilter()];
310 if( !aFilename.isEmpty()
311 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
312 && aFormat==SMESH::MED_V2_1){
313 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
314 QObject::tr("SMESH_WRN_WARNING"),
315 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
316 QObject::tr("SMESH_BUT_YES"),
317 QObject::tr("SMESH_BUT_NO"),
326 if ( !aFilename.isEmpty() ) {
327 // Check whether the file already exists and delete it if yes
328 QFile aFile( aFilename );
329 if ( aFile.exists() )
331 SUIT_OverrideCursor wc;
332 switch ( theCommandID ) {
335 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
339 aMesh->ExportDAT( aFilename.latin1() );
343 aMesh->ExportUNV( aFilename.latin1() );
353 inline void InverseEntityMode(unsigned int& theOutputMode,
354 unsigned int theMode)
356 bool anIsNotPresent = ~theOutputMode & theMode;
358 theOutputMode |= theMode;
360 theOutputMode &= ~theMode;
363 void SetDisplayEntity(int theCommandID){
364 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
365 SALOME_ListIO selected;
367 aSel->selectedObjects( selected );
369 if(selected.Extent() >= 1){
370 SALOME_ListIteratorOfListIO It( selected );
371 for(; It.More(); It.Next()){
372 Handle(SALOME_InteractiveObject) IObject = It.Value();
373 if(IObject->hasEntry()){
374 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
375 unsigned int aMode = anActor->GetEntityMode();
376 switch(theCommandID){
378 InverseEntityMode(aMode,SMESH_Actor::eEdges);
381 InverseEntityMode(aMode,SMESH_Actor::eFaces);
384 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
387 aMode = SMESH_Actor::eAllEntity;
391 anActor->SetEntityMode(aMode);
398 void SetDisplayMode(int theCommandID){
399 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
400 SALOME_ListIO selected;
402 aSel->selectedObjects( selected );
404 if(selected.Extent() >= 1){
405 switch(theCommandID){
407 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
408 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
412 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
413 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
416 SALOME_ListIteratorOfListIO It( selected );
417 for(; It.More(); It.Next()){
418 Handle(SALOME_InteractiveObject) IObject = It.Value();
419 if(IObject->hasEntry()){
420 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
421 switch(theCommandID){
423 anActor->SetRepresentation(SMESH_Actor::eEdge);
426 anActor->SetRepresentation(SMESH_Actor::eSurface);
429 if(anActor->IsShrunk())
432 anActor->SetShrink();
435 anActor->SetRepresentation(SMESH_Actor::ePoint);
439 anActor->GetSufaceColor(color[0], color[1], color[2]);
440 int c0 = int (color[0] * 255);
441 int c1 = int (color[1] * 255);
442 int c2 = int (color[2] * 255);
443 QColor c(c0, c1, c2);
446 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
447 c0 = int (edgecolor[0] * 255);
448 c1 = int (edgecolor[1] * 255);
449 c2 = int (edgecolor[2] * 255);
450 QColor e(c0, c1, c2);
452 float backfacecolor[3];
453 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
454 c0 = int (backfacecolor[0] * 255);
455 c1 = int (backfacecolor[1] * 255);
456 c2 = int (backfacecolor[2] * 255);
457 QColor b(c0, c1, c2);
460 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
461 c0 = int (nodecolor[0] * 255);
462 c1 = int (nodecolor[1] * 255);
463 c2 = int (nodecolor[2] * 255);
464 QColor n(c0, c1, c2);
466 int Edgewidth = (int)anActor->GetLineWidth();
469 int intValue = int(anActor->GetNodeSize());
470 float Shrink = anActor->GetShrinkFactor();
472 SMESHGUI_Preferences_ColorDlg *aDlg =
473 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
474 aDlg->SetColor(1, c);
475 aDlg->SetColor(2, e);
476 aDlg->SetColor(3, n);
477 aDlg->SetColor(4, b);
478 aDlg->SetIntValue(1, Edgewidth);
479 aDlg->SetIntValue(2, intValue);
480 aDlg->SetIntValue(3, int(Shrink*100.));
482 QColor color = aDlg->GetColor(1);
483 QColor edgecolor = aDlg->GetColor(2);
484 QColor nodecolor = aDlg->GetColor(3);
485 QColor backfacecolor = aDlg->GetColor(4);
486 /* actor color and backface color */
487 anActor->SetSufaceColor(float (color.red()) / 255.,
488 float (color.green()) / 255.,
489 float (color.blue()) / 255.);
490 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
491 float (backfacecolor.green()) / 255.,
492 float (backfacecolor.blue()) / 255.);
495 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
496 float (edgecolor.green()) / 255.,
497 float (edgecolor.blue()) / 255.);
499 /* Shrink factor and size edges */
500 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
501 anActor->SetLineWidth(aDlg->GetIntValue(1));
503 /* Nodes color and size */
504 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
505 float (nodecolor.green()) / 255.,
506 float (nodecolor.blue()) / 255.);
507 anActor->SetNodeSize(aDlg->GetIntValue(2));
516 SMESH::RepaintCurrentView();
520 void Control( int theCommandID )
522 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
523 SALOME_ListIO selected;
525 aSel->selectedObjects( selected );
527 if( !selected.IsEmpty() ){
528 Handle(SALOME_InteractiveObject) anIO = selected.First();
531 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
532 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
533 switch ( theCommandID ){
535 aTitle = QObject::tr( "LENGTH_EDGES" );
536 aControl = SMESH_Actor::eLength;
539 aTitle = QObject::tr( "LENGTH2D_EDGES" );
540 aControl = SMESH_Actor::eLength2D;
543 aTitle = QObject::tr( "FREE_EDGES" );
544 aControl = SMESH_Actor::eFreeEdges;
547 aTitle = QObject::tr( "FREE_BORDERS" );
548 aControl = SMESH_Actor::eFreeBorders;
551 aTitle = QObject::tr( "MULTI_BORDERS" );
552 aControl = SMESH_Actor::eMultiConnection;
555 aTitle = QObject::tr( "MULTI2D_BORDERS" );
556 aControl = SMESH_Actor::eMultiConnection2D;
559 aTitle = QObject::tr( "AREA_ELEMENTS" );
560 aControl = SMESH_Actor::eArea;
563 aTitle = QObject::tr( "TAPER_ELEMENTS" );
564 aControl = SMESH_Actor::eTaper;
567 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
568 aControl = SMESH_Actor::eAspectRatio;
571 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
572 aControl = SMESH_Actor::eAspectRatio3D;
575 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
576 aControl = SMESH_Actor::eMinimumAngle;
579 aTitle = QObject::tr( "WARP_ELEMENTS" );
580 aControl = SMESH_Actor::eWarping;
583 aTitle = QObject::tr( "SKEW_ELEMENTS" );
584 aControl = SMESH_Actor::eSkew;
587 anActor->SetControlMode(aControl);
588 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
589 SMESH::RepaintCurrentView();
596 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
597 MeshObjectType theType,
598 const QString theInTypeName,
599 QString & theOutTypeName)
601 SMESH_TypeFilter aTypeFilter( theType );
603 if( !theIO.IsNull() )
605 entry = theIO->getEntry();
606 SalomeApp_DataOwner owner( entry );
607 if ( aTypeFilter.isOk( &owner )) {
608 theOutTypeName = theInTypeName;
616 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
618 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
619 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
621 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
622 CORBA::String_var anID = aSComp->GetID().c_str();
623 if (!strcmp(anID.in(),theIO->getEntry()))
629 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
630 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
631 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
632 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
633 CheckOIType ( theIO, GROUP, "Group", aTypeName )
641 QString CheckHomogeneousSelection()
643 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
644 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
645 SALOME_ListIO selected;
647 aSel->selectedObjects( selected );
649 QString RefType = CheckTypeObject(selected.First());
650 SALOME_ListIteratorOfListIO It(selected);
651 for (; It.More(); It.Next())
653 Handle(SALOME_InteractiveObject) IObject = It.Value();
654 QString Type = CheckTypeObject(IObject);
655 if (Type.compare(RefType) != 0)
656 return "Heterogeneous Selection";
663 void SMESHGUI::OnEditDelete()
665 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
666 SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
667 SALOME_ListIO selected; aSel->selectedObjects( selected );
669 QString aParentComponent = QString::null;
670 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
672 QString cur = anIt.Value()->getComponentDataType();
673 if( aParentComponent.isNull() )
674 aParentComponent = cur;
675 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
676 aParentComponent = "";
679 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
680 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
681 QObject::tr("ERR_ERROR"),
682 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
683 QObject::tr("BUT_OK") );
686 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
687 if (SUIT_MessageBox::warn2
688 (SMESHGUI::desktop(),
689 QObject::tr("SMESH_WRN_WARNING"),
690 QObject::tr("SMESH_REALLY_DELETE"),
691 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
694 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
695 SUIT_ViewManager* vm = anApp->activeViewManager();
696 int nbSf = vm->getViewsCount();
698 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
699 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
700 _PTR(GenericAttribute) anAttr;
701 _PTR(AttributeIOR) anIOR;
703 SALOME_ListIteratorOfListIO It(selected);
705 aStudyBuilder->NewCommand(); // There is a transaction
706 for(; It.More(); It.Next()){
707 Handle(SALOME_InteractiveObject) IObject = It.Value();
708 if(IObject->hasEntry()){
709 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
711 // disable removal of "SMESH" component object
712 if(SO->FindAttribute(anAttr, "AttributeIOR")){
714 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
718 /* Erase child graphical objects */
719 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
720 for(it->InitEx(true); it->More(); it->Next()){
721 _PTR(SObject) CSO = it->Value();
722 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
725 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
726 for(int i = 0; i < nbSf; i++){
727 SUIT_ViewWindow *sf = aViews[i];
728 CORBA::String_var anEntry = CSO->GetID().c_str();
729 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
730 SMESH::RemoveActor(sf,anActor);
736 /* Erase main graphical object */
737 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
738 for(int i = 0; i < nbSf; i++){
739 SUIT_ViewWindow *sf = aViews[i];
740 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
741 SMESH::RemoveActor(sf,anActor);
745 // Remove object(s) from data structures
746 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
748 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
749 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
750 QString objType = CheckTypeObject(IObject);
751 if ( !aGroup->_is_nil() ) { // DELETE GROUP
752 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
753 aMesh->RemoveGroup( aGroup );
755 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
756 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
757 aMesh->RemoveSubMesh( aSubMesh );
759 else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
760 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
761 aStudyBuilder->RemoveObjectWithChildren( obj );
763 else {// default action: remove SObject from the study
764 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
765 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
767 aStudyBuilder->RemoveObjectWithChildren( obj );
772 } /* IObject->hasEntry() */
774 aStudyBuilder->CommitCommand();
776 /* Clear any previous selection */
778 aSel->setSelectedObjects( l1 );
780 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
785 Standard_EXPORT CAM_Module* createModule()
787 return new SMESHGUI();
791 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
793 //=============================================================================
797 //=============================================================================
798 SMESHGUI::SMESHGUI() :
799 SalomeApp_Module( "SMESH" )
801 if ( CORBA::is_nil( myComponentSMESH ) )
803 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
804 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
805 myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
808 myActiveDialogBox = 0 ;
812 SMESH::GetFilterManager();
815 /* load resources for all available meshers */
816 SMESH::InitAvailableHypotheses();
819 //=============================================================================
823 //=============================================================================
824 SMESHGUI::~SMESHGUI()
826 SMESH::GetFilterManager()->Destroy();
827 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
830 //=============================================================================
834 //=============================================================================
835 SalomeApp_SelectionMgr* SMESHGUI::selectionMgr()
837 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
839 return dynamic_cast<SalomeApp_SelectionMgr*>( anApp->selectionMgr() );
844 bool SMESHGUI::automaticUpdate()
846 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
850 return resMgr->booleanValue( "SMESH", "auto_update", false );
853 //=============================================================================
857 //=============================================================================
858 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
860 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
863 //=============================================================================
867 //=============================================================================
868 SMESHGUI* SMESHGUI::GetSMESHGUI()
870 SMESHGUI* smeshMod = 0;
871 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
874 CAM_Module* module = app->module( "Mesh" );
875 smeshMod = dynamic_cast<SMESHGUI*>( module );
878 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
880 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
883 _PTR(Study) aStudy = study->studyDS();
885 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
894 Standard_EXPORT SMESHGUI* GetComponentGUI()
896 return SMESHGUI::GetSMESHGUI();
900 //=============================================================================
904 //=============================================================================
905 void SMESHGUI::SetState(int aState)
910 //=============================================================================
914 //=============================================================================
915 void SMESHGUI::ResetState()
920 //=============================================================================
924 //=============================================================================
925 void SMESHGUI::EmitSignalDeactivateDialog()
927 emit SignalDeactivateActiveDialog();
930 //=============================================================================
934 //=============================================================================
935 void SMESHGUI::EmitSignalStudyFrameChanged()
937 emit SignalStudyFrameChanged();
940 //=============================================================================
944 //=============================================================================
945 void SMESHGUI::EmitSignalCloseAllDialogs()
947 emit SignalCloseAllDialogs();
950 //=============================================================================
954 //=============================================================================
955 QDialog *SMESHGUI::GetActiveDialogBox()
957 return myActiveDialogBox;
960 //=============================================================================
964 //=============================================================================
965 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
967 myActiveDialogBox = (QDialog *) aDlg;
971 //=============================================================================
975 //=============================================================================
976 SUIT_Desktop* SMESHGUI::desktop()
978 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
980 return app->desktop();
985 //=============================================================================
989 //=============================================================================
990 SalomeApp_Study* SMESHGUI::activeStudy()
992 SUIT_Application* app = SUIT_Session::session()->activeApplication();
994 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
999 //=============================================================================
1003 //=============================================================================
1004 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1006 /* Here the position is on the bottom right corner - 10 */
1007 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1009 SUIT_Desktop *PP = desktop();
1010 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1011 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1015 //=============================================================================
1019 //=============================================================================
1020 static int isStudyLocked(_PTR(Study) theStudy){
1021 return theStudy->GetProperties()->IsLocked();
1024 static bool checkLock(_PTR(Study) theStudy) {
1025 if (isStudyLocked(theStudy)) {
1026 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1027 QObject::tr("WRN_WARNING"),
1028 QObject::tr("WRN_STUDY_LOCKED"),
1029 QObject::tr("BUT_OK") );
1035 //=======================================================================
1036 //function : CheckActiveStudyLocked
1038 //=======================================================================
1040 bool SMESHGUI::isActiveStudyLocked()
1042 _PTR(Study) aStudy = activeStudy()->studyDS();
1043 return checkLock( aStudy );
1046 //=============================================================================
1050 //=============================================================================
1051 bool SMESHGUI::OnGUIEvent( int theCommandID )
1053 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1057 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1058 SUIT_ResourceMgr* mgr = resourceMgr();
1062 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1063 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1065 //QAction* act = action( theCommandID );
1067 switch (theCommandID) {
1069 if(checkLock(aStudy)) break;
1077 if(checkLock(aStudy)) break;
1078 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1082 case 122: // EXPORT MED
1089 ::ExportMeshToFile(theCommandID);
1093 case 200: // SCALAR BAR
1095 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1096 SALOME_ListIO selected;
1098 aSel->selectedObjects( selected );
1100 if( selected.Extent() ) {
1101 Handle(SALOME_InteractiveObject) anIO = selected.First();
1102 if( anIO->hasEntry() ) {
1103 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1104 anActor->SetControlMode( SMESH_Actor::eNone );
1112 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1116 case 1134: // Clipping
1117 case 1133: // Tranparency
1118 case 1132: // Colors / Size
1125 ::SetDisplayMode(theCommandID);
1131 case 219: // Volumes
1132 case 220: // All Entity
1133 ::SetDisplayEntity(theCommandID);
1138 if(checkLock(aStudy)) break;
1139 SMESH::UpdateView();
1142 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1143 aSel->setSelectedObjects( l );
1148 case 301: // DISPLAY
1149 case 302: // DISPLAY ONLY
1151 SMESH::EDisplaing anAction;
1152 switch (theCommandID) {
1153 case 300: anAction = SMESH::eErase; break;
1154 case 301: anAction = SMESH::eDisplay; break;
1155 case 302: anAction = SMESH::eDisplayOnly; break;
1158 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1159 SALOME_ListIO sel_objects, to_process;
1161 aSel->selectedObjects( sel_objects );
1163 SALOME_ListIteratorOfListIO anIt( sel_objects );
1164 for( ; anIt.More(); anIt.Next() )
1166 Handle( SALOME_InteractiveObject ) obj = anIt.Value();
1167 if( obj->hasEntry() )
1169 _PTR(SObject) SO = activeStudy()->studyDS()->FindObjectID( obj->getEntry() );
1170 if( SO && QString( SO->GetID().c_str() ) == SO->GetFatherComponent()->GetID().c_str() )
1171 { //component is selected
1172 _PTR(SComponent) SC( SO->GetFatherComponent() );
1173 _PTR(ChildIterator) anIter ( activeStudy()->studyDS()->NewChildIterator( SC ) );
1174 anIter->InitEx( true );
1175 while( anIter->More() )
1177 _PTR(SObject) valSO ( anIter->Value() );
1178 _PTR(SObject) refSO;
1179 if( !valSO->ReferencedObject( refSO ) )
1181 QString id = valSO->GetID().c_str(),
1182 comp = SC->ComponentDataType().c_str(),
1183 val = valSO->GetName().c_str();
1185 Handle( SALOME_InteractiveObject ) new_obj =
1186 new SALOME_InteractiveObject( id.latin1(), comp.latin1(), val.latin1() );
1187 to_process.Append( new_obj );
1194 to_process.Append( obj );
1198 SALOME_ListIteratorOfListIO It( to_process );
1199 for (; It.More(); It.Next()) {
1200 Handle(SALOME_InteractiveObject) IOS = It.Value();
1201 if (IOS->hasEntry()) {
1202 SMESH::UpdateView(anAction, IOS->getEntry());
1203 if (anAction == SMESH::eDisplayOnly)
1204 anAction = SMESH::eDisplay;
1209 if (anAction == SMESH::eErase) {
1211 aSel->setSelectedObjects( l1 );
1214 aSel->setSelectedObjects( to_process );
1220 if(checkLock(aStudy)) break;
1223 EmitSignalDeactivateDialog();
1225 new SMESHGUI_NodesDlg(this);
1228 SUIT_MessageBox::warn1(desktop(),
1229 tr("SMESH_WRN_WARNING"),
1230 tr("SMESH_WRN_VIEWER_VTK"),
1231 tr("SMESH_BUT_OK"));
1236 case 2151: // FILTER
1240 EmitSignalDeactivateDialog();
1241 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1246 case 406: // MOVE NODE
1250 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1251 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1255 if(checkLock(aStudy)) break;
1256 new SMESHGUI_MoveNodesDlg(this);
1260 case 701: // COMPUTE MESH
1262 if(checkLock(aStudy)) break;
1264 SalomeApp_SelectionMgr *Sel = selectionMgr();
1265 SALOME_ListIO selected; Sel->selectedObjects( selected );
1267 int nbSel = selected.Extent();
1272 SMESH::SMESH_Mesh_var aMesh;
1273 SMESH::SMESH_subMesh_var aSubMesh;
1274 Handle(SALOME_InteractiveObject) IObject = selected.First();
1275 if (IObject->hasEntry()){
1276 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1277 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1278 if ( aShapeObject->_is_nil() ) {
1283 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1284 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1286 if (!aMesh->_is_nil()){
1287 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1288 if (!refShapeObject->_is_nil()) {
1289 if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1290 SUIT_MessageBox::warn1(desktop(),
1291 tr("SMESH_WRN_WARNING"),
1292 tr("SMESH_WRN_MISSING_PARAMETERS"),
1293 tr("SMESH_BUT_OK"));
1297 if (GetSMESHGen()->Compute(aMesh,refShapeObject))
1298 SMESH::ModifiedMesh(aMeshSObj,true);
1299 // TO Do : change icon of all submeshes
1301 SUIT_MessageBox::warn1(desktop(),
1302 tr("SMESH_WRN_WARNING"),
1303 tr("SMESH_WRN_COMPUTE_FAILED"),
1304 tr("SMESH_BUT_OK"));
1306 catch(const SALOME::SALOME_Exception & S_ex){
1307 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1310 }else if(!aSubMesh->_is_nil()){
1311 aMesh = aSubMesh->GetFather();
1312 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1313 if(!refShapeObject->_is_nil()){
1314 bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1316 SUIT_MessageBox::warn1(desktop(),
1317 tr("SMESH_WRN_WARNING"),
1318 tr("SMESH_WRN_MISSING_PARAMETERS"),
1319 tr("SMESH_BUT_OK"));
1323 if ( GetSMESHGen()->Compute(aMesh,refShapeObject) )
1324 SMESH::ModifiedMesh(aMeshSObj,true);
1325 // TO Do : change icon of all submeshes
1327 SUIT_MessageBox::warn1(desktop(),
1328 tr("SMESH_WRN_WARNING"),
1329 tr("SMESH_WRN_COMPUTE_FAILED"),
1330 tr("SMESH_BUT_OK"));
1331 }catch(const SALOME::SALOME_Exception & S_ex){
1332 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1338 CORBA::Long anId = aStudy->StudyId();
1339 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1340 if ( automaticUpdate() && aVisualObj){
1341 aVisualObj->Update();
1342 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1344 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1346 SMESH::DisplayActor(view,anActor); //apo
1350 SMESH::RepaintCurrentView();
1353 SUIT_MessageBox::warn1(desktop(),
1354 tr("SMESH_WRN_WARNING"),
1355 tr("SMESH_WRN_VIEWER_VTK"),
1356 tr("SMESH_BUT_OK"));
1362 case 702: // Create mesh
1363 startOperation( 702 );
1365 case 703: // Create sub-mesh
1366 startOperation( 703 );
1368 case 704: // Edit mesh/sub-mesh
1369 startOperation( 704 );
1371 case 407: // DIAGONAL INVERSION
1372 case 408: // Delete diagonal
1376 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1377 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1381 if ( checkLock( aStudy ) )
1384 /*Standard_Boolean aRes;
1385 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1386 if ( aMesh->_is_nil() )
1388 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1389 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1393 EmitSignalDeactivateDialog();
1394 if ( theCommandID == 407 )
1395 new SMESHGUI_TrianglesInversionDlg(this);
1397 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1400 case 409: // Change orientation
1401 case 410: // Union of triangles
1402 case 411: // Cutting of quadrangles
1406 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1407 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1411 if ( checkLock( aStudy ) )
1414 EmitSignalDeactivateDialog();
1415 SMESHGUI_MultiEditDlg* aDlg = NULL;
1416 if ( theCommandID == 409 )
1417 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1418 else if ( theCommandID == 410 )
1419 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1421 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1424 DefineDlgPosition( aDlg, x, y );
1429 case 412: // Smoothing
1431 if(checkLock(aStudy)) break;
1433 EmitSignalDeactivateDialog();
1434 new SMESHGUI_SmoothingDlg( this );
1437 SUIT_MessageBox::warn1(desktop(),
1438 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1439 tr("SMESH_BUT_OK"));
1443 case 413: // Extrusion
1445 if (checkLock(aStudy)) break;
1447 EmitSignalDeactivateDialog();
1448 new SMESHGUI_ExtrusionDlg ( this );
1450 SUIT_MessageBox::warn1(desktop(),
1451 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1452 tr("SMESH_BUT_OK"));
1456 case 414: // Revolution
1458 if(checkLock(aStudy)) break;
1460 EmitSignalDeactivateDialog();
1461 new SMESHGUI_RevolutionDlg( this );
1464 SUIT_MessageBox::warn1(desktop(),
1465 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1466 tr("SMESH_BUT_OK"));
1470 case 415: // Pattern mapping
1472 if ( checkLock( aStudy ) )
1476 EmitSignalDeactivateDialog();
1477 new SMESHGUI_MeshPatternDlg( this );
1480 SUIT_MessageBox::warn1(desktop(),
1481 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1482 tr("SMESH_BUT_OK"));
1486 case 416: // Extrusion along a path
1488 if (checkLock(aStudy)) break;
1490 EmitSignalDeactivateDialog();
1491 new SMESHGUI_ExtrusionAlongPathDlg( this );
1493 SUIT_MessageBox::warn1(desktop(),
1494 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1495 tr("SMESH_BUT_OK"));
1499 case 801: // CREATE GROUP
1503 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1504 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1508 if(checkLock(aStudy)) break;
1509 EmitSignalDeactivateDialog();
1510 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1512 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1513 SALOME_ListIO selected;
1515 aSel->selectedObjects( selected );
1517 int nbSel = selected.Extent();
1519 // check if mesh is selected
1520 aMesh = SMESH::GetMeshByIO( selected.First() );
1522 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1527 case 802: // CONSTRUCT GROUP
1531 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1532 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1536 if(checkLock(aStudy)) break;
1537 EmitSignalDeactivateDialog();
1539 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1540 SALOME_ListIO selected;
1542 aSel->selectedObjects( selected );
1544 int nbSel = selected.Extent();
1546 // check if submesh is selected
1547 Handle(SALOME_InteractiveObject) IObject = selected.First();
1548 if (IObject->hasEntry()) {
1549 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1551 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1552 if (!aSubMesh->_is_nil()) {
1554 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1555 // get submesh elements list by types
1556 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1557 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1558 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1559 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1560 // create group for each type o elements
1561 QString aName = IObject->getName();
1562 if (aNodes->length() > 0) {
1563 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1564 aGroup->Add(aNodes.inout());
1566 if (aEdges->length() > 0) {
1567 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1568 aGroup->Add(aEdges.inout());
1570 if (aFaces->length() > 0) {
1571 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1572 aGroup->Add(aFaces.inout());
1574 if (aVolumes->length() > 0) {
1575 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1576 aGroup->Add(aVolumes.inout());
1580 }catch(const SALOME::SALOME_Exception & S_ex){
1581 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1590 case 803: // EDIT GROUP
1594 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1595 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1599 if(checkLock(aStudy)) break;
1600 EmitSignalDeactivateDialog();
1602 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1603 SALOME_ListIO selected;
1605 aSel->selectedObjects( selected );
1607 SALOME_ListIteratorOfListIO It (selected);
1608 int nbSelectedGroups = 0;
1609 for ( ; It.More(); It.Next() )
1611 SMESH::SMESH_Group_var aGroup =
1612 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1613 if (!aGroup->_is_nil()) {
1615 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1619 if (nbSelectedGroups == 0)
1621 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil());
1627 case 804: // Add elements to group
1629 if(checkLock(aStudy)) break;
1630 if (myState == 800) {
1631 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1632 if (aDlg) aDlg->onAdd();
1637 case 805: // Remove elements from group
1639 if(checkLock(aStudy)) break;
1640 if (myState == 800) {
1641 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1642 if (aDlg) aDlg->onRemove();
1647 case 810: // Union Groups
1648 case 811: // Intersect groups
1649 case 812: // Cut groups
1653 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1654 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1658 if ( checkLock( aStudy ) )
1661 EmitSignalDeactivateDialog();
1664 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1665 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1666 else aMode = SMESHGUI_GroupOpDlg::CUT;
1668 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1672 case 813: // Delete groups with their contents
1676 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1677 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1681 if ( checkLock( aStudy ) )
1684 EmitSignalDeactivateDialog();
1686 new SMESHGUI_DeleteGroupDlg( this );
1690 case 900: // MESH INFOS
1692 EmitSignalDeactivateDialog();
1693 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1694 SALOME_ListIO selected;
1696 aSel->selectedObjects( selected );
1698 if ( selected.Extent() > 1 ) { // a dlg for each IO
1700 SALOME_ListIteratorOfListIO It (selected);
1701 for ( ; It.More(); It.Next() ) {
1702 IOs.Clear(); IOs.Append( It.Value() );
1703 aSel->setSelectedObjects( IOs );
1704 new SMESHGUI_MeshInfosDlg(this, "", false);
1706 // restore selection
1707 aSel->setSelectedObjects( selected );
1710 new SMESHGUI_MeshInfosDlg(this, "", false);
1714 case 902: // STANDARD MESH INFOS
1716 EmitSignalDeactivateDialog();
1717 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1718 SALOME_ListIO selected;
1720 aSel->selectedObjects( selected );
1722 if ( selected.Extent() > 1 ) { // a dlg for each IO
1724 SALOME_ListIteratorOfListIO It (selected);
1725 for ( ; It.More(); It.Next() ) {
1727 IOs.Append( It.Value() );
1728 aSel->setSelectedObjects( IOs );
1729 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1731 // restore selection
1732 aSel->setSelectedObjects( selected );
1735 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1739 case 1100: // EDIT HYPOTHESIS
1741 if(checkLock(aStudy)) break;
1743 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1744 SALOME_ListIO selected;
1746 aSel->selectedObjects( selected );
1748 int nbSel = selected.Extent();
1751 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1753 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1754 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1755 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1756 if ( !Hyp->_is_nil() )
1758 char* sName = Hyp->GetName();
1759 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1762 aCreator->EditHypothesis(Hyp);
1770 updateObjBrowser( true );
1774 case 1101: // RENAME
1776 if ( checkLock( aStudy ) )
1779 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1780 SALOME_ListIO selected;
1782 aSel->selectedObjects( selected );
1784 SALOME_ListIteratorOfListIO It( selected );
1785 for ( ; It.More(); It.Next() )
1787 Handle(SALOME_InteractiveObject) IObject = It.Value();
1788 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1789 _PTR(GenericAttribute) anAttr;
1790 _PTR(AttributeName) aName;
1793 if ( obj->FindAttribute(anAttr, "AttributeName") )
1796 QString newName = QString(aName->Value().c_str());
1797 newName = SalomeApp_NameDlg::getName( desktop(), newName );
1798 if ( !newName.isEmpty() )
1800 //old source: aStudy->renameIObject( IObject, newName );
1801 aName->SetValue( newName.latin1() );
1803 // if current object is group update group's name
1804 SMESH::SMESH_GroupBase_var aGroup =
1805 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1806 if (!aGroup->_is_nil() )
1807 aGroup->SetName( newName.latin1() );
1817 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1819 if(checkLock(aStudy)) break;
1820 SUIT_OverrideCursor wc;
1822 SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1823 SALOME_ListIO selected;
1825 aSel->selectedObjects( selected );
1827 SALOME_ListIteratorOfListIO It(selected);
1828 for (int i = 0; It.More(); It.Next(), i++) {
1829 Handle(SALOME_InteractiveObject) IObject = It.Value();
1830 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1833 aSel->setSelectedObjects( l1 );
1838 case 401: // GEOM::EDGE
1839 case 4021: // TRIANGLE
1841 case 4023: // POLYGON
1845 if(checkLock(aStudy)) break;
1847 EmitSignalDeactivateDialog();
1848 SMDSAbs_ElementType type = SMDSAbs_Edge;
1850 switch (theCommandID) {
1851 case 4021: // TRIANGLE
1852 type = SMDSAbs_Face; nbNodes = 3; break;
1854 type = SMDSAbs_Face; nbNodes = 4; break;
1856 type = SMDSAbs_Volume; nbNodes = 4; break;
1857 case 4023: // POLYGON
1858 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1860 type = SMDSAbs_Volume; nbNodes = 8; break;
1861 case 4033: // POLYHEDRE
1862 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1865 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1868 SUIT_MessageBox::warn1(desktop(),
1869 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1870 tr("SMESH_BUT_OK"));
1874 case 4033: // POLYHEDRON
1876 if(checkLock(aStudy)) break;
1878 EmitSignalDeactivateDialog();
1879 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1882 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1883 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1884 tr("SMESH_BUT_OK"));
1888 case 4041: // REMOVES NODES
1890 if(checkLock(aStudy)) break;
1892 EmitSignalDeactivateDialog();
1893 new SMESHGUI_RemoveNodesDlg(this);
1896 SUIT_MessageBox::warn1(desktop(),
1897 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1898 tr("SMESH_BUT_OK"));
1902 case 4042: // REMOVES ELEMENTS
1904 if(checkLock(aStudy)) break;
1906 EmitSignalDeactivateDialog();
1907 new SMESHGUI_RemoveElementsDlg(this);
1911 SUIT_MessageBox::warn1(desktop(),
1912 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1913 tr("SMESH_BUT_OK"));
1917 case 4051: // RENUMBERING NODES
1919 if(checkLock(aStudy)) break;
1921 EmitSignalDeactivateDialog();
1922 new SMESHGUI_RenumberingDlg( this, "", 0);
1926 SUIT_MessageBox::warn1(desktop(),
1927 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1928 tr("SMESH_BUT_OK"));
1932 case 4052: // RENUMBERING ELEMENTS
1934 if(checkLock(aStudy)) break;
1936 EmitSignalDeactivateDialog();
1937 new SMESHGUI_RenumberingDlg( this, "", 1);
1941 SUIT_MessageBox::warn1(desktop(),
1942 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1943 tr("SMESH_BUT_OK"));
1947 case 4061: // TRANSLATION
1949 if(checkLock(aStudy)) break;
1951 EmitSignalDeactivateDialog();
1952 new SMESHGUI_TranslationDlg( this );
1955 SUIT_MessageBox::warn1(desktop(),
1956 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1957 tr("SMESH_BUT_OK"));
1961 case 4062: // ROTATION
1963 if(checkLock(aStudy)) break;
1965 EmitSignalDeactivateDialog();
1966 new SMESHGUI_RotationDlg( this );
1969 SUIT_MessageBox::warn1(desktop(),
1970 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1971 tr("SMESH_BUT_OK"));
1975 case 4063: // SYMMETRY
1977 if(checkLock(aStudy)) break;
1979 EmitSignalDeactivateDialog();
1980 new SMESHGUI_SymmetryDlg( this );
1983 SUIT_MessageBox::warn1(desktop(),
1984 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1985 tr("SMESH_BUT_OK"));
1989 case 4064: // SEWING
1991 if(checkLock(aStudy)) break;
1993 EmitSignalDeactivateDialog();
1994 new SMESHGUI_SewingDlg( this );
1997 SUIT_MessageBox::warn1(desktop(),
1998 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1999 tr("SMESH_BUT_OK"));
2003 case 4065: // MERGE NODES
2005 if(checkLock(aStudy)) break;
2007 EmitSignalDeactivateDialog();
2008 new SMESHGUI_MergeNodesDlg( this );
2011 SUIT_MessageBox::warn1(desktop(),
2012 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2013 tr("SMESH_BUT_OK"));
2017 case 4066: // MERGE EQUAL ELEMENTS
2019 if (checkLock(aStudy)) break;
2021 EmitSignalDeactivateDialog();
2022 new SMESHGUI_EditMeshDlg(this,
2023 "SMESH_MERGE_ELEMENTS_TITLE",
2024 "ICON_DLG_MERGE_ELEMENTS",
2025 1); // MergeEqualElemets
2027 SUIT_MessageBox::warn1(desktop(),
2028 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2029 tr("SMESH_BUT_OK"));
2034 case 5105: // Library of selection filters
2036 static QValueList<int> aTypes;
2037 if ( aTypes.isEmpty() )
2039 aTypes.append( SMESH::NODE );
2040 aTypes.append( SMESH::EDGE );
2041 aTypes.append( SMESH::FACE );
2042 aTypes.append( SMESH::VOLUME );
2044 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2048 case 6017: // CONTROLS
2063 SalomeApp_SelectionMgr* mgr = selectionMgr();
2064 SALOME_ListIO selected; mgr->selectedObjects( selected );
2066 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2067 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2069 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2070 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2071 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2072 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2073 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2074 ::Control( theCommandID );
2079 SUIT_MessageBox::warn1(desktop(),
2080 tr( "SMESH_WRN_WARNING" ),
2081 tr( "SMESH_BAD_SELECTION" ),
2082 tr( "SMESH_BUT_OK" ) );
2086 SUIT_MessageBox::warn1(desktop(),
2087 tr( "SMESH_WRN_WARNING" ),
2088 tr( "NOT_A_VTK_VIEWER" ),
2089 tr( "SMESH_BUT_OK" ) );
2094 SalomeApp_SelectionMgr* mgr = selectionMgr();
2095 SALOME_ListIO selected; mgr->selectedObjects( selected );
2097 if (selected.Extent() == 1) {
2098 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2099 if(anIObject->hasEntry())
2100 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2101 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2108 SalomeApp_SelectionMgr* mgr = selectionMgr();
2109 SALOME_ListIO selected; mgr->selectedObjects( selected );
2111 if (selected.Extent() == 1) {
2112 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2113 if(anIObject->hasEntry())
2114 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2115 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2122 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2123 //updateObjBrowser();
2127 //=============================================================================
2131 //=============================================================================
2132 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2137 //=============================================================================
2141 //=============================================================================
2142 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2147 //=============================================================================
2151 //=============================================================================
2152 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2157 //=============================================================================
2158 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2159 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2161 //=============================================================================
2162 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2163 SUIT_ViewWindow* wnd )
2165 if(theIO->hasEntry()){
2166 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2167 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2171 //=======================================================================
2172 // function : createSMESHAction
2174 //=======================================================================
2175 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2178 QWidget* parent = application()->desktop();
2179 SUIT_ResourceMgr* resMgr = resourceMgr();
2181 if ( icon_id.length() )
2182 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2184 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2185 if ( !pix.isNull() )
2186 icon = QIconSet( pix );
2188 QString tooltip = tr( QString( "TOP_" )+po_id ),
2189 menu = tr( QString( "MEN_" )+po_id ),
2190 status_bar = tr( QString( "STB_" )+po_id );
2192 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2195 //=======================================================================
2196 // function : createPopupItem
2198 //=======================================================================
2199 void SMESHGUI::createPopupItem( const int id,
2200 const QString& clients,
2201 const QString& types,
2202 const QString& theRule,
2207 parentId = popupMgr()->actionId( action( pId ) );
2209 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2210 popupMgr()->insert( action( id ), parentId, 0 );
2212 QChar lc = QtxPopupMgr::Selection::defEquality();
2213 QString rule = "(%1) and (%2) and (%3)";
2214 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2215 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2216 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2219 bool cont = myRules.contains( id );
2221 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2223 popupMgr()->setRule( action( id ), rule, true );
2224 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2227 //=======================================================================
2228 // function : initialize
2230 //=======================================================================
2231 void SMESHGUI::initialize( CAM_Application* app )
2233 SalomeApp_Module::initialize( app );
2235 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2237 /* Automatic Update flag */
2238 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2240 // ----- create actions --------------
2242 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2243 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2244 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2245 createSMESHAction( 114, "NUM" );
2246 createSMESHAction( 121, "DAT" );
2247 createSMESHAction( 122, "MED" );
2248 createSMESHAction( 123, "UNV" );
2249 createSMESHAction( 124, "EXPORT_DAT" );
2250 createSMESHAction( 125, "EXPORT_MED" );
2251 createSMESHAction( 126, "EXPORT_UNV" );
2252 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2253 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2254 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2255 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2256 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2257 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2258 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2259 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2260 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2261 createSMESHAction( 804, "ADD" );
2262 createSMESHAction( 805, "REMOVE" );
2263 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2264 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2265 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2266 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2267 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2268 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2269 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2270 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2271 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2272 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2273 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2274 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2275 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2276 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2277 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2278 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2279 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2280 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2281 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2282 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2283 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2284 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2285 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2286 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2287 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2288 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2289 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2290 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2291 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2292 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2293 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2294 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2295 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2296 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2297 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2298 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2299 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2300 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2301 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2302 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2303 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2304 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2305 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2306 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2307 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2308 createSMESHAction( 415, "MAP", "ICON_MAP" );
2309 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2310 createSMESHAction( 200, "RESET" );
2311 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2312 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2313 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2314 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2315 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2316 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2317 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2318 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2319 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2320 createSMESHAction( 220, "ALL" );
2321 createSMESHAction( 1100, "EDIT_HYPO" );
2322 createSMESHAction( 1101, "RENAME" );
2323 createSMESHAction( 1102, "UNASSIGN" );
2324 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2325 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2326 createSMESHAction( 1131, "DISPMODE" );
2327 createSMESHAction( 1132, "COLORS" );
2328 createSMESHAction( 1133, "TRANSP" );
2329 createSMESHAction( 1134, "CLIP" );
2330 createSMESHAction( 1135, "DISP_ENT" );
2331 createSMESHAction( 2000, "CTRL" );
2333 createSMESHAction( 300, "ERASE" );
2334 createSMESHAction( 301, "DISPLAY" );
2335 createSMESHAction( 302, "DISPLAY_ONLY" );
2336 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2338 // ----- create menu --------------
2339 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2340 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2341 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2342 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2343 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2344 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2345 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2347 createMenu( separator(), fileId );
2349 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2350 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2351 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2352 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2353 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2354 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2356 createMenu( 111, importId, -1 );
2357 createMenu( 112, importId, -1 );
2358 createMenu( 113, importId, -1 );
2360 createMenu( 121, exportId, -1 );
2361 createMenu( 122, exportId, -1 );
2362 createMenu( 123, exportId, -1 );
2364 createMenu( separator(), fileId, 10 );
2366 createMenu( 33, editId, -1 );
2368 createMenu( 5105, toolsId, -1 );
2370 createMenu( 702, meshId, -1 );
2371 createMenu( 703, meshId, -1 );
2372 createMenu( 704, meshId, -1 );
2373 createMenu( separator(), meshId, -1 );
2374 createMenu( 701, meshId, -1 );
2375 createMenu( separator(), meshId, -1 );
2376 createMenu( 801, meshId, -1 );
2377 createMenu( 802, meshId, -1 );
2378 createMenu( 803, meshId, -1 );
2379 createMenu( separator(), meshId, -1 );
2380 createMenu( 810, meshId, -1 );
2381 createMenu( 811, meshId, -1 );
2382 createMenu( 812, meshId, -1 );
2383 createMenu( separator(), meshId, -1 );
2384 createMenu( 813, meshId, -1 );
2385 createMenu( separator(), meshId, -1 );
2386 createMenu( 900, meshId, -1 );
2387 createMenu( 902, meshId, -1 );
2388 createMenu( separator(), meshId, -1 );
2390 createMenu( 6003, ctrlId, -1 );
2391 createMenu( 6001, ctrlId, -1 );
2392 createMenu( 6004, ctrlId, -1 );
2393 createMenu( separator(), ctrlId, -1 );
2394 createMenu( 6002, ctrlId, -1 );
2395 createMenu( 6018, ctrlId, -1 );
2396 createMenu( 6019, ctrlId, -1 );
2397 createMenu( 6011, ctrlId, -1 );
2398 createMenu( 6012, ctrlId, -1 );
2399 createMenu( 6013, ctrlId, -1 );
2400 createMenu( 6014, ctrlId, -1 );
2401 createMenu( 6015, ctrlId, -1 );
2402 createMenu( 6016, ctrlId, -1 );
2403 createMenu( separator(), ctrlId, -1 );
2404 createMenu( 6017, ctrlId, -1 );
2405 createMenu( separator(), ctrlId, -1 );
2407 createMenu( 400, addId, -1 );
2408 createMenu( 401, addId, -1 );
2409 createMenu( 4021, addId, -1 );
2410 createMenu( 4022, addId, -1 );
2411 createMenu( 4023, addId, -1 );
2412 createMenu( 4031, addId, -1 );
2413 createMenu( 4032, addId, -1 );
2414 createMenu( 4033, addId, -1 );
2416 createMenu( 4041, removeId, -1 );
2417 createMenu( 4042, removeId, -1 );
2419 createMenu( 4051, renumId, -1 );
2420 createMenu( 4052, renumId, -1 );
2422 createMenu( 4061, transfId, -1 );
2423 createMenu( 4062, transfId, -1 );
2424 createMenu( 4063, transfId, -1 );
2425 createMenu( 4064, transfId, -1 );
2426 createMenu( 4065, transfId, -1 );
2427 createMenu( 4066, transfId, -1 );
2429 createMenu( 406, modifyId, -1 );
2430 createMenu( 407, modifyId, -1 );
2431 createMenu( 408, modifyId, -1 );
2432 createMenu( 409, modifyId, -1 );
2433 createMenu( 410, modifyId, -1 );
2434 createMenu( 411, modifyId, -1 );
2435 createMenu( 412, modifyId, -1 );
2436 createMenu( 413, modifyId, -1 );
2437 createMenu( 416, modifyId, -1 );
2438 createMenu( 414, modifyId, -1 );
2439 createMenu( 415, modifyId, -1 );
2441 createMenu( 214, viewId, -1 );
2443 // ----- create toolbars --------------
2444 int meshTb = createTool( tr( "TB_MESH" ) ),
2445 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2446 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2447 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2448 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2450 createTool( 702, meshTb );
2451 createTool( 703, meshTb );
2452 createTool( 704, meshTb );
2453 createTool( separator(), meshTb );
2454 createTool( 701, meshTb );
2455 createTool( separator(), meshTb );
2456 createTool( 801, meshTb );
2457 createTool( 802, meshTb );
2458 createTool( 803, meshTb );
2459 createTool( separator(), meshTb );
2460 createTool( 900, meshTb );
2461 createTool( 902, meshTb );
2462 createTool( separator(), meshTb );
2464 createTool( 6001, ctrlTb );
2465 createTool( 6003, ctrlTb );
2466 createTool( 6004, ctrlTb );
2467 createTool( separator(), ctrlTb );
2468 createTool( 6002, ctrlTb );
2469 createTool( 6018, ctrlTb );
2470 createTool( 6019, ctrlTb );
2471 createTool( 6011, ctrlTb );
2472 createTool( 6012, ctrlTb );
2473 createTool( 6013, ctrlTb );
2474 createTool( 6014, ctrlTb );
2475 createTool( 6015, ctrlTb );
2476 createTool( 6016, ctrlTb );
2477 createTool( separator(), ctrlTb );
2478 createTool( 6017, ctrlTb );
2479 createTool( separator(), ctrlTb );
2481 createTool( 400, addRemTb );
2482 createTool( 401, addRemTb );
2483 createTool( 4021, addRemTb );
2484 createTool( 4022, addRemTb );
2485 createTool( 4023, addRemTb );
2486 createTool( 4031, addRemTb );
2487 createTool( 4032, addRemTb );
2488 createTool( 4033, addRemTb );
2489 createTool( separator(), addRemTb );
2490 createTool( 4041, addRemTb );
2491 createTool( 4042, addRemTb );
2492 createTool( separator(), addRemTb );
2493 createTool( 4051, addRemTb );
2494 createTool( 4052, addRemTb );
2495 createTool( separator(), addRemTb );
2496 createTool( 4061, addRemTb );
2497 createTool( 4062, addRemTb );
2498 createTool( 4063, addRemTb );
2499 createTool( 4064, addRemTb );
2500 createTool( 4065, addRemTb );
2501 createTool( 4066, addRemTb );
2502 createTool( separator(), addRemTb );
2504 createTool( 406, modifyTb );
2505 createTool( 407, modifyTb );
2506 createTool( 408, modifyTb );
2507 createTool( 409, modifyTb );
2508 createTool( 410, modifyTb );
2509 createTool( 411, modifyTb );
2510 createTool( 412, modifyTb );
2511 createTool( 413, modifyTb );
2512 createTool( 416, modifyTb );
2513 createTool( 414, modifyTb );
2514 createTool( 415, modifyTb );
2516 createTool( 214, dispModeTb );
2520 QString OB = "'ObjectBrowser'",
2521 View = "'" + SVTK_Viewer::Type() + "'",
2523 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2524 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2525 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2526 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2527 elems = QString( "'%1' '%2' '%3' '%4' '%5'" ).
2528 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2529 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2530 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2531 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2532 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ),
2534 mesh_group = mesh + " " + subMesh + " " + group,
2535 hyp_alg = hypo + " " + algo;
2537 // popup for object browser
2539 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2540 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2541 createPopupItem( 803, OB, group ); // EDIT_GROUP
2542 popupMgr()->insert( separator(), -1, 0 );
2543 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2544 createPopupItem( 214, OB, mesh_group ); // UPDATE
2545 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2546 createPopupItem( 902, OB, mesh ); // STD_INFO
2547 popupMgr()->insert( separator(), -1, 0 );
2548 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2549 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2550 popupMgr()->insert( separator(), -1, 0 );
2551 createPopupItem( 1100, OB, hypo, "&& $hasReference={false}" ); // EDIT HYPOTHESIS
2552 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2553 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "&& $hasReference={false}" ); // RENAME
2554 popupMgr()->insert( separator(), -1, 0 );
2555 createPopupItem( 125, OB, mesh ); // EXPORT_MED
2556 createPopupItem( 126, OB, mesh ); // EXPORT_UNV
2557 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2558 popupMgr()->insert( separator(), -1, 0 );
2561 createPopupItem( 803, View, group ); // EDIT_GROUP
2562 createPopupItem( 804, View, elems ); // ADD
2563 createPopupItem( 805, View, elems ); // REMOVE
2564 popupMgr()->insert( separator(), -1, 0 );
2565 createPopupItem( 214, View, mesh_group ); // UPDATE
2566 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2567 createPopupItem( 902, View, mesh ); // STD_INFO
2568 popupMgr()->insert( separator(), -1, 0 );
2572 isInvisible("not( isVisible )"),
2573 isEmpty("numberOfNodes = 0"),
2574 isNotEmpty("numberOfNodes <> 0"),
2576 // has nodes, edges, etc in VISIBLE! actor
2577 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2578 hasElems("(count( elemTypes ) > 0)"),
2579 hasDifferentElems("(count( elemTypes ) > 1)"),
2580 hasEdges("({'Edge'} in elemTypes)"),
2581 hasFaces("({'Face'} in elemTypes)"),
2582 hasVolumes("({'Volume'} in elemTypes)");
2584 QString lc = QtxPopupMgr::Selection::defEquality();
2585 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2586 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2587 aType = aType.arg( mesh_group );
2588 QString aMeshInVTK = aClient + "&&" + aType;
2590 //-------------------------------------------------
2592 //-------------------------------------------------
2593 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2595 popupMgr()->insert( action( 9010 ), anId, -1 );
2596 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2597 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2599 popupMgr()->insert( action( 9011 ), anId, -1 );
2600 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2601 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2603 popupMgr()->insert( separator(), -1, -1 );
2605 //-------------------------------------------------
2607 //-------------------------------------------------
2608 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2610 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2611 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2612 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2614 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2615 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2616 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2618 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2619 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2620 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2622 popupMgr()->insert( separator(), anId, -1 );
2624 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2625 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2626 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2628 //-------------------------------------------------
2630 //-------------------------------------------------
2631 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2633 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2635 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2636 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2637 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2639 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2640 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2641 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2643 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2644 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2645 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2647 popupMgr()->insert( separator(), anId, -1 );
2649 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2650 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2652 //-------------------------------------------------
2654 //-------------------------------------------------
2655 popupMgr()->insert( action( 1132 ), -1, -1 );
2656 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2658 //-------------------------------------------------
2660 //-------------------------------------------------
2661 popupMgr()->insert( action( 1133 ), -1, -1 );
2662 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2664 //-------------------------------------------------
2666 //-------------------------------------------------
2667 popupMgr()->insert( action( 1134 ), -1, -1 );
2668 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2670 popupMgr()->insert( separator(), -1, -1 );
2672 //-------------------------------------------------
2674 //-------------------------------------------------
2676 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2677 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2678 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2680 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2682 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2683 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2685 popupMgr()->insert( separator(), anId, -1 );
2687 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2688 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2689 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2691 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2692 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2693 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2695 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2696 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2697 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2699 popupMgr()->insert( separator(), anId, -1 );
2701 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2702 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2703 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2705 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2706 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2707 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2709 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2710 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2711 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2713 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2714 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2715 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2717 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2718 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2719 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2721 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2722 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2723 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2725 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2726 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2727 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2729 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2730 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2731 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2733 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2734 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2735 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2737 popupMgr()->insert( separator(), anId, -1 );
2739 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2740 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2741 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2743 popupMgr()->insert( separator(), anId, -1 );
2745 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2746 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2748 popupMgr()->insert( separator(), -1, -1 );
2750 //-------------------------------------------------
2752 //-------------------------------------------------
2753 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2754 QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
2755 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2757 QString aRule = "type='Component' or (" + aClient + " and " + aType + " and " + aSelCount +
2758 " and " + anActiveVTK + " and " + isNotEmpty + " %1 )";
2759 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2760 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2762 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2763 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2765 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2766 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2768 popupMgr()->insert( separator(), -1, -1 );
2770 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
2771 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
2774 bool SMESHGUI::activateModule( SUIT_Study* study )
2776 bool res = SalomeApp_Module::activateModule( study );
2778 setMenuShown( true );
2779 setToolShown( true );
2784 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2786 setMenuShown( false );
2787 setToolShown( false );
2789 EmitSignalCloseAllDialogs();
2791 return SalomeApp_Module::deactivateModule( study );
2794 void SMESHGUI::OnGUIEvent()
2796 const QObject* obj = sender();
2797 if ( !obj || !obj->inherits( "QAction" ) )
2799 int id = actionId((QAction*)obj);
2804 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2806 if ( CORBA::is_nil( myComponentSMESH ) )
2808 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2809 return aGUI.myComponentSMESH;
2811 return myComponentSMESH;
2814 QString SMESHGUI::engineIOR() const
2816 CORBA::ORB_var anORB = getApp()->orb();
2817 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2821 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2823 SMESHGUI_Selection sel;
2824 sel.init( client, selectionMgr() );
2825 popupMgr()->updatePopup( menu, &sel );
2828 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2830 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2831 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2834 void SMESHGUI::viewManagers( QStringList& list ) const
2836 list.append( SVTK_Viewer::Type() );
2839 void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
2841 if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
2842 SMESH::UpdateSelectionProp( this );
2845 void SMESHGUI::createPreferences()
2847 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2849 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2850 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, SalomeApp_Preferences::Bool, "SMESH", "auto_update" );
2852 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2853 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "display_entity" );
2854 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, SalomeApp_Preferences::Bool, "SMESH", "use_precision" );
2856 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2857 setPreferenceProperty( precGroup, "columns", 1 );
2859 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2861 setPreferenceProperty( prec, "min", 0 );
2862 setPreferenceProperty( prec, "max", 16 );
2864 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2865 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, SalomeApp_Preferences::Selector, "SMESH", "display_mode" );
2867 modes.append( "Wireframe" );
2868 modes.append( "Shading" );
2869 modes.append( "Nodes" );
2870 modes.append( "Shrink" );
2871 QValueList<QVariant> indices;
2872 indices.append( 0 );
2873 indices.append( 1 );
2874 indices.append( 2 );
2875 indices.append( 3 );
2876 setPreferenceProperty( dispmode, "strings", modes );
2877 setPreferenceProperty( dispmode, "indexes", indices );
2879 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2880 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2882 addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" );
2883 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" );
2885 setPreferenceProperty( nodeSz, "min", 1 );
2886 setPreferenceProperty( nodeSz, "max", 5 );
2888 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2890 addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" );
2891 addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" );
2892 addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" );
2893 addPreference( "", elemGroup, SalomeApp_Preferences::Space );
2895 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" );
2896 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2898 setPreferenceProperty( elemW, "min", 1 );
2899 setPreferenceProperty( elemW, "max", 5 );
2901 setPreferenceProperty( shrink, "min", 0 );
2902 setPreferenceProperty( shrink, "max", 100 );
2904 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2906 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2908 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" );
2909 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" );
2910 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" );
2912 setPreferenceProperty( selW, "min", 1 );
2913 setPreferenceProperty( selW, "max", 5 );
2915 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2917 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" );
2918 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2920 setPreferenceProperty( preW, "min", 1 );
2921 setPreferenceProperty( preW, "max", 5 );
2923 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2925 addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" );
2926 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" );
2928 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2929 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2931 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2932 addPreference( tr( "SMESH_TITLE" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
2933 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
2934 addPreference( tr( "SMESH_LABELS" ), fontGr, SalomeApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
2937 fam.append( tr( "SMESH_FONT_ARIAL" ) );
2938 fam.append( tr( "SMESH_FONT_COURIER" ) );
2939 fam.append( tr( "SMESH_FONT_TIMES" ) );
2940 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2942 setPreferenceProperty( tfont, "families", fam );
2943 setPreferenceProperty( tfont, "system", false );
2944 setPreferenceProperty( tfont, "widget_flags", wflag );
2945 setPreferenceProperty( lfont, "families", fam );
2946 setPreferenceProperty( lfont, "system", false );
2947 setPreferenceProperty( lfont, "widget_flags", wflag );
2949 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
2951 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
2952 setPreferenceProperty( numcol, "min", 2 );
2953 setPreferenceProperty( numcol, "max", 256 );
2955 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
2956 setPreferenceProperty( numlab, "min", 2 );
2957 setPreferenceProperty( numlab, "max", 65 );
2959 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
2960 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
2961 QStringList orients;
2962 orients.append( tr( "SMESH_VERTICAL" ) );
2963 orients.append( tr( "SMESH_HORIZONTAL" ) );
2964 indices.clear(); indices.append( 0 ); indices.append( 1 );
2965 setPreferenceProperty( orient, "strings", orients );
2966 setPreferenceProperty( orient, "indexes", indices );
2968 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
2969 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
2970 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
2971 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
2972 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
2973 setPreferenceProperty( xv, "step", 0.1 );
2974 setPreferenceProperty( xv, "min", 0.0 );
2975 setPreferenceProperty( xv, "max", 1.0 );
2976 setPreferenceProperty( yv, "step", 0.1 );
2977 setPreferenceProperty( yv, "min", 0.0 );
2978 setPreferenceProperty( yv, "max", 1.0 );
2979 setPreferenceProperty( wv, "step", 0.1 );
2980 setPreferenceProperty( wv, "min", 0.0 );
2981 setPreferenceProperty( wv, "max", 1.0 );
2982 setPreferenceProperty( hv, "min", 0.0 );
2983 setPreferenceProperty( hv, "max", 1.0 );
2984 setPreferenceProperty( hv, "step", 0.1 );
2986 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
2987 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
2988 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
2989 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
2990 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
2991 setPreferenceProperty( xv, "min", 0.0 );
2992 setPreferenceProperty( xv, "max", 1.0 );
2993 setPreferenceProperty( xv, "step", 0.1 );
2994 setPreferenceProperty( xh, "min", 0.0 );
2995 setPreferenceProperty( xh, "max", 1.0 );
2996 setPreferenceProperty( xh, "step", 0.1 );
2997 setPreferenceProperty( yh, "min", 0.0 );
2998 setPreferenceProperty( yh, "max", 1.0 );
2999 setPreferenceProperty( yh, "step", 0.1 );
3000 setPreferenceProperty( wh, "min", 0.0 );
3001 setPreferenceProperty( wh, "max", 1.0 );
3002 setPreferenceProperty( wh, "step", 0.1 );
3003 setPreferenceProperty( hh, "min", 0.0 );
3004 setPreferenceProperty( hh, "max", 1.0 );
3005 setPreferenceProperty( hh, "step", 0.1 );
3008 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3012 //================================================================================
3014 * \brief Update something in accordance with update flags
3015 * \param theFlags - update flags
3017 * Update viewer or/and object browser etc. in accordance with update flags ( see
3018 * SalomeApp_UpdateFlags enumeration ).
3020 //================================================================================
3021 void SMESHGUI::update( const int flags )
3023 if ( flags & UF_Viewer | flags & UF_Forced )
3024 SMESH::UpdateView();
3026 SalomeApp_Module::update( flags );
3029 //================================================================================
3031 * \brief Set default selection mode
3033 * SLOT called when operation commited. Sets default selection mode
3035 //================================================================================
3036 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3038 SVTK_ViewWindow* vtkWnd =
3039 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3041 vtkWnd->SetSelectionMode( ActorSelection );
3044 //================================================================================
3046 * \brief Set default selection mode
3048 * SLOT called when operation aborted. Sets default selection mode
3050 //================================================================================
3051 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3053 SVTK_ViewWindow* vtkWnd =
3054 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3056 vtkWnd->SetSelectionMode( ActorSelection );
3059 //================================================================================
3061 * \brief Creates operation with given identifier
3062 * \param id - identifier of operation to be started
3063 * \return Pointer on created operation or NULL if operation is not created
3065 * Virtual method redefined from the base class creates operation with given id.
3066 * It is called called automatically from startOperation method of base class.
3068 //================================================================================
3069 SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
3071 SalomeApp_Operation* op = 0;
3072 // to do : create operation here
3075 case 702: // Create mesh
3076 op = new SMESHGUI_MeshOp( true, true );
3078 case 703: // Create sub-mesh
3079 op = new SMESHGUI_MeshOp( true, false );
3081 case 704: // Edit mesh/sub-mesh
3082 op = new SMESHGUI_MeshOp( false );
3089 op = SalomeApp_Module::createOperation( id );
3093 SalomeApp_Displayer* SMESHGUI::displayer()
3096 myDisplayer = new SMESHGUI_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );