1 // Copyright (C) 2007-2013 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.
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_FileInfoDlg.h"
48 #include "SMESHGUI_FileValidator.h"
49 #include "SMESHGUI_FilterDlg.h"
50 #include "SMESHGUI_FilterLibraryDlg.h"
51 #include "SMESHGUI_FindElemByPointDlg.h"
52 #include "SMESHGUI_GroupDlg.h"
53 #include "SMESHGUI_GroupOnShapeDlg.h"
54 #include "SMESHGUI_GroupOpDlg.h"
55 #include "SMESHGUI_Hypotheses.h"
56 #include "SMESHGUI_Make2DFrom3DOp.h"
57 #include "SMESHGUI_MakeNodeAtPointDlg.h"
58 #include "SMESHGUI_Measurements.h"
59 #include "SMESHGUI_MergeDlg.h"
60 #include "SMESHGUI_MeshInfo.h"
61 #include "SMESHGUI_MeshOp.h"
62 #include "SMESHGUI_MeshOrderOp.h"
63 #include "SMESHGUI_MeshPatternDlg.h"
64 #include "SMESHGUI_MultiEditDlg.h"
65 #include "SMESHGUI_NodesDlg.h"
66 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
67 #include "SMESHGUI_PropertiesDlg.h"
68 #include "SMESHGUI_RemoveElementsDlg.h"
69 #include "SMESHGUI_RemoveNodesDlg.h"
70 #include "SMESHGUI_RenumberingDlg.h"
71 #include "SMESHGUI_ReorientFacesDlg.h"
72 #include "SMESHGUI_RevolutionDlg.h"
73 #include "SMESHGUI_RotationDlg.h"
74 #include "SMESHGUI_ScaleDlg.h"
75 #include "SMESHGUI_Selection.h"
76 #include "SMESHGUI_SewingDlg.h"
77 #include "SMESHGUI_SingleEditDlg.h"
78 #include "SMESHGUI_SmoothingDlg.h"
79 #include "SMESHGUI_SymmetryDlg.h"
80 #include "SMESHGUI_TranslationDlg.h"
81 #include "SMESHGUI_TransparencyDlg.h"
83 #include "SMESHGUI_FilterUtils.h"
84 #include "SMESHGUI_GroupUtils.h"
85 #include "SMESHGUI_HypothesesUtils.h"
86 #include "SMESHGUI_MeshUtils.h"
87 #include "SMESHGUI_PatternUtils.h"
88 #include "SMESHGUI_Utils.h"
89 #include "SMESHGUI_VTKUtils.h"
91 #include <SMESH_version.h>
93 #include "SMESH_ControlsDef.hxx"
94 #include <SMESH_Actor.h>
95 #include <SMESH_ActorUtils.h>
96 #include <SMESH_Client.hxx>
97 #include <SMESH_ScalarBarActor.h>
98 #include <SMESH_TypeFilter.hxx>
100 // SALOME GUI includes
101 #include <SalomeApp_Application.h>
102 #include <SalomeApp_CheckFileDlg.h>
103 #include <SalomeApp_DataObject.h>
104 #include <SalomeApp_Study.h>
105 #include <SalomeApp_Tools.h>
107 #include <LightApp_DataOwner.h>
108 #include <LightApp_NameDlg.h>
109 #include <LightApp_Preferences.h>
110 #include <LightApp_SelectionMgr.h>
111 #include <LightApp_UpdateFlags.h>
113 #include <SVTK_ViewManager.h>
114 #include <SVTK_ViewModel.h>
115 #include <SVTK_ViewWindow.h>
117 #include <VTKViewer_Algorithm.h>
119 #include <SUIT_Desktop.h>
120 #include <SUIT_FileDlg.h>
121 #include <SUIT_MessageBox.h>
122 #include <SUIT_OverrideCursor.h>
123 #include <SUIT_ResourceMgr.h>
124 #include <SUIT_Session.h>
126 #include <QtxPopupMgr.h>
127 #include <QtxFontEdit.h>
129 #include <SALOME_ListIO.hxx>
130 #include <SALOME_ListIteratorOfListIO.hxx>
132 #ifndef DISABLE_PLOT2DVIEWER
133 #include <SPlot2d_ViewModel.h>
134 #include <SPlot2d_Histogram.h>
138 #include <SALOMEconfig.h>
139 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
140 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
141 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
144 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
145 #include <QApplication>
147 #include <QTextStream>
150 #include <boost/shared_ptr.hpp>
153 #include <vtkCallbackCommand.h>
154 #include <vtkCamera.h>
155 #include <vtkLookupTable.h>
156 #include <vtkPlane.h>
157 #include <vtkRenderer.h>
159 // SALOME KERNEL includes
160 #include <SALOMEDSClient_ClientFactory.hxx>
161 #include <SALOMEDSClient_IParameters.hxx>
162 #include <SALOMEDSClient_SComponent.hxx>
163 #include <SALOMEDSClient_StudyBuilder.hxx>
164 #include <SALOMEDS_Study.hxx>
167 #include <Standard_ErrorHandler.hxx>
168 #include <NCollection_DataMap.hxx>
170 #include <Basics_Utils.hxx>
172 //To disable automatic genericobj management, the following line should be commented.
173 //Otherwise, it should be uncommented.
174 //Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
175 #define WITHGENERICOBJ
177 // Below macro, when uncommented, switches on simplified (more performant) algorithm
178 // of auto-color picking up
179 #define SIMPLE_AUTOCOLOR
183 //=============================================================
184 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
187 void ExportMeshToFile(int theCommandID);
189 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
191 void SetDisplayEntity(int theCommandID);
193 void Control( int theCommandID );
197 //=============================================================
198 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
202 std::string myExtension;
204 if ( theCommandID == 113 ) {
205 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
206 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
208 else if ( theCommandID == 112 ) {
209 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
211 else if ( theCommandID == 111 ) {
212 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
214 else if ( theCommandID == 115 ) {
215 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
217 else if ( theCommandID == 116 ) {
218 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
220 else if ( theCommandID == 117 ) {
221 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
222 filter.append( QObject::tr( "All files (*)" ) );
224 else if ( theCommandID == 118 ) {
225 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
226 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
229 QString anInitialPath = "";
230 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
231 anInitialPath = QDir::currentPath();
233 QStringList filenames;
234 bool toCreateGroups = true;
236 // if ( theCommandID == 118 ) { // GMF
237 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
238 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
239 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
240 // fd->setNameFilters( filter );
241 // fd->SetChecked( true );
243 // filenames << fd->selectedFile();
244 // toCreateGroups = fd->IsChecked();
250 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
253 QObject::tr( "SMESH_IMPORT_MESH" ) );
255 if ( filenames.count() > 0 ) {
256 SUIT_OverrideCursor wc;
257 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
260 QStringList anEntryList;
261 bool isEmpty = false;
262 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
263 QString filename = *it;
264 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
266 switch ( theCommandID ) {
269 // DAT format (currently unsupported)
270 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
271 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
277 aMeshes->length( 1 );
278 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
279 if ( aMeshes[0]->_is_nil() )
280 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
281 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
287 SMESH::DriverMED_ReadStatus res;
288 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
289 if ( res != SMESH::DRS_OK ) {
290 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
291 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
298 aMeshes->length( 1 );
299 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
300 if ( aMeshes[0]->_is_nil() ) {
301 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
302 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
309 SMESH::DriverMED_ReadStatus res;
310 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
311 if ( res != SMESH::DRS_OK ) {
312 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
313 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
320 SMESH::DriverMED_ReadStatus res;
321 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toLatin1().constData(), res );
322 if ( res != SMESH::DRS_OK ) {
323 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
324 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
331 SMESH::ComputeError_var res;
332 aMeshes->length( 1 );
333 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toLatin1().constData(),
336 if ( res->code != SMESH::DRS_OK ) {
337 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
338 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
339 if ( strlen( res->comment.in() ) > 0 ) {
340 errors.back() += ": ";
341 errors.back() += res->comment.in();
348 catch ( const SALOME::SALOME_Exception& S_ex ) {
349 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
350 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
353 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
354 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
356 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
357 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
358 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
359 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
360 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
362 anEntryList.append( aMeshSO->GetID().c_str() );
364 // obj has been published in study. Its refcount has been incremented.
365 // It is safe to decrement its refcount
366 // so that it will be destroyed when the entry in study will be removed
367 aMeshes[i]->UnRegister();
375 // update Object browser
376 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
378 // browse to the published meshes
379 if( LightApp_Application* anApp =
380 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
381 anApp->browseObjects( anEntryList );
383 // show Error message box if there were errors
384 if ( errors.count() > 0 ) {
385 SUIT_MessageBox::critical( SMESHGUI::desktop(),
386 QObject::tr( "SMESH_ERROR" ),
387 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
390 // show warning message box, if some imported mesh is empty
392 SUIT_MessageBox::warning( SMESHGUI::desktop(),
393 QObject::tr( "SMESH_WRN_WARNING" ),
394 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
399 //================================================================================
401 * \brief Export selected meshes or groups into a file
403 //================================================================================
405 void ExportMeshToFile( int theCommandID )
407 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
408 SALOME_ListIO selected;
410 aSel->selectedObjects( selected );
412 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
413 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
414 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
415 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
416 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
417 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
418 const bool isGMF = ( theCommandID == 146 || theCommandID == 147 );
420 // actually, the following condition can't be met (added for insurance)
421 if( selected.Extent() == 0 ||
422 ( selected.Extent() > 1 && !isMED && !isSTL ))
425 // get mesh object from selection and check duplication of their names
426 bool hasDuplicatedMeshNames = false;
427 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
428 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
429 SALOME_ListIteratorOfListIO It( selected );
430 for( ; It.More(); It.Next() )
432 Handle(SALOME_InteractiveObject) anIObject = It.Value();
433 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
434 if ( aMeshItem->_is_nil() ) {
435 SUIT_MessageBox::warning( SMESHGUI::desktop(),
436 QObject::tr( "SMESH_WRN_WARNING" ),
437 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
441 QString aMeshName = anIObject->getName();
443 // check for name duplications
444 if ( !hasDuplicatedMeshNames )
445 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
446 if( aMeshName == (*aMeshIter).second ) {
447 hasDuplicatedMeshNames = true;
452 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
455 if( hasDuplicatedMeshNames && isMED ) {
456 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
457 QObject::tr("SMESH_WRN_WARNING"),
458 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
459 QObject::tr("SMESH_BUT_YES"),
460 QObject::tr("SMESH_BUT_NO"), 0, 1);
465 aMeshIter = aMeshList.begin();
466 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
467 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
468 QString aMeshName = (*aMeshIter).second;
470 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
472 // check for equal group names within each mesh
473 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
474 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
475 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
476 int aRet = SUIT_MessageBox::warning
477 (SMESHGUI::desktop(),
478 QObject::tr("SMESH_WRN_WARNING"),
479 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
480 QObject::tr("SMESH_BUT_YES"),
481 QObject::tr("SMESH_BUT_NO"), 0, 1);
488 // Warn the user about presence of not supported elements
490 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
494 notSupportedElemTypes.push_back( SMESH::Entity_0D );
495 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
500 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
501 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
502 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
503 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
504 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
505 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
506 notSupportedElemTypes.push_back( SMESH::Entity_0D );
507 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
512 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
513 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
514 notSupportedElemTypes.push_back( SMESH::Entity_0D );
515 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
520 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
521 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
526 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
527 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
528 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
529 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
530 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
531 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
532 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
537 notSupportedElemTypes.push_back( SMESH::Entity_0D );
538 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
539 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
540 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
541 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
542 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
543 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
544 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
545 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
547 if ( ! notSupportedElemTypes.empty() )
549 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
550 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
551 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
552 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
554 if ( !presentNotSupported.empty() )
557 const char* typeMsg[SMESH::Entity_Last] = {
558 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
559 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
560 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
561 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
562 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
563 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
564 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
565 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
567 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
568 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
569 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
570 if ( iType != presentNotSupported.size() - 1 )
571 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
573 int aRet = SUIT_MessageBox::warning
574 (SMESHGUI::desktop(),
575 QObject::tr("SMESH_WRN_WARNING"),
576 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
577 QObject::tr("SMESH_BUT_YES"),
578 QObject::tr("SMESH_BUT_NO"), 0, 1);
583 // Get parameters of export operation
586 SMESH::MED_VERSION aFormat;
587 // Init the parameters with the default values
588 bool aIsASCII_STL = true;
589 bool toCreateGroups = false;
590 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
592 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
593 bool toOverwrite = true;
594 bool toFindOutDim = true;
596 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
597 QString anInitialPath = "";
598 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
599 anInitialPath = QDir::currentPath();
601 // Get a file name to write in and additional otions
602 if ( isUNV || isDAT || isGMF ) // Export w/o options
605 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
607 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
609 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
610 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
611 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
612 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
613 anInitialPath + QString("/") + aMeshName,
614 aFilter, aTitle, false);
616 else if ( isCGNS )// Export to CGNS
618 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
619 fd->setWindowTitle( aTitle );
620 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
621 if ( !anInitialPath.isEmpty() )
622 fd->setDirectory( anInitialPath );
623 fd->selectFile(aMeshName);
624 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
625 fd->setValidator( fv );
628 aFilename = fd->selectedFile();
629 toOverwrite = fv->isOverwrite();
633 else if ( isSTL ) // Export to STL
635 QMap<QString, int> aFilterMap;
636 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
637 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
640 QMap<QString, int>::const_iterator it = aFilterMap.begin();
641 for ( ; it != aFilterMap.end(); ++it )
642 filters.push_back( it.key() );
644 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
645 fd->setWindowTitle( aTitle );
646 fd->setNameFilters( filters );
647 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
648 if ( !anInitialPath.isEmpty() )
649 fd->setDirectory( anInitialPath );
650 fd->selectFile(aMeshName);
654 aFilename = fd->selectedFile();
655 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
660 else if ( isMED || isSAUV ) // Export to MED or SAUV
662 QMap<QString, SMESH::MED_VERSION> aFilterMap;
663 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
665 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
666 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
667 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
670 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
671 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
672 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
676 QString aDefaultFilter;
677 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
678 for ( ; it != aFilterMap.end(); ++it ) {
679 filters.push_back( it.key() );
680 if (it.value() == SMESH::MED_V2_2)
681 aDefaultFilter = it.key();
683 QStringList checkBoxes;
684 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
686 SalomeApp_CheckFileDlg* fd =
687 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
688 fd->setWindowTitle( aTitle );
689 fd->setNameFilters( filters );
690 fd->selectNameFilter(aDefaultFilter);
691 fd->SetChecked(0,toCreateGroups);
692 fd->SetChecked(1,toFindOutDim);
693 if ( !anInitialPath.isEmpty() )
694 fd->setDirectory( anInitialPath );
695 fd->selectFile(aMeshName);
697 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
698 fd->setValidator( fv );
703 aFilename = fd->selectedFile();
705 aFilename = QString::null;
708 aFormat = aFilterMap[fd->selectedNameFilter()];
709 toOverwrite = fv->isOverwrite();
711 if ( !aFilename.isEmpty() ) {
712 // med-2.1 does not support poly elements
713 if ( aFormat==SMESH::MED_V2_1 )
714 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
715 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
716 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
717 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
718 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
720 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
721 QObject::tr("SMESH_WRN_WARNING"),
722 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
723 QObject::tr("SMESH_BUT_YES"),
724 QObject::tr("SMESH_BUT_NO"), 0, 1);
732 // can't append to an existing using other format
733 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
734 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
735 if( !isVersionOk || aVersion != aFormat ) {
736 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
737 QObject::tr("SMESH_WRN_WARNING"),
738 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
739 QObject::tr("SMESH_BUT_YES"),
740 QObject::tr("SMESH_BUT_NO"), 0, 1);
747 QStringList aMeshNamesCollisionList;
748 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
749 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
750 QString anExistingMeshName( aMeshNames[ i ] );
751 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
752 QString anExportMeshName = (*aMeshIter).second;
753 if( anExportMeshName == anExistingMeshName ) {
754 aMeshNamesCollisionList.append( anExportMeshName );
759 if( !aMeshNamesCollisionList.isEmpty() ) {
760 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
761 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
762 QObject::tr("SMESH_WRN_WARNING"),
763 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
764 QObject::tr("SMESH_BUT_YES"),
765 QObject::tr("SMESH_BUT_NO"),
766 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
775 toCreateGroups = fd->IsChecked(0);
776 toFindOutDim = fd->IsChecked(1);
786 if ( !aFilename.isEmpty() ) {
787 // Check whether the file already exists and delete it if yes
788 QFile aFile( aFilename );
789 if ( aFile.exists() && toOverwrite )
791 SUIT_OverrideCursor wc;
794 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
795 // bool Renumber = false;
796 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
798 // Renumber= resMgr->booleanValue("renumbering");
800 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
801 // aMeshEditor->RenumberNodes();
802 // aMeshEditor->RenumberElements();
803 // if ( SMESHGUI::automaticUpdate() )
804 // SMESH::UpdateView();
808 aMeshIter = aMeshList.begin();
809 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
811 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
812 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
813 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
814 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
815 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
817 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
818 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
823 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
825 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
826 if( !aMeshItem->_is_nil() )
827 aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
832 if ( aMeshOrGroup->_is_equivalent( aMesh ))
833 aMesh->ExportDAT( aFilename.toLatin1().data() );
835 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
839 if ( aMeshOrGroup->_is_equivalent( aMesh ))
840 aMesh->ExportUNV( aFilename.toLatin1().data() );
842 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
846 if ( aMeshOrGroup->_is_equivalent( aMesh ))
847 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
849 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
853 aMeshIter = aMeshList.begin();
854 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
856 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
857 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
858 aMeshItem->ExportCGNS( aMeshOrGroup,
859 aFilename.toLatin1().data(),
860 toOverwrite && aMeshIndex == 0 );
865 toCreateGroups = true;
866 aMesh->ExportGMF( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups );
869 catch (const SALOME::SALOME_Exception& S_ex){
871 SUIT_MessageBox::warning(SMESHGUI::desktop(),
872 QObject::tr("SMESH_WRN_WARNING"),
873 QObject::tr("SMESH_EXPORT_FAILED"));
879 inline void InverseEntityMode(unsigned int& theOutputMode,
880 unsigned int theMode)
882 bool anIsNotPresent = ~theOutputMode & theMode;
884 theOutputMode |= theMode;
886 theOutputMode &= ~theMode;
889 void SetDisplayEntity(int theCommandID){
890 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
891 SALOME_ListIO selected;
893 aSel->selectedObjects( selected );
895 if(selected.Extent() >= 1){
896 SALOME_ListIteratorOfListIO It( selected );
897 for( ; It.More(); It.Next()){
898 Handle(SALOME_InteractiveObject) IObject = It.Value();
899 if(IObject->hasEntry()){
900 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
901 unsigned int aMode = anActor->GetEntityMode();
902 switch(theCommandID){
904 InverseEntityMode(aMode,SMESH_Actor::eBallElem);
907 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
910 InverseEntityMode(aMode,SMESH_Actor::eEdges);
913 InverseEntityMode(aMode,SMESH_Actor::eFaces);
916 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
919 aMode = SMESH_Actor::eAllEntity;
923 anActor->SetEntityMode(aMode);
931 SALOME_ListIO selected;
932 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
936 LightApp_SelectionMgr* aSel = app->selectionMgr();
937 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
938 if( !aSel || !appStudy )
941 aSel->selectedObjects( selected );
942 if( selected.IsEmpty() )
945 Handle(SALOME_InteractiveObject) anIObject = selected.First();
947 _PTR(Study) aStudy = appStudy->studyDS();
948 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
949 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
950 if( aMainObject->_is_nil() )
953 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
955 QList<SALOMEDS::Color> aReservedColors;
957 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
958 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
960 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
961 //SALOMEDS::Color aColor = aGroupObject->GetColor();
963 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
964 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
965 #else // old algorithm for auto-colors
966 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
967 aReservedColors.append( aColor );
968 #endif // SIMPLE_AUTOCOLOR
970 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
974 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
975 switch ( aGroupObject->GetType ()) {
977 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
979 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
981 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
983 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
985 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
986 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
989 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
990 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
996 SMESH::RepaintCurrentView();
999 void OverallMeshQuality() {
1000 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1001 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1002 SALOME_ListIO selected;
1004 aSel->selectedObjects( selected );
1006 if ( selected.IsEmpty() ) return;
1007 SALOME_ListIteratorOfListIO It( selected );
1008 for ( ; It.More(); It.Next() ) {
1009 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1010 ctrlDlg->showInfo( It.Value() );
1015 QString functorToString( SMESH::Controls::FunctorPtr f )
1017 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1018 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1019 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1020 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1021 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1022 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1023 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1024 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1025 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1026 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1027 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1028 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1029 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1030 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1031 type = QObject::tr( "WARP_ELEMENTS" );
1032 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1033 type = QObject::tr( "TAPER_ELEMENTS" );
1034 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1035 type = QObject::tr( "SKEW_ELEMENTS" );
1036 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1037 type = QObject::tr( "AREA_ELEMENTS" );
1038 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1039 type = QObject::tr( "LENGTH_EDGES" );
1040 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1041 type = QObject::tr( "LENGTH2D_EDGES" );
1042 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1043 type = QObject::tr( "MULTI_BORDERS" );
1044 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1045 type = QObject::tr( "MULTI2D_BORDERS" );
1046 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1047 type = QObject::tr( "FREE_NODES" );
1048 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1049 type = QObject::tr( "FREE_EDGES" );
1050 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1051 type = QObject::tr( "FREE_BORDERS" );
1052 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1053 type = QObject::tr( "FREE_FACES" );
1054 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1055 type = QObject::tr( "BARE_BORDER_VOLUME" );
1056 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1057 type = QObject::tr( "BARE_BORDER_FACE" );
1058 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1059 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1060 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1061 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1062 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1063 type = QObject::tr( "EQUAL_NODE" );
1064 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1065 type = QObject::tr( "EQUAL_EDGE" );
1066 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1067 type = QObject::tr( "EQUAL_FACE" );
1068 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1069 type = QObject::tr( "EQUAL_VOLUME" );
1073 void SaveDistribution()
1075 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1076 SALOME_ListIO selected;
1078 aSel->selectedObjects( selected );
1080 if ( selected.Extent() == 1 ) {
1081 Handle(SALOME_InteractiveObject) anIO = selected.First();
1082 if ( anIO->hasEntry() ) {
1083 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1084 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1085 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1086 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1087 if ( aScalarBarActor && aFunctor ) {
1088 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1090 std::vector<int> elements;
1091 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1092 if ( mesh->_is_nil() ) {
1093 SMESH::SMESH_IDSource_var idSource =
1094 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1095 if ( !idSource->_is_nil() )
1097 SMESH::long_array_var ids = idSource->GetIDs();
1098 elements.resize( ids->length() );
1099 for ( unsigned i = 0; i < elements.size(); ++i )
1100 elements[i] = ids[i];
1103 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1104 vtkLookupTable* lookupTable =
1105 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1106 double * minmax = lookupTable->GetRange();
1107 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1108 std::vector<int> nbEvents;
1109 std::vector<double> funValues;
1110 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax, isLogarithmic );
1111 QString anInitialPath = "";
1112 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1113 anInitialPath = QDir::currentPath();
1114 QString aMeshName = anIO->getName();
1116 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1117 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1118 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1119 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1120 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1123 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1125 if ( !aFilename.isEmpty() ) {
1126 QFile f( aFilename );
1127 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1128 QTextStream out( &f );
1129 out << "# Mesh: " << aMeshName << endl;
1130 out << "# Control: " << functorToString( aFunctor ) << endl;
1132 out.setFieldWidth( 10 );
1133 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1134 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1145 void ShowDistribution() {
1146 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1147 SALOME_ListIO selected;
1149 aSel->selectedObjects( selected );
1151 if ( selected.Extent() == 1 ) {
1152 Handle(SALOME_InteractiveObject) anIO = selected.First();
1153 if ( anIO->hasEntry() ) {
1154 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1155 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1156 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1157 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1163 #ifndef DISABLE_PLOT2DVIEWER
1164 void PlotDistribution() {
1165 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1169 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1170 SALOME_ListIO selected;
1172 aSel->selectedObjects( selected );
1174 if ( selected.Extent() == 1 ) {
1175 Handle(SALOME_InteractiveObject) anIO = selected.First();
1176 if ( anIO->hasEntry() ) {
1177 //Find Actor by entry before getting Plot2d viewer,
1178 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1179 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1181 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1186 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1190 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1194 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1195 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1196 QString functorName = functorToString( anActor->GetFunctor());
1197 QString aHistogramName("%1 : %2");
1198 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1199 aHistogram->setName(aHistogramName);
1200 aHistogram->setHorTitle(functorName);
1201 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1202 aPlot->displayObject(aHistogram, true);
1207 #endif //DISABLE_PLOT2DVIEWER
1209 void DisableAutoColor(){
1210 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1211 SALOME_ListIO selected;
1213 aSel->selectedObjects( selected );
1215 if(selected.Extent()){
1216 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1217 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1218 if ( !aMesh->_is_nil() ) {
1219 aMesh->SetAutoColor( false );
1224 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1226 SALOME_ListIO selected;
1227 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1231 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1232 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1233 if( !aSel || !appStudy )
1236 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1237 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1238 aModule->EmitSignalDeactivateDialog();
1239 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1240 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1245 _PTR(Study) aStudy = appStudy->studyDS();
1247 aSel->selectedObjects( selected );
1249 if(selected.Extent() >= 1){
1250 switch(theCommandID){
1252 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1253 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1258 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1259 QColor orientationColor, outlineColor, volumeColor;
1260 int deltaF = 0, deltaV = 0;
1264 int outlineWidth = 1;
1265 double shrinkCoef = 0.0;
1266 double orientationScale = 0.0;
1267 bool orientation3d = false;
1268 VTK::MarkerType markerType = VTK::MT_NONE;
1269 VTK::MarkerScale markerScale = VTK::MS_NONE;
1271 bool hasNodes = false;
1272 int presentEntities = 0;
1273 bool firstTime = true;
1275 SALOME_ListIteratorOfListIO It( selected );
1276 for ( ; It.More(); It.Next() ) {
1277 Handle(SALOME_InteractiveObject) IObject = It.Value();
1278 if ( !IObject->hasEntry() ) continue;
1279 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1280 if ( !anActor || !anActor->GetObject() ) continue;
1283 // nodes: color, marker
1284 anActor->GetNodeColor( color[0], color[1], color[2] );
1285 nodeColor.setRgbF( color[0], color[1], color[2] );
1286 markerType = anActor->GetMarkerType();
1287 markerScale = anActor->GetMarkerScale();
1288 markerId = anActor->GetMarkerTexture();
1289 // edges: color, width
1290 anActor->GetEdgeColor( color[0], color[1], color[2] );
1291 edgeColor.setRgbF( color[0], color[1], color[2] );
1292 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1293 // faces: front color, back color (delta)
1294 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1295 faceColor.setRgbF( color[0], color[1], color[2] );
1296 // faces: front color, back color (delta)
1297 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1298 volumeColor.setRgbF( color[0], color[1], color[2] );
1299 // 0d elements: color, size
1300 anActor->Get0DColor( color[0], color[1], color[2] );
1301 elem0dColor.setRgbF( color[0], color[1], color[2] );
1302 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1303 // balls: color, size
1304 anActor->GetBallColor( color[0], color[1], color[2] );
1305 ballColor.setRgbF( color[0], color[1], color[2] );
1306 ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1308 anActor->GetOutlineColor( color[0], color[1], color[2] );
1309 outlineColor.setRgbF( color[0], color[1], color[2] );
1310 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1311 // orientation vectors: color, scale, 3d flag
1312 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1313 orientationColor.setRgbF( color[0], color[1], color[2] );
1314 orientationScale = anActor->GetFacesOrientationScale();
1315 orientation3d = anActor->GetFacesOrientation3DVectors();
1317 shrinkCoef = anActor->GetShrinkFactor();
1320 firstTime = false; // we only take properties from first object (for performance reasons)
1323 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1324 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1325 presentEntities = presentEntities | SMESH_Actor::eEdges;
1326 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1327 presentEntities = presentEntities | SMESH_Actor::eFaces;
1328 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1329 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1330 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1331 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1332 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1333 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1335 // as we know that all types of elements are present, we can exit the loop
1336 if ( presentEntities == SMESH_Actor::eAllEntity )
1340 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1341 // nodes: color, marker
1342 dlg.setNodeColor( nodeColor );
1343 if( markerType != VTK::MT_USER )
1344 dlg.setNodeMarker( markerType, markerScale );
1346 dlg.setNodeCustomMarker( markerId );
1347 // edges: color, line width
1348 dlg.setEdgeColor( edgeColor );
1349 dlg.setEdgeWidth( edgeWidth );
1350 // faces: front color, back color
1351 dlg.setFaceColor( faceColor, deltaF );
1352 // volumes: normal color, reversed color
1353 dlg.setVolumeColor( volumeColor, deltaV );
1354 // outlines: color, line width
1355 dlg.setOutlineColor( outlineColor );
1356 dlg.setOutlineWidth( outlineWidth );
1357 // 0d elements: color, size
1358 dlg.setElem0dColor( elem0dColor );
1359 dlg.setElem0dSize( elem0dSize );
1360 // balls: color, size
1361 dlg.setBallColor( ballColor );
1362 dlg.setBallSize( ballSize );
1363 // orientation: color, scale, 3d flag
1364 dlg.setOrientationColor( orientationColor );
1365 dlg.setOrientationSize( int( orientationScale * 100. ) );
1366 dlg.setOrientation3d( orientation3d );
1367 // shrink: scale factor
1368 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1369 // hide unused controls
1370 dlg.showControls( presentEntities, hasNodes );
1373 nodeColor = dlg.nodeColor();
1374 markerType = dlg.nodeMarkerType();
1375 markerScale = dlg.nodeMarkerScale();
1376 markerId = dlg.nodeMarkerId();
1377 edgeColor = dlg.edgeColor();
1378 edgeWidth = dlg.edgeWidth();
1379 faceColor = dlg.faceColor();
1380 deltaF = dlg.faceColorDelta();
1381 volumeColor = dlg.volumeColor();
1382 deltaV = dlg.volumeColorDelta();
1383 outlineColor = dlg.outlineColor();
1384 outlineWidth = dlg.outlineWidth();
1385 elem0dColor = dlg.elem0dColor();
1386 elem0dSize = dlg.elem0dSize();
1387 ballColor = dlg.ballColor();
1388 ballSize = dlg.ballSize();
1389 orientationColor = dlg.orientationColor();
1390 orientationScale = dlg.orientationSize() / 100.;
1391 orientation3d = dlg.orientation3d();
1392 shrinkCoef = dlg.shrinkCoef() / 100.;
1394 // store point markers map that might be changed by the user
1395 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1397 // set properties from dialog box to the presentations
1398 SALOME_ListIteratorOfListIO It( selected );
1399 for ( ; It.More(); It.Next() ) {
1400 Handle(SALOME_InteractiveObject) IObject = It.Value();
1401 if ( !IObject->hasEntry() ) continue;
1402 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1403 if ( !anActor ) continue;
1405 // nodes: color, marker
1406 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1407 if ( markerType != VTK::MT_USER ) {
1408 anActor->SetMarkerStd( markerType, markerScale );
1411 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1412 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1413 if ( iter != markerMap.end() )
1414 anActor->SetMarkerTexture( markerId, iter->second.second );
1416 // volumes: normal color, reversed color (delta)
1417 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1418 // faces: front color, back color (delta)
1419 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1420 // edges: color, width
1421 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1422 anActor->SetLineWidth( edgeWidth );
1424 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1425 anActor->SetOutlineWidth( outlineWidth );
1426 // 0D elements: color, size
1427 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1428 anActor->Set0DSize( elem0dSize );
1429 // balls: color, size
1430 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1431 anActor->SetBallSize( ballSize );
1432 // orientation: color, scale, 3d flag
1433 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1434 anActor->SetFacesOrientationScale( orientationScale );
1435 anActor->SetFacesOrientation3DVectors( orientation3d );
1437 anActor->SetShrinkFactor( shrinkCoef );
1439 // for groups, set also proper color
1440 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1441 if ( !aGroupObject->_is_nil() ) {
1442 SMESH::ElementType anElementType = aGroupObject->GetType();
1444 switch( anElementType ) {
1446 aColor = nodeColor; break;
1448 aColor = edgeColor; break;
1450 aColor = faceColor; break;
1452 aColor = volumeColor; break;
1454 aColor = elem0dColor; break;
1456 aColor = ballColor; break;
1460 if ( aColor.isValid() ) {
1461 SALOMEDS::Color aGroupColor;
1462 aGroupColor.R = aColor.redF();
1463 aGroupColor.G = aColor.greenF();
1464 aGroupColor.B = aColor.blueF();
1465 aGroupObject->SetColor( aGroupColor );
1467 } // if ( !aGroupObject->_is_nil() )
1468 } // for ( ; It.More(); It.Next() )
1469 SMESH::RepaintCurrentView();
1470 } // if ( dlg.exec() )
1473 } // switch(theCommandID)
1474 SALOME_ListIteratorOfListIO It( selected );
1475 for( ; It.More(); It.Next()){
1476 Handle(SALOME_InteractiveObject) IObject = It.Value();
1477 if(IObject->hasEntry()){
1478 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1479 switch(theCommandID){
1481 anActor->SetRepresentation(SMESH_Actor::eEdge);
1484 anActor->SetRepresentation(SMESH_Actor::eSurface);
1487 if(anActor->IsShrunk())
1488 anActor->UnShrink();
1490 anActor->SetShrink();
1493 anActor->SetRepresentation(SMESH_Actor::ePoint);
1496 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1497 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1500 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1501 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1507 SMESH::RepaintCurrentView();
1511 void Control( int theCommandID )
1513 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1514 SALOME_ListIO selected;
1516 aSel->selectedObjects( selected );
1518 if( !selected.IsEmpty() ){
1519 Handle(SALOME_InteractiveObject) anIO = selected.First();
1521 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1522 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1523 switch ( theCommandID ){
1525 aControl = SMESH_Actor::eLength;
1528 aControl = SMESH_Actor::eLength2D;
1531 aControl = SMESH_Actor::eFreeEdges;
1534 aControl = SMESH_Actor::eFreeBorders;
1537 aControl = SMESH_Actor::eMultiConnection;
1540 aControl = SMESH_Actor::eFreeNodes;
1543 aControl = SMESH_Actor::eMultiConnection2D;
1546 aControl = SMESH_Actor::eArea;
1549 aControl = SMESH_Actor::eTaper;
1552 aControl = SMESH_Actor::eAspectRatio;
1555 aControl = SMESH_Actor::eAspectRatio3D;
1558 aControl = SMESH_Actor::eMinimumAngle;
1561 aControl = SMESH_Actor::eWarping;
1564 aControl = SMESH_Actor::eSkew;
1567 aControl = SMESH_Actor::eVolume3D;
1570 aControl = SMESH_Actor::eFreeFaces;
1573 aControl = SMESH_Actor::eMaxElementLength2D;
1576 aControl = SMESH_Actor::eMaxElementLength3D;
1579 aControl = SMESH_Actor::eBareBorderVolume;
1582 aControl = SMESH_Actor::eBareBorderFace;
1585 aControl = SMESH_Actor::eOverConstrainedVolume;
1588 aControl = SMESH_Actor::eOverConstrainedFace;
1591 aControl = SMESH_Actor::eCoincidentNodes;
1594 aControl = SMESH_Actor::eCoincidentElems1D;
1597 aControl = SMESH_Actor:: eCoincidentElems2D;
1600 aControl = SMESH_Actor::eCoincidentElems3D;
1604 anActor->SetControlMode(aControl);
1605 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1606 SMESH::RepaintCurrentView();
1607 #ifndef DISABLE_PLOT2DVIEWER
1608 if(anActor->GetPlot2Histogram()) {
1609 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1610 QString functorName = functorToString( anActor->GetFunctor());
1611 QString aHistogramName("%1 : %2");
1612 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1613 aHistogram->setName(aHistogramName);
1614 aHistogram->setHorTitle(functorName);
1615 SMESH::ProcessIn2DViewers(anActor);
1624 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1625 SMESH::MeshObjectType theType,
1626 const QString theInTypeName,
1627 QString & theOutTypeName)
1629 SMESH_TypeFilter aTypeFilter( theType );
1631 if( !theIO.IsNull() )
1633 entry = theIO->getEntry();
1634 LightApp_DataOwner owner( entry );
1635 if ( aTypeFilter.isOk( &owner )) {
1636 theOutTypeName = theInTypeName;
1644 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1646 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1647 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1649 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1650 CORBA::String_var anID = aSComp->GetID().c_str();
1651 if (!strcmp(anID.in(),theIO->getEntry()))
1657 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1658 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1659 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1660 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1661 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1669 QString CheckHomogeneousSelection()
1671 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1672 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1673 SALOME_ListIO selected;
1675 aSel->selectedObjects( selected );
1677 QString RefType = CheckTypeObject(selected.First());
1678 SALOME_ListIteratorOfListIO It(selected);
1679 for ( ; It.More(); It.Next())
1681 Handle(SALOME_InteractiveObject) IObject = It.Value();
1682 QString Type = CheckTypeObject(IObject);
1683 if (Type.compare(RefType) != 0)
1684 return "Heterogeneous Selection";
1691 void SMESHGUI::OnEditDelete()
1693 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1694 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1695 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1697 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1698 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1699 _PTR(GenericAttribute) anAttr;
1700 _PTR(AttributeIOR) anIOR;
1702 int objectCount = 0;
1704 QString aParentComponent = QString::null;
1705 Handle(SALOME_InteractiveObject) anIO;
1706 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1708 anIO = anIt.Value();
1709 QString cur = anIO->getComponentDataType();
1710 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1712 // check if object is reference
1713 _PTR(SObject) aRefSObj;
1714 aNameList.append("\n - ");
1715 if ( aSO->ReferencedObject( aRefSObj ) ) {
1716 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1717 aNameList.append( aRefName );
1718 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1721 aNameList.append(anIO->getName());
1725 if( aParentComponent.isNull() )
1726 aParentComponent = cur;
1727 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1728 aParentComponent = "";
1731 if ( objectCount == 0 )
1732 return; // No Valid Objects Selected
1734 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1735 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1736 QObject::tr("ERR_ERROR"),
1737 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1740 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1741 if (SUIT_MessageBox::warning
1742 (SMESHGUI::desktop(),
1743 QObject::tr("SMESH_WRN_WARNING"),
1744 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1745 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1746 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1749 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1751 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1752 // then treat them all starting from the deepest objects (at list back)
1753 std::list< _PTR(SObject) > listSO;
1754 SALOME_ListIteratorOfListIO It(selected);
1755 for( ; It.More(); It.Next()) // loop on selected IO's
1757 Handle(SALOME_InteractiveObject) IObject = It.Value();
1758 if(IObject->hasEntry()) {
1759 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1761 // disable removal of "SMESH" component object
1762 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1764 if ( engineIOR() == anIOR->Value().c_str() )
1767 //Check the referenced object
1768 _PTR(SObject) aRefSObject;
1769 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1770 aSO = aRefSObject; // Delete main Object instead of reference
1772 listSO.push_back( aSO );
1773 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1774 for ( ; itSO != listSO.end(); ++itSO ) {
1775 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1776 for (it->InitEx(false); it->More(); it->Next())
1777 listSO.push_back( it->Value() );
1781 // Check if none of objects to delete is referred from outside
1782 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1783 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1785 _PTR(SObject) SO = *ritSO;
1786 if ( !SO ) continue;
1787 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1788 for (size_t i = 0; i < aReferences.size(); i++) {
1789 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1790 std::string type = aComponent->ComponentDataType();
1791 if ( type != "SMESH" )
1793 SUIT_MessageBox::warning( anApp->desktop(),
1794 QObject::tr("WRN_WARNING"),
1795 QObject::tr("DEP_OBJECT") );
1796 return; // outside SMESH, there is an object depending on a SMESH object
1801 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1802 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1804 Handle(SALOME_InteractiveObject) IObject = It.Value();
1805 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1806 if ( !mesh->_is_nil() )
1810 // Treat SO's in the list starting from the back
1811 aStudyBuilder->NewCommand(); // There is a transaction
1812 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1814 _PTR(SObject) SO = *ritSO;
1815 if ( !SO ) continue;
1816 std::string anEntry = SO->GetID();
1818 /** Erase graphical object **/
1819 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1820 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1821 // ViewManagerList aViewMenegers = anApp->viewManagers();
1822 // ViewManagerList::const_iterator it = aViewMenegers.begin();
1823 // for( ; it != aViewMenegers.end(); it++) {
1824 // SUIT_ViewManager* vm = *it;
1825 // int nbSf = vm ? vm->getViewsCount() : 0;
1827 // QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1828 // for(int i = 0; i < nbSf; i++){
1829 // SUIT_ViewWindow *sf = aViews[i];
1830 // if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1831 // SMESH::RemoveActor(sf,anActor);
1837 /** Remove an object from data structures **/
1838 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1839 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1840 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1841 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1842 aMesh->RemoveGroup( aGroup );
1844 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1845 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1846 aMesh->RemoveSubMesh( aSubMesh );
1848 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1850 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1853 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1854 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1855 QString objType = CheckTypeObject(IObject);
1856 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1857 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1858 aStudyBuilder->RemoveObjectWithChildren( SO );
1860 else {// default action: remove SObject from the study
1861 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1862 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1864 aStudyBuilder->RemoveObjectWithChildren( SO );
1868 } /* listSO back loop */
1870 aStudyBuilder->CommitCommand();
1872 /* Clear any previous selection */
1874 aSel->setSelectedObjects( l1 );
1876 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1881 SMESHGUI_EXPORT CAM_Module* createModule()
1883 return new SMESHGUI();
1886 SMESHGUI_EXPORT char* getModuleVersion() {
1887 return (char*)SMESH_VERSION_STR;
1891 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1893 //=============================================================================
1897 //=============================================================================
1898 SMESHGUI::SMESHGUI() :
1899 SalomeApp_Module( "SMESH" )
1901 if ( CORBA::is_nil( myComponentSMESH ) )
1903 CORBA::Boolean anIsEmbeddedMode;
1904 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1905 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1907 // 0019923: EDF 765 SMESH : default values of hypothesis
1908 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1909 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1910 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1911 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1912 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1914 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1915 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1916 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1918 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1919 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1923 myActiveDialogBox = 0;
1924 myFilterLibraryDlg = 0;
1928 myEventCallbackCommand = vtkCallbackCommand::New();
1929 myEventCallbackCommand->Delete();
1930 myEventCallbackCommand->SetClientData( this );
1931 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1934 /* load resources for all available meshers */
1935 SMESH::InitAvailableHypotheses();
1938 //=============================================================================
1942 //=============================================================================
1943 SMESHGUI::~SMESHGUI()
1947 //=============================================================================
1951 //=============================================================================
1952 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1954 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1956 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1961 //=============================================================================
1965 //=============================================================================
1966 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1968 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1972 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1973 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1974 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1975 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1976 return autoUpdate && !exceeded;
1979 //=============================================================================
1983 //=============================================================================
1984 bool SMESHGUI::automaticUpdate( SMESH::SMESH_Mesh_ptr theMesh,
1985 int* entities, bool* limitExceeded )
1987 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1991 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1992 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1993 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
1995 long requestedSize = theMesh->NbElements();
1997 *entities = SMESH_Actor::eAllEntity;
1999 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2001 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2003 if ( incrementalLimit ) {
2004 long nbOdElems = theMesh->Nb0DElements();
2005 long nbEdges = theMesh->NbEdges();
2006 long nbFaces = theMesh->NbFaces();
2007 long nbVolumes = theMesh->NbVolumes();
2008 long nbBalls = theMesh->NbBalls();
2011 if ( nbOdElems > 0 ) {
2012 if ( total + nbOdElems > updateLimit )
2013 *entities = *entities & ~SMESH_Actor::e0DElements;
2019 if ( nbEdges > 0 ) {
2020 if ( total + nbEdges > updateLimit )
2021 *entities = *entities & ~SMESH_Actor::eEdges;
2027 if ( nbFaces > 0 ) {
2028 if ( total + nbFaces > updateLimit )
2029 *entities = *entities & ~SMESH_Actor::eFaces;
2035 if ( nbVolumes > 0 ) {
2036 if ( total + nbVolumes > updateLimit )
2037 *entities = *entities & ~SMESH_Actor::eVolumes;
2043 if ( nbBalls > 0 ) {
2044 if ( total + nbBalls > updateLimit )
2045 *entities = *entities & ~SMESH_Actor::eBallElem;
2052 return autoUpdate && !exceeded;
2055 //=============================================================================
2059 //=============================================================================
2060 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2062 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2065 //=============================================================================
2069 //=============================================================================
2070 SMESHGUI* SMESHGUI::GetSMESHGUI()
2072 SMESHGUI* smeshMod = 0;
2073 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2076 CAM_Module* module = app->module( "Mesh" );
2077 smeshMod = dynamic_cast<SMESHGUI*>( module );
2080 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2082 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2085 _PTR(Study) aStudy = study->studyDS();
2087 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2096 Standard_EXPORT SMESHGUI* GetComponentGUI()
2098 return SMESHGUI::GetSMESHGUI();
2102 //=============================================================================
2106 //=============================================================================
2107 void SMESHGUI::SetState(int aState)
2112 //=============================================================================
2116 //=============================================================================
2117 void SMESHGUI::ResetState()
2122 //=============================================================================
2126 //=============================================================================
2127 void SMESHGUI::EmitSignalDeactivateDialog()
2129 emit SignalDeactivateActiveDialog();
2132 //=============================================================================
2136 //=============================================================================
2137 void SMESHGUI::EmitSignalStudyFrameChanged()
2139 emit SignalStudyFrameChanged();
2142 //=============================================================================
2146 //=============================================================================
2147 void SMESHGUI::EmitSignalCloseAllDialogs()
2149 emit SignalCloseAllDialogs();
2152 //=============================================================================
2156 //=============================================================================
2157 void SMESHGUI::EmitSignalVisibilityChanged()
2159 emit SignalVisibilityChanged();
2162 //=============================================================================
2166 //=============================================================================
2167 QDialog *SMESHGUI::GetActiveDialogBox()
2169 return myActiveDialogBox;
2172 //=============================================================================
2176 //=============================================================================
2177 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2179 myActiveDialogBox = (QDialog *) aDlg;
2183 //=============================================================================
2187 //=============================================================================
2188 SUIT_Desktop* SMESHGUI::desktop()
2190 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2192 return app->desktop();
2197 //=============================================================================
2201 //=============================================================================
2202 SalomeApp_Study* SMESHGUI::activeStudy()
2204 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2206 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2211 //=============================================================================
2215 //=============================================================================
2216 void SMESHGUI::Modified( bool theIsUpdateActions )
2218 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2219 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2220 appStudy->Modified();
2221 if( theIsUpdateActions )
2222 app->updateActions();
2227 //=============================================================================
2231 //=============================================================================
2232 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2234 /* Here the position is on the bottom right corner - 10 */
2235 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2237 SUIT_Desktop *PP = desktop();
2238 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2239 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2243 //=============================================================================
2247 //=============================================================================
2248 static int isStudyLocked(_PTR(Study) theStudy){
2249 return theStudy->GetProperties()->IsLocked();
2252 static bool checkLock(_PTR(Study) theStudy) {
2253 if (isStudyLocked(theStudy)) {
2254 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2255 QObject::tr("WRN_WARNING"),
2256 QObject::tr("WRN_STUDY_LOCKED") );
2262 //=======================================================================
2263 //function : CheckActiveStudyLocked
2265 //=======================================================================
2267 bool SMESHGUI::isActiveStudyLocked()
2269 _PTR(Study) aStudy = activeStudy()->studyDS();
2270 return checkLock( aStudy );
2273 //=============================================================================
2277 //=============================================================================
2278 bool SMESHGUI::OnGUIEvent( int theCommandID )
2280 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2284 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2285 SUIT_ResourceMgr* mgr = resourceMgr();
2289 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2290 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2293 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2294 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2296 //QAction* act = action( theCommandID );
2298 switch (theCommandID) {
2300 if(checkLock(aStudy)) break;
2312 if(checkLock(aStudy)) break;
2313 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2317 case 150: //MED FILE INFORMATION
2319 SALOME_ListIO selected;
2320 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2322 aSel->selectedObjects( selected );
2323 if( selected.Extent() )
2325 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2326 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2327 if ( !aMesh->_is_nil() )
2329 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2336 case 122: // EXPORT MED
2351 ::ExportMeshToFile(theCommandID);
2355 case 200: // SCALAR BAR
2357 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2358 SALOME_ListIO selected;
2360 aSel->selectedObjects( selected );
2362 if( selected.Extent() ) {
2363 Handle(SALOME_InteractiveObject) anIO = selected.First();
2364 if( anIO->hasEntry() ) {
2365 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2366 anActor->SetControlMode( SMESH_Actor::eNone );
2367 #ifndef DISABLE_PLOT2DVIEWER
2368 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2377 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2382 // dump control distribution data to the text file
2383 ::SaveDistribution();
2389 // show/ distribution
2390 ::ShowDistribution();
2394 #ifndef DISABLE_PLOT2DVIEWER
2397 // plot distribution
2398 ::PlotDistribution();
2409 ::DisableAutoColor();
2412 case 1134: // Clipping
2413 case 1133: // Tranparency
2414 case 1132: // Display preferences (colors, shrink size, line width, ...)
2421 ::SetDisplayMode(theCommandID, myMarkerMap);
2424 //2D quadratic representation
2427 ::SetDisplayMode(theCommandID, myMarkerMap);
2431 case 216: // 0D elements
2434 case 219: // Volumes
2435 case 220: // All Entity
2437 ::SetDisplayEntity(theCommandID);
2440 case 221: // Orientation of faces
2442 LightApp_SelectionMgr* mgr = selectionMgr();
2443 SALOME_ListIO selected; mgr->selectedObjects( selected );
2445 SALOME_ListIteratorOfListIO it(selected);
2446 for( ; it.More(); it.Next()) {
2447 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2448 if(anIObject->hasEntry()) {
2449 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2450 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2459 if(checkLock(aStudy)) break;
2460 SUIT_OverrideCursor wc;
2462 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2465 SMESH::UpdateView();
2467 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2468 SMESH::OnVisuException();
2470 catch (...) { // PAL16774 (Crash after display of many groups)
2471 SMESH::OnVisuException();
2475 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2476 aSel->selectedObjects( l );
2477 aSel->setSelectedObjects( l );
2482 case 301: // DISPLAY
2483 case 302: // DISPLAY ONLY
2485 SMESH::EDisplaing anAction;
2486 switch (theCommandID) {
2487 case 300: anAction = SMESH::eErase; break;
2488 case 301: anAction = SMESH::eDisplay; break;
2489 case 302: anAction = SMESH::eDisplayOnly; break;
2492 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2493 SALOME_ListIO sel_objects, to_process;
2495 aSel->selectedObjects( sel_objects );
2497 if( theCommandID==302 )
2499 MESSAGE("anAction = SMESH::eDisplayOnly");
2500 startOperation( myEraseAll );
2503 extractContainers( sel_objects, to_process );
2506 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2510 SALOME_ListIteratorOfListIO It( to_process );
2511 for ( ; It.More(); It.Next()) {
2513 Handle(SALOME_InteractiveObject) IOS = It.Value();
2514 if (IOS->hasEntry()) {
2516 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2517 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2518 break; // PAL16774 (Crash after display of many groups)
2520 if (anAction == SMESH::eDisplayOnly)
2522 MESSAGE("anAction = SMESH::eDisplayOnly");
2523 anAction = SMESH::eDisplay;
2529 // PAL13338 + PAL15161 -->
2530 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2531 MESSAGE("anAction = SMESH::eDisplayOnly");
2532 SMESH::UpdateView();
2533 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2535 // PAL13338 + PAL15161 <--
2537 catch (...) { // PAL16774 (Crash after display of many groups)
2538 SMESH::OnVisuException();
2541 if (anAction == SMESH::eErase) {
2542 MESSAGE("anAction == SMESH::eErase");
2544 aSel->setSelectedObjects( l1 );
2547 aSel->setSelectedObjects( to_process );
2554 if(checkLock(aStudy)) break;
2557 EmitSignalDeactivateDialog();
2559 ( new SMESHGUI_NodesDlg( this ) )->show();
2562 SUIT_MessageBox::warning(desktop(),
2563 tr("SMESH_WRN_WARNING"),
2564 tr("SMESH_WRN_VIEWER_VTK"));
2569 case 2151: // FILTER
2573 EmitSignalDeactivateDialog();
2574 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2579 case 701: // COMPUTE MESH
2580 case 711: // PRECOMPUTE MESH
2581 case 712: // EVALUATE MESH
2582 case 713: // MESH ORDER
2583 case 702: // Create mesh
2584 case 703: // Create sub-mesh
2585 case 704: // Edit mesh/sub-mesh
2586 startOperation( theCommandID );
2588 case 705: // copy mesh
2590 if (checkLock(aStudy)) break;
2591 EmitSignalDeactivateDialog();
2592 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2595 case 710: // Build compound mesh
2597 if (checkLock(aStudy)) break;
2598 EmitSignalDeactivateDialog();
2599 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2603 case 407: // DIAGONAL INVERSION
2604 case 408: // Delete diagonal
2608 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2609 tr( "NOT_A_VTK_VIEWER" ) );
2613 if ( checkLock( aStudy ) )
2616 /*Standard_Boolean aRes;
2617 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2618 if ( aMesh->_is_nil() )
2620 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2621 tr( "SMESH_BAD_SELECTION" ) );
2625 EmitSignalDeactivateDialog();
2626 if ( theCommandID == 407 )
2627 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2629 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2632 case 409: // Change orientation
2633 case 410: // Union of triangles
2634 case 411: // Cutting of quadrangles
2635 case 419: // Splitting volumes into tetrahedra
2639 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2640 tr( "NOT_A_VTK_VIEWER" ) );
2644 if ( checkLock( aStudy ) )
2647 EmitSignalDeactivateDialog();
2648 SMESHGUI_MultiEditDlg* aDlg = NULL;
2649 if ( theCommandID == 409 )
2650 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2651 else if ( theCommandID == 410 )
2652 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2653 else if ( theCommandID == 419 )
2654 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2656 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2661 case 412: // Smoothing
2663 if(checkLock(aStudy)) break;
2665 EmitSignalDeactivateDialog();
2666 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2669 SUIT_MessageBox::warning(desktop(),
2670 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2674 case 413: // Extrusion
2676 if (checkLock(aStudy)) break;
2678 EmitSignalDeactivateDialog();
2679 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2681 SUIT_MessageBox::warning(desktop(),
2682 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2686 case 414: // Revolution
2688 if(checkLock(aStudy)) break;
2690 EmitSignalDeactivateDialog();
2691 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2694 SUIT_MessageBox::warning(desktop(),
2695 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2699 case 415: // Pattern mapping
2701 if ( checkLock( aStudy ) )
2705 EmitSignalDeactivateDialog();
2706 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2709 SUIT_MessageBox::warning(desktop(),
2710 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2714 case 416: // Extrusion along a path
2716 if (checkLock(aStudy)) break;
2718 EmitSignalDeactivateDialog();
2719 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2721 SUIT_MessageBox::warning(desktop(),
2722 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2726 case 417: // Convert mesh to quadratic
2727 case 418: // create 2D mesh from 3D
2728 case 420: // Reorient faces
2729 case 806: // CREATE GEO GROUP
2731 startOperation( theCommandID );
2734 case 801: // CREATE GROUP
2738 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2739 tr( "NOT_A_VTK_VIEWER" ) );
2743 if(checkLock(aStudy)) break;
2744 EmitSignalDeactivateDialog();
2745 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2747 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2748 SALOME_ListIO selected;
2750 aSel->selectedObjects( selected );
2752 int nbSel = selected.Extent();
2754 // check if mesh is selected
2755 aMesh = SMESH::GetMeshByIO( selected.First() );
2757 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2762 case 802: // CONSTRUCT GROUP
2766 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2767 tr( "NOT_A_VTK_VIEWER" ) );
2771 if(checkLock(aStudy)) break;
2772 EmitSignalDeactivateDialog();
2774 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2775 SALOME_ListIO selected;
2777 aSel->selectedObjects( selected );
2779 int nbSel = selected.Extent();
2781 // check if submesh is selected
2782 Handle(SALOME_InteractiveObject) IObject = selected.First();
2783 if (IObject->hasEntry()) {
2784 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2786 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2787 if (!aSubMesh->_is_nil()) {
2789 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2790 // get submesh elements list by types
2791 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2792 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2793 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2794 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2795 // create group for each type o elements
2796 QString aName = IObject->getName();
2797 QStringList anEntryList;
2798 if (aNodes->length() > 0) {
2799 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2800 aGroup->Add(aNodes.inout());
2801 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2802 anEntryList.append( aSObject->GetID().c_str() );
2804 if (aEdges->length() > 0) {
2805 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2806 aGroup->Add(aEdges.inout());
2807 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2808 anEntryList.append( aSObject->GetID().c_str() );
2810 if (aFaces->length() > 0) {
2811 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2812 aGroup->Add(aFaces.inout());
2813 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2814 anEntryList.append( aSObject->GetID().c_str() );
2816 if (aVolumes->length() > 0) {
2817 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2818 aGroup->Add(aVolumes.inout());
2819 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2820 anEntryList.append( aSObject->GetID().c_str() );
2823 anApp->browseObjects( anEntryList );
2825 catch(const SALOME::SALOME_Exception & S_ex){
2826 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2833 SUIT_MessageBox::warning(desktop(),
2834 tr("SMESH_WRN_WARNING"),
2835 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2840 case 803: // EDIT GROUP
2844 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2845 tr( "NOT_A_VTK_VIEWER" ) );
2849 if(checkLock(aStudy)) break;
2850 EmitSignalDeactivateDialog();
2852 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2853 SALOME_ListIO selected;
2855 aSel->selectedObjects( selected );
2857 SALOME_ListIteratorOfListIO It (selected);
2858 int nbSelectedGroups = 0;
2859 for ( ; It.More(); It.Next() )
2861 SMESH::SMESH_GroupBase_var aGroup =
2862 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2863 if (!aGroup->_is_nil()) {
2865 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2869 if (nbSelectedGroups == 0)
2871 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2877 case 804: // Add elements to group
2879 if(checkLock(aStudy)) break;
2880 if (myState == 800) {
2881 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2882 if (aDlg) aDlg->onAdd();
2887 case 805: // Remove elements from group
2889 if(checkLock(aStudy)) break;
2890 if (myState == 800) {
2891 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2892 if (aDlg) aDlg->onRemove();
2897 case 815: // Edit GEOM GROUP as standalone
2901 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2902 tr( "NOT_A_VTK_VIEWER" ) );
2906 if(checkLock(aStudy)) break;
2907 EmitSignalDeactivateDialog();
2909 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2910 SALOME_ListIO selected;
2912 aSel->selectedObjects( selected );
2914 SALOME_ListIteratorOfListIO It (selected);
2915 for ( ; It.More(); It.Next() )
2917 SMESH::SMESH_GroupOnGeom_var aGroup =
2918 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2919 if (!aGroup->_is_nil()) {
2920 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2925 SMESH::SMESH_GroupOnFilter_var aGroup =
2926 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2927 if (!aGroup->_is_nil()) {
2928 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2936 case 810: // Union Groups
2937 case 811: // Intersect groups
2938 case 812: // Cut groups
2942 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2943 tr( "NOT_A_VTK_VIEWER" ) );
2947 if ( checkLock( aStudy ) )
2950 EmitSignalDeactivateDialog();
2952 SMESHGUI_GroupOpDlg* aDlg = 0;
2953 if ( theCommandID == 810 )
2954 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2955 else if ( theCommandID == 811 )
2956 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2958 aDlg = new SMESHGUI_CutGroupsDlg( this );
2965 case 814: // Create groups of entities from existing groups of superior dimensions
2967 if ( checkLock( aStudy ) )
2970 EmitSignalDeactivateDialog();
2971 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2977 case 813: // Delete groups with their contents
2981 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2982 tr( "NOT_A_VTK_VIEWER" ) );
2986 if ( checkLock( aStudy ) )
2989 EmitSignalDeactivateDialog();
2991 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2995 case 900: // MESH INFOS
2996 case 903: // WHAT IS
2998 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2999 EmitSignalDeactivateDialog();
3000 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3001 SALOME_ListIO selected;
3003 aSel->selectedObjects( selected );
3005 if ( selected.Extent() > 1 ) { // a dlg for each IO
3006 SALOME_ListIteratorOfListIO It( selected );
3007 for ( ; It.More(); It.Next() ) {
3008 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3009 dlg->showInfo( It.Value() );
3014 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3020 case 904: // FIND ELEM
3022 startOperation( theCommandID );
3026 case 1100: // EDIT HYPOTHESIS
3028 if(checkLock(aStudy)) break;
3030 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3031 SALOME_ListIO selected;
3033 aSel->selectedObjects( selected );
3035 int nbSel = selected.Extent();
3038 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3039 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3041 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
3042 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
3043 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
3044 if ( !aHypothesis->_is_nil() )
3047 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3048 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3050 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3060 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
3062 if(checkLock(aStudy)) break;
3063 SUIT_OverrideCursor wc;
3065 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3066 SALOME_ListIO selected;
3068 aSel->selectedObjects( selected, QString::null, false );
3070 SALOME_ListIteratorOfListIO It(selected);
3071 for (int i = 0; It.More(); It.Next(), i++) {
3072 Handle(SALOME_InteractiveObject) IObject = It.Value();
3073 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3076 aSel->setSelectedObjects( l1 );
3082 case 4009: // ELEM0D
3084 case 4021: // TRIANGLE
3086 case 4023: // POLYGON
3090 case 4134: // PYRAMID
3091 case 4135: // OCTA12
3093 if(checkLock(aStudy)) break;
3095 EmitSignalDeactivateDialog();
3096 SMDSAbs_EntityType type = SMDSEntity_Edge;
3097 switch (theCommandID) {
3098 case 4008: type = SMDSEntity_Ball; break;
3099 case 4009: type = SMDSEntity_0D; break;
3100 case 4021: type = SMDSEntity_Triangle; break;
3101 case 4022: type = SMDSEntity_Quadrangle; break;
3102 case 4031: type = SMDSEntity_Tetra; break;
3103 case 4023: type = SMDSEntity_Polygon; break;
3104 case 4032: type = SMDSEntity_Hexa; break;
3105 case 4133: type = SMDSEntity_Penta; break;
3106 case 4134: type = SMDSEntity_Pyramid; break;
3107 case 4135: type = SMDSEntity_Hexagonal_Prism; break;
3110 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3113 SUIT_MessageBox::warning(desktop(),
3114 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3118 case 4033: // POLYHEDRON
3120 if(checkLock(aStudy)) break;
3122 EmitSignalDeactivateDialog();
3123 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3126 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3127 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3131 case 4034: // QUADRATIC EDGE
3132 case 4035: // QUADRATIC TRIANGLE
3133 case 4036: // QUADRATIC QUADRANGLE
3134 case 4136: // BIQUADRATIC QUADRANGLE
3135 case 4137: // BIQUADRATIC TRIANGLE
3136 case 4037: // QUADRATIC TETRAHEDRON
3137 case 4038: // QUADRATIC PYRAMID
3138 case 4039: // QUADRATIC PENTAHEDRON
3139 case 4040: // QUADRATIC HEXAHEDRON
3140 case 4140: // TRIQUADRATIC HEXAHEDRON
3142 if(checkLock(aStudy)) break;
3144 EmitSignalDeactivateDialog();
3145 SMDSAbs_EntityType type = SMDSEntity_Last;
3147 switch (theCommandID) {
3148 case 4034: type = SMDSEntity_Quad_Edge; break;
3149 case 4035: type = SMDSEntity_Quad_Triangle; break;
3150 case 4036: type = SMDSEntity_Quad_Quadrangle; break;
3151 case 4136: type = SMDSEntity_BiQuad_Quadrangle; break;
3152 case 4137: type = SMDSEntity_BiQuad_Triangle; break;
3153 case 4037: type = SMDSEntity_Quad_Tetra; break;
3154 case 4038: type = SMDSEntity_Quad_Pyramid; break;
3155 case 4039: type = SMDSEntity_Quad_Penta; break;
3156 case 4040: type = SMDSEntity_Quad_Hexa; break;
3157 case 4140: type = SMDSEntity_TriQuad_Hexa; break;
3160 if ( type != SMDSEntity_Last )
3161 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3164 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3165 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3169 case 4041: // REMOVES NODES
3171 if(checkLock(aStudy)) break;
3173 EmitSignalDeactivateDialog();
3174 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3177 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3178 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3182 case 4042: // REMOVES ELEMENTS
3184 if(checkLock(aStudy)) break;
3186 EmitSignalDeactivateDialog();
3187 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3191 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3192 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3196 case 4043: { // CLEAR_MESH
3198 if(checkLock(aStudy)) break;
3200 SALOME_ListIO selected;
3201 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3202 aSel->selectedObjects( selected );
3204 SUIT_OverrideCursor wc;
3205 SALOME_ListIteratorOfListIO It (selected);
3206 for ( ; It.More(); It.Next() )
3208 Handle(SALOME_InteractiveObject) IOS = It.Value();
3209 SMESH::SMESH_Mesh_var aMesh =
3210 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3211 if ( aMesh->_is_nil()) continue;
3213 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3215 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3216 SMESH::ModifiedMesh( aMeshSObj, false, true);
3217 // hide groups and submeshes
3218 _PTR(ChildIterator) anIter =
3219 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3220 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3222 _PTR(SObject) so = anIter->Value();
3223 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3226 catch (const SALOME::SALOME_Exception& S_ex){
3228 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3232 SMESH::UpdateView();
3236 case 4044: // REMOVE ORPHAN NODES
3238 if(checkLock(aStudy)) break;
3239 SALOME_ListIO selected;
3240 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3241 aSel->selectedObjects( selected );
3242 if ( selected.Extent() == 1 ) {
3243 Handle(SALOME_InteractiveObject) anIO = selected.First();
3244 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3245 if ( !aMesh->_is_nil() ) {
3246 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3247 tr( "SMESH_WARNING" ),
3248 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3249 SUIT_MessageBox::Yes |
3250 SUIT_MessageBox::No,
3251 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3254 SUIT_OverrideCursor wc;
3255 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3256 int removed = aMeshEditor->RemoveOrphanNodes();
3257 SUIT_MessageBox::information(SMESHGUI::desktop(),
3258 tr("SMESH_INFORMATION"),
3259 tr("NB_NODES_REMOVED").arg(removed));
3260 if ( removed > 0 ) {
3261 SMESH::UpdateView();
3262 SMESHGUI::Modified();
3265 catch (const SALOME::SALOME_Exception& S_ex) {
3266 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3275 case 4051: // RENUMBERING NODES
3277 if(checkLock(aStudy)) break;
3279 EmitSignalDeactivateDialog();
3280 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3284 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3285 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3289 case 4052: // RENUMBERING ELEMENTS
3291 if(checkLock(aStudy)) break;
3293 EmitSignalDeactivateDialog();
3294 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3298 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3299 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3303 case 4061: // TRANSLATION
3305 if(checkLock(aStudy)) break;
3307 EmitSignalDeactivateDialog();
3308 ( new SMESHGUI_TranslationDlg( this ) )->show();
3311 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3312 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3316 case 4062: // ROTATION
3318 if(checkLock(aStudy)) break;
3320 EmitSignalDeactivateDialog();
3321 ( new SMESHGUI_RotationDlg( this ) )->show();
3324 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3325 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3329 case 4063: // SYMMETRY
3331 if(checkLock(aStudy)) break;
3333 EmitSignalDeactivateDialog();
3334 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3337 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3338 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3342 case 4064: // SEWING
3344 if(checkLock(aStudy)) break;
3346 EmitSignalDeactivateDialog();
3347 ( new SMESHGUI_SewingDlg( this ) )->show();
3350 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3351 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3355 case 4065: // MERGE NODES
3357 if(checkLock(aStudy)) break;
3359 EmitSignalDeactivateDialog();
3360 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3363 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3364 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3368 case 4066: // MERGE EQUAL ELEMENTS
3370 if (checkLock(aStudy)) break;
3372 EmitSignalDeactivateDialog();
3373 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3375 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3376 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3381 case 4067: // MAKE MESH PASS THROUGH POINT
3382 startOperation( 4067 );
3387 if(checkLock(aStudy)) break;
3389 EmitSignalDeactivateDialog();
3390 ( new SMESHGUI_ScaleDlg( this ) )->show();
3393 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3394 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3399 case 4069: // DUPLICATE NODES
3401 if(checkLock(aStudy)) break;
3403 EmitSignalDeactivateDialog();
3404 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3407 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3408 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3413 case 4070: // 0D_ON_ALL_NODES
3414 startOperation( 4070 );
3417 case 5105: // Library of selection filters
3419 static QList<int> aTypes;
3420 if ( aTypes.isEmpty() )
3422 aTypes.append( SMESH::NODE );
3423 aTypes.append( SMESH::EDGE );
3424 aTypes.append( SMESH::FACE );
3425 aTypes.append( SMESH::VOLUME );
3427 if (!myFilterLibraryDlg)
3428 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3429 else if (myFilterLibraryDlg->isHidden())
3430 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3431 myFilterLibraryDlg->raise();
3435 case 6017: // CONTROLS
3463 LightApp_SelectionMgr* mgr = selectionMgr();
3464 SALOME_ListIO selected; mgr->selectedObjects( selected );
3466 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3467 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3469 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3470 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3471 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3472 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3473 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3474 SUIT_OverrideCursor wc;
3475 ::Control( theCommandID );
3480 SUIT_MessageBox::warning(desktop(),
3481 tr( "SMESH_WRN_WARNING" ),
3482 tr( "SMESH_BAD_SELECTION" ) );
3486 SUIT_MessageBox::warning(desktop(),
3487 tr( "SMESH_WRN_WARNING" ),
3488 tr( "NOT_A_VTK_VIEWER" ) );
3492 OverallMeshQuality();
3496 SUIT_OverrideCursor wc;
3497 LightApp_SelectionMgr* mgr = selectionMgr();
3498 SALOME_ListIO selected; mgr->selectedObjects( selected );
3500 SALOME_ListIteratorOfListIO it(selected);
3501 for( ; it.More(); it.Next()) {
3502 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3503 if(anIObject->hasEntry()) {
3504 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3505 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );