1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
33 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
34 #include "SMESHGUI_AddMeshElementDlg.h"
35 #include "SMESHGUI_AddQuadraticElementDlg.h"
36 #include "SMESHGUI_BuildCompoundDlg.h"
37 #include "SMESHGUI_ClippingDlg.h"
38 #include "SMESHGUI_ComputeDlg.h"
39 #include "SMESHGUI_ConvToQuadOp.h"
40 #include "SMESHGUI_CopyMeshDlg.h"
41 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
42 #include "SMESHGUI_DeleteGroupDlg.h"
43 #include "SMESHGUI_Displayer.h"
44 #include "SMESHGUI_DuplicateNodesDlg.h"
45 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
46 #include "SMESHGUI_ExtrusionDlg.h"
47 #include "SMESHGUI_FieldSelectorWdg.h"
48 #include "SMESHGUI_FileInfoDlg.h"
49 #include "SMESHGUI_FileValidator.h"
50 #include "SMESHGUI_FilterDlg.h"
51 #include "SMESHGUI_FilterLibraryDlg.h"
52 #include "SMESHGUI_FindElemByPointDlg.h"
53 #include "SMESHGUI_GroupDlg.h"
54 #include "SMESHGUI_GroupOnShapeDlg.h"
55 #include "SMESHGUI_GroupOpDlg.h"
56 #include "SMESHGUI_Hypotheses.h"
57 #include "SMESHGUI_Make2DFrom3DOp.h"
58 #include "SMESHGUI_MakeNodeAtPointDlg.h"
59 #include "SMESHGUI_Measurements.h"
60 #include "SMESHGUI_MergeDlg.h"
61 #include "SMESHGUI_MeshInfo.h"
62 #include "SMESHGUI_MeshOp.h"
63 #include "SMESHGUI_MeshOrderOp.h"
64 #include "SMESHGUI_MeshPatternDlg.h"
65 #include "SMESHGUI_MultiEditDlg.h"
66 #include "SMESHGUI_NodesDlg.h"
67 #include "SMESHGUI_Operations.h"
68 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
69 #include "SMESHGUI_PropertiesDlg.h"
70 #include "SMESHGUI_RemoveElementsDlg.h"
71 #include "SMESHGUI_RemoveNodesDlg.h"
72 #include "SMESHGUI_RenumberingDlg.h"
73 #include "SMESHGUI_ReorientFacesDlg.h"
74 #include "SMESHGUI_RevolutionDlg.h"
75 #include "SMESHGUI_RotationDlg.h"
76 #include "SMESHGUI_ScaleDlg.h"
77 #include "SMESHGUI_Selection.h"
78 #include "SMESHGUI_SewingDlg.h"
79 #include "SMESHGUI_SingleEditDlg.h"
80 #include "SMESHGUI_SmoothingDlg.h"
81 #include "SMESHGUI_SymmetryDlg.h"
82 #include "SMESHGUI_TranslationDlg.h"
83 #include "SMESHGUI_TransparencyDlg.h"
84 #include "SMESHGUI_DisplayEntitiesDlg.h"
85 #include "SMESHGUI_SplitBiQuad.h"
87 #include "SMESHGUI_FilterUtils.h"
88 #include "SMESHGUI_GEOMGenUtils.h"
89 #include "SMESHGUI_GroupUtils.h"
90 #include "SMESHGUI_HypothesesUtils.h"
91 #include "SMESHGUI_MeshUtils.h"
92 #include "SMESHGUI_PatternUtils.h"
93 #include "SMESHGUI_Utils.h"
94 #include "SMESHGUI_VTKUtils.h"
96 #include "SMESH_version.h"
98 #include "SMESH_ControlsDef.hxx"
99 #include "SMESH_Actor.h"
100 #include "SMESH_ActorUtils.h"
101 #include "SMESH_Client.hxx"
102 #include "SMESH_ScalarBarActor.h"
103 #include "SMESH_TypeFilter.hxx"
105 // SALOME GUI includes
106 #include <SalomeApp_Application.h>
107 #include <SalomeApp_CheckFileDlg.h>
108 #include <SalomeApp_DataObject.h>
109 #include <SalomeApp_Study.h>
110 #include <SalomeApp_Tools.h>
112 #include <LightApp_DataOwner.h>
113 #include <LightApp_NameDlg.h>
114 #include <LightApp_Preferences.h>
115 #include <LightApp_SelectionMgr.h>
116 #include <LightApp_UpdateFlags.h>
118 #include <SVTK_ViewManager.h>
119 #include <SVTK_ViewModel.h>
120 #include <SVTK_ViewWindow.h>
122 #include <VTKViewer_Algorithm.h>
124 #include <SUIT_Desktop.h>
125 #include <SUIT_FileDlg.h>
126 #include <SUIT_MessageBox.h>
127 #include <SUIT_OverrideCursor.h>
128 #include <SUIT_ResourceMgr.h>
129 #include <SUIT_Session.h>
131 #include <QtxPopupMgr.h>
132 #include <QtxFontEdit.h>
134 #include <SALOME_ListIO.hxx>
136 #ifndef DISABLE_PLOT2DVIEWER
137 #include <SPlot2d_ViewModel.h>
138 #include <SPlot2d_Histogram.h>
142 #include <SALOMEconfig.h>
143 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
144 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
145 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
148 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
149 #include <QApplication>
151 #include <QTextStream>
156 #include <boost/shared_ptr.hpp>
159 #include <vtkCallbackCommand.h>
160 #include <vtkCamera.h>
161 #include <vtkLookupTable.h>
162 #include <vtkPlane.h>
163 #include <vtkRenderer.h>
165 // SALOME KERNEL includes
166 #include <SALOMEDSClient_ClientFactory.hxx>
167 #include <SALOMEDSClient_IParameters.hxx>
168 #include <SALOMEDSClient_SComponent.hxx>
169 #include <SALOMEDSClient_StudyBuilder.hxx>
170 #include <SALOMEDS_Study.hxx>
171 #include <SALOMEDS_SObject.hxx>
172 #include "utilities.h"
175 #include <Standard_ErrorHandler.hxx>
176 #include <NCollection_DataMap.hxx>
177 #include <NCollection_DoubleMap.hxx>
179 #include <Basics_Utils.hxx>
181 // Below macro, when uncommented, switches on simplified (more performant) algorithm
182 // of auto-color picking up
183 #define SIMPLE_AUTOCOLOR
188 //=============================================================
189 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
192 void ExportMeshToFile(int theCommandID);
194 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
196 void SetDisplayEntity(int theCommandID);
198 int ActionToControl( int theID, bool theReversed = false );
200 void Control( int theCommandID );
203 //================================================================================
205 * \brief Reads meshes from file
207 //================================================================================
209 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
213 std::string myExtension;
215 if ( theCommandID == SMESHOp::OpImportMED ) {
216 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
217 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
219 else if ( theCommandID == SMESHOp::OpImportUNV ) {
220 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
222 else if ( theCommandID == SMESHOp::OpImportDAT ) {
223 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
225 else if ( theCommandID == SMESHOp::OpImportSTL ) {
226 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
229 else if ( theCommandID == SMESHOp::OpImportCGNS ) {
230 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
233 else if ( theCommandID == SMESHOp::OpImportSAUV ) {
234 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
235 filter.append( QObject::tr( "All files (*)" ) );
237 else if ( theCommandID == SMESHOp::OpImportGMF ) {
238 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
239 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
242 QString anInitialPath = "";
243 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
244 anInitialPath = QDir::currentPath();
246 QStringList filenames;
247 bool toCreateGroups = true;
249 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
250 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
251 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
252 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
253 // fd->setNameFilters( filter );
254 // fd->SetChecked( true );
256 // filenames << fd->selectedFile();
257 // toCreateGroups = fd->IsChecked();
263 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
266 QObject::tr( "SMESH_IMPORT_MESH" ) );
268 if ( filenames.count() > 0 ) {
269 SUIT_OverrideCursor wc;
270 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
273 QStringList anEntryList;
274 bool isEmpty = false;
275 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
276 QString filename = *it;
277 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
279 switch ( theCommandID ) {
280 case SMESHOp::OpImportDAT:
282 // DAT format (currently unsupported)
283 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
284 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
287 case SMESHOp::OpImportUNV:
290 aMeshes->length( 1 );
291 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
292 if ( aMeshes[0]->_is_nil() )
293 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
294 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
297 case SMESHOp::OpImportMED:
300 SMESH::DriverMED_ReadStatus res;
301 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
302 if ( res != SMESH::DRS_OK ) {
303 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
304 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
308 case SMESHOp::OpImportSTL:
311 aMeshes->length( 1 );
312 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
313 if ( aMeshes[0]->_is_nil() ) {
314 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
315 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
320 case SMESHOp::OpImportCGNS:
323 SMESH::DriverMED_ReadStatus res;
324 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
325 if ( res != SMESH::DRS_OK ) {
326 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
327 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
332 case SMESHOp::OpImportSAUV:
335 SMESH::DriverMED_ReadStatus res;
336 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
337 if ( res != SMESH::DRS_OK ) {
338 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
339 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
343 case SMESHOp::OpImportGMF:
346 SMESH::ComputeError_var res;
347 aMeshes->length( 1 );
348 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
351 if ( res->code != SMESH::DRS_OK ) {
352 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
353 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
354 if ( strlen( res->comment.in() ) > 0 ) {
355 errors.back() += ": ";
356 errors.back() += res->comment.in();
363 catch ( const SALOME::SALOME_Exception& S_ex ) {
364 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
365 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
368 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
369 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
371 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
372 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
373 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
374 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
375 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
377 anEntryList.append( aMeshSO->GetID().c_str() );
385 // update Object browser
386 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
388 // browse to the published meshes
389 if( LightApp_Application* anApp =
390 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
391 anApp->browseObjects( anEntryList );
393 // show Error message box if there were errors
394 if ( errors.count() > 0 ) {
395 SUIT_MessageBox::critical( SMESHGUI::desktop(),
396 QObject::tr( "SMESH_ERROR" ),
397 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
400 // show warning message box, if some imported mesh is empty
402 SUIT_MessageBox::warning( SMESHGUI::desktop(),
403 QObject::tr( "SMESH_WRN_WARNING" ),
404 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
409 //================================================================================
411 * \brief Export selected meshes or groups into a file
413 //================================================================================
415 void ExportMeshToFile( int theCommandID )
417 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
418 SALOME_ListIO selected;
420 aSel->selectedObjects( selected );
422 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT ||
423 theCommandID == SMESHOp::OpPopupExportDAT );
424 const bool isMED = ( theCommandID == SMESHOp::OpExportMED ||
425 theCommandID == SMESHOp::OpPopupExportMED );
426 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV ||
427 theCommandID == SMESHOp::OpPopupExportUNV );
428 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL ||
429 theCommandID == SMESHOp::OpPopupExportSTL );
431 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS ||
432 theCommandID == SMESHOp::OpPopupExportCGNS );
434 const bool isCGNS= false;
436 const bool isSAUV= ( theCommandID == SMESHOp::OpExportSAUV ||
437 theCommandID == SMESHOp::OpPopupExportSAUV );
438 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF ||
439 theCommandID == SMESHOp::OpPopupExportGMF );
441 const bool multiMeshSupported = ( isMED || isCGNS ); // file can hold several meshes
442 if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
445 // get mesh object from selection and check duplication of their names
446 bool hasDuplicatedMeshNames = false;
447 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
448 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
449 SALOME_ListIteratorOfListIO It( selected );
450 for( ; It.More(); It.Next() )
452 Handle(SALOME_InteractiveObject) anIObject = It.Value();
453 SMESH::SMESH_IDSource_var aMeshItem =
454 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
455 if ( aMeshItem->_is_nil() ) {
456 SUIT_MessageBox::warning( SMESHGUI::desktop(),
457 QObject::tr( "SMESH_WRN_WARNING" ),
458 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
462 QString aMeshName = anIObject->getName();
464 // check for name duplications
465 if ( !hasDuplicatedMeshNames )
466 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
467 if( aMeshName == (*aMeshIter).second ) {
468 hasDuplicatedMeshNames = true;
473 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
476 if( hasDuplicatedMeshNames && isMED ) {
477 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
478 QObject::tr("SMESH_WRN_WARNING"),
479 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
480 QObject::tr("SMESH_BUT_YES"),
481 QObject::tr("SMESH_BUT_NO"), 0, 1);
486 aMeshIter = aMeshList.begin();
487 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
488 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
489 QString aMeshName = (*aMeshIter).second;
491 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
493 // check for equal group names within each mesh
494 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
495 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
496 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
497 int aRet = SUIT_MessageBox::warning
498 (SMESHGUI::desktop(),
499 QObject::tr("SMESH_WRN_WARNING"),
500 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
501 QObject::tr("SMESH_BUT_YES"),
502 QObject::tr("SMESH_BUT_NO"), 0, 1);
509 // Warn the user about presence of not supported elements
511 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
515 notSupportedElemTypes.push_back( SMESH::Entity_0D );
516 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
521 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
522 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
523 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
524 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
525 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
526 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
527 notSupportedElemTypes.push_back( SMESH::Entity_0D );
528 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
533 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
534 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
535 notSupportedElemTypes.push_back( SMESH::Entity_0D );
536 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
541 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
546 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
547 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
548 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
549 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
550 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
551 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
552 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
553 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
558 notSupportedElemTypes.push_back( SMESH::Entity_0D );
559 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
560 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
561 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
562 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
563 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
564 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
565 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
566 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
568 if ( ! notSupportedElemTypes.empty() )
570 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
571 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
572 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
573 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
575 if ( !presentNotSupported.empty() )
578 const char* typeMsg[] = {
579 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
580 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
581 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
582 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
583 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
584 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
585 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
586 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
588 // is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
589 const int nbTypes = sizeof( typeMsg ) / sizeof( const char* );
590 int _assert[( nbTypes == SMESH::Entity_Last ) ? 1 : -1 ]; _assert[0]=1;
592 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
593 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
594 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
595 if ( iType != presentNotSupported.size() - 1 )
596 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
598 int aRet = SUIT_MessageBox::warning
599 (SMESHGUI::desktop(),
600 QObject::tr("SMESH_WRN_WARNING"),
601 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
602 QObject::tr("SMESH_BUT_YES"),
603 QObject::tr("SMESH_BUT_NO"), 0, 1);
608 // Get parameters of export operation
611 SMESH::MED_VERSION aFormat;
612 // Init the parameters with the default values
613 bool aIsASCII_STL = true;
614 bool toCreateGroups = false;
615 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
617 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
618 bool toOverwrite = true;
619 bool toFindOutDim = true;
621 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
622 QString anInitialPath = "";
623 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
624 anInitialPath = QDir::currentPath();
626 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
628 // Get a file name to write in and additional otions
629 if ( isUNV || isDAT || isGMF ) // Export w/o options
632 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
634 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
636 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
637 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
638 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
639 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
640 anInitialPath + QString("/") + aMeshName,
641 aFilter, aTitle, false);
643 else if ( isCGNS )// Export to CGNS
645 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
646 fd->setWindowTitle( aTitle );
647 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
648 if ( !anInitialPath.isEmpty() )
649 fd->setDirectory( anInitialPath );
650 fd->selectFile(aMeshName);
651 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
652 fd->setValidator( fv );
655 aFilename = fd->selectedFile();
656 toOverwrite = fv->isOverwrite();
660 else if ( isSTL ) // Export to STL
662 QMap<QString, int> aFilterMap;
663 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
664 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
667 QMap<QString, int>::const_iterator it = aFilterMap.begin();
668 for ( ; it != aFilterMap.end(); ++it )
669 filters.push_back( it.key() );
671 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
672 fd->setWindowTitle( aTitle );
673 fd->setNameFilters( filters );
674 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
675 if ( !anInitialPath.isEmpty() )
676 fd->setDirectory( anInitialPath );
677 fd->selectFile(aMeshName);
681 aFilename = fd->selectedFile();
682 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
687 else if ( isMED || isSAUV ) // Export to MED or SAUV
689 QMap<QString, SMESH::MED_VERSION> aFilterMap;
690 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
692 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
693 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
694 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
697 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
698 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
699 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
703 QString aDefaultFilter;
704 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
705 for ( ; it != aFilterMap.end(); ++it ) {
706 filters.push_back( it.key() );
707 if (it.value() == SMESH::MED_V2_2)
708 aDefaultFilter = it.key();
710 QStringList checkBoxes;
711 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
713 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
714 QList< QWidget* > wdgList;
715 if ( fieldSelWdg->GetAllFeilds( aMeshList, aFieldList ))
716 wdgList.append( fieldSelWdg );
718 SalomeApp_CheckFileDlg* fd =
719 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
720 fd->setWindowTitle( aTitle );
721 fd->setNameFilters( filters );
722 fd->selectNameFilter( aDefaultFilter );
723 fd->SetChecked( toCreateGroups, 0 );
724 fd->SetChecked( toFindOutDim, 1 );
725 if ( !anInitialPath.isEmpty() )
726 fd->setDirectory( anInitialPath );
727 fd->selectFile(aMeshName);
730 QListView *lview = fd->findChild<QListView*>("listView");
732 lview->setMinimumHeight(200);
734 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
736 tview->setMinimumHeight(200);
739 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
740 fd->setValidator( fv );
745 aFilename = fd->selectedFile();
747 aFilename = QString::null;
750 aFormat = aFilterMap[fd->selectedNameFilter()];
751 toOverwrite = fv->isOverwrite();
753 if ( !aFilename.isEmpty() ) {
754 // med-2.1 does not support poly elements
755 if ( aFormat==SMESH::MED_V2_1 )
756 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
757 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
758 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
759 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
760 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
762 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
763 QObject::tr("SMESH_WRN_WARNING"),
764 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
765 QObject::tr("SMESH_BUT_YES"),
766 QObject::tr("SMESH_BUT_NO"), 0, 1);
774 // can't append to an existing using other format
775 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
776 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
777 if( !isVersionOk || aVersion != aFormat ) {
778 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
779 QObject::tr("SMESH_WRN_WARNING"),
780 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
781 QObject::tr("SMESH_BUT_YES"),
782 QObject::tr("SMESH_BUT_NO"), 0, 1);
789 QStringList aMeshNamesCollisionList;
790 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
791 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
792 QString anExistingMeshName( aMeshNames[ i ] );
793 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
794 QString anExportMeshName = (*aMeshIter).second;
795 if( anExportMeshName == anExistingMeshName ) {
796 aMeshNamesCollisionList.append( anExportMeshName );
801 if( !aMeshNamesCollisionList.isEmpty() ) {
802 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
803 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
804 QObject::tr("SMESH_WRN_WARNING"),
805 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
806 QObject::tr("SMESH_BUT_YES"),
807 QObject::tr("SMESH_BUT_NO"),
808 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
817 toCreateGroups = fd->IsChecked(0);
818 toFindOutDim = fd->IsChecked(1);
819 fieldSelWdg->GetSelectedFeilds();
820 if ( !fieldSelWdg->parent() )
831 if ( !aFilename.isEmpty() ) {
832 // Check whether the file already exists and delete it if yes
833 QFile aFile( aFilename );
834 if ( aFile.exists() && toOverwrite )
836 SUIT_OverrideCursor wc;
839 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
840 // bool Renumber = false;
841 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
843 // Renumber= resMgr->booleanValue("renumbering");
845 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
846 // aMeshEditor->RenumberNodes();
847 // aMeshEditor->RenumberElements();
848 // if ( SMESHGUI::automaticUpdate() )
849 // SMESH::UpdateView();
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 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
859 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
860 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
861 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
862 aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
863 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
865 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
866 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim,
867 fields, geoAssFields.toLatin1().data() );
872 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
874 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
875 if( !aMeshItem->_is_nil() )
876 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
881 if ( aMeshOrGroup->_is_equivalent( aMesh ))
882 aMesh->ExportDAT( aFilename.toUtf8().data() );
884 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
888 if ( aMeshOrGroup->_is_equivalent( aMesh ))
889 aMesh->ExportUNV( aFilename.toUtf8().data() );
891 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
895 if ( aMeshOrGroup->_is_equivalent( aMesh ))
896 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
898 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
902 aMeshIter = aMeshList.begin();
903 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
905 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
906 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
907 aMeshItem->ExportCGNS( aMeshOrGroup,
908 aFilename.toUtf8().data(),
909 toOverwrite && aMeshIndex == 0 );
914 toCreateGroups = true;
915 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
918 catch (const SALOME::SALOME_Exception& S_ex){
920 SUIT_MessageBox::warning(SMESHGUI::desktop(),
921 QObject::tr("SMESH_WRN_WARNING"),
922 QObject::tr("SMESH_EXPORT_FAILED"));
928 inline void InverseEntityMode(unsigned int& theOutputMode,
929 unsigned int theMode)
931 bool anIsNotPresent = ~theOutputMode & theMode;
933 theOutputMode |= theMode;
935 theOutputMode &= ~theMode;
938 void SetDisplayEntity(int theCommandID)
940 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
941 SALOME_ListIO selected;
943 aSel->selectedObjects( selected );
945 if ( selected.Extent() >= 1 ) {
946 SALOME_ListIteratorOfListIO It( selected );
947 for( ; It.More(); It.Next()){
948 Handle(SALOME_InteractiveObject) IObject = It.Value();
949 if(IObject->hasEntry()){
950 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
951 unsigned int aMode = anActor->GetEntityMode();
952 switch(theCommandID){
953 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
954 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
955 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
956 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
957 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
958 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
961 anActor->SetEntityMode(aMode);
970 SalomeApp_Application* app =
971 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
975 LightApp_SelectionMgr* aSel = app->selectionMgr();
976 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
977 if ( !aSel || !appStudy )
980 SALOME_ListIO selected;
981 aSel->selectedObjects( selected );
982 if ( selected.IsEmpty() )
985 Handle(SALOME_InteractiveObject) anIObject = selected.First();
987 _PTR(Study) aStudy = appStudy->studyDS();
988 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
989 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
990 if ( aMainObject->_is_nil() )
993 SUIT_OverrideCursor wc;
995 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
997 QList<SALOMEDS::Color> aReservedColors;
999 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1000 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1002 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1004 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1005 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1006 #else // old algorithm for auto-colors
1007 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1008 aReservedColors.append( aColor );
1009 #endif // SIMPLE_AUTOCOLOR
1010 aGroupObject->SetColor( aColor );
1012 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1013 if ( aGroupSObject ) {
1016 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1017 switch ( aGroupObject->GetType ()) {
1019 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1021 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1023 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1025 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1027 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1028 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1031 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1032 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1038 SMESH::RepaintCurrentView();
1041 void OverallMeshQuality()
1043 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1044 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1045 SALOME_ListIO selected;
1047 aSel->selectedObjects( selected );
1049 if ( selected.IsEmpty() ) return;
1050 SALOME_ListIteratorOfListIO It( selected );
1051 for ( ; It.More(); It.Next() ) {
1052 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1053 ctrlDlg->showInfo( It.Value() );
1058 QString functorToString( SMESH::Controls::FunctorPtr f )
1060 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1061 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1062 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1063 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1064 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1065 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1066 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1067 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1068 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1069 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1070 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1071 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1072 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1073 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1074 type = QObject::tr( "WARP_ELEMENTS" );
1075 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1076 type = QObject::tr( "TAPER_ELEMENTS" );
1077 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1078 type = QObject::tr( "SKEW_ELEMENTS" );
1079 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1080 type = QObject::tr( "AREA_ELEMENTS" );
1081 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1082 type = QObject::tr( "LENGTH_EDGES" );
1083 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1084 type = QObject::tr( "LENGTH2D_EDGES" );
1085 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1086 type = QObject::tr( "MULTI_BORDERS" );
1087 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1088 type = QObject::tr( "MULTI2D_BORDERS" );
1089 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1090 type = QObject::tr( "FREE_NODES" );
1091 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1092 type = QObject::tr( "FREE_EDGES" );
1093 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1094 type = QObject::tr( "FREE_BORDERS" );
1095 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1096 type = QObject::tr( "FREE_FACES" );
1097 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1098 type = QObject::tr( "BARE_BORDER_VOLUME" );
1099 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1100 type = QObject::tr( "BARE_BORDER_FACE" );
1101 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1102 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1103 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1104 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1105 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1106 type = QObject::tr( "EQUAL_NODE" );
1107 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1108 type = QObject::tr( "EQUAL_EDGE" );
1109 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1110 type = QObject::tr( "EQUAL_FACE" );
1111 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1112 type = QObject::tr( "EQUAL_VOLUME" );
1116 void SaveDistribution()
1118 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1119 SALOME_ListIO selected;
1121 aSel->selectedObjects( selected );
1123 if ( selected.Extent() == 1 ) {
1124 Handle(SALOME_InteractiveObject) anIO = selected.First();
1125 if ( anIO->hasEntry() ) {
1126 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1128 anActor->GetScalarBarActor() &&
1129 anActor->GetControlMode() != SMESH_Actor::eNone )
1131 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1132 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1133 if ( aScalarBarActor && aFunctor ) {
1134 SMESH::Controls::NumericalFunctor* aNumFun =
1135 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1137 std::vector<int> elements;
1138 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1139 if ( mesh->_is_nil() ) {
1140 SMESH::SMESH_IDSource_var idSource =
1141 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1142 if ( !idSource->_is_nil() )
1144 SMESH::long_array_var ids = idSource->GetIDs();
1145 elements.resize( ids->length() );
1146 for ( unsigned i = 0; i < elements.size(); ++i )
1147 elements[i] = ids[i];
1150 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1151 vtkLookupTable* lookupTable =
1152 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1153 double * minmax = lookupTable->GetRange();
1154 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1155 std::vector<int> nbEvents;
1156 std::vector<double> funValues;
1157 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1158 elements, minmax, isLogarithmic );
1159 QString anInitialPath = "";
1160 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1161 anInitialPath = QDir::currentPath();
1162 QString aMeshName = anIO->getName();
1164 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1165 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1166 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1167 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1168 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1171 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1173 if ( !aFilename.isEmpty() ) {
1174 QFile f( aFilename );
1175 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1176 QTextStream out( &f );
1177 out << "# Mesh: " << aMeshName << endl;
1178 out << "# Control: " << functorToString( aFunctor ) << endl;
1180 out.setFieldWidth( 10 );
1181 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1182 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1193 void ShowElement( int theCommandID )
1195 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1196 SALOME_ListIO selected;
1198 aSel->selectedObjects( selected );
1200 if ( selected.Extent() == 1 ) {
1201 Handle(SALOME_InteractiveObject) anIO = selected.First();
1202 if ( anIO->hasEntry() ) {
1203 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1205 anActor->GetScalarBarActor() &&
1206 anActor->GetControlMode() != SMESH_Actor::eNone )
1208 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1209 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1210 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1212 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1213 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1220 #ifndef DISABLE_PLOT2DVIEWER
1221 void PlotDistribution()
1223 SalomeApp_Application* app =
1224 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1228 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1229 SALOME_ListIO selected;
1231 aSel->selectedObjects( selected );
1233 if ( selected.Extent() == 1 ) {
1234 Handle(SALOME_InteractiveObject) anIO = selected.First();
1235 if ( anIO->hasEntry() ) {
1236 //Find Actor by entry before getting Plot2d viewer,
1237 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1238 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1240 SUIT_ViewManager* aViewManager =
1241 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1245 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1249 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1253 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1255 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1256 QString functorName = functorToString( anActor->GetFunctor());
1257 QString aHistogramName("%1 : %2");
1258 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1259 aHistogram->setName(aHistogramName);
1260 aHistogram->setHorTitle(functorName);
1261 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1262 aPlot->displayObject(aHistogram, true);
1267 #endif //DISABLE_PLOT2DVIEWER
1269 void DisableAutoColor()
1271 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1272 SALOME_ListIO selected;
1274 aSel->selectedObjects( selected );
1276 if ( selected.Extent() ) {
1277 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1278 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1279 if ( !aMesh->_is_nil() ) {
1280 aMesh->SetAutoColor( false );
1287 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1288 SALOME_ListIO selected;
1290 aSel->selectedObjects( selected );
1291 if ( selected.Extent() )
1293 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1294 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1295 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1297 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1298 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1305 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1307 SALOME_ListIO selected;
1308 SalomeApp_Application* app =
1309 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1313 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1314 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1315 if ( !aSel || !appStudy )
1318 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1319 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1320 aModule->EmitSignalDeactivateDialog();
1321 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1322 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1327 _PTR(Study) aStudy = appStudy->studyDS();
1329 aSel->selectedObjects( selected );
1331 if ( selected.Extent() >= 1 )
1333 switch ( theCommandID ) {
1334 case SMESHOp::OpTransparency:
1336 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1337 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1340 case SMESHOp::OpProperties:
1343 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1344 QColor orientationColor, outlineColor, volumeColor;
1345 int deltaF = 0, deltaV = 0;
1348 double ballScale = 1.0;
1350 int outlineWidth = 1;
1351 double shrinkCoef = 0.0;
1352 double orientationScale = 0.0;
1353 bool orientation3d = false;
1354 VTK::MarkerType markerType = VTK::MT_NONE;
1355 VTK::MarkerScale markerScale = VTK::MS_NONE;
1357 bool hasNodes = false;
1358 int presentEntities = 0;
1359 bool firstTime = true;
1361 SALOME_ListIteratorOfListIO It( selected );
1362 for ( ; It.More(); It.Next() ) {
1363 Handle(SALOME_InteractiveObject) IObject = It.Value();
1364 if ( !IObject->hasEntry() ) continue;
1365 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1366 if ( !anActor || !anActor->GetObject() ) continue;
1369 // nodes: color, marker
1370 anActor->GetNodeColor( color[0], color[1], color[2] );
1371 nodeColor.setRgbF( color[0], color[1], color[2] );
1372 markerType = anActor->GetMarkerType();
1373 markerScale = anActor->GetMarkerScale();
1374 markerId = anActor->GetMarkerTexture();
1375 // edges: color, width
1376 anActor->GetEdgeColor( color[0], color[1], color[2] );
1377 edgeColor.setRgbF( color[0], color[1], color[2] );
1378 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1379 // faces: front color, back color (delta)
1380 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1381 faceColor.setRgbF( color[0], color[1], color[2] );
1382 // faces: front color, back color (delta)
1383 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1384 volumeColor.setRgbF( color[0], color[1], color[2] );
1385 // 0d elements: color, size
1386 anActor->Get0DColor( color[0], color[1], color[2] );
1387 elem0dColor.setRgbF( color[0], color[1], color[2] );
1388 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1389 // balls: color, size
1390 anActor->GetBallColor( color[0], color[1], color[2] );
1391 ballColor.setRgbF( color[0], color[1], color[2] );
1392 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1393 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1395 anActor->GetOutlineColor( color[0], color[1], color[2] );
1396 outlineColor.setRgbF( color[0], color[1], color[2] );
1397 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1398 // orientation vectors: color, scale, 3d flag
1399 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1400 orientationColor.setRgbF( color[0], color[1], color[2] );
1401 orientationScale = anActor->GetFacesOrientationScale();
1402 orientation3d = anActor->GetFacesOrientation3DVectors();
1404 shrinkCoef = anActor->GetShrinkFactor();
1407 firstTime = false; // we only take properties from first object (for performance reasons)
1410 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1411 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1412 presentEntities = presentEntities | SMESH_Actor::eEdges;
1413 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1414 presentEntities = presentEntities | SMESH_Actor::eFaces;
1415 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1416 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1417 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1418 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1419 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1420 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1422 // as we know that all types of elements are present, we can exit the loop
1423 if ( presentEntities == SMESH_Actor::eAllEntity )
1427 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1428 // nodes: color, marker
1429 dlg.setNodeColor( nodeColor );
1430 if( markerType != VTK::MT_USER )
1431 dlg.setNodeMarker( markerType, markerScale );
1433 dlg.setNodeCustomMarker( markerId );
1434 // edges: color, line width
1435 dlg.setEdgeColor( edgeColor );
1436 dlg.setEdgeWidth( edgeWidth );
1437 // faces: front color, back color
1438 dlg.setFaceColor( faceColor, deltaF );
1439 // volumes: normal color, reversed color
1440 dlg.setVolumeColor( volumeColor, deltaV );
1441 // outlines: color, line width
1442 dlg.setOutlineColor( outlineColor );
1443 dlg.setOutlineWidth( outlineWidth );
1444 // 0d elements: color, size
1445 dlg.setElem0dColor( elem0dColor );
1446 dlg.setElem0dSize( elem0dSize );
1447 // balls: color, size
1448 dlg.setBallColor( ballColor );
1449 //dlg.setBallSize( ballSize );
1450 dlg.setBallScale( ballScale );
1451 // orientation: color, scale, 3d flag
1452 dlg.setOrientationColor( orientationColor );
1453 dlg.setOrientationSize( int( orientationScale * 100. ) );
1454 dlg.setOrientation3d( orientation3d );
1455 // shrink: scale factor
1456 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1457 // hide unused controls
1458 dlg.showControls( presentEntities, hasNodes );
1461 nodeColor = dlg.nodeColor();
1462 markerType = dlg.nodeMarkerType();
1463 markerScale = dlg.nodeMarkerScale();
1464 markerId = dlg.nodeMarkerId();
1465 edgeColor = dlg.edgeColor();
1466 edgeWidth = dlg.edgeWidth();
1467 faceColor = dlg.faceColor();
1468 deltaF = dlg.faceColorDelta();
1469 volumeColor = dlg.volumeColor();
1470 deltaV = dlg.volumeColorDelta();
1471 outlineColor = dlg.outlineColor();
1472 outlineWidth = dlg.outlineWidth();
1473 elem0dColor = dlg.elem0dColor();
1474 elem0dSize = dlg.elem0dSize();
1475 ballColor = dlg.ballColor();
1476 // ballSize = dlg.ballSize();
1477 ballScale = dlg.ballScale();
1478 orientationColor = dlg.orientationColor();
1479 orientationScale = dlg.orientationSize() / 100.;
1480 orientation3d = dlg.orientation3d();
1481 shrinkCoef = dlg.shrinkCoef() / 100.;
1483 // store point markers map that might be changed by the user
1484 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1486 // set properties from dialog box to the presentations
1487 SALOME_ListIteratorOfListIO It( selected );
1488 for ( ; It.More(); It.Next() ) {
1489 Handle(SALOME_InteractiveObject) IObject = It.Value();
1490 if ( !IObject->hasEntry() ) continue;
1491 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1492 if ( !anActor ) continue;
1494 // nodes: color, marker
1495 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1496 if ( markerType != VTK::MT_USER ) {
1497 anActor->SetMarkerStd( markerType, markerScale );
1500 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1501 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1502 if ( iter != markerMap.end() )
1503 anActor->SetMarkerTexture( markerId, iter->second.second );
1505 // volumes: normal color, reversed color (delta)
1506 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1507 // faces: front color, back color (delta)
1508 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1509 // edges: color, width
1510 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1511 anActor->SetLineWidth( edgeWidth );
1513 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1514 anActor->SetOutlineWidth( outlineWidth );
1515 // 0D elements: color, size
1516 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1517 anActor->Set0DSize( elem0dSize );
1518 // balls: color, size
1519 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1520 // anActor->SetBallSize( ballSize );
1521 anActor->SetBallScale( ballScale );
1522 // orientation: color, scale, 3d flag
1523 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1524 anActor->SetFacesOrientationScale( orientationScale );
1525 anActor->SetFacesOrientation3DVectors( orientation3d );
1527 anActor->SetShrinkFactor( shrinkCoef );
1529 // for groups, set also proper color
1530 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1531 if ( !aGroupObject->_is_nil() ) {
1532 SMESH::ElementType anElementType = aGroupObject->GetType();
1534 switch( anElementType ) {
1536 aColor = nodeColor; break;
1538 aColor = edgeColor; break;
1540 aColor = faceColor; break;
1542 aColor = volumeColor; break;
1544 aColor = elem0dColor; break;
1546 aColor = ballColor; break;
1550 if ( aColor.isValid() ) {
1551 SALOMEDS::Color aGroupColor;
1552 aGroupColor.R = aColor.redF();
1553 aGroupColor.G = aColor.greenF();
1554 aGroupColor.B = aColor.blueF();
1555 aGroupObject->SetColor( aGroupColor );
1557 } // if ( !aGroupObject->_is_nil() )
1558 } // for ( ; It.More(); It.Next() )
1559 SMESH::RepaintCurrentView();
1560 } // if ( dlg.exec() )
1562 } // case SMESHOp::OpProperties:
1563 } // switch(theCommandID)
1564 SALOME_ListIteratorOfListIO It( selected );
1565 for( ; It.More(); It.Next()){
1566 Handle(SALOME_InteractiveObject) IObject = It.Value();
1567 if(IObject->hasEntry()){
1568 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1569 switch(theCommandID){
1570 case SMESHOp::OpDMWireframe:
1571 anActor->SetRepresentation(SMESH_Actor::eEdge);
1573 case SMESHOp::OpDMShading:
1574 anActor->SetRepresentation(SMESH_Actor::eSurface);
1576 case SMESHOp::OpDMShrink:
1577 if(anActor->IsShrunk())
1578 anActor->UnShrink();
1580 anActor->SetShrink();
1582 case SMESHOp::OpDMNodes:
1583 anActor->SetRepresentation(SMESH_Actor::ePoint);
1585 case SMESHOp::OpRepresentationLines:
1586 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1587 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1589 case SMESHOp::OpRepresentationArcs:
1590 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1591 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1597 SMESH::RepaintCurrentView();
1601 int ActionToControl( int theID, bool theReversed )
1603 NCollection_DoubleMap<int,int> ActionControl;
1604 ActionControl.Bind( 0, SMESH_Actor::eNone );
1605 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1606 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1607 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1608 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1609 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1610 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1611 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1612 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1613 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1614 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1615 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1616 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1617 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1618 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1619 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1620 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1621 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1622 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1623 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1624 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1625 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1626 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1627 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1628 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1629 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1630 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1632 return theReversed ? ActionControl.Find2( theID ) : ActionControl.Find1( theID );
1635 void Control( int theCommandID )
1637 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ) );
1638 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1639 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1640 SALOME_ListIO selected;
1642 aSel->selectedObjects( selected );
1644 if ( !selected.IsEmpty() ) {
1645 SALOME_ListIteratorOfListIO It(selected);
1646 for ( ; It.More(); It.Next())
1648 Handle(SALOME_InteractiveObject) anIO = It.Value();
1650 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1652 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1653 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
1654 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
1655 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
1656 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
1657 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry()) ) {
1658 anActor->SetControlMode(aControl);
1659 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1660 SMESH::RepaintCurrentView();
1661 #ifndef DISABLE_PLOT2DVIEWER
1662 if ( anActor->GetPlot2Histogram() ) {
1663 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1664 QString functorName = functorToString( anActor->GetFunctor() );
1665 QString aHistogramName("%1 : %2");
1666 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1667 aHistogram->setName( aHistogramName );
1668 aHistogram->setHorTitle( functorName );
1669 SMESH::ProcessIn2DViewers( anActor );
1681 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1682 SMESH::MeshObjectType theType,
1683 const QString theInTypeName,
1684 QString & theOutTypeName)
1686 SMESH_TypeFilter aTypeFilter( theType );
1688 if ( !theIO.IsNull() )
1690 entry = theIO->getEntry();
1691 LightApp_DataOwner owner( entry );
1692 if ( aTypeFilter.isOk( &owner )) {
1693 theOutTypeName = theInTypeName;
1701 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1703 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1704 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1706 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1707 CORBA::String_var anID = aSComp->GetID().c_str();
1708 if ( !strcmp(anID.in(),theIO->getEntry()) )
1714 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1715 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1716 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1717 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1718 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1726 QString CheckHomogeneousSelection()
1728 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1729 SALOME_ListIO selected;
1731 aSel->selectedObjects( selected );
1733 QString RefType = CheckTypeObject(selected.First());
1734 SALOME_ListIteratorOfListIO It(selected);
1735 for ( ; It.More(); It.Next())
1737 Handle(SALOME_InteractiveObject) IObject = It.Value();
1738 QString Type = CheckTypeObject(IObject);
1739 if ( Type.compare(RefType) != 0 )
1740 return "Heterogeneous Selection";
1746 uint randomize( uint size )
1748 static bool initialized = false;
1749 if ( !initialized ) {
1750 qsrand( QDateTime::currentDateTime().toTime_t() );
1754 v = uint( (double)( v ) / RAND_MAX * size );
1755 v = qMax( uint(0), qMin ( v, size-1 ) );
1761 void SMESHGUI::OnEditDelete()
1763 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1764 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1765 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1767 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1768 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1769 _PTR(GenericAttribute) anAttr;
1770 _PTR(AttributeIOR) anIOR;
1772 int objectCount = 0;
1774 QString aParentComponent = QString::null;
1775 Handle(SALOME_InteractiveObject) anIO;
1776 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1778 anIO = anIt.Value();
1779 QString cur = anIO->getComponentDataType();
1780 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1782 // check if object is reference
1783 _PTR(SObject) aRefSObj;
1784 aNameList.append("\n - ");
1785 if ( aSO->ReferencedObject( aRefSObj ) ) {
1786 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1787 aNameList.append( aRefName );
1788 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1791 aNameList.append(anIO->getName());
1795 if( aParentComponent.isNull() )
1796 aParentComponent = cur;
1797 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1798 aParentComponent = "";
1801 if ( objectCount == 0 )
1802 return; // No Valid Objects Selected
1804 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1805 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1806 QObject::tr("ERR_ERROR"),
1807 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1810 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1811 if (SUIT_MessageBox::warning
1812 (SMESHGUI::desktop(),
1813 QObject::tr("SMESH_WRN_WARNING"),
1814 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1815 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1816 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1819 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1821 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1822 // then treat them all starting from the deepest objects (at list back)
1823 std::list< _PTR(SObject) > listSO;
1824 SALOME_ListIteratorOfListIO It(selected);
1825 for( ; It.More(); It.Next()) // loop on selected IO's
1827 Handle(SALOME_InteractiveObject) IObject = It.Value();
1828 if(IObject->hasEntry()) {
1829 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1831 // disable removal of "SMESH" component object
1832 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1834 if ( engineIOR() == anIOR->Value().c_str() )
1837 //Check the referenced object
1838 _PTR(SObject) aRefSObject;
1839 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1840 aSO = aRefSObject; // Delete main Object instead of reference
1842 listSO.push_back( aSO );
1843 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1844 for ( ; itSO != listSO.end(); ++itSO ) {
1845 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1846 for (it->InitEx(false); it->More(); it->Next())
1847 listSO.push_back( it->Value() );
1851 // Check if none of objects to delete is referred from outside
1852 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1853 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1855 _PTR(SObject) SO = *ritSO;
1856 if ( !SO ) continue;
1857 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1858 for (size_t i = 0; i < aReferences.size(); i++) {
1859 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1860 std::string type = aComponent->ComponentDataType();
1861 if ( type != "SMESH" )
1863 SUIT_MessageBox::warning( anApp->desktop(),
1864 QObject::tr("WRN_WARNING"),
1865 QObject::tr("DEP_OBJECT") );
1866 return; // outside SMESH, there is an object depending on a SMESH object
1871 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1872 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1874 Handle(SALOME_InteractiveObject) IObject = It.Value();
1875 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1876 if ( !mesh->_is_nil() )
1880 // Treat SO's in the list starting from the back
1881 aStudyBuilder->NewCommand(); // There is a transaction
1882 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1884 _PTR(SObject) SO = *ritSO;
1885 if ( !SO ) continue;
1886 std::string anEntry = SO->GetID();
1888 /** Erase graphical object and remove all its data **/
1889 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1890 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1892 /** Remove an object from data structures **/
1893 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1894 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1895 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1896 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1897 aMesh->RemoveGroup( aGroup );
1899 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1900 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1901 aMesh->RemoveSubMesh( aSubMesh );
1903 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1905 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1908 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1909 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1910 QString objType = CheckTypeObject(IObject);
1911 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1912 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1913 aStudyBuilder->RemoveObjectWithChildren( SO );
1915 else {// default action: remove SObject from the study
1916 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1917 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1919 aStudyBuilder->RemoveObjectWithChildren( SO );
1923 } /* listSO back loop */
1925 aStudyBuilder->CommitCommand();
1927 /* Clear any previous selection */
1929 aSel->setSelectedObjects( l1 );
1931 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1935 SMESHGUI_EXPORT CAM_Module* createModule()
1937 return new SMESHGUI();
1940 SMESHGUI_EXPORT char* getModuleVersion() {
1941 return (char*)SMESH_VERSION_STR;
1945 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1947 //=============================================================================
1951 //=============================================================================
1952 SMESHGUI::SMESHGUI() :
1953 SalomeApp_Module( "SMESH" )
1955 if ( CORBA::is_nil( myComponentSMESH ) )
1957 CORBA::Boolean anIsEmbeddedMode;
1958 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1959 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1961 // 0019923: EDF 765 SMESH : default values of hypothesis
1962 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1963 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1964 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1965 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1966 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1968 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
1969 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1970 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1972 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1973 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1977 myActiveDialogBox = 0;
1978 myFilterLibraryDlg = 0;
1982 myEventCallbackCommand = vtkCallbackCommand::New();
1983 myEventCallbackCommand->Delete();
1984 myEventCallbackCommand->SetClientData( this );
1985 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1988 /* load resources for all available meshers */
1989 SMESH::InitAvailableHypotheses();
1992 //=============================================================================
1996 //=============================================================================
1997 SMESHGUI::~SMESHGUI()
2001 //=============================================================================
2005 //=============================================================================
2006 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2008 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2010 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2015 //=============================================================================
2019 //=============================================================================
2020 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2022 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2026 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2027 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2028 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2029 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2030 return autoUpdate && !exceeded;
2033 //=============================================================================
2037 //=============================================================================
2038 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2039 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2041 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2045 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2046 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2047 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2049 SMESH::long_array_var info = theMesh->GetMeshInfo();
2050 long nbOdElems = info[SMDSEntity_0D];
2051 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2052 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2053 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2054 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2055 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2056 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2057 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2058 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] +
2059 info[SMDSEntity_Polyhedra] +
2060 info[SMDSEntity_Hexagonal_Prism];
2061 long nbBalls = info[SMDSEntity_Ball];
2063 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2064 *nbElements = requestedSize;
2066 *entities = SMESH_Actor::eAllEntity;
2069 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2071 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2073 if ( incrementalLimit ) {
2076 if ( nbOdElems > 0 ) {
2077 if ( total + nbOdElems > updateLimit ) {
2078 *entities = *entities & ~SMESH_Actor::e0DElements;
2079 *hidden = *hidden | SMESH_Actor::e0DElements;
2086 if ( nbEdges > 0 ) {
2087 if ( total + nbEdges > updateLimit ) {
2088 *entities = *entities & ~SMESH_Actor::eEdges;
2089 *hidden = *hidden | SMESH_Actor::eEdges;
2096 if ( nbFaces > 0 ) {
2097 if ( total + nbFaces > updateLimit ) {
2098 *entities = *entities & ~SMESH_Actor::eFaces;
2099 *hidden = *hidden | SMESH_Actor::eFaces;
2106 if ( nbVolumes > 0 ) {
2107 if ( total + nbVolumes > updateLimit ) {
2108 *entities = *entities & ~SMESH_Actor::eVolumes;
2109 *hidden = *hidden | SMESH_Actor::eVolumes;
2116 if ( nbBalls > 0 ) {
2117 if ( total + nbBalls > updateLimit ) {
2118 *entities = *entities & ~SMESH_Actor::eBallElem;
2119 *hidden = *hidden | SMESH_Actor::eBallElem;
2127 return autoUpdate && !exceeded;
2130 //=============================================================================
2134 //=============================================================================
2135 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2137 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2140 //=============================================================================
2144 //=============================================================================
2145 SMESHGUI* SMESHGUI::GetSMESHGUI()
2147 SMESHGUI* smeshMod = 0;
2148 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2151 CAM_Module* module = app->module( "Mesh" );
2152 smeshMod = dynamic_cast<SMESHGUI*>( module );
2155 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2157 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2160 _PTR(Study) aStudy = study->studyDS();
2162 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2171 Standard_EXPORT SMESHGUI* GetComponentGUI()
2173 return SMESHGUI::GetSMESHGUI();
2177 //=============================================================================
2181 //=============================================================================
2182 void SMESHGUI::SetState(int aState)
2187 //=============================================================================
2191 //=============================================================================
2192 void SMESHGUI::ResetState()
2197 //=============================================================================
2201 //=============================================================================
2202 void SMESHGUI::EmitSignalDeactivateDialog()
2204 emit SignalDeactivateActiveDialog();
2207 //=============================================================================
2211 //=============================================================================
2212 void SMESHGUI::EmitSignalStudyFrameChanged()
2214 emit SignalStudyFrameChanged();
2217 //=============================================================================
2221 //=============================================================================
2222 void SMESHGUI::EmitSignalCloseAllDialogs()
2224 emit SignalCloseAllDialogs();
2227 //=============================================================================
2231 //=============================================================================
2232 void SMESHGUI::EmitSignalVisibilityChanged()
2234 emit SignalVisibilityChanged();
2237 //=============================================================================
2241 //=============================================================================
2242 void SMESHGUI::EmitSignalCloseView()
2244 emit SignalCloseView();
2247 //=============================================================================
2251 //=============================================================================
2252 void SMESHGUI::EmitSignalActivatedViewManager()
2254 emit SignalActivatedViewManager();
2257 //=============================================================================
2261 //=============================================================================
2262 QDialog *SMESHGUI::GetActiveDialogBox()
2264 return myActiveDialogBox;
2267 //=============================================================================
2271 //=============================================================================
2272 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2274 myActiveDialogBox = (QDialog *) aDlg;
2278 //=============================================================================
2282 //=============================================================================
2283 SUIT_Desktop* SMESHGUI::desktop()
2285 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2287 return app->desktop();
2292 //=============================================================================
2296 //=============================================================================
2297 SalomeApp_Study* SMESHGUI::activeStudy()
2299 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2301 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2306 //=============================================================================
2310 //=============================================================================
2311 void SMESHGUI::Modified( bool theIsUpdateActions )
2313 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2314 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2315 appStudy->Modified();
2316 if( theIsUpdateActions )
2317 app->updateActions();
2322 //=============================================================================
2326 //=============================================================================
2327 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2329 /* Here the position is on the bottom right corner - 10 */
2330 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2332 SUIT_Desktop *PP = desktop();
2333 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2334 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2338 //=============================================================================
2342 //=============================================================================
2343 static int isStudyLocked(_PTR(Study) theStudy){
2344 return theStudy->GetProperties()->IsLocked();
2347 static bool checkLock(_PTR(Study) theStudy) {
2348 if (isStudyLocked(theStudy)) {
2349 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2350 QObject::tr("WRN_WARNING"),
2351 QObject::tr("WRN_STUDY_LOCKED") );
2357 //=======================================================================
2358 //function : CheckActiveStudyLocked
2360 //=======================================================================
2362 bool SMESHGUI::isActiveStudyLocked()
2364 _PTR(Study) aStudy = activeStudy()->studyDS();
2365 return checkLock( aStudy );
2368 //=============================================================================
2372 //=============================================================================
2373 bool SMESHGUI::OnGUIEvent( int theCommandID )
2375 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2379 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2380 SUIT_ResourceMgr* mgr = resourceMgr();
2384 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2385 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2388 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2389 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2391 //QAction* act = action( theCommandID );
2393 switch (theCommandID) {
2394 case SMESHOp::OpDelete:
2395 if(checkLock(aStudy)) break;
2398 case SMESHOp::OpImportDAT:
2399 case SMESHOp::OpImportUNV:
2400 case SMESHOp::OpImportMED:
2401 case SMESHOp::OpImportSTL:
2403 case SMESHOp::OpImportCGNS:
2405 case SMESHOp::OpImportSAUV:
2406 case SMESHOp::OpImportGMF:
2408 if(checkLock(aStudy)) break;
2409 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2413 case SMESHOp::OpFileInformation:
2415 SALOME_ListIO selected;
2416 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2418 aSel->selectedObjects( selected );
2419 if( selected.Extent() )
2421 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2422 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2423 if ( !aMesh->_is_nil() )
2425 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2431 case SMESHOp::OpExportDAT:
2432 case SMESHOp::OpExportMED:
2433 case SMESHOp::OpExportUNV:
2434 case SMESHOp::OpExportSTL:
2436 case SMESHOp::OpExportCGNS:
2438 case SMESHOp::OpExportSAUV:
2439 case SMESHOp::OpExportGMF:
2440 case SMESHOp::OpPopupExportDAT:
2441 case SMESHOp::OpPopupExportMED:
2442 case SMESHOp::OpPopupExportUNV:
2443 case SMESHOp::OpPopupExportSTL:
2445 case SMESHOp::OpPopupExportCGNS:
2447 case SMESHOp::OpPopupExportSAUV:
2448 case SMESHOp::OpPopupExportGMF:
2450 ::ExportMeshToFile(theCommandID);
2454 case SMESHOp::OpReset: // SCALAR BAR
2456 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2457 SALOME_ListIO selected;
2459 aSel->selectedObjects( selected );
2461 SALOME_ListIteratorOfListIO it(selected);
2462 for( ; it.More(); it.Next()) {
2463 Handle(SALOME_InteractiveObject) anIO = it.Value();
2464 if( anIO->hasEntry() ) {
2465 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2466 anActor->SetControlMode( SMESH_Actor::eNone );
2467 #ifndef DISABLE_PLOT2DVIEWER
2468 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2473 SMESH::UpdateView();
2476 case SMESHOp::OpScalarBarProperties:
2478 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2481 case SMESHOp::OpShowScalarBar:
2483 // show/hide scalar bar
2484 ::ShowElement(theCommandID);
2487 case SMESHOp::OpSaveDistribution:
2489 // dump control distribution data to the text file
2490 ::SaveDistribution();
2494 case SMESHOp::OpShowDistribution:
2496 // show/hide distribution
2497 ::ShowElement(theCommandID);
2501 #ifndef DISABLE_PLOT2DVIEWER
2502 case SMESHOp::OpPlotDistribution:
2504 // plot distribution
2505 ::PlotDistribution();
2511 case SMESHOp::OpAutoColor:
2515 case SMESHOp::OpDisableAutoColor:
2516 ::DisableAutoColor();
2519 case SMESHOp::OpClipping:
2520 case SMESHOp::OpTransparency:
2521 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2524 case SMESHOp::OpDMWireframe:
2525 case SMESHOp::OpDMShading:
2526 case SMESHOp::OpDMNodes:
2527 case SMESHOp::OpDMShrink:
2528 ::SetDisplayMode(theCommandID, myMarkerMap);
2531 //2D quadratic representation
2532 case SMESHOp::OpRepresentationLines:
2533 case SMESHOp::OpRepresentationArcs:
2534 ::SetDisplayMode(theCommandID, myMarkerMap);
2538 case SMESHOp::OpDE0DElements:
2539 case SMESHOp::OpDEEdges:
2540 case SMESHOp::OpDEFaces:
2541 case SMESHOp::OpDEVolumes:
2542 case SMESHOp::OpDEBalls:
2543 case SMESHOp::OpDEAllEntity:
2544 ::SetDisplayEntity(theCommandID);
2547 // Choose entities to be displayed
2548 case SMESHOp::OpDEChoose:
2550 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2554 case SMESHOp::OpOrientationOnFaces:
2556 LightApp_SelectionMgr* mgr = selectionMgr();
2557 SALOME_ListIO selected; mgr->selectedObjects( selected );
2559 SALOME_ListIteratorOfListIO it(selected);
2560 for( ; it.More(); it.Next()) {
2561 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2562 if(anIObject->hasEntry()) {
2563 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2564 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2571 case SMESHOp::OpUpdate:
2573 if(checkLock(aStudy)) break;
2574 SUIT_OverrideCursor wc;
2576 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2579 SMESH::UpdateView();
2581 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2582 SMESH::OnVisuException();
2584 catch (...) { // PAL16774 (Crash after display of many groups)
2585 SMESH::OnVisuException();
2589 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2590 aSel->selectedObjects( l );
2591 aSel->setSelectedObjects( l );
2595 case SMESHOp::OpHide:
2596 case SMESHOp::OpShow:
2597 case SMESHOp::OpShowOnly:
2599 SMESH::EDisplaing anAction;
2600 switch (theCommandID) {
2601 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2602 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2603 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2606 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2607 SALOME_ListIO sel_objects, to_process;
2609 aSel->selectedObjects( sel_objects );
2611 if ( theCommandID==SMESHOp::OpShowOnly )
2613 MESSAGE("anAction = SMESH::eDisplayOnly");
2614 startOperation( myEraseAll );
2617 extractContainers( sel_objects, to_process );
2620 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2624 SALOME_ListIteratorOfListIO It( to_process );
2625 for ( ; It.More(); It.Next())
2627 Handle(SALOME_InteractiveObject) IOS = It.Value();
2628 if ( IOS->hasEntry() )
2630 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2631 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2632 break; // PAL16774 (Crash after display of many groups)
2634 if (anAction == SMESH::eDisplayOnly)
2635 anAction = SMESH::eDisplay;
2640 // PAL13338 + PAL15161 -->
2641 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !checkLock(aStudy)) {
2642 MESSAGE("anAction = SMESH::eDisplayOnly");
2643 SMESH::UpdateView();
2644 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2646 // PAL13338 + PAL15161 <--
2648 catch (...) { // PAL16774 (Crash after display of many groups)
2649 SMESH::OnVisuException();
2652 if (anAction == SMESH::eErase) {
2653 MESSAGE("anAction == SMESH::eErase");
2655 aSel->setSelectedObjects( l1 );
2658 aSel->setSelectedObjects( to_process );
2663 case SMESHOp::OpNode:
2665 if(checkLock(aStudy)) break;
2668 EmitSignalDeactivateDialog();
2670 ( new SMESHGUI_NodesDlg( this ) )->show();
2673 SUIT_MessageBox::warning(desktop(),
2674 tr("SMESH_WRN_WARNING"),
2675 tr("SMESH_WRN_VIEWER_VTK"));
2680 case SMESHOp::OpCreateMesh:
2681 case SMESHOp::OpCreateSubMesh:
2682 case SMESHOp::OpEditMeshOrSubMesh:
2683 case SMESHOp::OpCompute:
2684 case SMESHOp::OpPreCompute:
2685 case SMESHOp::OpEvaluate:
2686 case SMESHOp::OpMeshOrder:
2687 startOperation( theCommandID );
2689 case SMESHOp::OpCopyMesh:
2691 if (checkLock(aStudy)) break;
2692 EmitSignalDeactivateDialog();
2693 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2696 case SMESHOp::OpBuildCompoundMesh:
2698 if (checkLock(aStudy)) break;
2699 EmitSignalDeactivateDialog();
2700 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2704 case SMESHOp::OpDiagonalInversion:
2705 case SMESHOp::OpUnionOfTwoTriangle:
2709 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2710 tr( "NOT_A_VTK_VIEWER" ) );
2714 if ( checkLock( aStudy ) )
2717 /*Standard_Boolean aRes;
2718 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2719 if ( aMesh->_is_nil() )
2721 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2722 tr( "SMESH_BAD_SELECTION" ) );
2726 EmitSignalDeactivateDialog();
2727 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2728 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2730 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2733 case SMESHOp::OpOrientation:
2734 case SMESHOp::OpUnionOfTriangles:
2735 case SMESHOp::OpCuttingOfQuadrangles:
2736 case SMESHOp::OpSplitVolumes:
2740 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2741 tr( "NOT_A_VTK_VIEWER" ) );
2745 if ( checkLock( aStudy ) )
2748 EmitSignalDeactivateDialog();
2749 SMESHGUI_MultiEditDlg* aDlg = NULL;
2750 if ( theCommandID == SMESHOp::OpOrientation )
2751 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2752 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2753 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2754 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2755 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2757 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2762 case SMESHOp::OpSmoothing:
2764 if(checkLock(aStudy)) break;
2766 EmitSignalDeactivateDialog();
2767 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2770 SUIT_MessageBox::warning(desktop(),
2771 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2775 case SMESHOp::OpExtrusion:
2777 if (checkLock(aStudy)) break;
2779 EmitSignalDeactivateDialog();
2780 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2782 SUIT_MessageBox::warning(desktop(),
2783 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2787 case SMESHOp::OpExtrusionAlongAPath:
2789 if (checkLock(aStudy)) break;
2791 EmitSignalDeactivateDialog();
2792 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2794 SUIT_MessageBox::warning(desktop(),
2795 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2799 case SMESHOp::OpRevolution:
2801 if(checkLock(aStudy)) break;
2803 EmitSignalDeactivateDialog();
2804 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2807 SUIT_MessageBox::warning(desktop(),
2808 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2812 case SMESHOp::OpPatternMapping:
2814 if ( checkLock( aStudy ) )
2818 EmitSignalDeactivateDialog();
2819 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2822 SUIT_MessageBox::warning(desktop(),
2823 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2827 case SMESHOp::OpSplitBiQuadratic:
2828 case SMESHOp::OpConvertMeshToQuadratic:
2829 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
2830 case SMESHOp::OpReorientFaces:
2831 case SMESHOp::OpCreateGeometryGroup:
2833 startOperation( theCommandID );
2836 case SMESHOp::OpCreateGroup:
2840 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2841 tr( "NOT_A_VTK_VIEWER" ) );
2845 if(checkLock(aStudy)) break;
2846 EmitSignalDeactivateDialog();
2847 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2849 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2850 SALOME_ListIO selected;
2852 aSel->selectedObjects( selected );
2854 int nbSel = selected.Extent();
2856 // check if mesh is selected
2857 aMesh = SMESH::GetMeshByIO( selected.First() );
2859 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2864 case SMESHOp::OpConstructGroup:
2868 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2869 tr( "NOT_A_VTK_VIEWER" ) );
2873 if(checkLock(aStudy)) break;
2874 EmitSignalDeactivateDialog();
2876 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2877 SALOME_ListIO selected;
2879 aSel->selectedObjects( selected );
2881 int nbSel = selected.Extent();
2883 // check if submesh is selected
2884 Handle(SALOME_InteractiveObject) IObject = selected.First();
2885 if (IObject->hasEntry()) {
2886 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2888 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2889 if (!aSubMesh->_is_nil()) {
2891 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2892 // get submesh elements list by types
2893 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2894 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2895 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2896 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2897 // create group for each type o elements
2898 QString aName = IObject->getName();
2899 QStringList anEntryList;
2900 if (aNodes->length() > 0) {
2901 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2902 aGroup->Add(aNodes.inout());
2903 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2904 anEntryList.append( aSObject->GetID().c_str() );
2906 if (aEdges->length() > 0) {
2907 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2908 aGroup->Add(aEdges.inout());
2909 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2910 anEntryList.append( aSObject->GetID().c_str() );
2912 if (aFaces->length() > 0) {
2913 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2914 aGroup->Add(aFaces.inout());
2915 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2916 anEntryList.append( aSObject->GetID().c_str() );
2918 if (aVolumes->length() > 0) {
2919 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2920 aGroup->Add(aVolumes.inout());
2921 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2922 anEntryList.append( aSObject->GetID().c_str() );
2925 anApp->browseObjects( anEntryList );
2927 catch(const SALOME::SALOME_Exception & S_ex){
2928 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2935 SUIT_MessageBox::warning(desktop(),
2936 tr("SMESH_WRN_WARNING"),
2937 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2942 case SMESHOp::OpEditGroup:
2946 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2947 tr( "NOT_A_VTK_VIEWER" ) );
2951 if(checkLock(aStudy)) break;
2952 EmitSignalDeactivateDialog();
2954 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2955 SALOME_ListIO selected;
2957 aSel->selectedObjects( selected );
2959 SALOME_ListIteratorOfListIO It (selected);
2960 int nbSelectedGroups = 0;
2961 for ( ; It.More(); It.Next() )
2963 SMESH::SMESH_GroupBase_var aGroup =
2964 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2965 if (!aGroup->_is_nil()) {
2967 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2971 if (nbSelectedGroups == 0)
2973 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2979 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
2981 if(checkLock(aStudy)) break;
2982 if (myState == 800) {
2983 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2984 if (aDlg) aDlg->onAdd();
2989 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
2991 if(checkLock(aStudy)) break;
2992 if (myState == 800) {
2993 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2994 if (aDlg) aDlg->onRemove();
2999 case SMESHOp::OpEditGeomGroupAsGroup:
3003 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3004 tr( "NOT_A_VTK_VIEWER" ) );
3008 if(checkLock(aStudy)) break;
3009 EmitSignalDeactivateDialog();
3011 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3012 SALOME_ListIO selected;
3014 aSel->selectedObjects( selected );
3016 SALOME_ListIteratorOfListIO It (selected);
3017 for ( ; It.More(); It.Next() )
3019 SMESH::SMESH_GroupOnGeom_var aGroup =
3020 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3021 if (!aGroup->_is_nil()) {
3022 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3027 SMESH::SMESH_GroupOnFilter_var aGroup =
3028 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3029 if (!aGroup->_is_nil()) {
3030 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3038 case SMESHOp::OpUnionGroups:
3039 case SMESHOp::OpIntersectGroups:
3040 case SMESHOp::OpCutGroups:
3044 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3045 tr( "NOT_A_VTK_VIEWER" ) );
3049 if ( checkLock( aStudy ) )
3052 EmitSignalDeactivateDialog();
3054 SMESHGUI_GroupOpDlg* aDlg = 0;
3055 if ( theCommandID == SMESHOp::OpUnionGroups )
3056 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3057 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3058 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3060 aDlg = new SMESHGUI_CutGroupsDlg( this );
3067 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3069 if ( checkLock( aStudy ) )
3072 EmitSignalDeactivateDialog();
3073 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3079 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3083 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3084 tr( "NOT_A_VTK_VIEWER" ) );
3088 if ( checkLock( aStudy ) )
3091 EmitSignalDeactivateDialog();
3093 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3097 case SMESHOp::OpMeshInformation:
3098 case SMESHOp::OpWhatIs:
3100 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3101 EmitSignalDeactivateDialog();
3102 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3103 SALOME_ListIO selected;
3105 aSel->selectedObjects( selected );
3107 if ( selected.Extent() > 1 ) { // a dlg for each IO
3108 SALOME_ListIteratorOfListIO It( selected );
3109 for ( ; It.More(); It.Next() ) {
3110 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3111 dlg->showInfo( It.Value() );
3116 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3122 case SMESHOp::OpFindElementByPoint:
3124 startOperation( theCommandID );
3128 case SMESHOp::OpEditHypothesis:
3130 if(checkLock(aStudy)) break;
3132 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3133 SALOME_ListIO selected;
3135 aSel->selectedObjects( selected );
3137 int nbSel = selected.Extent();
3140 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3141 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3143 if ( !aHypothesis->_is_nil() )
3145 SMESHGUI_GenericHypothesisCreator* aCreator =
3146 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3149 // set geometry of mesh and sub-mesh to aCreator
3150 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3151 if ( selected.Extent() == 1 )
3153 QString subGeomID, meshGeomID;
3154 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3155 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3157 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3158 aCreator->setShapeEntry( subGeomID );
3159 aCreator->setMainShapeEntry( meshGeomID );
3163 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3173 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3175 if(checkLock(aStudy)) break;
3176 SUIT_OverrideCursor wc;
3178 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3179 SALOME_ListIO selected;
3181 aSel->selectedObjects( selected, QString::null, false );
3183 SALOME_ListIteratorOfListIO It(selected);
3184 for (int i = 0; It.More(); It.Next(), i++) {
3185 Handle(SALOME_InteractiveObject) IObject = It.Value();
3186 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3189 aSel->setSelectedObjects( l1 );
3194 case SMESHOp::OpElem0D:
3195 case SMESHOp::OpBall:
3196 case SMESHOp::OpEdge:
3197 case SMESHOp::OpTriangle:
3198 case SMESHOp::OpQuadrangle:
3199 case SMESHOp::OpPolygon:
3200 case SMESHOp::OpTetrahedron:
3201 case SMESHOp::OpHexahedron:
3202 case SMESHOp::OpPentahedron:
3203 case SMESHOp::OpPyramid:
3204 case SMESHOp::OpHexagonalPrism:
3206 if(checkLock(aStudy)) break;
3208 EmitSignalDeactivateDialog();
3209 SMDSAbs_EntityType type = SMDSEntity_Edge;
3210 switch (theCommandID) {
3211 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3212 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3213 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3214 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3215 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3216 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3217 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3218 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3219 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3220 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3223 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3226 SUIT_MessageBox::warning(desktop(),
3227 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3231 case SMESHOp::OpPolyhedron:
3233 if(checkLock(aStudy)) break;
3235 EmitSignalDeactivateDialog();
3236 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3239 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3240 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3244 case SMESHOp::OpQuadraticEdge:
3245 case SMESHOp::OpQuadraticTriangle:
3246 case SMESHOp::OpBiQuadraticTriangle:
3247 case SMESHOp::OpQuadraticQuadrangle:
3248 case SMESHOp::OpBiQuadraticQuadrangle:
3249 case SMESHOp::OpQuadraticPolygon:
3250 case SMESHOp::OpQuadraticTetrahedron:
3251 case SMESHOp::OpQuadraticPyramid:
3252 case SMESHOp::OpQuadraticPentahedron:
3253 case SMESHOp::OpQuadraticHexahedron:
3254 case SMESHOp::OpTriQuadraticHexahedron:
3256 if(checkLock(aStudy)) break;
3258 EmitSignalDeactivateDialog();
3259 SMDSAbs_EntityType type = SMDSEntity_Last;
3261 switch (theCommandID) {
3262 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3263 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3264 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3265 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3266 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3267 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3268 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3269 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3270 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3271 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3272 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3275 if ( type != SMDSEntity_Last )
3276 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3279 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3280 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3284 case SMESHOp::OpRemoveNodes:
3286 if(checkLock(aStudy)) break;
3288 EmitSignalDeactivateDialog();
3289 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3292 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3293 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3297 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3299 if(checkLock(aStudy)) break;
3301 EmitSignalDeactivateDialog();
3302 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3306 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3307 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3311 case SMESHOp::OpClearMesh: {
3313 if(checkLock(aStudy)) break;
3315 SALOME_ListIO selected;
3316 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3317 aSel->selectedObjects( selected );
3319 SUIT_OverrideCursor wc;
3320 SALOME_ListIteratorOfListIO It (selected);
3321 for ( ; It.More(); It.Next() )
3323 Handle(SALOME_InteractiveObject) IOS = It.Value();
3324 SMESH::SMESH_Mesh_var aMesh =
3325 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3326 if ( aMesh->_is_nil()) continue;
3328 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3330 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3331 SMESH::ModifiedMesh( aMeshSObj, false, true);
3332 // hide groups and submeshes
3333 _PTR(ChildIterator) anIter =
3334 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3335 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3337 _PTR(SObject) so = anIter->Value();
3338 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3341 catch (const SALOME::SALOME_Exception& S_ex){
3343 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3347 SMESH::UpdateView();
3351 case SMESHOp::OpRemoveOrphanNodes:
3353 if(checkLock(aStudy)) break;
3354 SALOME_ListIO selected;
3355 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3356 aSel->selectedObjects( selected );
3357 if ( selected.Extent() == 1 ) {
3358 Handle(SALOME_InteractiveObject) anIO = selected.First();
3359 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3360 if ( !aMesh->_is_nil() ) {
3361 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3362 tr( "SMESH_WARNING" ),
3363 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3364 SUIT_MessageBox::Yes |
3365 SUIT_MessageBox::No,
3366 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3369 SUIT_OverrideCursor wc;
3370 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3371 int removed = aMeshEditor->RemoveOrphanNodes();
3372 SUIT_MessageBox::information(SMESHGUI::desktop(),
3373 tr("SMESH_INFORMATION"),
3374 tr("NB_NODES_REMOVED").arg(removed));
3375 if ( removed > 0 ) {
3376 SMESH::UpdateView();
3377 SMESHGUI::Modified();
3380 catch (const SALOME::SALOME_Exception& S_ex) {
3381 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3390 case SMESHOp::OpRenumberingNodes:
3392 if(checkLock(aStudy)) break;
3394 EmitSignalDeactivateDialog();
3395 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3399 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3400 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3404 case SMESHOp::OpRenumberingElements:
3406 if(checkLock(aStudy)) break;
3408 EmitSignalDeactivateDialog();
3409 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3413 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3414 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3418 case SMESHOp::OpTranslation:
3420 if(checkLock(aStudy)) break;
3422 EmitSignalDeactivateDialog();
3423 ( new SMESHGUI_TranslationDlg( this ) )->show();
3426 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3427 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3431 case SMESHOp::OpRotation:
3433 if(checkLock(aStudy)) break;
3435 EmitSignalDeactivateDialog();
3436 ( new SMESHGUI_RotationDlg( this ) )->show();
3439 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3440 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3444 case SMESHOp::OpSymmetry:
3446 if(checkLock(aStudy)) break;
3448 EmitSignalDeactivateDialog();
3449 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3452 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3453 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3457 case SMESHOp::OpScale:
3459 if(checkLock(aStudy)) break;
3461 EmitSignalDeactivateDialog();
3462 ( new SMESHGUI_ScaleDlg( this ) )->show();
3465 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3466 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3471 case SMESHOp::OpSewing:
3473 if(checkLock(aStudy)) break;
3475 EmitSignalDeactivateDialog();
3476 ( new SMESHGUI_SewingDlg( this ) )->show();
3479 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3480 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3484 case SMESHOp::OpMergeNodes:
3486 if(checkLock(aStudy)) break;
3488 EmitSignalDeactivateDialog();
3489 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3492 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3493 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3497 case SMESHOp::OpMergeElements:
3499 if (checkLock(aStudy)) break;
3501 EmitSignalDeactivateDialog();
3502 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3504 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3505 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3510 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3511 startOperation( SMESHOp::OpMoveNode );
3514 case SMESHOp::OpDuplicateNodes:
3516 if(checkLock(aStudy)) break;
3518 EmitSignalDeactivateDialog();
3519 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3522 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3523 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));