1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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, Open CASCADE S.A.S.
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
33 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
34 #include "SMESHGUI_AddMeshElementDlg.h"
35 #include "SMESHGUI_AddQuadraticElementDlg.h"
36 #include "SMESHGUI_BuildCompoundDlg.h"
37 #include "SMESHGUI_ClippingDlg.h"
38 #include "SMESHGUI_ComputeDlg.h"
39 #include "SMESHGUI_ConvToQuadOp.h"
40 #include "SMESHGUI_CopyMeshDlg.h"
41 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
42 #include "SMESHGUI_DeleteGroupDlg.h"
43 #include "SMESHGUI_Displayer.h"
44 #include "SMESHGUI_DuplicateNodesDlg.h"
45 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
46 #include "SMESHGUI_ExtrusionDlg.h"
47 #include "SMESHGUI_FieldSelectorWdg.h"
48 #include "SMESHGUI_FileInfoDlg.h"
49 #include "SMESHGUI_FileValidator.h"
50 #include "SMESHGUI_FilterDlg.h"
51 #include "SMESHGUI_FilterLibraryDlg.h"
52 #include "SMESHGUI_FindElemByPointDlg.h"
53 #include "SMESHGUI_GroupDlg.h"
54 #include "SMESHGUI_GroupOnShapeDlg.h"
55 #include "SMESHGUI_GroupOpDlg.h"
56 #include "SMESHGUI_Hypotheses.h"
57 #include "SMESHGUI_Make2DFrom3DOp.h"
58 #include "SMESHGUI_MakeNodeAtPointDlg.h"
59 #include "SMESHGUI_Measurements.h"
60 #include "SMESHGUI_MergeDlg.h"
61 #include "SMESHGUI_MeshInfo.h"
62 #include "SMESHGUI_MeshOp.h"
63 #include "SMESHGUI_MeshOrderOp.h"
64 #include "SMESHGUI_MeshPatternDlg.h"
65 #include "SMESHGUI_MultiEditDlg.h"
66 #include "SMESHGUI_NodesDlg.h"
67 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
68 #include "SMESHGUI_PropertiesDlg.h"
69 #include "SMESHGUI_RemoveElementsDlg.h"
70 #include "SMESHGUI_RemoveNodesDlg.h"
71 #include "SMESHGUI_RenumberingDlg.h"
72 #include "SMESHGUI_ReorientFacesDlg.h"
73 #include "SMESHGUI_RevolutionDlg.h"
74 #include "SMESHGUI_RotationDlg.h"
75 #include "SMESHGUI_ScaleDlg.h"
76 #include "SMESHGUI_Selection.h"
77 #include "SMESHGUI_SewingDlg.h"
78 #include "SMESHGUI_SingleEditDlg.h"
79 #include "SMESHGUI_SmoothingDlg.h"
80 #include "SMESHGUI_SymmetryDlg.h"
81 #include "SMESHGUI_TranslationDlg.h"
82 #include "SMESHGUI_TransparencyDlg.h"
84 #include "SMESHGUI_FilterUtils.h"
85 #include "SMESHGUI_GroupUtils.h"
86 #include "SMESHGUI_HypothesesUtils.h"
87 #include "SMESHGUI_MeshUtils.h"
88 #include "SMESHGUI_PatternUtils.h"
89 #include "SMESHGUI_Utils.h"
90 #include "SMESHGUI_VTKUtils.h"
92 #include <SMESH_version.h>
94 #include "SMESH_ControlsDef.hxx"
95 #include <SMESH_Actor.h>
96 #include <SMESH_ActorUtils.h>
97 #include <SMESH_Client.hxx>
98 #include <SMESH_ScalarBarActor.h>
99 #include <SMESH_TypeFilter.hxx>
101 // SALOME GUI includes
102 #include <SalomeApp_Application.h>
103 #include <SalomeApp_CheckFileDlg.h>
104 #include <SalomeApp_DataObject.h>
105 #include <SalomeApp_Study.h>
106 #include <SalomeApp_Tools.h>
108 #include <LightApp_DataOwner.h>
109 #include <LightApp_NameDlg.h>
110 #include <LightApp_Preferences.h>
111 #include <LightApp_SelectionMgr.h>
112 #include <LightApp_UpdateFlags.h>
114 #include <SVTK_ViewManager.h>
115 #include <SVTK_ViewModel.h>
116 #include <SVTK_ViewWindow.h>
118 #include <VTKViewer_Algorithm.h>
120 #include <PyInterp_Interp.h>
122 #include <SUIT_Desktop.h>
123 #include <SUIT_FileDlg.h>
124 #include <SUIT_MessageBox.h>
125 #include <SUIT_OverrideCursor.h>
126 #include <SUIT_ResourceMgr.h>
127 #include <SUIT_Session.h>
129 #include <QtxPopupMgr.h>
130 #include <QtxFontEdit.h>
132 #include <SALOME_ListIO.hxx>
133 #include <SALOME_ListIteratorOfListIO.hxx>
135 #ifndef DISABLE_PLOT2DVIEWER
136 #include <SPlot2d_ViewModel.h>
137 #include <SPlot2d_Histogram.h>
141 #include <SALOMEconfig.h>
142 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
143 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
144 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
147 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
148 #include <QApplication>
150 #include <QTextStream>
153 #include <boost/shared_ptr.hpp>
156 #include <vtkCallbackCommand.h>
157 #include <vtkCamera.h>
158 #include <vtkLookupTable.h>
159 #include <vtkPlane.h>
160 #include <vtkRenderer.h>
162 // SALOME KERNEL includes
163 #include <SALOMEDSClient_ClientFactory.hxx>
164 #include <SALOMEDSClient_IParameters.hxx>
165 #include <SALOMEDSClient_SComponent.hxx>
166 #include <SALOMEDSClient_StudyBuilder.hxx>
167 #include <SALOMEDS_Study.hxx>
168 #include <SALOMEDS_SObject.hxx>
171 #include <Standard_ErrorHandler.hxx>
172 #include <NCollection_DataMap.hxx>
174 #include <Basics_Utils.hxx>
176 //To disable automatic genericobj management, the following line should be commented.
177 //Otherwise, it should be uncommented.
178 //Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
179 #define WITHGENERICOBJ
181 // Below macro, when uncommented, switches on simplified (more performant) algorithm
182 // of auto-color picking up
183 #define SIMPLE_AUTOCOLOR
185 // REMOVE the code about MPLMathText_Disabler if it does not complite at porting to ParaView-4.1
186 #include <vtkMatplotlibMathTextUtilities.h>
189 // Creation of this class disables vtkMatplotlibMathTextUtilities
190 struct MPLMathText_Disabler : protected vtkMatplotlibMathTextUtilities
192 MPLMathText_Disabler()
194 vtkMatplotlibMathTextUtilities::MPLMathTextAvailable =
195 vtkMatplotlibMathTextUtilities::UNAVAILABLE;
203 //=============================================================
204 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
207 void ExportMeshToFile(int theCommandID);
209 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
211 void SetDisplayEntity(int theCommandID);
213 void Control( int theCommandID );
216 //================================================================================
218 * \brief Reads meshes from file
220 //================================================================================
222 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
226 std::string myExtension;
228 if ( theCommandID == 113 ) {
229 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
230 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
232 else if ( theCommandID == 112 ) {
233 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
235 else if ( theCommandID == 111 ) {
236 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
238 else if ( theCommandID == 115 ) {
239 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
241 else if ( theCommandID == 116 ) {
242 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
244 else if ( theCommandID == 117 ) {
245 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
246 filter.append( QObject::tr( "All files (*)" ) );
248 else if ( theCommandID == 118 ) {
249 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
250 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
253 QString anInitialPath = "";
254 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
255 anInitialPath = QDir::currentPath();
257 QStringList filenames;
258 bool toCreateGroups = true;
260 // if ( theCommandID == 118 ) { // GMF
261 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
262 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
263 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
264 // fd->setNameFilters( filter );
265 // fd->SetChecked( true );
267 // filenames << fd->selectedFile();
268 // toCreateGroups = fd->IsChecked();
274 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
277 QObject::tr( "SMESH_IMPORT_MESH" ) );
279 if ( filenames.count() > 0 ) {
280 SUIT_OverrideCursor wc;
281 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
284 QStringList anEntryList;
285 bool isEmpty = false;
286 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
287 QString filename = *it;
288 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
290 switch ( theCommandID ) {
293 // DAT format (currently unsupported)
294 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
295 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
301 aMeshes->length( 1 );
302 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
303 if ( aMeshes[0]->_is_nil() )
304 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
305 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
311 SMESH::DriverMED_ReadStatus res;
312 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
313 if ( res != SMESH::DRS_OK ) {
314 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
315 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
322 aMeshes->length( 1 );
323 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
324 if ( aMeshes[0]->_is_nil() ) {
325 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
326 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
333 SMESH::DriverMED_ReadStatus res;
334 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
335 if ( res != SMESH::DRS_OK ) {
336 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
337 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
344 SMESH::DriverMED_ReadStatus res;
345 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
346 if ( res != SMESH::DRS_OK ) {
347 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
348 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
355 SMESH::ComputeError_var res;
356 aMeshes->length( 1 );
357 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
360 if ( res->code != SMESH::DRS_OK ) {
361 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
362 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
363 if ( strlen( res->comment.in() ) > 0 ) {
364 errors.back() += ": ";
365 errors.back() += res->comment.in();
372 catch ( const SALOME::SALOME_Exception& S_ex ) {
373 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
374 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
377 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
378 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
380 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
381 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
382 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
383 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
384 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
386 anEntryList.append( aMeshSO->GetID().c_str() );
394 // update Object browser
395 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
397 // browse to the published meshes
398 if( LightApp_Application* anApp =
399 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
400 anApp->browseObjects( anEntryList );
402 // show Error message box if there were errors
403 if ( errors.count() > 0 ) {
404 SUIT_MessageBox::critical( SMESHGUI::desktop(),
405 QObject::tr( "SMESH_ERROR" ),
406 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
409 // show warning message box, if some imported mesh is empty
411 SUIT_MessageBox::warning( SMESHGUI::desktop(),
412 QObject::tr( "SMESH_WRN_WARNING" ),
413 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
418 //================================================================================
420 * \brief Export selected meshes or groups into a file
422 //================================================================================
424 void ExportMeshToFile( int theCommandID )
426 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
427 SALOME_ListIO selected;
429 aSel->selectedObjects( selected );
431 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
432 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
433 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
434 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
435 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
436 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
437 const bool isGMF = ( theCommandID == 146 || theCommandID == 147 );
439 // actually, the following condition can't be met (added for insurance)
440 if( selected.Extent() == 0 ||
441 ( selected.Extent() > 1 && !isMED && !isSTL ))
444 // get mesh object from selection and check duplication of their names
445 bool hasDuplicatedMeshNames = false;
446 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
447 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
448 SALOME_ListIteratorOfListIO It( selected );
449 for( ; It.More(); It.Next() )
451 Handle(SALOME_InteractiveObject) anIObject = It.Value();
452 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
453 if ( aMeshItem->_is_nil() ) {
454 SUIT_MessageBox::warning( SMESHGUI::desktop(),
455 QObject::tr( "SMESH_WRN_WARNING" ),
456 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
460 QString aMeshName = anIObject->getName();
462 // check for name duplications
463 if ( !hasDuplicatedMeshNames )
464 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
465 if( aMeshName == (*aMeshIter).second ) {
466 hasDuplicatedMeshNames = true;
471 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
474 if( hasDuplicatedMeshNames && isMED ) {
475 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
476 QObject::tr("SMESH_WRN_WARNING"),
477 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
478 QObject::tr("SMESH_BUT_YES"),
479 QObject::tr("SMESH_BUT_NO"), 0, 1);
484 aMeshIter = aMeshList.begin();
485 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
486 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
487 QString aMeshName = (*aMeshIter).second;
489 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
491 // check for equal group names within each mesh
492 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
493 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
494 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
495 int aRet = SUIT_MessageBox::warning
496 (SMESHGUI::desktop(),
497 QObject::tr("SMESH_WRN_WARNING"),
498 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
499 QObject::tr("SMESH_BUT_YES"),
500 QObject::tr("SMESH_BUT_NO"), 0, 1);
507 // Warn the user about presence of not supported elements
509 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
513 notSupportedElemTypes.push_back( SMESH::Entity_0D );
514 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
519 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
520 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
521 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
522 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
523 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
524 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
525 notSupportedElemTypes.push_back( SMESH::Entity_0D );
526 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
531 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
532 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
533 notSupportedElemTypes.push_back( SMESH::Entity_0D );
534 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
539 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
540 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
545 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
546 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
547 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
548 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
549 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
550 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
551 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
556 notSupportedElemTypes.push_back( SMESH::Entity_0D );
557 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
558 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
559 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
560 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
561 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
562 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
563 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
564 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
566 if ( ! notSupportedElemTypes.empty() )
568 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
569 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
570 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
571 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
573 if ( !presentNotSupported.empty() )
576 const char* typeMsg[SMESH::Entity_Last] = {
577 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
578 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
579 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
580 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
581 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
582 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
583 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
584 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
586 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
587 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
588 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
589 if ( iType != presentNotSupported.size() - 1 )
590 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
592 int aRet = SUIT_MessageBox::warning
593 (SMESHGUI::desktop(),
594 QObject::tr("SMESH_WRN_WARNING"),
595 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
596 QObject::tr("SMESH_BUT_YES"),
597 QObject::tr("SMESH_BUT_NO"), 0, 1);
602 // Get parameters of export operation
605 SMESH::MED_VERSION aFormat;
606 // Init the parameters with the default values
607 bool aIsASCII_STL = true;
608 bool toCreateGroups = false;
609 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
611 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
612 bool toOverwrite = true;
613 bool toFindOutDim = true;
615 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
616 QString anInitialPath = "";
617 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
618 anInitialPath = QDir::currentPath();
620 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
622 // Get a file name to write in and additional otions
623 if ( isUNV || isDAT || isGMF ) // Export w/o options
626 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
628 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
630 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
631 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
632 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
633 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
634 anInitialPath + QString("/") + aMeshName,
635 aFilter, aTitle, false);
637 else if ( isCGNS )// Export to CGNS
639 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
640 fd->setWindowTitle( aTitle );
641 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
642 if ( !anInitialPath.isEmpty() )
643 fd->setDirectory( anInitialPath );
644 fd->selectFile(aMeshName);
645 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
646 fd->setValidator( fv );
649 aFilename = fd->selectedFile();
650 toOverwrite = fv->isOverwrite();
654 else if ( isSTL ) // Export to STL
656 QMap<QString, int> aFilterMap;
657 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
658 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
661 QMap<QString, int>::const_iterator it = aFilterMap.begin();
662 for ( ; it != aFilterMap.end(); ++it )
663 filters.push_back( it.key() );
665 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
666 fd->setWindowTitle( aTitle );
667 fd->setNameFilters( filters );
668 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
669 if ( !anInitialPath.isEmpty() )
670 fd->setDirectory( anInitialPath );
671 fd->selectFile(aMeshName);
675 aFilename = fd->selectedFile();
676 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
681 else if ( isMED || isSAUV ) // Export to MED or SAUV
683 QMap<QString, SMESH::MED_VERSION> aFilterMap;
684 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
686 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
687 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
688 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
691 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
692 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
693 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
697 QString aDefaultFilter;
698 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
699 for ( ; it != aFilterMap.end(); ++it ) {
700 filters.push_back( it.key() );
701 if (it.value() == SMESH::MED_V2_2)
702 aDefaultFilter = it.key();
704 QStringList checkBoxes;
705 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
707 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
708 QList< QWidget* > wdgList;
709 if ( fieldSelWdg->GetAllFeilds( aMeshList, aFieldList ))
710 wdgList.append( fieldSelWdg );
712 SalomeApp_CheckFileDlg* fd =
713 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
714 fd->setWindowTitle( aTitle );
715 fd->setNameFilters( filters );
716 fd->selectNameFilter( aDefaultFilter );
717 fd->SetChecked( toCreateGroups, 0 );
718 fd->SetChecked( toFindOutDim, 1 );
719 if ( !anInitialPath.isEmpty() )
720 fd->setDirectory( anInitialPath );
721 fd->selectFile(aMeshName);
723 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
724 fd->setValidator( fv );
729 aFilename = fd->selectedFile();
731 aFilename = QString::null;
734 aFormat = aFilterMap[fd->selectedNameFilter()];
735 toOverwrite = fv->isOverwrite();
737 if ( !aFilename.isEmpty() ) {
738 // med-2.1 does not support poly elements
739 if ( aFormat==SMESH::MED_V2_1 )
740 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
741 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
742 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
743 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
744 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
746 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
747 QObject::tr("SMESH_WRN_WARNING"),
748 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
749 QObject::tr("SMESH_BUT_YES"),
750 QObject::tr("SMESH_BUT_NO"), 0, 1);
758 // can't append to an existing using other format
759 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
760 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
761 if( !isVersionOk || aVersion != aFormat ) {
762 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
763 QObject::tr("SMESH_WRN_WARNING"),
764 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
765 QObject::tr("SMESH_BUT_YES"),
766 QObject::tr("SMESH_BUT_NO"), 0, 1);
773 QStringList aMeshNamesCollisionList;
774 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
775 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
776 QString anExistingMeshName( aMeshNames[ i ] );
777 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
778 QString anExportMeshName = (*aMeshIter).second;
779 if( anExportMeshName == anExistingMeshName ) {
780 aMeshNamesCollisionList.append( anExportMeshName );
785 if( !aMeshNamesCollisionList.isEmpty() ) {
786 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
787 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
788 QObject::tr("SMESH_WRN_WARNING"),
789 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
790 QObject::tr("SMESH_BUT_YES"),
791 QObject::tr("SMESH_BUT_NO"),
792 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
801 toCreateGroups = fd->IsChecked(0);
802 toFindOutDim = fd->IsChecked(1);
803 fieldSelWdg->GetSelectedFeilds();
804 if ( !fieldSelWdg->parent() )
815 if ( !aFilename.isEmpty() ) {
816 // Check whether the file already exists and delete it if yes
817 QFile aFile( aFilename );
818 if ( aFile.exists() && toOverwrite )
820 SUIT_OverrideCursor wc;
823 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
824 // bool Renumber = false;
825 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
827 // Renumber= resMgr->booleanValue("renumbering");
829 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
830 // aMeshEditor->RenumberNodes();
831 // aMeshEditor->RenumberElements();
832 // if ( SMESHGUI::automaticUpdate() )
833 // SMESH::UpdateView();
837 aMeshIter = aMeshList.begin();
838 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
840 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
841 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
842 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
843 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
844 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
845 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
846 aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
847 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
849 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
850 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim,
851 fields, geoAssFields.toLatin1().data() );
856 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
858 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
859 if( !aMeshItem->_is_nil() )
860 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
865 if ( aMeshOrGroup->_is_equivalent( aMesh ))
866 aMesh->ExportDAT( aFilename.toUtf8().data() );
868 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
872 if ( aMeshOrGroup->_is_equivalent( aMesh ))
873 aMesh->ExportUNV( aFilename.toUtf8().data() );
875 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
879 if ( aMeshOrGroup->_is_equivalent( aMesh ))
880 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
882 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
886 aMeshIter = aMeshList.begin();
887 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
889 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
890 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
891 aMeshItem->ExportCGNS( aMeshOrGroup,
892 aFilename.toUtf8().data(),
893 toOverwrite && aMeshIndex == 0 );
898 toCreateGroups = true;
899 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
902 catch (const SALOME::SALOME_Exception& S_ex){
904 SUIT_MessageBox::warning(SMESHGUI::desktop(),
905 QObject::tr("SMESH_WRN_WARNING"),
906 QObject::tr("SMESH_EXPORT_FAILED"));
912 inline void InverseEntityMode(unsigned int& theOutputMode,
913 unsigned int theMode)
915 bool anIsNotPresent = ~theOutputMode & theMode;
917 theOutputMode |= theMode;
919 theOutputMode &= ~theMode;
922 void SetDisplayEntity(int theCommandID){
923 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
924 SALOME_ListIO selected;
926 aSel->selectedObjects( selected );
928 if(selected.Extent() >= 1){
929 SALOME_ListIteratorOfListIO It( selected );
930 for( ; It.More(); It.Next()){
931 Handle(SALOME_InteractiveObject) IObject = It.Value();
932 if(IObject->hasEntry()){
933 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
934 unsigned int aMode = anActor->GetEntityMode();
935 switch(theCommandID){
937 InverseEntityMode(aMode,SMESH_Actor::eBallElem);
940 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
943 InverseEntityMode(aMode,SMESH_Actor::eEdges);
946 InverseEntityMode(aMode,SMESH_Actor::eFaces);
949 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
952 aMode = SMESH_Actor::eAllEntity;
956 anActor->SetEntityMode(aMode);
965 SALOME_ListIO selected;
966 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
970 LightApp_SelectionMgr* aSel = app->selectionMgr();
971 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
972 if( !aSel || !appStudy )
975 aSel->selectedObjects( selected );
976 if( selected.IsEmpty() )
979 Handle(SALOME_InteractiveObject) anIObject = selected.First();
981 _PTR(Study) aStudy = appStudy->studyDS();
982 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
983 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
984 if( aMainObject->_is_nil() )
987 SUIT_OverrideCursor wc;
989 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
991 QList<SALOMEDS::Color> aReservedColors;
993 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
994 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
996 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
997 //SALOMEDS::Color aColor = aGroupObject->GetColor();
999 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1000 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1001 #else // old algorithm for auto-colors
1002 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1003 aReservedColors.append( aColor );
1004 #endif // SIMPLE_AUTOCOLOR
1005 aGroupObject->SetColor( aColor );
1007 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1008 if (aGroupSObject) {
1011 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1012 switch ( aGroupObject->GetType ()) {
1014 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1016 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1018 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1020 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1022 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1023 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1026 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1027 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1033 SMESH::RepaintCurrentView();
1036 void OverallMeshQuality() {
1037 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1038 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1039 SALOME_ListIO selected;
1041 aSel->selectedObjects( selected );
1043 if ( selected.IsEmpty() ) return;
1044 SALOME_ListIteratorOfListIO It( selected );
1045 for ( ; It.More(); It.Next() ) {
1046 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1047 ctrlDlg->showInfo( It.Value() );
1052 QString functorToString( SMESH::Controls::FunctorPtr f )
1054 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1055 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1056 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1057 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1058 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1059 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1060 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1061 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1062 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1063 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1064 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1065 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1066 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1067 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1068 type = QObject::tr( "WARP_ELEMENTS" );
1069 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1070 type = QObject::tr( "TAPER_ELEMENTS" );
1071 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1072 type = QObject::tr( "SKEW_ELEMENTS" );
1073 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1074 type = QObject::tr( "AREA_ELEMENTS" );
1075 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1076 type = QObject::tr( "LENGTH_EDGES" );
1077 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1078 type = QObject::tr( "LENGTH2D_EDGES" );
1079 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1080 type = QObject::tr( "MULTI_BORDERS" );
1081 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1082 type = QObject::tr( "MULTI2D_BORDERS" );
1083 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1084 type = QObject::tr( "FREE_NODES" );
1085 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1086 type = QObject::tr( "FREE_EDGES" );
1087 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1088 type = QObject::tr( "FREE_BORDERS" );
1089 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1090 type = QObject::tr( "FREE_FACES" );
1091 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1092 type = QObject::tr( "BARE_BORDER_VOLUME" );
1093 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1094 type = QObject::tr( "BARE_BORDER_FACE" );
1095 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1096 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1097 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1098 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1099 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1100 type = QObject::tr( "EQUAL_NODE" );
1101 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1102 type = QObject::tr( "EQUAL_EDGE" );
1103 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1104 type = QObject::tr( "EQUAL_FACE" );
1105 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1106 type = QObject::tr( "EQUAL_VOLUME" );
1110 void SaveDistribution()
1112 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1113 SALOME_ListIO selected;
1115 aSel->selectedObjects( selected );
1117 if ( selected.Extent() == 1 ) {
1118 Handle(SALOME_InteractiveObject) anIO = selected.First();
1119 if ( anIO->hasEntry() ) {
1120 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1121 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1122 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1123 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1124 if ( aScalarBarActor && aFunctor ) {
1125 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1127 std::vector<int> elements;
1128 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1129 if ( mesh->_is_nil() ) {
1130 SMESH::SMESH_IDSource_var idSource =
1131 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1132 if ( !idSource->_is_nil() )
1134 SMESH::long_array_var ids = idSource->GetIDs();
1135 elements.resize( ids->length() );
1136 for ( unsigned i = 0; i < elements.size(); ++i )
1137 elements[i] = ids[i];
1140 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1141 vtkLookupTable* lookupTable =
1142 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1143 double * minmax = lookupTable->GetRange();
1144 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1145 std::vector<int> nbEvents;
1146 std::vector<double> funValues;
1147 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax, isLogarithmic );
1148 QString anInitialPath = "";
1149 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1150 anInitialPath = QDir::currentPath();
1151 QString aMeshName = anIO->getName();
1153 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1154 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1155 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1156 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1157 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1160 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1162 if ( !aFilename.isEmpty() ) {
1163 QFile f( aFilename );
1164 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1165 QTextStream out( &f );
1166 out << "# Mesh: " << aMeshName << endl;
1167 out << "# Control: " << functorToString( aFunctor ) << endl;
1169 out.setFieldWidth( 10 );
1170 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1171 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1182 void ShowDistribution() {
1183 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1184 SALOME_ListIO selected;
1186 aSel->selectedObjects( selected );
1188 if ( selected.Extent() == 1 ) {
1189 Handle(SALOME_InteractiveObject) anIO = selected.First();
1190 if ( anIO->hasEntry() ) {
1191 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1192 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1193 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1194 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1200 #ifndef DISABLE_PLOT2DVIEWER
1201 void PlotDistribution() {
1202 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1206 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1207 SALOME_ListIO selected;
1209 aSel->selectedObjects( selected );
1211 if ( selected.Extent() == 1 ) {
1212 Handle(SALOME_InteractiveObject) anIO = selected.First();
1213 if ( anIO->hasEntry() ) {
1214 //Find Actor by entry before getting Plot2d viewer,
1215 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1216 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1218 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1223 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1227 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1231 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1232 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1233 QString functorName = functorToString( anActor->GetFunctor());
1234 QString aHistogramName("%1 : %2");
1235 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1236 aHistogram->setName(aHistogramName);
1237 aHistogram->setHorTitle(functorName);
1238 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1239 aPlot->displayObject(aHistogram, true);
1244 #endif //DISABLE_PLOT2DVIEWER
1246 void DisableAutoColor(){
1247 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1248 SALOME_ListIO selected;
1250 aSel->selectedObjects( selected );
1252 if(selected.Extent()){
1253 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1254 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1255 if ( !aMesh->_is_nil() ) {
1256 aMesh->SetAutoColor( false );
1261 void sortChildren(){
1262 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1263 SALOME_ListIO selected;
1265 aSel->selectedObjects( selected );
1267 if(selected.Extent()){
1268 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1269 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1270 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1272 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1273 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1280 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1282 SALOME_ListIO selected;
1283 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1287 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1288 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1289 if( !aSel || !appStudy )
1292 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1293 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1294 aModule->EmitSignalDeactivateDialog();
1295 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1296 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1301 _PTR(Study) aStudy = appStudy->studyDS();
1303 aSel->selectedObjects( selected );
1305 if(selected.Extent() >= 1){
1306 switch(theCommandID){
1308 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1309 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1314 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1315 QColor orientationColor, outlineColor, volumeColor;
1316 int deltaF = 0, deltaV = 0;
1320 int outlineWidth = 1;
1321 double shrinkCoef = 0.0;
1322 double orientationScale = 0.0;
1323 bool orientation3d = false;
1324 VTK::MarkerType markerType = VTK::MT_NONE;
1325 VTK::MarkerScale markerScale = VTK::MS_NONE;
1327 bool hasNodes = false;
1328 int presentEntities = 0;
1329 bool firstTime = true;
1331 SALOME_ListIteratorOfListIO It( selected );
1332 for ( ; It.More(); It.Next() ) {
1333 Handle(SALOME_InteractiveObject) IObject = It.Value();
1334 if ( !IObject->hasEntry() ) continue;
1335 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1336 if ( !anActor || !anActor->GetObject() ) continue;
1339 // nodes: color, marker
1340 anActor->GetNodeColor( color[0], color[1], color[2] );
1341 nodeColor.setRgbF( color[0], color[1], color[2] );
1342 markerType = anActor->GetMarkerType();
1343 markerScale = anActor->GetMarkerScale();
1344 markerId = anActor->GetMarkerTexture();
1345 // edges: color, width
1346 anActor->GetEdgeColor( color[0], color[1], color[2] );
1347 edgeColor.setRgbF( color[0], color[1], color[2] );
1348 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1349 // faces: front color, back color (delta)
1350 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1351 faceColor.setRgbF( color[0], color[1], color[2] );
1352 // faces: front color, back color (delta)
1353 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1354 volumeColor.setRgbF( color[0], color[1], color[2] );
1355 // 0d elements: color, size
1356 anActor->Get0DColor( color[0], color[1], color[2] );
1357 elem0dColor.setRgbF( color[0], color[1], color[2] );
1358 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1359 // balls: color, size
1360 anActor->GetBallColor( color[0], color[1], color[2] );
1361 ballColor.setRgbF( color[0], color[1], color[2] );
1362 ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1364 anActor->GetOutlineColor( color[0], color[1], color[2] );
1365 outlineColor.setRgbF( color[0], color[1], color[2] );
1366 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1367 // orientation vectors: color, scale, 3d flag
1368 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1369 orientationColor.setRgbF( color[0], color[1], color[2] );
1370 orientationScale = anActor->GetFacesOrientationScale();
1371 orientation3d = anActor->GetFacesOrientation3DVectors();
1373 shrinkCoef = anActor->GetShrinkFactor();
1376 firstTime = false; // we only take properties from first object (for performance reasons)
1379 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1380 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1381 presentEntities = presentEntities | SMESH_Actor::eEdges;
1382 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1383 presentEntities = presentEntities | SMESH_Actor::eFaces;
1384 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1385 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1386 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1387 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1388 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1389 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1391 // as we know that all types of elements are present, we can exit the loop
1392 if ( presentEntities == SMESH_Actor::eAllEntity )
1396 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1397 // nodes: color, marker
1398 dlg.setNodeColor( nodeColor );
1399 if( markerType != VTK::MT_USER )
1400 dlg.setNodeMarker( markerType, markerScale );
1402 dlg.setNodeCustomMarker( markerId );
1403 // edges: color, line width
1404 dlg.setEdgeColor( edgeColor );
1405 dlg.setEdgeWidth( edgeWidth );
1406 // faces: front color, back color
1407 dlg.setFaceColor( faceColor, deltaF );
1408 // volumes: normal color, reversed color
1409 dlg.setVolumeColor( volumeColor, deltaV );
1410 // outlines: color, line width
1411 dlg.setOutlineColor( outlineColor );
1412 dlg.setOutlineWidth( outlineWidth );
1413 // 0d elements: color, size
1414 dlg.setElem0dColor( elem0dColor );
1415 dlg.setElem0dSize( elem0dSize );
1416 // balls: color, size
1417 dlg.setBallColor( ballColor );
1418 dlg.setBallSize( ballSize );
1419 // orientation: color, scale, 3d flag
1420 dlg.setOrientationColor( orientationColor );
1421 dlg.setOrientationSize( int( orientationScale * 100. ) );
1422 dlg.setOrientation3d( orientation3d );
1423 // shrink: scale factor
1424 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1425 // hide unused controls
1426 dlg.showControls( presentEntities, hasNodes );
1429 nodeColor = dlg.nodeColor();
1430 markerType = dlg.nodeMarkerType();
1431 markerScale = dlg.nodeMarkerScale();
1432 markerId = dlg.nodeMarkerId();
1433 edgeColor = dlg.edgeColor();
1434 edgeWidth = dlg.edgeWidth();
1435 faceColor = dlg.faceColor();
1436 deltaF = dlg.faceColorDelta();
1437 volumeColor = dlg.volumeColor();
1438 deltaV = dlg.volumeColorDelta();
1439 outlineColor = dlg.outlineColor();
1440 outlineWidth = dlg.outlineWidth();
1441 elem0dColor = dlg.elem0dColor();
1442 elem0dSize = dlg.elem0dSize();
1443 ballColor = dlg.ballColor();
1444 ballSize = dlg.ballSize();
1445 orientationColor = dlg.orientationColor();
1446 orientationScale = dlg.orientationSize() / 100.;
1447 orientation3d = dlg.orientation3d();
1448 shrinkCoef = dlg.shrinkCoef() / 100.;
1450 // store point markers map that might be changed by the user
1451 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1453 // set properties from dialog box to the presentations
1454 SALOME_ListIteratorOfListIO It( selected );
1455 for ( ; It.More(); It.Next() ) {
1456 Handle(SALOME_InteractiveObject) IObject = It.Value();
1457 if ( !IObject->hasEntry() ) continue;
1458 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1459 if ( !anActor ) continue;
1461 // nodes: color, marker
1462 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1463 if ( markerType != VTK::MT_USER ) {
1464 anActor->SetMarkerStd( markerType, markerScale );
1467 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1468 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1469 if ( iter != markerMap.end() )
1470 anActor->SetMarkerTexture( markerId, iter->second.second );
1472 // volumes: normal color, reversed color (delta)
1473 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1474 // faces: front color, back color (delta)
1475 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1476 // edges: color, width
1477 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1478 anActor->SetLineWidth( edgeWidth );
1480 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1481 anActor->SetOutlineWidth( outlineWidth );
1482 // 0D elements: color, size
1483 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1484 anActor->Set0DSize( elem0dSize );
1485 // balls: color, size
1486 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1487 anActor->SetBallSize( ballSize );
1488 // orientation: color, scale, 3d flag
1489 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1490 anActor->SetFacesOrientationScale( orientationScale );
1491 anActor->SetFacesOrientation3DVectors( orientation3d );
1493 anActor->SetShrinkFactor( shrinkCoef );
1495 // for groups, set also proper color
1496 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1497 if ( !aGroupObject->_is_nil() ) {
1498 SMESH::ElementType anElementType = aGroupObject->GetType();
1500 switch( anElementType ) {
1502 aColor = nodeColor; break;
1504 aColor = edgeColor; break;
1506 aColor = faceColor; break;
1508 aColor = volumeColor; break;
1510 aColor = elem0dColor; break;
1512 aColor = ballColor; break;
1516 if ( aColor.isValid() ) {
1517 SALOMEDS::Color aGroupColor;
1518 aGroupColor.R = aColor.redF();
1519 aGroupColor.G = aColor.greenF();
1520 aGroupColor.B = aColor.blueF();
1521 aGroupObject->SetColor( aGroupColor );
1523 } // if ( !aGroupObject->_is_nil() )
1524 } // for ( ; It.More(); It.Next() )
1525 SMESH::RepaintCurrentView();
1526 } // if ( dlg.exec() )
1529 } // switch(theCommandID)
1530 SALOME_ListIteratorOfListIO It( selected );
1531 for( ; It.More(); It.Next()){
1532 Handle(SALOME_InteractiveObject) IObject = It.Value();
1533 if(IObject->hasEntry()){
1534 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1535 switch(theCommandID){
1537 anActor->SetRepresentation(SMESH_Actor::eEdge);
1540 anActor->SetRepresentation(SMESH_Actor::eSurface);
1543 if(anActor->IsShrunk())
1544 anActor->UnShrink();
1546 anActor->SetShrink();
1549 anActor->SetRepresentation(SMESH_Actor::ePoint);
1552 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1553 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1556 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1557 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1563 SMESH::RepaintCurrentView();
1567 void Control( int theCommandID )
1569 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1570 SALOME_ListIO selected;
1572 aSel->selectedObjects( selected );
1574 if( !selected.IsEmpty() ){
1575 Handle(SALOME_InteractiveObject) anIO = selected.First();
1577 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1578 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1579 switch ( theCommandID ){
1581 aControl = SMESH_Actor::eLength;
1584 aControl = SMESH_Actor::eLength2D;
1587 aControl = SMESH_Actor::eFreeEdges;
1590 aControl = SMESH_Actor::eFreeBorders;
1593 aControl = SMESH_Actor::eMultiConnection;
1596 aControl = SMESH_Actor::eFreeNodes;
1599 aControl = SMESH_Actor::eMultiConnection2D;
1602 aControl = SMESH_Actor::eArea;
1605 aControl = SMESH_Actor::eTaper;
1608 aControl = SMESH_Actor::eAspectRatio;
1611 aControl = SMESH_Actor::eAspectRatio3D;
1614 aControl = SMESH_Actor::eMinimumAngle;
1617 aControl = SMESH_Actor::eWarping;
1620 aControl = SMESH_Actor::eSkew;
1623 aControl = SMESH_Actor::eVolume3D;
1626 aControl = SMESH_Actor::eFreeFaces;
1629 aControl = SMESH_Actor::eMaxElementLength2D;
1632 aControl = SMESH_Actor::eMaxElementLength3D;
1635 aControl = SMESH_Actor::eBareBorderVolume;
1638 aControl = SMESH_Actor::eBareBorderFace;
1641 aControl = SMESH_Actor::eOverConstrainedVolume;
1644 aControl = SMESH_Actor::eOverConstrainedFace;
1647 aControl = SMESH_Actor::eCoincidentNodes;
1650 aControl = SMESH_Actor::eCoincidentElems1D;
1653 aControl = SMESH_Actor:: eCoincidentElems2D;
1656 aControl = SMESH_Actor::eCoincidentElems3D;
1660 anActor->SetControlMode(aControl);
1661 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1662 SMESH::RepaintCurrentView();
1663 #ifndef DISABLE_PLOT2DVIEWER
1664 if(anActor->GetPlot2Histogram()) {
1665 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1666 QString functorName = functorToString( anActor->GetFunctor());
1667 QString aHistogramName("%1 : %2");
1668 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1669 aHistogram->setName(aHistogramName);
1670 aHistogram->setHorTitle(functorName);
1671 SMESH::ProcessIn2DViewers(anActor);
1680 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1681 SMESH::MeshObjectType theType,
1682 const QString theInTypeName,
1683 QString & theOutTypeName)
1685 SMESH_TypeFilter aTypeFilter( theType );
1687 if( !theIO.IsNull() )
1689 entry = theIO->getEntry();
1690 LightApp_DataOwner owner( entry );
1691 if ( aTypeFilter.isOk( &owner )) {
1692 theOutTypeName = theInTypeName;
1700 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1702 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1703 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1705 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1706 CORBA::String_var anID = aSComp->GetID().c_str();
1707 if (!strcmp(anID.in(),theIO->getEntry()))
1713 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1714 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1715 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1716 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1717 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1725 QString CheckHomogeneousSelection()
1727 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1728 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1729 SALOME_ListIO selected;
1731 aSel->selectedObjects( selected );
1733 QString RefType = CheckTypeObject(selected.First());
1734 SALOME_ListIteratorOfListIO It(selected);
1735 for ( ; It.More(); It.Next())
1737 Handle(SALOME_InteractiveObject) IObject = It.Value();
1738 QString Type = CheckTypeObject(IObject);
1739 if (Type.compare(RefType) != 0)
1740 return "Heterogeneous Selection";
1748 void SMESHGUI::OnEditDelete()
1750 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1751 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1752 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1754 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1755 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1756 _PTR(GenericAttribute) anAttr;
1757 _PTR(AttributeIOR) anIOR;
1759 int objectCount = 0;
1761 QString aParentComponent = QString::null;
1762 Handle(SALOME_InteractiveObject) anIO;
1763 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1765 anIO = anIt.Value();
1766 QString cur = anIO->getComponentDataType();
1767 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1769 // check if object is reference
1770 _PTR(SObject) aRefSObj;
1771 aNameList.append("\n - ");
1772 if ( aSO->ReferencedObject( aRefSObj ) ) {
1773 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1774 aNameList.append( aRefName );
1775 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1778 aNameList.append(anIO->getName());
1782 if( aParentComponent.isNull() )
1783 aParentComponent = cur;
1784 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1785 aParentComponent = "";
1788 if ( objectCount == 0 )
1789 return; // No Valid Objects Selected
1791 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1792 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1793 QObject::tr("ERR_ERROR"),
1794 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1797 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1798 if (SUIT_MessageBox::warning
1799 (SMESHGUI::desktop(),
1800 QObject::tr("SMESH_WRN_WARNING"),
1801 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1802 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1803 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1806 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1808 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1809 // then treat them all starting from the deepest objects (at list back)
1810 std::list< _PTR(SObject) > listSO;
1811 SALOME_ListIteratorOfListIO It(selected);
1812 for( ; It.More(); It.Next()) // loop on selected IO's
1814 Handle(SALOME_InteractiveObject) IObject = It.Value();
1815 if(IObject->hasEntry()) {
1816 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1818 // disable removal of "SMESH" component object
1819 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1821 if ( engineIOR() == anIOR->Value().c_str() )
1824 //Check the referenced object
1825 _PTR(SObject) aRefSObject;
1826 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1827 aSO = aRefSObject; // Delete main Object instead of reference
1829 listSO.push_back( aSO );
1830 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1831 for ( ; itSO != listSO.end(); ++itSO ) {
1832 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1833 for (it->InitEx(false); it->More(); it->Next())
1834 listSO.push_back( it->Value() );
1838 // Check if none of objects to delete is referred from outside
1839 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1840 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1842 _PTR(SObject) SO = *ritSO;
1843 if ( !SO ) continue;
1844 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1845 for (size_t i = 0; i < aReferences.size(); i++) {
1846 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1847 std::string type = aComponent->ComponentDataType();
1848 if ( type != "SMESH" )
1850 SUIT_MessageBox::warning( anApp->desktop(),
1851 QObject::tr("WRN_WARNING"),
1852 QObject::tr("DEP_OBJECT") );
1853 return; // outside SMESH, there is an object depending on a SMESH object
1858 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1859 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1861 Handle(SALOME_InteractiveObject) IObject = It.Value();
1862 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1863 if ( !mesh->_is_nil() )
1867 // Treat SO's in the list starting from the back
1868 aStudyBuilder->NewCommand(); // There is a transaction
1869 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1871 _PTR(SObject) SO = *ritSO;
1872 if ( !SO ) continue;
1873 std::string anEntry = SO->GetID();
1875 /** Erase graphical object and remove all its data **/
1876 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1877 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1879 /** Remove an object from data structures **/
1880 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1881 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1882 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1883 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1884 aMesh->RemoveGroup( aGroup );
1886 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1887 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1888 aMesh->RemoveSubMesh( aSubMesh );
1890 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1892 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1895 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1896 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1897 QString objType = CheckTypeObject(IObject);
1898 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1899 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1900 aStudyBuilder->RemoveObjectWithChildren( SO );
1902 else {// default action: remove SObject from the study
1903 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1904 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1906 aStudyBuilder->RemoveObjectWithChildren( SO );
1910 } /* listSO back loop */
1912 aStudyBuilder->CommitCommand();
1914 /* Clear any previous selection */
1916 aSel->setSelectedObjects( l1 );
1918 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1922 SMESHGUI_EXPORT CAM_Module* createModule()
1924 return new SMESHGUI();
1927 SMESHGUI_EXPORT char* getModuleVersion() {
1928 return (char*)SMESH_VERSION_STR;
1932 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1934 //=============================================================================
1938 //=============================================================================
1939 SMESHGUI::SMESHGUI() :
1940 SalomeApp_Module( "SMESH" )
1942 if ( CORBA::is_nil( myComponentSMESH ) )
1944 CORBA::Boolean anIsEmbeddedMode;
1945 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1946 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1948 // 0019923: EDF 765 SMESH : default values of hypothesis
1949 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1950 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1951 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1952 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1953 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1955 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1956 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1957 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1959 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1960 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1964 myActiveDialogBox = 0;
1965 myFilterLibraryDlg = 0;
1969 myEventCallbackCommand = vtkCallbackCommand::New();
1970 myEventCallbackCommand->Delete();
1971 myEventCallbackCommand->SetClientData( this );
1972 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1975 /* load resources for all available meshers */
1976 SMESH::InitAvailableHypotheses();
1978 MPLMathText_Disabler d; // disable vtkMatplotlibMathTextUtilities
1981 //=============================================================================
1985 //=============================================================================
1986 SMESHGUI::~SMESHGUI()
1990 //=============================================================================
1994 //=============================================================================
1995 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1997 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1999 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2004 //=============================================================================
2008 //=============================================================================
2009 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2011 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2015 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2016 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2017 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2018 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2019 return autoUpdate && !exceeded;
2022 //=============================================================================
2026 //=============================================================================
2027 bool SMESHGUI::automaticUpdate( SMESH::SMESH_Mesh_ptr theMesh,
2028 int* entities, bool* limitExceeded, int* hidden )
2030 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2034 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2035 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2036 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2038 long requestedSize = theMesh->NbElements();
2040 *entities = SMESH_Actor::eAllEntity;
2043 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2045 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2047 if ( incrementalLimit ) {
2048 long nbOdElems = theMesh->Nb0DElements();
2049 long nbEdges = theMesh->NbEdges();
2050 long nbFaces = theMesh->NbFaces();
2051 long nbVolumes = theMesh->NbVolumes();
2052 long nbBalls = theMesh->NbBalls();
2055 if ( nbOdElems > 0 ) {
2056 if ( total + nbOdElems > updateLimit ) {
2057 *entities = *entities & ~SMESH_Actor::e0DElements;
2058 *hidden = *hidden | SMESH_Actor::e0DElements;
2065 if ( nbEdges > 0 ) {
2066 if ( total + nbEdges > updateLimit ) {
2067 *entities = *entities & ~SMESH_Actor::eEdges;
2068 *hidden = *hidden | SMESH_Actor::eEdges;
2075 if ( nbFaces > 0 ) {
2076 if ( total + nbFaces > updateLimit ) {
2077 *entities = *entities & ~SMESH_Actor::eFaces;
2078 *hidden = *hidden | SMESH_Actor::eFaces;
2085 if ( nbVolumes > 0 ) {
2086 if ( total + nbVolumes > updateLimit ) {
2087 *entities = *entities & ~SMESH_Actor::eVolumes;
2088 *hidden = *hidden | SMESH_Actor::eVolumes;
2095 if ( nbBalls > 0 ) {
2096 if ( total + nbBalls > updateLimit ) {
2097 *entities = *entities & ~SMESH_Actor::eBallElem;
2098 *hidden = *hidden | SMESH_Actor::eBallElem;
2106 return autoUpdate && !exceeded;
2109 //=============================================================================
2113 //=============================================================================
2114 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2116 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2119 //=============================================================================
2123 //=============================================================================
2124 SMESHGUI* SMESHGUI::GetSMESHGUI()
2126 SMESHGUI* smeshMod = 0;
2127 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2130 CAM_Module* module = app->module( "Mesh" );
2131 smeshMod = dynamic_cast<SMESHGUI*>( module );
2134 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2136 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2139 _PTR(Study) aStudy = study->studyDS();
2141 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2150 Standard_EXPORT SMESHGUI* GetComponentGUI()
2152 return SMESHGUI::GetSMESHGUI();
2156 //=============================================================================
2160 //=============================================================================
2161 void SMESHGUI::SetState(int aState)
2166 //=============================================================================
2170 //=============================================================================
2171 void SMESHGUI::ResetState()
2176 //=============================================================================
2180 //=============================================================================
2181 void SMESHGUI::EmitSignalDeactivateDialog()
2183 emit SignalDeactivateActiveDialog();
2186 //=============================================================================
2190 //=============================================================================
2191 void SMESHGUI::EmitSignalStudyFrameChanged()
2193 emit SignalStudyFrameChanged();
2196 //=============================================================================
2200 //=============================================================================
2201 void SMESHGUI::EmitSignalCloseAllDialogs()
2203 emit SignalCloseAllDialogs();
2206 //=============================================================================
2210 //=============================================================================
2211 void SMESHGUI::EmitSignalVisibilityChanged()
2213 emit SignalVisibilityChanged();
2216 //=============================================================================
2220 //=============================================================================
2221 QDialog *SMESHGUI::GetActiveDialogBox()
2223 return myActiveDialogBox;
2226 //=============================================================================
2230 //=============================================================================
2231 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2233 myActiveDialogBox = (QDialog *) aDlg;
2237 //=============================================================================
2241 //=============================================================================
2242 SUIT_Desktop* SMESHGUI::desktop()
2244 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2246 return app->desktop();
2251 //=============================================================================
2255 //=============================================================================
2256 SalomeApp_Study* SMESHGUI::activeStudy()
2258 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2260 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2265 //=============================================================================
2269 //=============================================================================
2270 void SMESHGUI::Modified( bool theIsUpdateActions )
2272 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2273 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2274 appStudy->Modified();
2275 if( theIsUpdateActions )
2276 app->updateActions();
2281 //=============================================================================
2285 //=============================================================================
2286 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2288 /* Here the position is on the bottom right corner - 10 */
2289 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2291 SUIT_Desktop *PP = desktop();
2292 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2293 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2297 //=============================================================================
2301 //=============================================================================
2302 static int isStudyLocked(_PTR(Study) theStudy){
2303 return theStudy->GetProperties()->IsLocked();
2306 static bool checkLock(_PTR(Study) theStudy) {
2307 if (isStudyLocked(theStudy)) {
2308 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2309 QObject::tr("WRN_WARNING"),
2310 QObject::tr("WRN_STUDY_LOCKED") );
2316 //=======================================================================
2317 //function : CheckActiveStudyLocked
2319 //=======================================================================
2321 bool SMESHGUI::isActiveStudyLocked()
2323 _PTR(Study) aStudy = activeStudy()->studyDS();
2324 return checkLock( aStudy );
2327 //=============================================================================
2331 //=============================================================================
2332 bool SMESHGUI::OnGUIEvent( int theCommandID )
2334 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2338 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2339 SUIT_ResourceMgr* mgr = resourceMgr();
2343 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2344 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2347 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2348 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2350 //QAction* act = action( theCommandID );
2352 switch (theCommandID) {
2354 if(checkLock(aStudy)) break;
2366 if(checkLock(aStudy)) break;
2367 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2371 case 150: //MED FILE INFORMATION
2373 SALOME_ListIO selected;
2374 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2376 aSel->selectedObjects( selected );
2377 if( selected.Extent() )
2379 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2380 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2381 if ( !aMesh->_is_nil() )
2383 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2390 case 122: // EXPORT MED
2405 ::ExportMeshToFile(theCommandID);
2409 case 200: // SCALAR BAR
2411 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2412 SALOME_ListIO selected;
2414 aSel->selectedObjects( selected );
2416 if( selected.Extent() ) {
2417 Handle(SALOME_InteractiveObject) anIO = selected.First();
2418 if( anIO->hasEntry() ) {
2419 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2420 anActor->SetControlMode( SMESH_Actor::eNone );
2421 #ifndef DISABLE_PLOT2DVIEWER
2422 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2431 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2436 // dump control distribution data to the text file
2437 ::SaveDistribution();
2443 // show/ distribution
2444 ::ShowDistribution();
2448 #ifndef DISABLE_PLOT2DVIEWER
2451 // plot distribution
2452 ::PlotDistribution();
2463 ::DisableAutoColor();
2466 case 1134: // Clipping
2467 case 1133: // Tranparency
2468 case 1132: // Display preferences (colors, shrink size, line width, ...)
2475 ::SetDisplayMode(theCommandID, myMarkerMap);
2478 //2D quadratic representation
2481 ::SetDisplayMode(theCommandID, myMarkerMap);
2485 case 216: // 0D elements
2488 case 219: // Volumes
2489 case 220: // All Entity
2491 ::SetDisplayEntity(theCommandID);
2494 case 221: // Orientation of faces
2496 LightApp_SelectionMgr* mgr = selectionMgr();
2497 SALOME_ListIO selected; mgr->selectedObjects( selected );
2499 SALOME_ListIteratorOfListIO it(selected);
2500 for( ; it.More(); it.Next()) {
2501 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2502 if(anIObject->hasEntry()) {
2503 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2504 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2513 if(checkLock(aStudy)) break;
2514 SUIT_OverrideCursor wc;
2516 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2519 SMESH::UpdateView();
2521 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2522 SMESH::OnVisuException();
2524 catch (...) { // PAL16774 (Crash after display of many groups)
2525 SMESH::OnVisuException();
2529 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2530 aSel->selectedObjects( l );
2531 aSel->setSelectedObjects( l );
2536 case 301: // DISPLAY
2537 case 302: // DISPLAY ONLY
2539 SMESH::EDisplaing anAction;
2540 switch (theCommandID) {
2541 case 300: anAction = SMESH::eErase; break;
2542 case 301: anAction = SMESH::eDisplay; break;
2543 case 302: anAction = SMESH::eDisplayOnly; break;
2546 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2547 SALOME_ListIO sel_objects, to_process;
2549 aSel->selectedObjects( sel_objects );
2551 if( theCommandID==302 )
2553 MESSAGE("anAction = SMESH::eDisplayOnly");
2554 startOperation( myEraseAll );
2557 extractContainers( sel_objects, to_process );
2560 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2564 SALOME_ListIteratorOfListIO It( to_process );
2565 for ( ; It.More(); It.Next()) {
2567 Handle(SALOME_InteractiveObject) IOS = It.Value();
2568 if (IOS->hasEntry()) {
2570 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2571 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2572 break; // PAL16774 (Crash after display of many groups)
2574 if (anAction == SMESH::eDisplayOnly)
2576 MESSAGE("anAction = SMESH::eDisplayOnly");
2577 anAction = SMESH::eDisplay;
2583 // PAL13338 + PAL15161 -->
2584 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2585 MESSAGE("anAction = SMESH::eDisplayOnly");
2586 SMESH::UpdateView();
2587 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2589 // PAL13338 + PAL15161 <--
2591 catch (...) { // PAL16774 (Crash after display of many groups)
2592 SMESH::OnVisuException();
2595 if (anAction == SMESH::eErase) {
2596 MESSAGE("anAction == SMESH::eErase");
2598 aSel->setSelectedObjects( l1 );
2601 aSel->setSelectedObjects( to_process );
2608 if(checkLock(aStudy)) break;
2611 EmitSignalDeactivateDialog();
2613 ( new SMESHGUI_NodesDlg( this ) )->show();
2616 SUIT_MessageBox::warning(desktop(),
2617 tr("SMESH_WRN_WARNING"),
2618 tr("SMESH_WRN_VIEWER_VTK"));
2623 case 2151: // FILTER
2627 EmitSignalDeactivateDialog();
2628 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2633 case 701: // COMPUTE MESH
2634 case 711: // PRECOMPUTE MESH
2635 case 712: // EVALUATE MESH
2636 case 713: // MESH ORDER
2637 case 702: // Create mesh
2638 case 703: // Create sub-mesh
2639 case 704: // Edit mesh/sub-mesh
2640 startOperation( theCommandID );
2642 case 705: // copy mesh
2644 if (checkLock(aStudy)) break;
2645 EmitSignalDeactivateDialog();
2646 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2649 case 710: // Build compound mesh
2651 if (checkLock(aStudy)) break;
2652 EmitSignalDeactivateDialog();
2653 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2657 case 407: // DIAGONAL INVERSION
2658 case 408: // Delete diagonal
2662 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2663 tr( "NOT_A_VTK_VIEWER" ) );
2667 if ( checkLock( aStudy ) )
2670 /*Standard_Boolean aRes;
2671 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2672 if ( aMesh->_is_nil() )
2674 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2675 tr( "SMESH_BAD_SELECTION" ) );
2679 EmitSignalDeactivateDialog();
2680 if ( theCommandID == 407 )
2681 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2683 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2686 case 409: // Change orientation
2687 case 410: // Union of triangles
2688 case 411: // Cutting of quadrangles
2689 case 419: // Splitting volumes into tetrahedra
2693 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2694 tr( "NOT_A_VTK_VIEWER" ) );
2698 if ( checkLock( aStudy ) )
2701 EmitSignalDeactivateDialog();
2702 SMESHGUI_MultiEditDlg* aDlg = NULL;
2703 if ( theCommandID == 409 )
2704 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2705 else if ( theCommandID == 410 )
2706 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2707 else if ( theCommandID == 419 )
2708 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2710 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2715 case 412: // Smoothing
2717 if(checkLock(aStudy)) break;
2719 EmitSignalDeactivateDialog();
2720 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2723 SUIT_MessageBox::warning(desktop(),
2724 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2728 case 413: // Extrusion
2730 if (checkLock(aStudy)) break;
2732 EmitSignalDeactivateDialog();
2733 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2735 SUIT_MessageBox::warning(desktop(),
2736 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2740 case 414: // Revolution
2742 if(checkLock(aStudy)) break;
2744 EmitSignalDeactivateDialog();
2745 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2748 SUIT_MessageBox::warning(desktop(),
2749 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2753 case 415: // Pattern mapping
2755 if ( checkLock( aStudy ) )
2759 EmitSignalDeactivateDialog();
2760 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2763 SUIT_MessageBox::warning(desktop(),
2764 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2768 case 416: // Extrusion along a path
2770 if (checkLock(aStudy)) break;
2772 EmitSignalDeactivateDialog();
2773 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2775 SUIT_MessageBox::warning(desktop(),
2776 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2780 case 417: // Convert mesh to quadratic
2781 case 418: // create 2D mesh from 3D
2782 case 420: // Reorient faces
2783 case 806: // CREATE GEO GROUP
2785 startOperation( theCommandID );
2788 case 801: // CREATE GROUP
2792 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2793 tr( "NOT_A_VTK_VIEWER" ) );
2797 if(checkLock(aStudy)) break;
2798 EmitSignalDeactivateDialog();
2799 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2801 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2802 SALOME_ListIO selected;
2804 aSel->selectedObjects( selected );
2806 int nbSel = selected.Extent();
2808 // check if mesh is selected
2809 aMesh = SMESH::GetMeshByIO( selected.First() );
2811 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2816 case 802: // CONSTRUCT GROUP
2820 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2821 tr( "NOT_A_VTK_VIEWER" ) );
2825 if(checkLock(aStudy)) break;
2826 EmitSignalDeactivateDialog();
2828 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2829 SALOME_ListIO selected;
2831 aSel->selectedObjects( selected );
2833 int nbSel = selected.Extent();
2835 // check if submesh is selected
2836 Handle(SALOME_InteractiveObject) IObject = selected.First();
2837 if (IObject->hasEntry()) {
2838 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2840 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2841 if (!aSubMesh->_is_nil()) {
2843 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2844 // get submesh elements list by types
2845 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2846 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2847 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2848 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2849 // create group for each type o elements
2850 QString aName = IObject->getName();
2851 QStringList anEntryList;
2852 if (aNodes->length() > 0) {
2853 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2854 aGroup->Add(aNodes.inout());
2855 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2856 anEntryList.append( aSObject->GetID().c_str() );
2858 if (aEdges->length() > 0) {
2859 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2860 aGroup->Add(aEdges.inout());
2861 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2862 anEntryList.append( aSObject->GetID().c_str() );
2864 if (aFaces->length() > 0) {
2865 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2866 aGroup->Add(aFaces.inout());
2867 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2868 anEntryList.append( aSObject->GetID().c_str() );
2870 if (aVolumes->length() > 0) {
2871 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2872 aGroup->Add(aVolumes.inout());
2873 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2874 anEntryList.append( aSObject->GetID().c_str() );
2877 anApp->browseObjects( anEntryList );
2879 catch(const SALOME::SALOME_Exception & S_ex){
2880 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2887 SUIT_MessageBox::warning(desktop(),
2888 tr("SMESH_WRN_WARNING"),
2889 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2894 case 803: // EDIT GROUP
2898 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2899 tr( "NOT_A_VTK_VIEWER" ) );
2903 if(checkLock(aStudy)) break;
2904 EmitSignalDeactivateDialog();
2906 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2907 SALOME_ListIO selected;
2909 aSel->selectedObjects( selected );
2911 SALOME_ListIteratorOfListIO It (selected);
2912 int nbSelectedGroups = 0;
2913 for ( ; It.More(); It.Next() )
2915 SMESH::SMESH_GroupBase_var aGroup =
2916 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2917 if (!aGroup->_is_nil()) {
2919 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2923 if (nbSelectedGroups == 0)
2925 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2931 case 804: // Add elements to group
2933 if(checkLock(aStudy)) break;
2934 if (myState == 800) {
2935 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2936 if (aDlg) aDlg->onAdd();
2941 case 805: // Remove elements from group
2943 if(checkLock(aStudy)) break;
2944 if (myState == 800) {
2945 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2946 if (aDlg) aDlg->onRemove();
2951 case 815: // Edit GEOM GROUP as standalone
2955 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2956 tr( "NOT_A_VTK_VIEWER" ) );
2960 if(checkLock(aStudy)) break;
2961 EmitSignalDeactivateDialog();
2963 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2964 SALOME_ListIO selected;
2966 aSel->selectedObjects( selected );
2968 SALOME_ListIteratorOfListIO It (selected);
2969 for ( ; It.More(); It.Next() )
2971 SMESH::SMESH_GroupOnGeom_var aGroup =
2972 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2973 if (!aGroup->_is_nil()) {
2974 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2979 SMESH::SMESH_GroupOnFilter_var aGroup =
2980 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2981 if (!aGroup->_is_nil()) {
2982 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2990 case 810: // Union Groups
2991 case 811: // Intersect groups
2992 case 812: // Cut groups
2996 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2997 tr( "NOT_A_VTK_VIEWER" ) );
3001 if ( checkLock( aStudy ) )
3004 EmitSignalDeactivateDialog();
3006 SMESHGUI_GroupOpDlg* aDlg = 0;
3007 if ( theCommandID == 810 )
3008 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3009 else if ( theCommandID == 811 )
3010 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3012 aDlg = new SMESHGUI_CutGroupsDlg( this );
3019 case 814: // Create groups of entities from existing groups of superior dimensions
3021 if ( checkLock( aStudy ) )
3024 EmitSignalDeactivateDialog();
3025 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3031 case 813: // Delete groups with their contents
3035 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3036 tr( "NOT_A_VTK_VIEWER" ) );
3040 if ( checkLock( aStudy ) )
3043 EmitSignalDeactivateDialog();
3045 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3049 case 900: // MESH INFOS
3050 case 903: // WHAT IS
3052 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3053 EmitSignalDeactivateDialog();
3054 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3055 SALOME_ListIO selected;
3057 aSel->selectedObjects( selected );
3059 if ( selected.Extent() > 1 ) { // a dlg for each IO
3060 SALOME_ListIteratorOfListIO It( selected );
3061 for ( ; It.More(); It.Next() ) {
3062 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3063 dlg->showInfo( It.Value() );
3068 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3074 case 904: // FIND ELEM
3076 startOperation( theCommandID );
3080 case 1100: // EDIT HYPOTHESIS
3082 if(checkLock(aStudy)) break;
3084 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3085 SALOME_ListIO selected;
3087 aSel->selectedObjects( selected );
3089 int nbSel = selected.Extent();
3092 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3093 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3095 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
3096 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
3097 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
3098 if ( !aHypothesis->_is_nil() )
3101 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3102 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3104 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3114 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
3116 if(checkLock(aStudy)) break;
3117 SUIT_OverrideCursor wc;
3119 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3120 SALOME_ListIO selected;
3122 aSel->selectedObjects( selected, QString::null, false );
3124 SALOME_ListIteratorOfListIO It(selected);
3125 for (int i = 0; It.More(); It.Next(), i++) {
3126 Handle(SALOME_InteractiveObject) IObject = It.Value();
3127 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3130 aSel->setSelectedObjects( l1 );
3136 case 4009: // ELEM0D
3138 case 4021: // TRIANGLE
3140 case 4023: // POLYGON
3144 case 4134: // PYRAMID
3145 case 4135: // OCTA12
3147 if(checkLock(aStudy)) break;
3149 EmitSignalDeactivateDialog();
3150 SMDSAbs_EntityType type = SMDSEntity_Edge;
3151 switch (theCommandID) {
3152 case 4008: type = SMDSEntity_Ball; break;
3153 case 4009: type = SMDSEntity_0D; break;
3154 case 4021: type = SMDSEntity_Triangle; break;
3155 case 4022: type = SMDSEntity_Quadrangle; break;
3156 case 4031: type = SMDSEntity_Tetra; break;
3157 case 4023: type = SMDSEntity_Polygon; break;
3158 case 4032: type = SMDSEntity_Hexa; break;
3159 case 4133: type = SMDSEntity_Penta; break;
3160 case 4134: type = SMDSEntity_Pyramid; break;
3161 case 4135: type = SMDSEntity_Hexagonal_Prism; break;
3164 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3167 SUIT_MessageBox::warning(desktop(),
3168 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3172 case 4033: // POLYHEDRON
3174 if(checkLock(aStudy)) break;
3176 EmitSignalDeactivateDialog();
3177 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3180 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3181 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3185 case 4034: // QUADRATIC EDGE
3186 case 4035: // QUADRATIC TRIANGLE
3187 case 4036: // QUADRATIC QUADRANGLE
3188 case 4136: // BIQUADRATIC QUADRANGLE
3189 case 4137: // BIQUADRATIC TRIANGLE
3190 case 4037: // QUADRATIC TETRAHEDRON
3191 case 4038: // QUADRATIC PYRAMID
3192 case 4039: // QUADRATIC PENTAHEDRON
3193 case 4040: // QUADRATIC HEXAHEDRON
3194 case 4140: // TRIQUADRATIC HEXAHEDRON
3196 if(checkLock(aStudy)) break;
3198 EmitSignalDeactivateDialog();
3199 SMDSAbs_EntityType type = SMDSEntity_Last;
3201 switch (theCommandID) {
3202 case 4034: type = SMDSEntity_Quad_Edge; break;
3203 case 4035: type = SMDSEntity_Quad_Triangle; break;
3204 case 4036: type = SMDSEntity_Quad_Quadrangle; break;
3205 case 4136: type = SMDSEntity_BiQuad_Quadrangle; break;
3206 case 4137: type = SMDSEntity_BiQuad_Triangle; break;
3207 case 4037: type = SMDSEntity_Quad_Tetra; break;
3208 case 4038: type = SMDSEntity_Quad_Pyramid; break;
3209 case 4039: type = SMDSEntity_Quad_Penta; break;
3210 case 4040: type = SMDSEntity_Quad_Hexa; break;
3211 case 4140: type = SMDSEntity_TriQuad_Hexa; break;
3214 if ( type != SMDSEntity_Last )
3215 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3218 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3219 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3223 case 4041: // REMOVES NODES
3225 if(checkLock(aStudy)) break;
3227 EmitSignalDeactivateDialog();
3228 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3231 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3232 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3236 case 4042: // REMOVES ELEMENTS
3238 if(checkLock(aStudy)) break;
3240 EmitSignalDeactivateDialog();
3241 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3245 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3246 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3250 case 4043: { // CLEAR_MESH
3252 if(checkLock(aStudy)) break;
3254 SALOME_ListIO selected;
3255 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3256 aSel->selectedObjects( selected );
3258 SUIT_OverrideCursor wc;
3259 SALOME_ListIteratorOfListIO It (selected);
3260 for ( ; It.More(); It.Next() )
3262 Handle(SALOME_InteractiveObject) IOS = It.Value();
3263 SMESH::SMESH_Mesh_var aMesh =
3264 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3265 if ( aMesh->_is_nil()) continue;
3267 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3269 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3270 SMESH::ModifiedMesh( aMeshSObj, false, true);
3271 // hide groups and submeshes
3272 _PTR(ChildIterator) anIter =
3273 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3274 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3276 _PTR(SObject) so = anIter->Value();
3277 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3280 catch (const SALOME::SALOME_Exception& S_ex){
3282 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3286 SMESH::UpdateView();
3290 case 4044: // REMOVE ORPHAN NODES
3292 if(checkLock(aStudy)) break;
3293 SALOME_ListIO selected;
3294 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3295 aSel->selectedObjects( selected );
3296 if ( selected.Extent() == 1 ) {
3297 Handle(SALOME_InteractiveObject) anIO = selected.First();
3298 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3299 if ( !aMesh->_is_nil() ) {
3300 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3301 tr( "SMESH_WARNING" ),
3302 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3303 SUIT_MessageBox::Yes |
3304 SUIT_MessageBox::No,
3305 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3308 SUIT_OverrideCursor wc;
3309 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3310 int removed = aMeshEditor->RemoveOrphanNodes();
3311 SUIT_MessageBox::information(SMESHGUI::desktop(),
3312 tr("SMESH_INFORMATION"),
3313 tr("NB_NODES_REMOVED").arg(removed));
3314 if ( removed > 0 ) {
3315 SMESH::UpdateView();
3316 SMESHGUI::Modified();
3319 catch (const SALOME::SALOME_Exception& S_ex) {
3320 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3329 case 4051: // RENUMBERING NODES
3331 if(checkLock(aStudy)) break;
3333 EmitSignalDeactivateDialog();
3334 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3338 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3339 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3343 case 4052: // RENUMBERING ELEMENTS
3345 if(checkLock(aStudy)) break;
3347 EmitSignalDeactivateDialog();
3348 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3352 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3353 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3357 case 4061: // TRANSLATION
3359 if(checkLock(aStudy)) break;
3361 EmitSignalDeactivateDialog();
3362 ( new SMESHGUI_TranslationDlg( this ) )->show();
3365 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3366 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3370 case 4062: // ROTATION
3372 if(checkLock(aStudy)) break;
3374 EmitSignalDeactivateDialog();
3375 ( new SMESHGUI_RotationDlg( this ) )->show();
3378 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3379 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3383 case 4063: // SYMMETRY
3385 if(checkLock(aStudy)) break;
3387 EmitSignalDeactivateDialog();
3388 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3391 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3392 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3396 case 4064: // SEWING
3398 if(checkLock(aStudy)) break;
3400 EmitSignalDeactivateDialog();
3401 ( new SMESHGUI_SewingDlg( this ) )->show();
3404 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3405 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3409 case 4065: // MERGE NODES
3411 if(checkLock(aStudy)) break;
3413 EmitSignalDeactivateDialog();
3414 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3417 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3418 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3422 case 4066: // MERGE EQUAL ELEMENTS
3424 if (checkLock(aStudy)) break;
3426 EmitSignalDeactivateDialog();
3427 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3429 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3430 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3435 case 4067: // MAKE MESH PASS THROUGH POINT
3436 startOperation( 4067 );
3441 if(checkLock(aStudy)) break;
3443 EmitSignalDeactivateDialog();
3444 ( new SMESHGUI_ScaleDlg( this ) )->show();
3447 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3448 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3453 case 4069: // DUPLICATE NODES
3455 if(checkLock(aStudy)) break;
3457 EmitSignalDeactivateDialog();
3458 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3461 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3462 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3467 case 4070: // 0D_ON_ALL_NODES
3468 startOperation( 4070 );
3471 case 5105: // Library of selection filters
3473 static QList<int> aTypes;
3474 if ( aTypes.isEmpty() )
3476 aTypes.append( SMESH::NODE );
3477 aTypes.append( SMESH::EDGE );
3478 aTypes.append( SMESH::FACE );
3479 aTypes.append( SMESH::VOLUME );
3481 if (!myFilterLibraryDlg)
3482 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3483 else if (myFilterLibraryDlg->isHidden())
3484 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3485 myFilterLibraryDlg->raise();
3489 case 6017: // CONTROLS
3517 LightApp_SelectionMgr* mgr = selectionMgr();
3518 SALOME_ListIO selected; mgr->selectedObjects( selected );
3520 if ( selected.Extent() == 1 && selected.First()->hasEnt