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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESH_Client.hxx"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_WhatIsDlg.h"
39 #include "SMESHGUI_Preferences_ColorDlg.h"
40 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
41 #include "SMESHGUI_Preferences_SelectionDlg.h"
42 #include "SMESHGUI_Hypotheses.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_AddQuadraticElementDlg.h"
46 #include "SMESHGUI_FilterDlg.h"
47 #include "SMESHGUI_FilterLibraryDlg.h"
48 #include "SMESHGUI_SingleEditDlg.h"
49 #include "SMESHGUI_MultiEditDlg.h"
50 #include "SMESHGUI_GroupOpDlg.h"
51 #include "SMESHGUI_DeleteGroupDlg.h"
52 #include "SMESHGUI_SmoothingDlg.h"
53 #include "SMESHGUI_RenumberingDlg.h"
54 #include "SMESHGUI_ExtrusionDlg.h"
55 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
56 #include "SMESHGUI_RevolutionDlg.h"
57 #include "SMESHGUI_TranslationDlg.h"
58 #include "SMESHGUI_RotationDlg.h"
59 #include "SMESHGUI_SymmetryDlg.h"
60 #include "SMESHGUI_SewingDlg.h"
61 #include "SMESHGUI_EditMeshDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_Selection.h"
64 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
65 #include "SMESHGUI_ConvToQuadOp.h"
66 #include "SMESHGUI_MeshOp.h"
67 #include "SMESHGUI_Displayer.h"
68 #include "SMESHGUI_MakeNodeAtPointDlg.h"
69 #include "SMESHGUI_BuildCompoundDlg.h"
70 #include "SMESHGUI_ComputeDlg.h"
72 #include "SMESHGUI_Utils.h"
73 #include "SMESHGUI_GEOMGenUtils.h"
74 #include "SMESHGUI_MeshUtils.h"
75 #include "SMESHGUI_GroupUtils.h"
76 #include "SMESHGUI_FilterUtils.h"
77 #include "SMESHGUI_PatternUtils.h"
78 #include "SMESHGUI_VTKUtils.h"
79 #include "SMESHGUI_HypothesesUtils.h"
81 #include "SMESH_Actor.h"
82 #include "SMESH_Object.h"
83 #include "SMESH_TypeFilter.hxx"
85 #include "SalomeApp_Tools.h"
86 #include "SalomeApp_Study.h"
87 #include "SalomeApp_Application.h"
88 #include "SalomeApp_CheckFileDlg.h"
89 #include "SalomeApp_ImportOperation.h"
91 #include "LightApp_DataOwner.h"
92 #include "LightApp_Preferences.h"
93 #include "LightApp_VTKSelector.h"
94 #include "LightApp_Operation.h"
95 #include "LightApp_UpdateFlags.h"
96 #include "LightApp_NameDlg.h"
98 #include <SVTK_ViewWindow.h>
99 #include <SVTK_ViewModel.h>
100 #include <SVTK_InteractorStyle.h>
101 #include <SVTK_RenderWindowInteractor.h>
102 #include <SVTK_ViewManager.h>
104 #include "OB_Browser.h"
106 #include "SUIT_Tools.h"
107 #include "SUIT_MessageBox.h"
108 #include "SUIT_ResourceMgr.h"
109 #include "SUIT_FileDlg.h"
110 #include "SUIT_Desktop.h"
111 #include "SUIT_OverrideCursor.h"
112 #include "SUIT_Study.h"
113 #include "SUIT_Session.h"
115 #include "QtxPopupMgr.h"
117 #include "SALOME_ListIO.hxx"
118 #include "SALOME_ListIteratorOfListIO.hxx"
119 #include "SALOME_InteractiveObject.hxx"
120 #include "SALOME_NamingService.hxx"
121 #include "SALOME_LifeCycleCORBA.hxx"
123 #include "SALOMEconfig.h"
124 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
125 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
128 #define INCLUDE_MENUITEM_DEF
129 #include <qpopupmenu.h>
135 #include <boost/shared_ptr.hpp>
138 #include <vtkRenderer.h>
139 #include <vtkRenderWindow.h>
140 #include <vtkActorCollection.h>
141 #include <vtkScalarBarActor.h>
142 #include <vtkUnstructuredGrid.h>
144 #include "utilities.h"
146 #include "SALOMEDS_Study.hxx"
147 #include "SALOMEDSClient_StudyBuilder.hxx"
148 #include "SALOMEDSClient_SComponent.hxx"
150 #include <Standard_ErrorHandler.hxx>
156 //=============================================================
157 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
160 void ExportMeshToFile(int theCommandID);
162 void SetDisplayMode(int theCommandID);
164 void SetDisplayEntity(int theCommandID);
166 void Control( int theCommandID );
170 //=============================================================
171 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
177 if(theCommandID == 113){
178 filter.append(QObject::tr("MED files (*.med)"));
179 filter.append(QObject::tr("All files (*)"));
180 }else if (theCommandID == 112){
181 filter.append(QObject::tr("IDEAS files (*.unv)"));
182 }else if (theCommandID == 111){
183 filter.append(QObject::tr("DAT files (*.dat)"));
185 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
188 QObject::tr("Import mesh"),
190 if(!filename.isEmpty()) {
191 SUIT_OverrideCursor wc;
192 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
195 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
196 switch ( theCommandID ) {
199 aMeshes->length( 1 );
200 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
205 SMESH::DriverMED_ReadStatus res;
206 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
207 if ( res != SMESH::DRS_OK ) {
209 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
210 QObject::tr("SMESH_WRN_WARNING"),
211 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
212 QObject::tr("SMESH_BUT_OK"));
213 aMeshes->length( 0 );
220 bool isEmpty = false;
221 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
222 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
224 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
225 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
226 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
227 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
228 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
235 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
236 QObject::tr("SMESH_WRN_WARNING"),
237 QObject::tr("SMESH_DRS_EMPTY"),
238 QObject::tr("SMESH_BUT_OK"));
242 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
244 catch (const SALOME::SALOME_Exception& S_ex){
246 SalomeApp_Tools::QtCatchCorbaException(S_ex);
253 void ExportMeshToFile( int theCommandID )
255 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
256 SALOME_ListIO selected;
258 aSel->selectedObjects( selected );
260 if(selected.Extent()){
261 Handle(SALOME_InteractiveObject) anIObject = selected.First();
262 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
263 if ( !aMesh->_is_nil() ) {
264 QString aFilter, aTitle = QObject::tr("Export mesh");
265 QMap<QString, SMESH::MED_VERSION> aFilterMap;
266 QMap<QString, int> aFilterMapSTL;
267 switch ( theCommandID ) {
271 if (aMesh->HasDuplicatedGroupNamesMED()) {
272 int aRet = SUIT_MessageBox::warn2
273 (SMESHGUI::desktop(),
274 QObject::tr("SMESH_WRN_WARNING"),
275 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
276 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
282 QString v21( aMesh->GetVersionString( SMESH::MED_V2_1, 2));
283 QString v22( aMesh->GetVersionString( SMESH::MED_V2_2, 2));
284 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
285 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
290 aFilter = QObject::tr("DAT files (*.dat)");
295 if (aMesh->NbPyramids()) {
296 int aRet = SUIT_MessageBox::warn2
297 (SMESHGUI::desktop(),
298 QObject::tr("SMESH_WRN_WARNING"),
299 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
300 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
305 aFilter = QObject::tr("IDEAS files (*.unv)");
313 there must be check on others mesh elements not equal triangles
315 if (aMesh->NbTriangles() < 1) {
316 SUIT_MessageBox::warn1
317 (SMESHGUI::desktop(),
318 QObject::tr("SMESH_WRN_WARNING"),
319 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
320 QObject::tr("SMESH_BUT_OK"));
323 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
324 int aRet = SUIT_MessageBox::warn2
325 (SMESHGUI::desktop(),
326 QObject::tr("SMESH_WRN_WARNING"),
327 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
328 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
334 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
335 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
343 SMESH::MED_VERSION aFormat;
344 // Init the parameter with the default value
345 bool aIsASCII_STL = true;
346 bool toCreateGroups = false;
347 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
349 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
351 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
353 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
355 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
357 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
358 for ( ; it != aFilterMapSTL.end(); ++it )
359 filters.push_back( it.key() );
361 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
362 fd->setCaption( aTitle );
363 fd->setFilters( filters );
364 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
368 aFilename = fd->selectedFile();
369 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
376 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
377 for ( ; it != aFilterMap.end(); ++it )
378 filters.push_back( it.key() );
380 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
381 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
382 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
383 fd->setCaption( aTitle );
384 fd->setFilters( filters );
385 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
386 fd->SetChecked(toCreateGroups);
390 aFilename = fd->selectedFile();
391 aFormat = aFilterMap[fd->selectedFilter()];
393 if ( !aFilename.isEmpty()
394 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
395 && aFormat==SMESH::MED_V2_1) {
396 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
397 QObject::tr("SMESH_WRN_WARNING"),
398 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
399 QObject::tr("SMESH_BUT_YES"),
400 QObject::tr("SMESH_BUT_NO"),
407 toCreateGroups = fd->IsChecked();
410 if ( !aFilename.isEmpty() ) {
411 // Check whether the file already exists and delete it if yes
412 QFile aFile( aFilename );
413 if ( aFile.exists() )
415 SUIT_OverrideCursor wc;
418 bool Renumber = false ;
419 // PAL 14172 : Check of we have to renumber or not from the preferences before export
421 Renumber= resMgr->booleanValue("SMESH","renumbering");
423 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
424 aMeshEditor->RenumberNodes();
425 aMeshEditor->RenumberElements();
426 if ( SMESHGUI::automaticUpdate() )
429 switch ( theCommandID ) {
432 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
436 aMesh->ExportDAT( aFilename.latin1() );
440 aMesh->ExportUNV( aFilename.latin1() );
444 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
450 catch (const SALOME::SALOME_Exception& S_ex){
452 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
453 QObject::tr("SMESH_WRN_WARNING"),
454 QObject::tr("SMESH_EXPORT_FAILED"),
455 QObject::tr("SMESH_BUT_OK"));
463 inline void InverseEntityMode(unsigned int& theOutputMode,
464 unsigned int theMode)
466 bool anIsNotPresent = ~theOutputMode & theMode;
468 theOutputMode |= theMode;
470 theOutputMode &= ~theMode;
473 void SetDisplayEntity(int theCommandID){
474 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
475 SALOME_ListIO selected;
477 aSel->selectedObjects( selected );
479 if(selected.Extent() >= 1){
480 SALOME_ListIteratorOfListIO It( selected );
481 for(; It.More(); It.Next()){
482 Handle(SALOME_InteractiveObject) IObject = It.Value();
483 if(IObject->hasEntry()){
484 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
485 unsigned int aMode = anActor->GetEntityMode();
486 switch(theCommandID){
488 InverseEntityMode(aMode,SMESH_Actor::eEdges);
491 InverseEntityMode(aMode,SMESH_Actor::eFaces);
494 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
497 aMode = SMESH_Actor::eAllEntity;
501 anActor->SetEntityMode(aMode);
508 void SetDisplayMode(int theCommandID){
509 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
510 SALOME_ListIO selected;
512 aSel->selectedObjects( selected );
514 if(selected.Extent() >= 1){
515 switch(theCommandID){
517 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
518 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
522 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
523 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
526 SALOME_ListIteratorOfListIO It( selected );
527 for(; It.More(); It.Next()){
528 Handle(SALOME_InteractiveObject) IObject = It.Value();
529 if(IObject->hasEntry()){
530 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
531 switch(theCommandID){
533 anActor->SetRepresentation(SMESH_Actor::eEdge);
536 anActor->SetRepresentation(SMESH_Actor::eSurface);
539 if(anActor->IsShrunk())
542 anActor->SetShrink();
545 anActor->SetRepresentation(SMESH_Actor::ePoint);
548 vtkFloatingPointType color[3];
549 anActor->GetSufaceColor(color[0], color[1], color[2]);
550 int c0 = int (color[0] * 255);
551 int c1 = int (color[1] * 255);
552 int c2 = int (color[2] * 255);
553 QColor c(c0, c1, c2);
555 vtkFloatingPointType edgecolor[3];
556 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
557 c0 = int (edgecolor[0] * 255);
558 c1 = int (edgecolor[1] * 255);
559 c2 = int (edgecolor[2] * 255);
560 QColor e(c0, c1, c2);
562 vtkFloatingPointType backfacecolor[3];
563 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
564 c0 = int (backfacecolor[0] * 255);
565 c1 = int (backfacecolor[1] * 255);
566 c2 = int (backfacecolor[2] * 255);
567 QColor b(c0, c1, c2);
569 vtkFloatingPointType nodecolor[3];
570 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
571 c0 = int (nodecolor[0] * 255);
572 c1 = int (nodecolor[1] * 255);
573 c2 = int (nodecolor[2] * 255);
574 QColor n(c0, c1, c2);
576 int Edgewidth = (int)anActor->GetLineWidth();
579 int intValue = int(anActor->GetNodeSize());
580 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
582 SMESHGUI_Preferences_ColorDlg *aDlg =
583 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
584 aDlg->SetColor(1, c);
585 aDlg->SetColor(2, e);
586 aDlg->SetColor(3, n);
587 aDlg->SetColor(4, b);
588 aDlg->SetIntValue(1, Edgewidth);
589 aDlg->SetIntValue(2, intValue);
590 aDlg->SetIntValue(3, int(Shrink*100.));
592 QColor color = aDlg->GetColor(1);
593 QColor edgecolor = aDlg->GetColor(2);
594 QColor nodecolor = aDlg->GetColor(3);
595 QColor backfacecolor = aDlg->GetColor(4);
596 /* actor color and backface color */
597 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
598 vtkFloatingPointType (color.green()) / 255.,
599 vtkFloatingPointType (color.blue()) / 255.);
600 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
601 vtkFloatingPointType (backfacecolor.green()) / 255.,
602 vtkFloatingPointType (backfacecolor.blue()) / 255.);
605 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
606 vtkFloatingPointType (edgecolor.green()) / 255.,
607 vtkFloatingPointType (edgecolor.blue()) / 255.);
609 /* Shrink factor and size edges */
610 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
611 anActor->SetLineWidth(aDlg->GetIntValue(1));
613 /* Nodes color and size */
614 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
615 vtkFloatingPointType (nodecolor.green()) / 255.,
616 vtkFloatingPointType (nodecolor.blue()) / 255.);
617 anActor->SetNodeSize(aDlg->GetIntValue(2));
626 SMESH::RepaintCurrentView();
630 void Control( int theCommandID )
632 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
633 SALOME_ListIO selected;
635 aSel->selectedObjects( selected );
637 if( !selected.IsEmpty() ){
638 Handle(SALOME_InteractiveObject) anIO = selected.First();
641 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
642 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
643 switch ( theCommandID ){
645 aTitle = QObject::tr( "LENGTH_EDGES" );
646 aControl = SMESH_Actor::eLength;
649 aTitle = QObject::tr( "LENGTH2D_EDGES" );
650 aControl = SMESH_Actor::eLength2D;
653 aTitle = QObject::tr( "FREE_EDGES" );
654 aControl = SMESH_Actor::eFreeEdges;
657 aTitle = QObject::tr( "FREE_BORDERS" );
658 aControl = SMESH_Actor::eFreeBorders;
661 aTitle = QObject::tr( "MULTI_BORDERS" );
662 aControl = SMESH_Actor::eMultiConnection;
665 aTitle = QObject::tr( "MULTI2D_BORDERS" );
666 aControl = SMESH_Actor::eMultiConnection2D;
669 aTitle = QObject::tr( "AREA_ELEMENTS" );
670 aControl = SMESH_Actor::eArea;
673 aTitle = QObject::tr( "TAPER_ELEMENTS" );
674 aControl = SMESH_Actor::eTaper;
677 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
678 aControl = SMESH_Actor::eAspectRatio;
681 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
682 aControl = SMESH_Actor::eAspectRatio3D;
685 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
686 aControl = SMESH_Actor::eMinimumAngle;
689 aTitle = QObject::tr( "WARP_ELEMENTS" );
690 aControl = SMESH_Actor::eWarping;
693 aTitle = QObject::tr( "SKEW_ELEMENTS" );
694 aControl = SMESH_Actor::eSkew;
697 aTitle = QObject::tr( "SMESH_VOLUME" );
698 aControl = SMESH_Actor::eVolume3D;
701 anActor->SetControlMode(aControl);
702 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
703 SMESH::RepaintCurrentView();
710 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
711 MeshObjectType theType,
712 const QString theInTypeName,
713 QString & theOutTypeName)
715 SMESH_TypeFilter aTypeFilter( theType );
717 if( !theIO.IsNull() )
719 entry = theIO->getEntry();
720 LightApp_DataOwner owner( entry );
721 if ( aTypeFilter.isOk( &owner )) {
722 theOutTypeName = theInTypeName;
730 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
732 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
733 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
735 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
736 CORBA::String_var anID = aSComp->GetID().c_str();
737 if (!strcmp(anID.in(),theIO->getEntry()))
743 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
744 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
745 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
746 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
747 CheckOIType ( theIO, GROUP, "Group", aTypeName )
755 QString CheckHomogeneousSelection()
757 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
758 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
759 SALOME_ListIO selected;
761 aSel->selectedObjects( selected );
763 QString RefType = CheckTypeObject(selected.First());
764 SALOME_ListIteratorOfListIO It(selected);
765 for (; It.More(); It.Next())
767 Handle(SALOME_InteractiveObject) IObject = It.Value();
768 QString Type = CheckTypeObject(IObject);
769 if (Type.compare(RefType) != 0)
770 return "Heterogeneous Selection";
777 void SMESHGUI::OnEditDelete()
779 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
780 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
781 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
783 QString aParentComponent = QString::null;
784 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
786 QString cur = anIt.Value()->getComponentDataType();
787 if( aParentComponent.isNull() )
788 aParentComponent = cur;
789 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
790 aParentComponent = "";
793 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
794 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
795 QObject::tr("ERR_ERROR"),
796 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
797 QObject::tr("BUT_OK") );
800 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
801 if (SUIT_MessageBox::warn2
802 (SMESHGUI::desktop(),
803 QObject::tr("SMESH_WRN_WARNING"),
804 QObject::tr("SMESH_REALLY_DELETE"),
805 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
808 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
809 SUIT_ViewManager* vm = anApp->activeViewManager();
810 int nbSf = vm->getViewsCount();
812 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
813 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
814 _PTR(GenericAttribute) anAttr;
815 _PTR(AttributeIOR) anIOR;
817 SALOME_ListIteratorOfListIO It(selected);
819 aStudyBuilder->NewCommand(); // There is a transaction
820 for(; It.More(); It.Next()){ // loop on selected IO's
821 Handle(SALOME_InteractiveObject) IObject = It.Value();
822 if(IObject->hasEntry()) {
823 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
825 // disable removal of "SMESH" component object
826 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
828 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
832 // put the whole hierarchy of sub-objects of the selected SO into a list and
833 // then treat them all starting from the deepest objects (at list back)
835 list< _PTR(SObject) > listSO;
836 listSO.push_back( aSO );
837 list< _PTR(SObject) >::iterator itSO = listSO.begin();
838 for ( ; itSO != listSO.end(); ++itSO ) {
839 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
840 for (it->InitEx(false); it->More(); it->Next())
841 listSO.push_back( it->Value() );
844 // treat SO's in the list starting from the back
846 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
847 for ( ; ritSO != listSO.rend(); ++ritSO ) {
848 _PTR(SObject) SO = *ritSO;
850 string anEntry = SO->GetID();
852 /** Erase graphical object **/
853 if(SO->FindAttribute(anAttr, "AttributeIOR")){
854 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
855 for(int i = 0; i < nbSf; i++){
856 SUIT_ViewWindow *sf = aViews[i];
857 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
858 SMESH::RemoveActor(sf,anActor);
863 /** Remove an object from data structures **/
864 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
865 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
866 if ( !aGroup->_is_nil() ) { // DELETE GROUP
867 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
868 aMesh->RemoveGroup( aGroup );
870 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
871 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
872 aMesh->RemoveSubMesh( aSubMesh );
874 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
876 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
879 IObject = new SALOME_InteractiveObject
880 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
881 QString objType = CheckTypeObject(IObject);
882 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
883 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
884 aStudyBuilder->RemoveObjectWithChildren( SO );
886 else {// default action: remove SObject from the study
887 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
888 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
890 aStudyBuilder->RemoveObjectWithChildren( SO );
894 } /* listSO back loop */
895 } /* IObject->hasEntry() */
897 aStudyBuilder->CommitCommand();
899 /* Clear any previous selection */
901 aSel->setSelectedObjects( l1 );
903 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
908 Standard_EXPORT CAM_Module* createModule()
910 return new SMESHGUI();
914 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
916 //=============================================================================
920 //=============================================================================
921 SMESHGUI::SMESHGUI() :
922 SalomeApp_Module( "SMESH" )
924 if ( CORBA::is_nil( myComponentSMESH ) )
926 CORBA::Boolean anIsEmbeddedMode;
927 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
930 myActiveDialogBox = 0;
931 myFilterLibraryDlg = 0;
935 SMESH::GetFilterManager();
938 /* load resources for all available meshers */
939 SMESH::InitAvailableHypotheses();
942 //=============================================================================
946 //=============================================================================
947 SMESHGUI::~SMESHGUI()
949 SMESH::GetFilterManager()->Destroy();
950 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
953 //=============================================================================
957 //=============================================================================
958 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
960 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
962 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
967 bool SMESHGUI::automaticUpdate()
969 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
973 return resMgr->booleanValue( "SMESH", "auto_update", false );
976 //=============================================================================
980 //=============================================================================
981 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
983 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
986 //=============================================================================
990 //=============================================================================
991 SMESHGUI* SMESHGUI::GetSMESHGUI()
993 SMESHGUI* smeshMod = 0;
994 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
997 CAM_Module* module = app->module( "Mesh" );
998 smeshMod = dynamic_cast<SMESHGUI*>( module );
1001 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1003 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1006 _PTR(Study) aStudy = study->studyDS();
1008 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1017 Standard_EXPORT SMESHGUI* GetComponentGUI()
1019 return SMESHGUI::GetSMESHGUI();
1023 //=============================================================================
1027 //=============================================================================
1028 void SMESHGUI::SetState(int aState)
1033 //=============================================================================
1037 //=============================================================================
1038 void SMESHGUI::ResetState()
1043 //=============================================================================
1047 //=============================================================================
1048 void SMESHGUI::EmitSignalDeactivateDialog()
1050 emit SignalDeactivateActiveDialog();
1053 //=============================================================================
1057 //=============================================================================
1058 void SMESHGUI::EmitSignalStudyFrameChanged()
1060 emit SignalStudyFrameChanged();
1063 //=============================================================================
1067 //=============================================================================
1068 void SMESHGUI::EmitSignalCloseAllDialogs()
1070 emit SignalCloseAllDialogs();
1073 //=============================================================================
1077 //=============================================================================
1078 QDialog *SMESHGUI::GetActiveDialogBox()
1080 return myActiveDialogBox;
1083 //=============================================================================
1087 //=============================================================================
1088 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1090 myActiveDialogBox = (QDialog *) aDlg;
1094 //=============================================================================
1098 //=============================================================================
1099 SUIT_Desktop* SMESHGUI::desktop()
1101 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1103 return app->desktop();
1108 //=============================================================================
1112 //=============================================================================
1113 SalomeApp_Study* SMESHGUI::activeStudy()
1115 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1117 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1122 //=============================================================================
1126 //=============================================================================
1127 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1129 /* Here the position is on the bottom right corner - 10 */
1130 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1132 SUIT_Desktop *PP = desktop();
1133 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1134 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1138 //=============================================================================
1142 //=============================================================================
1143 static int isStudyLocked(_PTR(Study) theStudy){
1144 return theStudy->GetProperties()->IsLocked();
1147 static bool checkLock(_PTR(Study) theStudy) {
1148 if (isStudyLocked(theStudy)) {
1149 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1150 QObject::tr("WRN_WARNING"),
1151 QObject::tr("WRN_STUDY_LOCKED"),
1152 QObject::tr("BUT_OK") );
1158 //=======================================================================
1159 //function : CheckActiveStudyLocked
1161 //=======================================================================
1163 bool SMESHGUI::isActiveStudyLocked()
1165 _PTR(Study) aStudy = activeStudy()->studyDS();
1166 return checkLock( aStudy );
1169 //=============================================================================
1173 //=============================================================================
1174 bool SMESHGUI::OnGUIEvent( int theCommandID )
1176 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1180 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1181 SUIT_ResourceMgr* mgr = resourceMgr();
1185 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1186 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1189 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1190 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1192 //QAction* act = action( theCommandID );
1194 switch (theCommandID) {
1196 if(checkLock(aStudy)) break;
1204 if(checkLock(aStudy)) break;
1205 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1209 case 122: // EXPORT MED
1218 ::ExportMeshToFile(theCommandID);
1222 case 200: // SCALAR BAR
1224 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1225 SALOME_ListIO selected;
1227 aSel->selectedObjects( selected );
1229 if( selected.Extent() ) {
1230 Handle(SALOME_InteractiveObject) anIO = selected.First();
1231 if( anIO->hasEntry() ) {
1232 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1233 anActor->SetControlMode( SMESH_Actor::eNone );
1241 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1245 case 1134: // Clipping
1246 case 1133: // Tranparency
1247 case 1132: // Colors / Size
1254 ::SetDisplayMode(theCommandID);
1260 case 219: // Volumes
1261 case 220: // All Entity
1262 ::SetDisplayEntity(theCommandID);
1267 if(checkLock(aStudy)) break;
1269 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1272 SMESH::UpdateView();
1274 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1275 SMESH::OnVisuException();
1277 catch (...) { // PAL16774 (Crash after display of many groups)
1278 SMESH::OnVisuException();
1282 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1283 aSel->selectedObjects( l );
1284 aSel->setSelectedObjects( l );
1289 case 301: // DISPLAY
1290 case 302: // DISPLAY ONLY
1292 SMESH::EDisplaing anAction;
1293 switch (theCommandID) {
1294 case 300: anAction = SMESH::eErase; break;
1295 case 301: anAction = SMESH::eDisplay; break;
1296 case 302: anAction = SMESH::eDisplayOnly; break;
1299 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1300 SALOME_ListIO sel_objects, to_process;
1302 aSel->selectedObjects( sel_objects );
1304 if( theCommandID==302 )
1305 startOperation( myEraseAll );
1307 extractContainers( sel_objects, to_process );
1310 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1314 SALOME_ListIteratorOfListIO It( to_process );
1315 for (; It.More(); It.Next()) {
1316 Handle(SALOME_InteractiveObject) IOS = It.Value();
1317 if (IOS->hasEntry()) {
1318 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1319 break; // PAL16774 (Crash after display of many groups)
1320 if (anAction == SMESH::eDisplayOnly)
1321 anAction = SMESH::eDisplay;
1326 // PAL13338 + PAL15161 -->
1327 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1328 SMESH::UpdateView();
1329 // PAL13338 + PAL15161 <--
1331 catch (...) { // PAL16774 (Crash after display of many groups)
1332 SMESH::OnVisuException();
1335 if (anAction == SMESH::eErase) {
1337 aSel->setSelectedObjects( l1 );
1340 aSel->setSelectedObjects( to_process );
1347 if(checkLock(aStudy)) break;
1350 EmitSignalDeactivateDialog();
1352 new SMESHGUI_NodesDlg(this);
1355 SUIT_MessageBox::warn1(desktop(),
1356 tr("SMESH_WRN_WARNING"),
1357 tr("SMESH_WRN_VIEWER_VTK"),
1358 tr("SMESH_BUT_OK"));
1363 case 2151: // FILTER
1367 EmitSignalDeactivateDialog();
1368 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1373 case 406: // MOVE NODE
1377 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1378 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1382 if(checkLock(aStudy)) break;
1383 new SMESHGUI_MoveNodesDlg(this);
1387 case 701: // COMPUTE MESH
1389 if (checkLock(aStudy)) break;
1391 startOperation( 701 );
1395 case 702: // Create mesh
1396 startOperation( 702 );
1398 case 703: // Create sub-mesh
1399 startOperation( 703 );
1401 case 704: // Edit mesh/sub-mesh
1402 startOperation( 704 );
1404 case 710: // Build compound mesh
1406 if (checkLock(aStudy)) break;
1407 EmitSignalDeactivateDialog();
1408 new SMESHGUI_BuildCompoundDlg( this );
1411 case 407: // DIAGONAL INVERSION
1412 case 408: // Delete diagonal
1416 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1417 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1421 if ( checkLock( aStudy ) )
1424 /*Standard_Boolean aRes;
1425 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1426 if ( aMesh->_is_nil() )
1428 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1429 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1433 EmitSignalDeactivateDialog();
1434 if ( theCommandID == 407 )
1435 new SMESHGUI_TrianglesInversionDlg(this);
1437 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1440 case 409: // Change orientation
1441 case 410: // Union of triangles
1442 case 411: // Cutting of quadrangles
1446 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1447 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1451 if ( checkLock( aStudy ) )
1454 EmitSignalDeactivateDialog();
1455 SMESHGUI_MultiEditDlg* aDlg = NULL;
1456 if ( theCommandID == 409 )
1457 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1458 else if ( theCommandID == 410 )
1459 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1461 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1466 case 412: // Smoothing
1468 if(checkLock(aStudy)) break;
1470 EmitSignalDeactivateDialog();
1471 new SMESHGUI_SmoothingDlg( this );
1474 SUIT_MessageBox::warn1(desktop(),
1475 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1476 tr("SMESH_BUT_OK"));
1480 case 413: // Extrusion
1482 if (checkLock(aStudy)) break;
1484 EmitSignalDeactivateDialog();
1485 new SMESHGUI_ExtrusionDlg ( this );
1487 SUIT_MessageBox::warn1(desktop(),
1488 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1489 tr("SMESH_BUT_OK"));
1493 case 414: // Revolution
1495 if(checkLock(aStudy)) break;
1497 EmitSignalDeactivateDialog();
1498 new SMESHGUI_RevolutionDlg( this );
1501 SUIT_MessageBox::warn1(desktop(),
1502 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1503 tr("SMESH_BUT_OK"));
1507 case 415: // Pattern mapping
1509 if ( checkLock( aStudy ) )
1513 EmitSignalDeactivateDialog();
1514 new SMESHGUI_MeshPatternDlg( this );
1517 SUIT_MessageBox::warn1(desktop(),
1518 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1519 tr("SMESH_BUT_OK"));
1523 case 416: // Extrusion along a path
1525 if (checkLock(aStudy)) break;
1527 EmitSignalDeactivateDialog();
1528 new SMESHGUI_ExtrusionAlongPathDlg( this );
1530 SUIT_MessageBox::warn1(desktop(),
1531 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1532 tr("SMESH_BUT_OK"));
1536 case 417: // Convert mesh to quadratic
1538 startOperation( 417 );
1539 /* if (checkLock(aStudy)) break;
1541 EmitSignalDeactivateDialog();
1542 new SMESHGUI_ConvToQuadDlg();
1544 SUIT_MessageBox::warn1(desktop(),
1545 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1546 tr("SMESH_BUT_OK"));
1550 case 801: // CREATE GROUP
1554 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1555 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1559 if(checkLock(aStudy)) break;
1560 EmitSignalDeactivateDialog();
1561 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1563 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1564 SALOME_ListIO selected;
1566 aSel->selectedObjects( selected );
1568 int nbSel = selected.Extent();
1570 // check if mesh is selected
1571 aMesh = SMESH::GetMeshByIO( selected.First() );
1573 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1578 case 802: // CONSTRUCT GROUP
1582 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1583 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1587 if(checkLock(aStudy)) break;
1588 EmitSignalDeactivateDialog();
1590 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1591 SALOME_ListIO selected;
1593 aSel->selectedObjects( selected );
1595 int nbSel = selected.Extent();
1597 // check if submesh is selected
1598 Handle(SALOME_InteractiveObject) IObject = selected.First();
1599 if (IObject->hasEntry()) {
1600 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1602 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1603 if (!aSubMesh->_is_nil()) {
1605 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1606 // get submesh elements list by types
1607 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1608 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1609 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1610 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1611 // create group for each type o elements
1612 QString aName = IObject->getName();
1613 if (aNodes->length() > 0) {
1614 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1615 aGroup->Add(aNodes.inout());
1617 if (aEdges->length() > 0) {
1618 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1619 aGroup->Add(aEdges.inout());
1621 if (aFaces->length() > 0) {
1622 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1623 aGroup->Add(aFaces.inout());
1625 if (aVolumes->length() > 0) {
1626 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1627 aGroup->Add(aVolumes.inout());
1632 catch(const SALOME::SALOME_Exception & S_ex){
1633 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1640 SUIT_MessageBox::warn1(desktop(),
1641 tr("SMESH_WRN_WARNING"),
1642 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1643 tr("SMESH_BUT_OK"));
1648 case 803: // EDIT GROUP
1652 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1653 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1657 if(checkLock(aStudy)) break;
1658 EmitSignalDeactivateDialog();
1660 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1661 SALOME_ListIO selected;
1663 aSel->selectedObjects( selected );
1665 SALOME_ListIteratorOfListIO It (selected);
1666 int nbSelectedGroups = 0;
1667 for ( ; It.More(); It.Next() )
1669 SMESH::SMESH_GroupBase_var aGroup =
1670 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1671 if (!aGroup->_is_nil()) {
1673 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1677 if (nbSelectedGroups == 0)
1679 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1685 case 804: // Add elements to group
1687 if(checkLock(aStudy)) break;
1688 if (myState == 800) {
1689 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1690 if (aDlg) aDlg->onAdd();
1695 case 805: // Remove elements from group
1697 if(checkLock(aStudy)) break;
1698 if (myState == 800) {
1699 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1700 if (aDlg) aDlg->onRemove();
1705 case 810: // Union Groups
1706 case 811: // Intersect groups
1707 case 812: // Cut groups
1711 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1712 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1716 if ( checkLock( aStudy ) )
1719 EmitSignalDeactivateDialog();
1722 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1723 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1724 else aMode = SMESHGUI_GroupOpDlg::CUT;
1726 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1730 case 813: // Delete groups with their contents
1734 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1735 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1739 if ( checkLock( aStudy ) )
1742 EmitSignalDeactivateDialog();
1744 new SMESHGUI_DeleteGroupDlg( this );
1748 case 900: // MESH INFOS
1750 EmitSignalDeactivateDialog();
1751 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1752 SALOME_ListIO selected;
1754 aSel->selectedObjects( selected );
1756 if ( selected.Extent() > 1 ) { // a dlg for each IO
1758 SALOME_ListIteratorOfListIO It (selected);
1759 for ( ; It.More(); It.Next() ) {
1760 IOs.Clear(); IOs.Append( It.Value() );
1761 aSel->setSelectedObjects( IOs );
1762 new SMESHGUI_MeshInfosDlg(this, "", false);
1764 // restore selection
1765 aSel->setSelectedObjects( selected );
1768 new SMESHGUI_MeshInfosDlg(this, "", false);
1772 case 902: // STANDARD MESH INFOS
1774 EmitSignalDeactivateDialog();
1775 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1776 SALOME_ListIO selected;
1778 aSel->selectedObjects( selected );
1780 if ( selected.Extent() > 1 ) { // a dlg for each IO
1782 SALOME_ListIteratorOfListIO It (selected);
1783 for ( ; It.More(); It.Next() ) {
1785 IOs.Append( It.Value() );
1786 aSel->setSelectedObjects( IOs );
1787 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1789 // restore selection
1790 aSel->setSelectedObjects( selected );
1793 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1797 case 903: // WHAT IS
1799 EmitSignalDeactivateDialog();
1800 new SMESHGUI_WhatIsDlg( this, "", false);
1804 case 1100: // EDIT HYPOTHESIS
1806 if(checkLock(aStudy)) break;
1808 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1809 SALOME_ListIO selected;
1811 aSel->selectedObjects( selected );
1813 int nbSel = selected.Extent();
1816 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1817 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1819 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1820 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1821 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1822 if ( !aHypothesis->_is_nil() )
1824 CORBA::String_var aHypType = aHypothesis->GetName();
1825 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
1827 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1834 updateObjBrowser( true );
1838 case 1101: // RENAME
1840 if ( checkLock( aStudy ) )
1843 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1844 SALOME_ListIO selected;
1846 aSel->selectedObjects( selected );
1848 SALOME_ListIteratorOfListIO It( selected );
1849 for ( ; It.More(); It.Next() )
1851 Handle(SALOME_InteractiveObject) IObject = It.Value();
1852 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1853 _PTR(GenericAttribute) anAttr;
1854 _PTR(AttributeName) aName;
1857 if ( obj->FindAttribute(anAttr, "AttributeName") )
1860 QString newName = QString(aName->Value().c_str());
1861 newName = LightApp_NameDlg::getName(desktop(), newName);
1862 if ( !newName.isEmpty() )
1864 //old source: aStudy->renameIObject( IObject, newName );
1865 aName->SetValue( newName.latin1() );
1867 // if current object is group update group's name
1868 SMESH::SMESH_GroupBase_var aGroup =
1869 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1870 if (!aGroup->_is_nil() )
1871 aGroup->SetName( newName.latin1() );
1881 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1883 if(checkLock(aStudy)) break;
1884 SUIT_OverrideCursor wc;
1886 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1887 SALOME_ListIO selected;
1889 aSel->selectedObjects( selected, QString::null, false );
1891 SALOME_ListIteratorOfListIO It(selected);
1892 for (int i = 0; It.More(); It.Next(), i++) {
1893 Handle(SALOME_InteractiveObject) IObject = It.Value();
1894 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1897 aSel->setSelectedObjects( l1 );
1902 case 401: // GEOM::EDGE
1903 case 4021: // TRIANGLE
1905 case 4023: // POLYGON
1909 if(checkLock(aStudy)) break;
1911 EmitSignalDeactivateDialog();
1912 SMDSAbs_ElementType type = SMDSAbs_Edge;
1914 switch (theCommandID) {
1915 case 4021: // TRIANGLE
1916 type = SMDSAbs_Face; nbNodes = 3; break;
1918 type = SMDSAbs_Face; nbNodes = 4; break;
1920 type = SMDSAbs_Volume; nbNodes = 4; break;
1921 case 4023: // POLYGON
1922 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1924 type = SMDSAbs_Volume; nbNodes = 8; break;
1925 case 4033: // POLYHEDRE
1926 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1929 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1932 SUIT_MessageBox::warn1(desktop(),
1933 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1934 tr("SMESH_BUT_OK"));
1938 case 4033: // POLYHEDRON
1940 if(checkLock(aStudy)) break;
1942 EmitSignalDeactivateDialog();
1943 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1946 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1947 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1948 tr("SMESH_BUT_OK"));
1952 case 4034: // QUADRATIC EDGE
1953 case 4035: // QUADRATIC TRIANGLE
1954 case 4036: // QUADRATIC QUADRANGLE
1955 case 4037: // QUADRATIC TETRAHEDRON
1956 case 4038: // QUADRATIC PYRAMID
1957 case 4039: // QUADRATIC PENTAHEDRON
1958 case 4040: // QUADRATIC HEXAHEDRON
1960 if(checkLock(aStudy)) break;
1962 EmitSignalDeactivateDialog();
1965 switch (theCommandID) {
1967 type = QUAD_EDGE; break;
1969 type = QUAD_TRIANGLE; break;
1971 type = QUAD_QUADRANGLE; break;
1973 type = QUAD_TETRAHEDRON; break;
1975 type = QUAD_PYRAMID; break;
1977 type = QUAD_PENTAHEDRON; break;
1979 type = QUAD_HEXAHEDRON;
1983 new SMESHGUI_AddQuadraticElementDlg( this, type );
1986 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1987 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1988 tr("SMESH_BUT_OK"));
1992 case 4041: // REMOVES NODES
1994 if(checkLock(aStudy)) break;
1996 EmitSignalDeactivateDialog();
1997 new SMESHGUI_RemoveNodesDlg(this);
2000 SUIT_MessageBox::warn1(desktop(),
2001 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2002 tr("SMESH_BUT_OK"));
2006 case 4042: // REMOVES ELEMENTS
2008 if(checkLock(aStudy)) break;
2010 EmitSignalDeactivateDialog();
2011 new SMESHGUI_RemoveElementsDlg(this);
2015 SUIT_MessageBox::warn1(desktop(),
2016 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2017 tr("SMESH_BUT_OK"));
2021 case 4051: // RENUMBERING NODES
2023 if(checkLock(aStudy)) break;
2025 EmitSignalDeactivateDialog();
2026 new SMESHGUI_RenumberingDlg( this, "", 0);
2030 SUIT_MessageBox::warn1(desktop(),
2031 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2032 tr("SMESH_BUT_OK"));
2036 case 4052: // RENUMBERING ELEMENTS
2038 if(checkLock(aStudy)) break;
2040 EmitSignalDeactivateDialog();
2041 new SMESHGUI_RenumberingDlg( this, "", 1);
2045 SUIT_MessageBox::warn1(desktop(),
2046 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2047 tr("SMESH_BUT_OK"));
2051 case 4061: // TRANSLATION
2053 if(checkLock(aStudy)) break;
2055 EmitSignalDeactivateDialog();
2056 new SMESHGUI_TranslationDlg( this );
2059 SUIT_MessageBox::warn1(desktop(),
2060 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2061 tr("SMESH_BUT_OK"));
2065 case 4062: // ROTATION
2067 if(checkLock(aStudy)) break;
2069 EmitSignalDeactivateDialog();
2070 new SMESHGUI_RotationDlg( this );
2073 SUIT_MessageBox::warn1(desktop(),
2074 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2075 tr("SMESH_BUT_OK"));
2079 case 4063: // SYMMETRY
2081 if(checkLock(aStudy)) break;
2083 EmitSignalDeactivateDialog();
2084 new SMESHGUI_SymmetryDlg( this );
2087 SUIT_MessageBox::warn1(desktop(),
2088 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2089 tr("SMESH_BUT_OK"));
2093 case 4064: // SEWING
2095 if(checkLock(aStudy)) break;
2097 EmitSignalDeactivateDialog();
2098 new SMESHGUI_SewingDlg( this );
2101 SUIT_MessageBox::warn1(desktop(),
2102 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2103 tr("SMESH_BUT_OK"));
2107 case 4065: // MERGE NODES
2109 if(checkLock(aStudy)) break;
2111 EmitSignalDeactivateDialog();
2112 new SMESHGUI_EditMeshDlg( this, 0 );
2115 SUIT_MessageBox::warn1(desktop(),
2116 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2117 tr("SMESH_BUT_OK"));
2121 case 4066: // MERGE EQUAL ELEMENTS
2123 if (checkLock(aStudy)) break;
2125 EmitSignalDeactivateDialog();
2126 new SMESHGUI_EditMeshDlg( this, 1 );
2128 SUIT_MessageBox::warn1(desktop(),
2129 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2130 tr("SMESH_BUT_OK"));
2135 case 4067: // MAKE MESH PASS THROUGH POINT
2136 startOperation( 4067 );
2139 case 5105: // Library of selection filters
2141 static QValueList<int> aTypes;
2142 if ( aTypes.isEmpty() )
2144 aTypes.append( SMESH::NODE );
2145 aTypes.append( SMESH::EDGE );
2146 aTypes.append( SMESH::FACE );
2147 aTypes.append( SMESH::VOLUME );
2149 if (!myFilterLibraryDlg)
2150 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2151 else if (myFilterLibraryDlg->isHidden())
2152 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2153 myFilterLibraryDlg->raise();
2157 case 6017: // CONTROLS
2173 LightApp_SelectionMgr* mgr = selectionMgr();
2174 SALOME_ListIO selected; mgr->selectedObjects( selected );
2176 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2177 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2179 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2180 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2181 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2182 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2183 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2184 ::Control( theCommandID );
2189 SUIT_MessageBox::warn1(desktop(),
2190 tr( "SMESH_WRN_WARNING" ),
2191 tr( "SMESH_BAD_SELECTION" ),
2192 tr( "SMESH_BUT_OK" ) );
2196 SUIT_MessageBox::warn1(desktop(),
2197 tr( "SMESH_WRN_WARNING" ),
2198 tr( "NOT_A_VTK_VIEWER" ),
2199 tr( "SMESH_BUT_OK" ) );
2204 LightApp_SelectionMgr* mgr = selectionMgr();
2205 SALOME_ListIO selected; mgr->selectedObjects( selected );
2207 SALOME_ListIteratorOfListIO it(selected);
2208 for(; it.More(); it.Next()) {
2209 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2210 if(anIObject->hasEntry()) {
2211 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2212 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2220 LightApp_SelectionMgr* mgr = selectionMgr();
2221 SALOME_ListIO selected; mgr->selectedObjects( selected );
2223 if (selected.Extent() == 1) {
2224 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2225 if(anIObject->hasEntry())
2226 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2227 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2234 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2235 //updateObjBrowser();
2239 //=============================================================================
2243 //=============================================================================
2244 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2249 //=============================================================================
2253 //=============================================================================
2254 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2259 //=============================================================================
2263 //=============================================================================
2264 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2269 //=============================================================================
2270 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2271 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2273 //=============================================================================
2274 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2275 SUIT_ViewWindow* wnd )
2277 if(theIO->hasEntry()){
2278 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2279 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2283 //=======================================================================
2284 // function : createSMESHAction
2286 //=======================================================================
2287 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2290 QWidget* parent = application()->desktop();
2291 SUIT_ResourceMgr* resMgr = resourceMgr();
2293 if ( icon_id.length() )
2294 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2296 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2297 if ( !pix.isNull() )
2298 icon = QIconSet( pix );
2300 QString tooltip = tr( QString( "TOP_" )+po_id ),
2301 menu = tr( QString( "MEN_" )+po_id ),
2302 status_bar = tr( QString( "STB_" )+po_id );
2304 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2307 //=======================================================================
2308 // function : createPopupItem
2310 //=======================================================================
2311 void SMESHGUI::createPopupItem( const int id,
2312 const QString& clients,
2313 const QString& types,
2314 const QString& theRule,
2319 parentId = popupMgr()->actionId( action( pId ) );
2321 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2322 popupMgr()->insert( action( id ), parentId, 0 );
2324 QChar lc = QtxPopupMgr::Selection::defEquality();
2325 QString rule = "(%1) and (%2) and (%3)";
2326 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2327 if( clients.isEmpty() )
2328 rule = rule.arg( QString( "true" ) );
2330 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2331 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2334 bool cont = myRules.contains( id );
2336 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2338 popupMgr()->setRule( action( id ), rule, true );
2339 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2342 //=======================================================================
2343 // function : initialize
2345 //=======================================================================
2346 void SMESHGUI::initialize( CAM_Application* app )
2348 SalomeApp_Module::initialize( app );
2350 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2352 /* Automatic Update flag */
2353 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2355 // ----- create actions --------------
2357 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2358 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2359 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2360 createSMESHAction( 114, "NUM" );
2361 createSMESHAction( 121, "DAT" );
2362 createSMESHAction( 122, "MED" );
2363 createSMESHAction( 123, "UNV" );
2364 createSMESHAction( 140, "STL" );
2365 createSMESHAction( 124, "EXPORT_DAT" );
2366 createSMESHAction( 125, "EXPORT_MED" );
2367 createSMESHAction( 126, "EXPORT_UNV" );
2368 createSMESHAction( 141, "EXPORT_STL" );
2369 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2370 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2371 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2372 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2373 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2374 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2375 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2376 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2377 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2378 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2379 createSMESHAction( 804, "ADD" );
2380 createSMESHAction( 805, "REMOVE" );
2381 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2382 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2383 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2384 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2385 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2386 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2387 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2388 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2389 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2390 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2391 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2392 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2393 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2394 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2395 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2396 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2397 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2398 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2399 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2400 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2401 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2402 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2403 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2404 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2405 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2406 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2407 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2408 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2409 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2410 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2411 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2412 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2413 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2414 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2415 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2416 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2417 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2418 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2419 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2420 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2421 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2422 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2423 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2424 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2425 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2426 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2427 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2428 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2429 createSMESHAction( 415, "MAP", "ICON_MAP" );
2430 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2431 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2432 createSMESHAction( 200, "RESET" );
2433 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2434 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2435 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2436 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2437 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2438 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2439 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2440 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2441 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2442 createSMESHAction( 220, "ALL" );
2443 createSMESHAction( 1100, "EDIT_HYPO" );
2444 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2445 createSMESHAction( 1102, "UNASSIGN" );
2446 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2447 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2448 createSMESHAction( 1131, "DISPMODE" );
2449 createSMESHAction( 1132, "COLORS" );
2450 createSMESHAction( 1133, "TRANSP" );
2451 createSMESHAction( 1134, "CLIP" );
2452 createSMESHAction( 1135, "DISP_ENT" );
2453 createSMESHAction( 2000, "CTRL" );
2455 createSMESHAction( 300, "ERASE" );
2456 createSMESHAction( 301, "DISPLAY" );
2457 createSMESHAction( 302, "DISPLAY_ONLY" );
2458 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2459 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2460 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2461 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2462 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2463 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2464 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2465 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2467 // ----- create menu --------------
2468 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2469 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2470 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2471 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2472 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2473 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2474 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2476 createMenu( separator(), fileId );
2478 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2479 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2480 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2481 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2482 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2483 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2485 createMenu( 111, importId, -1 );
2486 createMenu( 112, importId, -1 );
2487 createMenu( 113, importId, -1 );
2489 createMenu( 121, exportId, -1 );
2490 createMenu( 122, exportId, -1 );
2491 createMenu( 123, exportId, -1 );
2492 createMenu( 140, exportId, -1 ); // export to stl STL
2494 createMenu( separator(), fileId, 10 );
2496 createMenu( 33, editId, -1 );
2498 createMenu( 5105, toolsId, -1 );
2500 createMenu( 702, meshId, -1 );
2501 createMenu( 703, meshId, -1 );
2502 createMenu( 704, meshId, -1 );
2503 createMenu( 710, meshId, -1 );
2504 createMenu( separator(), meshId, -1 );
2505 createMenu( 701, meshId, -1 );
2506 createMenu( separator(), meshId, -1 );
2507 createMenu( 801, meshId, -1 );
2508 createMenu( 802, meshId, -1 );
2509 createMenu( 803, meshId, -1 );
2510 createMenu( separator(), meshId, -1 );
2511 createMenu( 810, meshId, -1 );
2512 createMenu( 811, meshId, -1 );
2513 createMenu( 812, meshId, -1 );
2514 createMenu( separator(), meshId, -1 );
2515 createMenu( 813, meshId, -1 );
2516 createMenu( separator(), meshId, -1 );
2517 createMenu( 900, meshId, -1 );
2518 createMenu( 902, meshId, -1 );
2519 createMenu( 903, meshId, -1 );
2520 createMenu( separator(), meshId, -1 );
2522 createMenu( 6003, ctrlId, -1 );
2523 createMenu( 6001, ctrlId, -1 );
2524 createMenu( 6004, ctrlId, -1 );
2525 createMenu( separator(), ctrlId, -1 );
2526 createMenu( 6002, ctrlId, -1 );
2527 createMenu( 6018, ctrlId, -1 );
2528 createMenu( 6019, ctrlId, -1 );
2529 createMenu( 6011, ctrlId, -1 );
2530 createMenu( 6012, ctrlId, -1 );
2531 createMenu( 6013, ctrlId, -1 );
2532 createMenu( 6014, ctrlId, -1 );
2533 createMenu( 6015, ctrlId, -1 );
2534 createMenu( 6016, ctrlId, -1 );
2535 createMenu( separator(), ctrlId, -1 );
2536 createMenu( 6017, ctrlId, -1 );
2537 createMenu( 6009, ctrlId, -1 );
2538 createMenu( separator(), ctrlId, -1 );
2540 createMenu( 400, addId, -1 );
2541 createMenu( 401, addId, -1 );
2542 createMenu( 4021, addId, -1 );
2543 createMenu( 4022, addId, -1 );
2544 createMenu( 4023, addId, -1 );
2545 createMenu( 4031, addId, -1 );
2546 createMenu( 4032, addId, -1 );
2547 createMenu( 4033, addId, -1 );
2548 createMenu( separator(), addId, -1 );
2549 createMenu( 4034, addId, -1 );
2550 createMenu( 4035, addId, -1 );
2551 createMenu( 4036, addId, -1 );
2552 createMenu( 4037, addId, -1 );
2553 createMenu( 4038, addId, -1 );
2554 createMenu( 4039, addId, -1 );
2555 createMenu( 4040, addId, -1 );
2557 createMenu( 4041, removeId, -1 );
2558 createMenu( 4042, removeId, -1 );
2560 createMenu( 4051, renumId, -1 );
2561 createMenu( 4052, renumId, -1 );
2563 createMenu( 4061, transfId, -1 );
2564 createMenu( 4062, transfId, -1 );
2565 createMenu( 4063, transfId, -1 );
2566 createMenu( 4064, transfId, -1 );
2567 createMenu( 4065, transfId, -1 );
2568 createMenu( 4066, transfId, -1 );
2570 createMenu( 406, modifyId, -1 );
2571 createMenu( 4067,modifyId, -1 );
2572 createMenu( 407, modifyId, -1 );
2573 createMenu( 408, modifyId, -1 );
2574 createMenu( 409, modifyId, -1 );
2575 createMenu( 410, modifyId, -1 );
2576 createMenu( 411, modifyId, -1 );
2577 createMenu( 412, modifyId, -1 );
2578 createMenu( 413, modifyId, -1 );
2579 createMenu( 416, modifyId, -1 );
2580 createMenu( 414, modifyId, -1 );
2581 createMenu( 415, modifyId, -1 );
2582 createMenu( 417, modifyId, -1 );
2584 createMenu( 214, viewId, -1 );
2586 // ----- create toolbars --------------
2587 int meshTb = createTool( tr( "TB_MESH" ) ),
2588 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2589 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2590 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2591 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2593 createTool( 702, meshTb );
2594 createTool( 703, meshTb );
2595 createTool( 704, meshTb );
2596 createTool( 710, meshTb );
2597 createTool( separator(), meshTb );
2598 createTool( 701, meshTb );
2599 createTool( separator(), meshTb );
2600 createTool( 801, meshTb );
2601 createTool( 802, meshTb );
2602 createTool( 803, meshTb );
2603 createTool( separator(), meshTb );
2604 createTool( 900, meshTb );
2605 createTool( 902, meshTb );
2606 createTool( 903, meshTb );
2607 createTool( separator(), meshTb );
2609 createTool( 6001, ctrlTb );
2610 createTool( 6003, ctrlTb );
2611 createTool( 6004, ctrlTb );
2612 createTool( separator(), ctrlTb );
2613 createTool( 6002, ctrlTb );
2614 createTool( 6018, ctrlTb );
2615 createTool( 6019, ctrlTb );
2616 createTool( 6011, ctrlTb );
2617 createTool( 6012, ctrlTb );
2618 createTool( 6013, ctrlTb );
2619 createTool( 6014, ctrlTb );
2620 createTool( 6015, ctrlTb );
2621 createTool( 6016, ctrlTb );
2622 createTool( separator(), ctrlTb );
2623 createTool( 6017, ctrlTb );
2624 createTool( 6009, ctrlTb );
2625 createTool( separator(), ctrlTb );
2627 createTool( 400, addRemTb );
2628 createTool( 401, addRemTb );
2629 createTool( 4021, addRemTb );
2630 createTool( 4022, addRemTb );
2631 createTool( 4023, addRemTb );
2632 createTool( 4031, addRemTb );
2633 createTool( 4032, addRemTb );
2634 createTool( 4033, addRemTb );
2635 createTool( separator(), addRemTb );
2636 createTool( 4034, addRemTb );
2637 createTool( 4035, addRemTb );
2638 createTool( 4036, addRemTb );
2639 createTool( 4037, addRemTb );
2640 createTool( 4038, addRemTb );
2641 createTool( 4039, addRemTb );
2642 createTool( 4040, addRemTb );
2643 createTool( separator(), addRemTb );
2644 createTool( 4041, addRemTb );
2645 createTool( 4042, addRemTb );
2646 createTool( separator(), addRemTb );
2647 createTool( 4051, addRemTb );
2648 createTool( 4052, addRemTb );
2649 createTool( separator(), addRemTb );
2650 createTool( 4061, addRemTb );
2651 createTool( 4062, addRemTb );
2652 createTool( 4063, addRemTb );
2653 createTool( 4064, addRemTb );
2654 createTool( 4065, addRemTb );
2655 createTool( 4066, addRemTb );
2656 createTool( separator(), addRemTb );
2658 createTool( 406, modifyTb );
2659 createTool( 4067,modifyTb );
2660 createTool( 407, modifyTb );
2661 createTool( 408, modifyTb );
2662 createTool( 409, modifyTb );
2663 createTool( 410, modifyTb );
2664 createTool( 411, modifyTb );
2665 createTool( 412, modifyTb );
2666 createTool( 413, modifyTb );
2667 createTool( 416, modifyTb );
2668 createTool( 414, modifyTb );
2669 createTool( 415, modifyTb );
2670 createTool( 417, modifyTb );
2672 createTool( 214, dispModeTb );
2676 QString OB = "'ObjectBrowser'",
2677 View = "'" + SVTK_Viewer::Type() + "'",
2679 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2680 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2681 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2682 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2683 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2684 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2685 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2686 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2687 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2688 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2689 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2691 mesh_group = mesh + " " + subMesh + " " + group,
2692 hyp_alg = hypo + " " + algo;
2694 // popup for object browser
2696 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2697 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2698 createPopupItem( 803, OB, group ); // EDIT_GROUP
2699 popupMgr()->insert( separator(), -1, 0 );
2700 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2701 createPopupItem( 214, OB, mesh_group ); // UPDATE
2702 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2703 createPopupItem( 902, OB, mesh ); // STD_INFO
2704 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2705 popupMgr()->insert( separator(), -1, 0 );
2706 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2707 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2708 popupMgr()->insert( separator(), -1, 0 );
2709 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2710 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2711 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2712 popupMgr()->insert( separator(), -1, 0 );
2714 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2715 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2716 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2717 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2718 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2719 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2720 popupMgr()->insert( separator(), -1, 0 );
2723 createPopupItem( 803, View, group ); // EDIT_GROUP
2724 createPopupItem( 804, View, elems ); // ADD
2725 createPopupItem( 805, View, elems ); // REMOVE
2726 popupMgr()->insert( separator(), -1, 0 );
2727 createPopupItem( 214, View, mesh_group ); // UPDATE
2728 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2729 createPopupItem( 902, View, mesh ); // STD_INFO
2730 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2731 popupMgr()->insert( separator(), -1, 0 );
2735 isInvisible("not( isVisible )"),
2736 isEmpty("numberOfNodes = 0"),
2737 isNotEmpty("numberOfNodes <> 0"),
2739 // has nodes, edges, etc in VISIBLE! actor
2740 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2741 hasElems("(count( elemTypes ) > 0)"),
2742 hasDifferentElems("(count( elemTypes ) > 1)"),
2743 hasEdges("({'Edge'} in elemTypes)"),
2744 hasFaces("({'Face'} in elemTypes)"),
2745 hasVolumes("({'Volume'} in elemTypes)");
2747 QString lc = QtxPopupMgr::Selection::defEquality();
2748 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2749 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2750 aType = aType.arg( mesh_group );
2751 QString aMeshInVTK = aClient + "&&" + aType;
2753 //-------------------------------------------------
2755 //-------------------------------------------------
2756 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2758 popupMgr()->insert( action( 9010 ), anId, -1 );
2759 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2760 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2762 popupMgr()->insert( action( 9011 ), anId, -1 );
2763 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2764 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2766 popupMgr()->insert( separator(), -1, -1 );
2768 //-------------------------------------------------
2770 //-------------------------------------------------
2771 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2773 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2774 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2775 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2777 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2778 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2779 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2781 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2782 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2783 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2785 popupMgr()->insert( separator(), anId, -1 );
2787 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2788 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2789 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2791 //-------------------------------------------------
2793 //-------------------------------------------------
2794 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2796 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2798 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2799 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2800 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2802 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2803 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2804 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2806 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2807 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2808 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2810 popupMgr()->insert( separator(), anId, -1 );
2812 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2813 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2815 //-------------------------------------------------
2817 //-------------------------------------------------
2818 popupMgr()->insert( action( 1132 ), -1, -1 );
2819 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2821 //-------------------------------------------------
2823 //-------------------------------------------------
2824 popupMgr()->insert( action( 1133 ), -1, -1 );
2825 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2827 //-------------------------------------------------
2829 //-------------------------------------------------
2830 popupMgr()->insert( action( 1134 ), -1, -1 );
2831 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2833 popupMgr()->insert( separator(), -1, -1 );
2835 //-------------------------------------------------
2837 //-------------------------------------------------
2839 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2840 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2841 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2843 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2845 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2846 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2848 popupMgr()->insert( separator(), anId, -1 );
2850 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2851 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2852 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2854 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2855 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2856 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2858 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2859 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2860 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2862 popupMgr()->insert( separator(), anId, -1 );
2864 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2865 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2866 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2868 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2869 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2870 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2872 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2873 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2874 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2876 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2877 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2878 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2880 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2881 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2882 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2884 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2885 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2886 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2888 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2889 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2890 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2892 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2893 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2894 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2896 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2897 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2898 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2900 popupMgr()->insert( separator(), anId, -1 );
2902 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2903 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2904 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2906 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2907 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2908 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2910 popupMgr()->insert( separator(), anId, -1 );
2912 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2913 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2915 popupMgr()->insert( separator(), -1, -1 );
2917 //-------------------------------------------------
2919 //-------------------------------------------------
2920 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2921 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2922 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2924 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2925 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2926 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2927 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2929 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2930 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2932 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2933 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2935 popupMgr()->insert( separator(), -1, -1 );
2937 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2938 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2941 bool SMESHGUI::activateModule( SUIT_Study* study )
2943 bool res = SalomeApp_Module::activateModule( study );
2945 setMenuShown( true );
2946 setToolShown( true );
2948 // Reset actions accelerator keys
2949 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
2950 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
2951 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
2956 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2958 setMenuShown( false );
2959 setToolShown( false );
2961 EmitSignalCloseAllDialogs();
2963 // Unset actions accelerator keys
2964 action(111)->setAccel(QKeySequence()); // Import DAT
2965 action(112)->setAccel(QKeySequence()); // Import UNV
2966 action(113)->setAccel(QKeySequence()); // Import MED
2968 return SalomeApp_Module::deactivateModule( study );
2971 void SMESHGUI::studyClosed( SUIT_Study* s )
2973 SMESH::RemoveVisuData( s->id() );
2974 SalomeApp_Module::studyClosed( s );
2977 void SMESHGUI::OnGUIEvent()
2979 const QObject* obj = sender();
2980 if ( !obj || !obj->inherits( "QAction" ) )
2982 int id = actionId((QAction*)obj);
2987 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2989 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2990 if ( CORBA::is_nil( myComponentSMESH ) )
2992 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2994 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2995 return aGUI.myComponentSMESH;
2998 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2999 return myComponentSMESH;
3002 QString SMESHGUI::engineIOR() const
3004 CORBA::ORB_var anORB = getApp()->orb();
3005 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3009 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3011 SMESHGUI_Selection sel;
3012 sel.init( client, selectionMgr() );
3013 popupMgr()->updatePopup( menu, &sel );
3016 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3018 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3019 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3022 void SMESHGUI::viewManagers( QStringList& list ) const
3024 list.append( SVTK_Viewer::Type() );
3027 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3029 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3030 SMESH::UpdateSelectionProp( this );
3033 void SMESHGUI::createPreferences()
3035 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3037 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3038 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3040 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3041 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3042 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3044 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3045 setPreferenceProperty( precGroup, "columns", 1 );
3047 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3049 setPreferenceProperty( prec, "min", 0 );
3050 setPreferenceProperty( prec, "max", 16 );
3052 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3053 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3055 modes.append( "Wireframe" );
3056 modes.append( "Shading" );
3057 modes.append( "Nodes" );
3058 modes.append( "Shrink" );
3059 QValueList<QVariant> indices;
3060 indices.append( 0 );
3061 indices.append( 1 );
3062 indices.append( 2 );
3063 indices.append( 3 );
3064 setPreferenceProperty( dispmode, "strings", modes );
3065 setPreferenceProperty( dispmode, "indexes", indices );
3067 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3068 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3069 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3071 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3072 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3074 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3075 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3077 setPreferenceProperty( nodeSz, "min", 1 );
3078 setPreferenceProperty( nodeSz, "max", 5 );
3080 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3082 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3083 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3084 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3085 addPreference( "", elemGroup, LightApp_Preferences::Space );
3087 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3088 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3090 setPreferenceProperty( elemW, "min", 1 );
3091 setPreferenceProperty( elemW, "max", 5 );
3093 setPreferenceProperty( shrink, "min", 0 );
3094 setPreferenceProperty( shrink, "max", 100 );
3096 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3098 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3100 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3101 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3102 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3104 setPreferenceProperty( selW, "min", 1 );
3105 setPreferenceProperty( selW, "max", 5 );
3107 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3109 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3110 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3112 setPreferenceProperty( preW, "min", 1 );
3113 setPreferenceProperty( preW, "max", 5 );
3115 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3117 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3118 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3119 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3121 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3122 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3124 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3125 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3126 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3127 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3130 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3131 fam.append( tr( "SMESH_FONT_COURIER" ) );
3132 fam.append( tr( "SMESH_FONT_TIMES" ) );
3133 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3135 setPreferenceProperty( tfont, "families", fam );
3136 setPreferenceProperty( tfont, "system", false );
3137 setPreferenceProperty( tfont, "widget_flags", wflag );
3138 setPreferenceProperty( lfont, "families", fam );
3139 setPreferenceProperty( lfont, "system", false );
3140 setPreferenceProperty( lfont, "widget_flags", wflag );
3142 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3144 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3145 setPreferenceProperty( numcol, "min", 2 );
3146 setPreferenceProperty( numcol, "max", 256 );
3148 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3149 setPreferenceProperty( numlab, "min", 2 );
3150 setPreferenceProperty( numlab, "max", 65 );
3152 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3153 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3154 QStringList orients;
3155 orients.append( tr( "SMESH_VERTICAL" ) );
3156 orients.append( tr( "SMESH_HORIZONTAL" ) );
3157 indices.clear(); indices.append( 0 ); indices.append( 1 );
3158 setPreferenceProperty( orient, "strings", orients );
3159 setPreferenceProperty( orient, "indexes", indices );
3161 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3162 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3163 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3164 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3165 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3166 setPreferenceProperty( xv, "step", 0.1 );
3167 setPreferenceProperty( xv, "min", 0.0 );
3168 setPreferenceProperty( xv, "max", 1.0 );
3169 setPreferenceProperty( yv, "step", 0.1 );
3170 setPreferenceProperty( yv, "min", 0.0 );
3171 setPreferenceProperty( yv, "max", 1.0 );
3172 setPreferenceProperty( wv, "step", 0.1 );
3173 setPreferenceProperty( wv, "min", 0.0 );
3174 setPreferenceProperty( wv, "max", 1.0 );
3175 setPreferenceProperty( hv, "min", 0.0 );
3176 setPreferenceProperty( hv, "max", 1.0 );
3177 setPreferenceProperty( hv, "step", 0.1 );
3179 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3180 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3181 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3182 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3183 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3184 setPreferenceProperty( xv, "min", 0.0 );
3185 setPreferenceProperty( xv, "max", 1.0 );
3186 setPreferenceProperty( xv, "step", 0.1 );
3187 setPreferenceProperty( xh, "min", 0.0 );
3188 setPreferenceProperty( xh, "max", 1.0 );
3189 setPreferenceProperty( xh, "step", 0.1 );
3190 setPreferenceProperty( yh, "min", 0.0 );
3191 setPreferenceProperty( yh, "max", 1.0 );
3192 setPreferenceProperty( yh, "step", 0.1 );
3193 setPreferenceProperty( wh, "min", 0.0 );
3194 setPreferenceProperty( wh, "max", 1.0 );
3195 setPreferenceProperty( wh, "step", 0.1 );
3196 setPreferenceProperty( hh, "min", 0.0 );
3197 setPreferenceProperty( hh, "max", 1.0 );
3198 setPreferenceProperty( hh, "step", 0.1 );
3201 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3203 if( sect=="SMESH" ){
3204 float sbX1,sbY1,sbW,sbH;
3205 float aTol = 1.00000009999999;
3206 std::string aWarning;
3207 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3208 if( name=="selection_object_color" || name=="selection_element_color" ||
3209 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3210 name=="selection_precision_node" || name=="selection_precision_element" ||
3211 name=="selection_precision_object")
3212 SMESH::UpdateSelectionProp( this );
3213 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3214 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3215 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3216 if(sbX1+sbW > aTol){
3217 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3220 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3221 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3224 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3225 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3226 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3227 if(sbY1+sbH > aTol){
3228 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3231 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3232 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3235 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3236 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3237 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3238 if(sbX1+sbW > aTol){
3239 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3242 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3243 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3246 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3247 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3248 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3249 if(sbY1+sbH > aTol){
3250 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3253 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3254 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3258 if(aWarning.size() != 0){
3259 aWarning += "The default values are applied instead.";
3260 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3261 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3262 QObject::tr(aWarning.c_str()),
3263 QObject::tr("SMESH_BUT_OK"));
3268 //================================================================================
3270 * \brief Update something in accordance with update flags
3271 * \param theFlags - update flags
3273 * Update viewer or/and object browser etc. in accordance with update flags ( see
3274 * LightApp_UpdateFlags enumeration ).
3276 //================================================================================
3277 void SMESHGUI::update( const int flags )
3279 if ( flags & UF_Viewer | flags & UF_Forced )
3280 SMESH::UpdateView();
3282 SalomeApp_Module::update( flags );
3285 //================================================================================
3287 * \brief Set default selection mode
3289 * SLOT called when operation commited. Sets default selection mode
3291 //================================================================================
3292 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3294 SVTK_ViewWindow* vtkWnd =
3295 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3297 vtkWnd->SetSelectionMode( ActorSelection );
3300 //================================================================================
3302 * \brief Set default selection mode
3304 * SLOT called when operation aborted. Sets default selection mode
3306 //================================================================================
3307 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3309 SVTK_ViewWindow* vtkWnd =
3310 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3312 vtkWnd->SetSelectionMode( ActorSelection );
3315 //================================================================================
3317 * \brief Creates operation with given identifier
3318 * \param id - identifier of operation to be started
3319 * \return Pointer on created operation or NULL if operation is not created
3321 * Virtual method redefined from the base class creates operation with given id.
3322 * It is called called automatically from startOperation method of base class.
3324 //================================================================================
3325 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3327 LightApp_Operation* op = 0;
3328 // to do : create operation here
3331 case 701: // Compute mesh
3332 op = new SMESHGUI_ComputeOp();
3334 case 702: // Create mesh
3335 op = new SMESHGUI_MeshOp( true, true );
3337 case 703: // Create sub-mesh
3338 op = new SMESHGUI_MeshOp( true, false );
3340 case 704: // Edit mesh/sub-mesh
3341 op = new SMESHGUI_MeshOp( false );
3343 case 417: //convert to quadratic
3344 op = new SMESHGUI_ConvToQuadOp();
3346 case 4067: // make mesh pass through point
3347 op = new SMESHGUI_MakeNodeAtPointOp();
3354 op = SalomeApp_Module::createOperation( id );
3358 //================================================================================
3360 * \brief Stops current operations and starts a given one
3361 * \param id - The id of the operation to start
3363 //================================================================================
3365 void SMESHGUI::switchToOperation(int id)
3367 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3368 activeStudy()->abortAllOperations();
3369 startOperation( id );
3372 LightApp_Displayer* SMESHGUI::displayer()
3375 myDisplayer = new SMESHGUI_Displayer( getApp() );