1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
33 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
34 #include "SMESHGUI_AddMeshElementDlg.h"
35 #include "SMESHGUI_AddQuadraticElementDlg.h"
36 #include "SMESHGUI_BuildCompoundDlg.h"
37 #include "SMESHGUI_ClippingDlg.h"
38 #include "SMESHGUI_ComputeDlg.h"
39 #include "SMESHGUI_ConvToQuadOp.h"
40 #include "SMESHGUI_CopyMeshDlg.h"
41 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
42 #include "SMESHGUI_DeleteGroupDlg.h"
43 #include "SMESHGUI_Displayer.h"
44 #include "SMESHGUI_DuplicateNodesDlg.h"
45 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
46 #include "SMESHGUI_ExtrusionDlg.h"
47 #include "SMESHGUI_FieldSelectorWdg.h"
48 #include "SMESHGUI_FileInfoDlg.h"
49 #include "SMESHGUI_FileValidator.h"
50 #include "SMESHGUI_FilterDlg.h"
51 #include "SMESHGUI_FilterLibraryDlg.h"
52 #include "SMESHGUI_FindElemByPointDlg.h"
53 #include "SMESHGUI_GroupDlg.h"
54 #include "SMESHGUI_GroupOnShapeDlg.h"
55 #include "SMESHGUI_GroupOpDlg.h"
56 #include "SMESHGUI_Hypotheses.h"
57 #include "SMESHGUI_Make2DFrom3DOp.h"
58 #include "SMESHGUI_MakeNodeAtPointDlg.h"
59 #include "SMESHGUI_Measurements.h"
60 #include "SMESHGUI_MergeDlg.h"
61 #include "SMESHGUI_MeshInfo.h"
62 #include "SMESHGUI_MeshOp.h"
63 #include "SMESHGUI_MeshOrderOp.h"
64 #include "SMESHGUI_MeshPatternDlg.h"
65 #include "SMESHGUI_MultiEditDlg.h"
66 #include "SMESHGUI_NodesDlg.h"
67 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
68 #include "SMESHGUI_PropertiesDlg.h"
69 #include "SMESHGUI_RemoveElementsDlg.h"
70 #include "SMESHGUI_RemoveNodesDlg.h"
71 #include "SMESHGUI_RenumberingDlg.h"
72 #include "SMESHGUI_ReorientFacesDlg.h"
73 #include "SMESHGUI_RevolutionDlg.h"
74 #include "SMESHGUI_RotationDlg.h"
75 #include "SMESHGUI_ScaleDlg.h"
76 #include "SMESHGUI_Selection.h"
77 #include "SMESHGUI_SewingDlg.h"
78 #include "SMESHGUI_SingleEditDlg.h"
79 #include "SMESHGUI_SmoothingDlg.h"
80 #include "SMESHGUI_SymmetryDlg.h"
81 #include "SMESHGUI_TranslationDlg.h"
82 #include "SMESHGUI_TransparencyDlg.h"
84 #include "SMESHGUI_FilterUtils.h"
85 #include "SMESHGUI_GroupUtils.h"
86 #include "SMESHGUI_HypothesesUtils.h"
87 #include "SMESHGUI_MeshUtils.h"
88 #include "SMESHGUI_PatternUtils.h"
89 #include "SMESHGUI_Utils.h"
90 #include "SMESHGUI_VTKUtils.h"
92 #include <SMESH_version.h>
94 #include "SMESH_ControlsDef.hxx"
95 #include <SMESH_Actor.h>
96 #include <SMESH_ActorUtils.h>
97 #include <SMESH_Client.hxx>
98 #include <SMESH_ScalarBarActor.h>
99 #include <SMESH_TypeFilter.hxx>
101 // SALOME GUI includes
102 #include <SalomeApp_Application.h>
103 #include <SalomeApp_CheckFileDlg.h>
104 #include <SalomeApp_DataObject.h>
105 #include <SalomeApp_Study.h>
106 #include <SalomeApp_Tools.h>
108 #include <LightApp_DataOwner.h>
109 #include <LightApp_NameDlg.h>
110 #include <LightApp_Preferences.h>
111 #include <LightApp_SelectionMgr.h>
112 #include <LightApp_UpdateFlags.h>
114 #include <SVTK_ViewManager.h>
115 #include <SVTK_ViewModel.h>
116 #include <SVTK_ViewWindow.h>
118 #include <VTKViewer_Algorithm.h>
120 #include <PyInterp_Interp.h>
122 #include <SUIT_Desktop.h>
123 #include <SUIT_FileDlg.h>
124 #include <SUIT_MessageBox.h>
125 #include <SUIT_OverrideCursor.h>
126 #include <SUIT_ResourceMgr.h>
127 #include <SUIT_Session.h>
129 #include <QtxPopupMgr.h>
130 #include <QtxFontEdit.h>
132 #include <SALOME_ListIO.hxx>
133 #include <SALOME_ListIteratorOfListIO.hxx>
135 #ifndef DISABLE_PLOT2DVIEWER
136 #include <SPlot2d_ViewModel.h>
137 #include <SPlot2d_Histogram.h>
141 #include <SALOMEconfig.h>
142 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
143 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
144 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
147 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
148 #include <QApplication>
150 #include <QTextStream>
153 #include <boost/shared_ptr.hpp>
156 #include <vtkCallbackCommand.h>
157 #include <vtkCamera.h>
158 #include <vtkLookupTable.h>
159 #include <vtkPlane.h>
160 #include <vtkRenderer.h>
162 // SALOME KERNEL includes
163 #include <SALOMEDSClient_ClientFactory.hxx>
164 #include <SALOMEDSClient_IParameters.hxx>
165 #include <SALOMEDSClient_SComponent.hxx>
166 #include <SALOMEDSClient_StudyBuilder.hxx>
167 #include <SALOMEDS_Study.hxx>
168 #include <SALOMEDS_SObject.hxx>
171 #include <Standard_ErrorHandler.hxx>
172 #include <NCollection_DataMap.hxx>
174 #include <Basics_Utils.hxx>
176 //To disable automatic genericobj management, the following line should be commented.
177 //Otherwise, it should be uncommented.
178 //Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
179 #define WITHGENERICOBJ
181 // Below macro, when uncommented, switches on simplified (more performant) algorithm
182 // of auto-color picking up
183 #define SIMPLE_AUTOCOLOR
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 void Control( int theCommandID );
201 //================================================================================
203 * \brief Reads meshes from file
205 //================================================================================
207 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
211 std::string myExtension;
213 if ( theCommandID == 113 ) {
214 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
215 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
217 else if ( theCommandID == 112 ) {
218 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
220 else if ( theCommandID == 111 ) {
221 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
223 else if ( theCommandID == 115 ) {
224 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
226 else if ( theCommandID == 116 ) {
227 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
229 else if ( theCommandID == 117 ) {
230 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
231 filter.append( QObject::tr( "All files (*)" ) );
233 else if ( theCommandID == 118 ) {
234 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
235 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
238 QString anInitialPath = "";
239 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
240 anInitialPath = QDir::currentPath();
242 QStringList filenames;
243 bool toCreateGroups = true;
245 // if ( theCommandID == 118 ) { // GMF
246 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
247 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
248 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
249 // fd->setNameFilters( filter );
250 // fd->SetChecked( true );
252 // filenames << fd->selectedFile();
253 // toCreateGroups = fd->IsChecked();
259 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
262 QObject::tr( "SMESH_IMPORT_MESH" ) );
264 if ( filenames.count() > 0 ) {
265 SUIT_OverrideCursor wc;
266 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
269 QStringList anEntryList;
270 bool isEmpty = false;
271 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
272 QString filename = *it;
273 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
275 switch ( theCommandID ) {
278 // DAT format (currently unsupported)
279 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
280 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
286 aMeshes->length( 1 );
287 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
288 if ( aMeshes[0]->_is_nil() )
289 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
290 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
296 SMESH::DriverMED_ReadStatus res;
297 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
298 if ( res != SMESH::DRS_OK ) {
299 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
300 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
307 aMeshes->length( 1 );
308 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
309 if ( aMeshes[0]->_is_nil() ) {
310 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
311 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
318 SMESH::DriverMED_ReadStatus res;
319 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
320 if ( res != SMESH::DRS_OK ) {
321 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
322 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
329 SMESH::DriverMED_ReadStatus res;
330 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
331 if ( res != SMESH::DRS_OK ) {
332 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
333 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
340 SMESH::ComputeError_var res;
341 aMeshes->length( 1 );
342 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
345 if ( res->code != SMESH::DRS_OK ) {
346 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
347 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
348 if ( strlen( res->comment.in() ) > 0 ) {
349 errors.back() += ": ";
350 errors.back() += res->comment.in();
357 catch ( const SALOME::SALOME_Exception& S_ex ) {
358 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
359 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
362 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
363 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
365 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
366 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
367 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
368 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
369 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
371 anEntryList.append( aMeshSO->GetID().c_str() );
379 // update Object browser
380 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
382 // browse to the published meshes
383 if( LightApp_Application* anApp =
384 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
385 anApp->browseObjects( anEntryList );
387 // show Error message box if there were errors
388 if ( errors.count() > 0 ) {
389 SUIT_MessageBox::critical( SMESHGUI::desktop(),
390 QObject::tr( "SMESH_ERROR" ),
391 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
394 // show warning message box, if some imported mesh is empty
396 SUIT_MessageBox::warning( SMESHGUI::desktop(),
397 QObject::tr( "SMESH_WRN_WARNING" ),
398 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
403 //================================================================================
405 * \brief Export selected meshes or groups into a file
407 //================================================================================
409 void ExportMeshToFile( int theCommandID )
411 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
412 SALOME_ListIO selected;
414 aSel->selectedObjects( selected );
416 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
417 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
418 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
419 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
420 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
421 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
422 const bool isGMF = ( theCommandID == 146 || theCommandID == 147 );
424 // actually, the following condition can't be met (added for insurance)
425 if( selected.Extent() == 0 ||
426 ( selected.Extent() > 1 && !isMED && !isSTL ))
429 // get mesh object from selection and check duplication of their names
430 bool hasDuplicatedMeshNames = false;
431 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
432 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
433 SALOME_ListIteratorOfListIO It( selected );
434 for( ; It.More(); It.Next() )
436 Handle(SALOME_InteractiveObject) anIObject = It.Value();
437 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
438 if ( aMeshItem->_is_nil() ) {
439 SUIT_MessageBox::warning( SMESHGUI::desktop(),
440 QObject::tr( "SMESH_WRN_WARNING" ),
441 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
445 QString aMeshName = anIObject->getName();
447 // check for name duplications
448 if ( !hasDuplicatedMeshNames )
449 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
450 if( aMeshName == (*aMeshIter).second ) {
451 hasDuplicatedMeshNames = true;
456 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
459 if( hasDuplicatedMeshNames && isMED ) {
460 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
461 QObject::tr("SMESH_WRN_WARNING"),
462 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
463 QObject::tr("SMESH_BUT_YES"),
464 QObject::tr("SMESH_BUT_NO"), 0, 1);
469 aMeshIter = aMeshList.begin();
470 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
471 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
472 QString aMeshName = (*aMeshIter).second;
474 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
476 // check for equal group names within each mesh
477 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
478 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
479 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
480 int aRet = SUIT_MessageBox::warning
481 (SMESHGUI::desktop(),
482 QObject::tr("SMESH_WRN_WARNING"),
483 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
484 QObject::tr("SMESH_BUT_YES"),
485 QObject::tr("SMESH_BUT_NO"), 0, 1);
492 // Warn the user about presence of not supported elements
494 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
498 notSupportedElemTypes.push_back( SMESH::Entity_0D );
499 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
504 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
505 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
506 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
507 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
508 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
509 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
510 notSupportedElemTypes.push_back( SMESH::Entity_0D );
511 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
516 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
517 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
518 notSupportedElemTypes.push_back( SMESH::Entity_0D );
519 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
524 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
525 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
530 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
531 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
532 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
533 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
534 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
535 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
536 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
541 notSupportedElemTypes.push_back( SMESH::Entity_0D );
542 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
543 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
544 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
545 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
546 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
547 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
548 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
549 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
551 if ( ! notSupportedElemTypes.empty() )
553 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
554 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
555 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
556 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
558 if ( !presentNotSupported.empty() )
561 const char* typeMsg[SMESH::Entity_Last] = {
562 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
563 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
564 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
565 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
566 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
567 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
568 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
569 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
571 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
572 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
573 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
574 if ( iType != presentNotSupported.size() - 1 )
575 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
577 int aRet = SUIT_MessageBox::warning
578 (SMESHGUI::desktop(),
579 QObject::tr("SMESH_WRN_WARNING"),
580 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
581 QObject::tr("SMESH_BUT_YES"),
582 QObject::tr("SMESH_BUT_NO"), 0, 1);
587 // Get parameters of export operation
590 SMESH::MED_VERSION aFormat;
591 // Init the parameters with the default values
592 bool aIsASCII_STL = true;
593 bool toCreateGroups = false;
594 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
596 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
597 bool toOverwrite = true;
598 bool toFindOutDim = true;
600 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
601 QString anInitialPath = "";
602 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
603 anInitialPath = QDir::currentPath();
605 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
607 // Get a file name to write in and additional otions
608 if ( isUNV || isDAT || isGMF ) // Export w/o options
611 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
613 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
615 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
616 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
617 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
618 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
619 anInitialPath + QString("/") + aMeshName,
620 aFilter, aTitle, false);
622 else if ( isCGNS )// Export to CGNS
624 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
625 fd->setWindowTitle( aTitle );
626 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
627 if ( !anInitialPath.isEmpty() )
628 fd->setDirectory( anInitialPath );
629 fd->selectFile(aMeshName);
630 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
631 fd->setValidator( fv );
634 aFilename = fd->selectedFile();
635 toOverwrite = fv->isOverwrite();
639 else if ( isSTL ) // Export to STL
641 QMap<QString, int> aFilterMap;
642 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
643 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
646 QMap<QString, int>::const_iterator it = aFilterMap.begin();
647 for ( ; it != aFilterMap.end(); ++it )
648 filters.push_back( it.key() );
650 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
651 fd->setWindowTitle( aTitle );
652 fd->setNameFilters( filters );
653 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
654 if ( !anInitialPath.isEmpty() )
655 fd->setDirectory( anInitialPath );
656 fd->selectFile(aMeshName);
660 aFilename = fd->selectedFile();
661 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
666 else if ( isMED || isSAUV ) // Export to MED or SAUV
668 QMap<QString, SMESH::MED_VERSION> aFilterMap;
669 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
671 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
672 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
673 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
676 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
677 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
678 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
682 QString aDefaultFilter;
683 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
684 for ( ; it != aFilterMap.end(); ++it ) {
685 filters.push_back( it.key() );
686 if (it.value() == SMESH::MED_V2_2)
687 aDefaultFilter = it.key();
689 QStringList checkBoxes;
690 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
692 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
693 QList< QWidget* > wdgList;
694 if ( fieldSelWdg->GetAllFeilds( aMeshList, aFieldList ))
695 wdgList.append( fieldSelWdg );
697 SalomeApp_CheckFileDlg* fd =
698 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
699 fd->setWindowTitle( aTitle );
700 fd->setNameFilters( filters );
701 fd->selectNameFilter( aDefaultFilter );
702 fd->SetChecked( toCreateGroups, 0 );
703 fd->SetChecked( toFindOutDim, 1 );
704 if ( !anInitialPath.isEmpty() )
705 fd->setDirectory( anInitialPath );
706 fd->selectFile(aMeshName);
708 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
709 fd->setValidator( fv );
714 aFilename = fd->selectedFile();
716 aFilename = QString::null;
719 aFormat = aFilterMap[fd->selectedNameFilter()];
720 toOverwrite = fv->isOverwrite();
722 if ( !aFilename.isEmpty() ) {
723 // med-2.1 does not support poly elements
724 if ( aFormat==SMESH::MED_V2_1 )
725 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
726 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
727 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
728 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
729 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
731 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
732 QObject::tr("SMESH_WRN_WARNING"),
733 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
734 QObject::tr("SMESH_BUT_YES"),
735 QObject::tr("SMESH_BUT_NO"), 0, 1);
743 // can't append to an existing using other format
744 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
745 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
746 if( !isVersionOk || aVersion != aFormat ) {
747 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
748 QObject::tr("SMESH_WRN_WARNING"),
749 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
750 QObject::tr("SMESH_BUT_YES"),
751 QObject::tr("SMESH_BUT_NO"), 0, 1);
758 QStringList aMeshNamesCollisionList;
759 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
760 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
761 QString anExistingMeshName( aMeshNames[ i ] );
762 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
763 QString anExportMeshName = (*aMeshIter).second;
764 if( anExportMeshName == anExistingMeshName ) {
765 aMeshNamesCollisionList.append( anExportMeshName );
770 if( !aMeshNamesCollisionList.isEmpty() ) {
771 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
772 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
773 QObject::tr("SMESH_WRN_WARNING"),
774 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
775 QObject::tr("SMESH_BUT_YES"),
776 QObject::tr("SMESH_BUT_NO"),
777 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
786 toCreateGroups = fd->IsChecked(0);
787 toFindOutDim = fd->IsChecked(1);
788 fieldSelWdg->GetSelectedFeilds();
789 if ( !fieldSelWdg->parent() )
800 if ( !aFilename.isEmpty() ) {
801 // Check whether the file already exists and delete it if yes
802 QFile aFile( aFilename );
803 if ( aFile.exists() && toOverwrite )
805 SUIT_OverrideCursor wc;
808 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
809 // bool Renumber = false;
810 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
812 // Renumber= resMgr->booleanValue("renumbering");
814 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
815 // aMeshEditor->RenumberNodes();
816 // aMeshEditor->RenumberElements();
817 // if ( SMESHGUI::automaticUpdate() )
818 // SMESH::UpdateView();
822 aMeshIter = aMeshList.begin();
823 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
825 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
826 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
827 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
828 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
829 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
830 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
831 aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
832 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
834 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
835 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim,
836 fields, geoAssFields.toLatin1().data() );
841 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
843 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
844 if( !aMeshItem->_is_nil() )
845 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
850 if ( aMeshOrGroup->_is_equivalent( aMesh ))
851 aMesh->ExportDAT( aFilename.toUtf8().data() );
853 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
857 if ( aMeshOrGroup->_is_equivalent( aMesh ))
858 aMesh->ExportUNV( aFilename.toUtf8().data() );
860 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
864 if ( aMeshOrGroup->_is_equivalent( aMesh ))
865 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
867 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
871 aMeshIter = aMeshList.begin();
872 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
874 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
875 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
876 aMeshItem->ExportCGNS( aMeshOrGroup,
877 aFilename.toUtf8().data(),
878 toOverwrite && aMeshIndex == 0 );
883 toCreateGroups = true;
884 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
887 catch (const SALOME::SALOME_Exception& S_ex){
889 SUIT_MessageBox::warning(SMESHGUI::desktop(),
890 QObject::tr("SMESH_WRN_WARNING"),
891 QObject::tr("SMESH_EXPORT_FAILED"));
897 inline void InverseEntityMode(unsigned int& theOutputMode,
898 unsigned int theMode)
900 bool anIsNotPresent = ~theOutputMode & theMode;
902 theOutputMode |= theMode;
904 theOutputMode &= ~theMode;
907 void SetDisplayEntity(int theCommandID){
908 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
909 SALOME_ListIO selected;
911 aSel->selectedObjects( selected );
913 if(selected.Extent() >= 1){
914 SALOME_ListIteratorOfListIO It( selected );
915 for( ; It.More(); It.Next()){
916 Handle(SALOME_InteractiveObject) IObject = It.Value();
917 if(IObject->hasEntry()){
918 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
919 unsigned int aMode = anActor->GetEntityMode();
920 switch(theCommandID){
922 InverseEntityMode(aMode,SMESH_Actor::eBallElem);
925 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
928 InverseEntityMode(aMode,SMESH_Actor::eEdges);
931 InverseEntityMode(aMode,SMESH_Actor::eFaces);
934 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
937 aMode = SMESH_Actor::eAllEntity;
941 anActor->SetEntityMode(aMode);
950 SALOME_ListIO selected;
951 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
955 LightApp_SelectionMgr* aSel = app->selectionMgr();
956 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
957 if( !aSel || !appStudy )
960 aSel->selectedObjects( selected );
961 if( selected.IsEmpty() )
964 Handle(SALOME_InteractiveObject) anIObject = selected.First();
966 _PTR(Study) aStudy = appStudy->studyDS();
967 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
968 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
969 if( aMainObject->_is_nil() )
972 SUIT_OverrideCursor wc;
974 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
976 QList<SALOMEDS::Color> aReservedColors;
978 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
979 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
981 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
982 //SALOMEDS::Color aColor = aGroupObject->GetColor();
984 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
985 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
986 #else // old algorithm for auto-colors
987 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
988 aReservedColors.append( aColor );
989 #endif // SIMPLE_AUTOCOLOR
990 aGroupObject->SetColor( aColor );
992 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
996 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
997 switch ( aGroupObject->GetType ()) {
999 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1001 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1003 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1005 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1007 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1008 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1011 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1012 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1018 SMESH::RepaintCurrentView();
1021 void OverallMeshQuality() {
1022 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1023 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1024 SALOME_ListIO selected;
1026 aSel->selectedObjects( selected );
1028 if ( selected.IsEmpty() ) return;
1029 SALOME_ListIteratorOfListIO It( selected );
1030 for ( ; It.More(); It.Next() ) {
1031 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1032 ctrlDlg->showInfo( It.Value() );
1037 QString functorToString( SMESH::Controls::FunctorPtr f )
1039 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1040 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1041 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1042 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1043 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1044 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1045 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1046 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1047 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1048 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1049 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1050 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1051 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1052 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1053 type = QObject::tr( "WARP_ELEMENTS" );
1054 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1055 type = QObject::tr( "TAPER_ELEMENTS" );
1056 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1057 type = QObject::tr( "SKEW_ELEMENTS" );
1058 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1059 type = QObject::tr( "AREA_ELEMENTS" );
1060 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1061 type = QObject::tr( "LENGTH_EDGES" );
1062 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1063 type = QObject::tr( "LENGTH2D_EDGES" );
1064 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1065 type = QObject::tr( "MULTI_BORDERS" );
1066 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1067 type = QObject::tr( "MULTI2D_BORDERS" );
1068 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1069 type = QObject::tr( "FREE_NODES" );
1070 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1071 type = QObject::tr( "FREE_EDGES" );
1072 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1073 type = QObject::tr( "FREE_BORDERS" );
1074 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1075 type = QObject::tr( "FREE_FACES" );
1076 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1077 type = QObject::tr( "BARE_BORDER_VOLUME" );
1078 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1079 type = QObject::tr( "BARE_BORDER_FACE" );
1080 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1081 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1082 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1083 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1084 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1085 type = QObject::tr( "EQUAL_NODE" );
1086 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1087 type = QObject::tr( "EQUAL_EDGE" );
1088 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1089 type = QObject::tr( "EQUAL_FACE" );
1090 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1091 type = QObject::tr( "EQUAL_VOLUME" );
1095 void SaveDistribution()
1097 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1098 SALOME_ListIO selected;
1100 aSel->selectedObjects( selected );
1102 if ( selected.Extent() == 1 ) {
1103 Handle(SALOME_InteractiveObject) anIO = selected.First();
1104 if ( anIO->hasEntry() ) {
1105 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1106 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1107 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1108 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1109 if ( aScalarBarActor && aFunctor ) {
1110 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1112 std::vector<int> elements;
1113 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1114 if ( mesh->_is_nil() ) {
1115 SMESH::SMESH_IDSource_var idSource =
1116 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1117 if ( !idSource->_is_nil() )
1119 SMESH::long_array_var ids = idSource->GetIDs();
1120 elements.resize( ids->length() );
1121 for ( unsigned i = 0; i < elements.size(); ++i )
1122 elements[i] = ids[i];
1125 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1126 vtkLookupTable* lookupTable =
1127 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1128 double * minmax = lookupTable->GetRange();
1129 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1130 std::vector<int> nbEvents;
1131 std::vector<double> funValues;
1132 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax, isLogarithmic );
1133 QString anInitialPath = "";
1134 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1135 anInitialPath = QDir::currentPath();
1136 QString aMeshName = anIO->getName();
1138 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1139 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1140 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1141 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1142 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1145 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1147 if ( !aFilename.isEmpty() ) {
1148 QFile f( aFilename );
1149 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1150 QTextStream out( &f );
1151 out << "# Mesh: " << aMeshName << endl;
1152 out << "# Control: " << functorToString( aFunctor ) << endl;
1154 out.setFieldWidth( 10 );
1155 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1156 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1167 void ShowDistribution() {
1168 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1169 SALOME_ListIO selected;
1171 aSel->selectedObjects( selected );
1173 if ( selected.Extent() == 1 ) {
1174 Handle(SALOME_InteractiveObject) anIO = selected.First();
1175 if ( anIO->hasEntry() ) {
1176 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1177 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1178 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1179 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1185 #ifndef DISABLE_PLOT2DVIEWER
1186 void PlotDistribution() {
1187 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1191 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1192 SALOME_ListIO selected;
1194 aSel->selectedObjects( selected );
1196 if ( selected.Extent() == 1 ) {
1197 Handle(SALOME_InteractiveObject) anIO = selected.First();
1198 if ( anIO->hasEntry() ) {
1199 //Find Actor by entry before getting Plot2d viewer,
1200 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1201 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1203 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1208 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1212 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1216 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1217 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1218 QString functorName = functorToString( anActor->GetFunctor());
1219 QString aHistogramName("%1 : %2");
1220 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1221 aHistogram->setName(aHistogramName);
1222 aHistogram->setHorTitle(functorName);
1223 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1224 aPlot->displayObject(aHistogram, true);
1229 #endif //DISABLE_PLOT2DVIEWER
1231 void DisableAutoColor(){
1232 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1233 SALOME_ListIO selected;
1235 aSel->selectedObjects( selected );
1237 if(selected.Extent()){
1238 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1239 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1240 if ( !aMesh->_is_nil() ) {
1241 aMesh->SetAutoColor( false );
1246 void sortChildren(){
1247 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1248 SALOME_ListIO selected;
1250 aSel->selectedObjects( selected );
1252 if(selected.Extent()){
1253 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1254 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1255 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1257 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1258 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1265 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1267 SALOME_ListIO selected;
1268 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1272 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1273 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1274 if( !aSel || !appStudy )
1277 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1278 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1279 aModule->EmitSignalDeactivateDialog();
1280 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1281 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1286 _PTR(Study) aStudy = appStudy->studyDS();
1288 aSel->selectedObjects( selected );
1290 if(selected.Extent() >= 1){
1291 switch(theCommandID){
1293 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1294 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1299 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1300 QColor orientationColor, outlineColor, volumeColor;
1301 int deltaF = 0, deltaV = 0;
1304 double ballScale = 1.0;
1306 int outlineWidth = 1;
1307 double shrinkCoef = 0.0;
1308 double orientationScale = 0.0;
1309 bool orientation3d = false;
1310 VTK::MarkerType markerType = VTK::MT_NONE;
1311 VTK::MarkerScale markerScale = VTK::MS_NONE;
1313 bool hasNodes = false;
1314 int presentEntities = 0;
1315 bool firstTime = true;
1317 SALOME_ListIteratorOfListIO It( selected );
1318 for ( ; It.More(); It.Next() ) {
1319 Handle(SALOME_InteractiveObject) IObject = It.Value();
1320 if ( !IObject->hasEntry() ) continue;
1321 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1322 if ( !anActor || !anActor->GetObject() ) continue;
1325 // nodes: color, marker
1326 anActor->GetNodeColor( color[0], color[1], color[2] );
1327 nodeColor.setRgbF( color[0], color[1], color[2] );
1328 markerType = anActor->GetMarkerType();
1329 markerScale = anActor->GetMarkerScale();
1330 markerId = anActor->GetMarkerTexture();
1331 // edges: color, width
1332 anActor->GetEdgeColor( color[0], color[1], color[2] );
1333 edgeColor.setRgbF( color[0], color[1], color[2] );
1334 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1335 // faces: front color, back color (delta)
1336 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1337 faceColor.setRgbF( color[0], color[1], color[2] );
1338 // faces: front color, back color (delta)
1339 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1340 volumeColor.setRgbF( color[0], color[1], color[2] );
1341 // 0d elements: color, size
1342 anActor->Get0DColor( color[0], color[1], color[2] );
1343 elem0dColor.setRgbF( color[0], color[1], color[2] );
1344 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1345 // balls: color, size
1346 anActor->GetBallColor( color[0], color[1], color[2] );
1347 ballColor.setRgbF( color[0], color[1], color[2] );
1348 ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1349 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1351 anActor->GetOutlineColor( color[0], color[1], color[2] );
1352 outlineColor.setRgbF( color[0], color[1], color[2] );
1353 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1354 // orientation vectors: color, scale, 3d flag
1355 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1356 orientationColor.setRgbF( color[0], color[1], color[2] );
1357 orientationScale = anActor->GetFacesOrientationScale();
1358 orientation3d = anActor->GetFacesOrientation3DVectors();
1360 shrinkCoef = anActor->GetShrinkFactor();
1363 firstTime = false; // we only take properties from first object (for performance reasons)
1366 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1367 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1368 presentEntities = presentEntities | SMESH_Actor::eEdges;
1369 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1370 presentEntities = presentEntities | SMESH_Actor::eFaces;
1371 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1372 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1373 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1374 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1375 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1376 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1378 // as we know that all types of elements are present, we can exit the loop
1379 if ( presentEntities == SMESH_Actor::eAllEntity )
1383 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1384 // nodes: color, marker
1385 dlg.setNodeColor( nodeColor );
1386 if( markerType != VTK::MT_USER )
1387 dlg.setNodeMarker( markerType, markerScale );
1389 dlg.setNodeCustomMarker( markerId );
1390 // edges: color, line width
1391 dlg.setEdgeColor( edgeColor );
1392 dlg.setEdgeWidth( edgeWidth );
1393 // faces: front color, back color
1394 dlg.setFaceColor( faceColor, deltaF );
1395 // volumes: normal color, reversed color
1396 dlg.setVolumeColor( volumeColor, deltaV );
1397 // outlines: color, line width
1398 dlg.setOutlineColor( outlineColor );
1399 dlg.setOutlineWidth( outlineWidth );
1400 // 0d elements: color, size
1401 dlg.setElem0dColor( elem0dColor );
1402 dlg.setElem0dSize( elem0dSize );
1403 // balls: color, size
1404 dlg.setBallColor( ballColor );
1405 dlg.setBallSize( ballSize );
1406 dlg.setBallScale( ballScale );
1407 // orientation: color, scale, 3d flag
1408 dlg.setOrientationColor( orientationColor );
1409 dlg.setOrientationSize( int( orientationScale * 100. ) );
1410 dlg.setOrientation3d( orientation3d );
1411 // shrink: scale factor
1412 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1413 // hide unused controls
1414 dlg.showControls( presentEntities, hasNodes );
1417 nodeColor = dlg.nodeColor();
1418 markerType = dlg.nodeMarkerType();
1419 markerScale = dlg.nodeMarkerScale();
1420 markerId = dlg.nodeMarkerId();
1421 edgeColor = dlg.edgeColor();
1422 edgeWidth = dlg.edgeWidth();
1423 faceColor = dlg.faceColor();
1424 deltaF = dlg.faceColorDelta();
1425 volumeColor = dlg.volumeColor();
1426 deltaV = dlg.volumeColorDelta();
1427 outlineColor = dlg.outlineColor();
1428 outlineWidth = dlg.outlineWidth();
1429 elem0dColor = dlg.elem0dColor();
1430 elem0dSize = dlg.elem0dSize();
1431 ballColor = dlg.ballColor();
1432 ballSize = dlg.ballSize();
1433 ballScale = dlg.ballScale();
1434 orientationColor = dlg.orientationColor();
1435 orientationScale = dlg.orientationSize() / 100.;
1436 orientation3d = dlg.orientation3d();
1437 shrinkCoef = dlg.shrinkCoef() / 100.;
1439 // store point markers map that might be changed by the user
1440 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1442 // set properties from dialog box to the presentations
1443 SALOME_ListIteratorOfListIO It( selected );
1444 for ( ; It.More(); It.Next() ) {
1445 Handle(SALOME_InteractiveObject) IObject = It.Value();
1446 if ( !IObject->hasEntry() ) continue;
1447 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1448 if ( !anActor ) continue;
1450 // nodes: color, marker
1451 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1452 if ( markerType != VTK::MT_USER ) {
1453 anActor->SetMarkerStd( markerType, markerScale );
1456 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1457 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1458 if ( iter != markerMap.end() )
1459 anActor->SetMarkerTexture( markerId, iter->second.second );
1461 // volumes: normal color, reversed color (delta)
1462 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1463 // faces: front color, back color (delta)
1464 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1465 // edges: color, width
1466 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1467 anActor->SetLineWidth( edgeWidth );
1469 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1470 anActor->SetOutlineWidth( outlineWidth );
1471 // 0D elements: color, size
1472 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1473 anActor->Set0DSize( elem0dSize );
1474 // balls: color, size
1475 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1476 anActor->SetBallSize( ballSize );
1477 anActor->SetBallScale( ballScale );
1478 // orientation: color, scale, 3d flag
1479 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1480 anActor->SetFacesOrientationScale( orientationScale );
1481 anActor->SetFacesOrientation3DVectors( orientation3d );
1483 anActor->SetShrinkFactor( shrinkCoef );
1485 // for groups, set also proper color
1486 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1487 if ( !aGroupObject->_is_nil() ) {
1488 SMESH::ElementType anElementType = aGroupObject->GetType();
1490 switch( anElementType ) {
1492 aColor = nodeColor; break;
1494 aColor = edgeColor; break;
1496 aColor = faceColor; break;
1498 aColor = volumeColor; break;
1500 aColor = elem0dColor; break;
1502 aColor = ballColor; break;
1506 if ( aColor.isValid() ) {
1507 SALOMEDS::Color aGroupColor;
1508 aGroupColor.R = aColor.redF();
1509 aGroupColor.G = aColor.greenF();
1510 aGroupColor.B = aColor.blueF();
1511 aGroupObject->SetColor( aGroupColor );
1513 } // if ( !aGroupObject->_is_nil() )
1514 } // for ( ; It.More(); It.Next() )
1515 SMESH::RepaintCurrentView();
1516 } // if ( dlg.exec() )
1519 } // switch(theCommandID)
1520 SALOME_ListIteratorOfListIO It( selected );
1521 for( ; It.More(); It.Next()){
1522 Handle(SALOME_InteractiveObject) IObject = It.Value();
1523 if(IObject->hasEntry()){
1524 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1525 switch(theCommandID){
1527 anActor->SetRepresentation(SMESH_Actor::eEdge);
1530 anActor->SetRepresentation(SMESH_Actor::eSurface);
1533 if(anActor->IsShrunk())
1534 anActor->UnShrink();
1536 anActor->SetShrink();
1539 anActor->SetRepresentation(SMESH_Actor::ePoint);
1542 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1543 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1546 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1547 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1553 SMESH::RepaintCurrentView();
1557 void Control( int theCommandID )
1559 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1560 SALOME_ListIO selected;
1562 aSel->selectedObjects( selected );
1564 if( !selected.IsEmpty() ){
1565 Handle(SALOME_InteractiveObject) anIO = selected.First();
1567 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1568 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1569 switch ( theCommandID ){
1571 aControl = SMESH_Actor::eLength;
1574 aControl = SMESH_Actor::eLength2D;
1577 aControl = SMESH_Actor::eFreeEdges;
1580 aControl = SMESH_Actor::eFreeBorders;
1583 aControl = SMESH_Actor::eMultiConnection;
1586 aControl = SMESH_Actor::eFreeNodes;
1589 aControl = SMESH_Actor::eMultiConnection2D;
1592 aControl = SMESH_Actor::eArea;
1595 aControl = SMESH_Actor::eTaper;
1598 aControl = SMESH_Actor::eAspectRatio;
1601 aControl = SMESH_Actor::eAspectRatio3D;
1604 aControl = SMESH_Actor::eMinimumAngle;
1607 aControl = SMESH_Actor::eWarping;
1610 aControl = SMESH_Actor::eSkew;
1613 aControl = SMESH_Actor::eVolume3D;
1616 aControl = SMESH_Actor::eFreeFaces;
1619 aControl = SMESH_Actor::eMaxElementLength2D;
1622 aControl = SMESH_Actor::eMaxElementLength3D;
1625 aControl = SMESH_Actor::eBareBorderVolume;
1628 aControl = SMESH_Actor::eBareBorderFace;
1631 aControl = SMESH_Actor::eOverConstrainedVolume;
1634 aControl = SMESH_Actor::eOverConstrainedFace;
1637 aControl = SMESH_Actor::eCoincidentNodes;
1640 aControl = SMESH_Actor::eCoincidentElems1D;
1643 aControl = SMESH_Actor:: eCoincidentElems2D;
1646 aControl = SMESH_Actor::eCoincidentElems3D;
1650 anActor->SetControlMode(aControl);
1651 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1652 SMESH::RepaintCurrentView();
1653 #ifndef DISABLE_PLOT2DVIEWER
1654 if(anActor->GetPlot2Histogram()) {
1655 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1656 QString functorName = functorToString( anActor->GetFunctor());
1657 QString aHistogramName("%1 : %2");
1658 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1659 aHistogram->setName(aHistogramName);
1660 aHistogram->setHorTitle(functorName);
1661 SMESH::ProcessIn2DViewers(anActor);
1670 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1671 SMESH::MeshObjectType theType,
1672 const QString theInTypeName,
1673 QString & theOutTypeName)
1675 SMESH_TypeFilter aTypeFilter( theType );
1677 if( !theIO.IsNull() )
1679 entry = theIO->getEntry();
1680 LightApp_DataOwner owner( entry );
1681 if ( aTypeFilter.isOk( &owner )) {
1682 theOutTypeName = theInTypeName;
1690 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1692 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1693 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1695 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1696 CORBA::String_var anID = aSComp->GetID().c_str();
1697 if (!strcmp(anID.in(),theIO->getEntry()))
1703 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1704 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1705 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1706 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1707 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1715 QString CheckHomogeneousSelection()
1717 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1718 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1719 SALOME_ListIO selected;
1721 aSel->selectedObjects( selected );
1723 QString RefType = CheckTypeObject(selected.First());
1724 SALOME_ListIteratorOfListIO It(selected);
1725 for ( ; It.More(); It.Next())
1727 Handle(SALOME_InteractiveObject) IObject = It.Value();
1728 QString Type = CheckTypeObject(IObject);
1729 if (Type.compare(RefType) != 0)
1730 return "Heterogeneous Selection";
1738 void SMESHGUI::OnEditDelete()
1740 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1741 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1742 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1744 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1745 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1746 _PTR(GenericAttribute) anAttr;
1747 _PTR(AttributeIOR) anIOR;
1749 int objectCount = 0;
1751 QString aParentComponent = QString::null;
1752 Handle(SALOME_InteractiveObject) anIO;
1753 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1755 anIO = anIt.Value();
1756 QString cur = anIO->getComponentDataType();
1757 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1759 // check if object is reference
1760 _PTR(SObject) aRefSObj;
1761 aNameList.append("\n - ");
1762 if ( aSO->ReferencedObject( aRefSObj ) ) {
1763 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1764 aNameList.append( aRefName );
1765 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1768 aNameList.append(anIO->getName());
1772 if( aParentComponent.isNull() )
1773 aParentComponent = cur;
1774 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1775 aParentComponent = "";
1778 if ( objectCount == 0 )
1779 return; // No Valid Objects Selected
1781 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1782 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1783 QObject::tr("ERR_ERROR"),
1784 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1787 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1788 if (SUIT_MessageBox::warning
1789 (SMESHGUI::desktop(),
1790 QObject::tr("SMESH_WRN_WARNING"),
1791 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1792 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1793 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1796 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1798 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1799 // then treat them all starting from the deepest objects (at list back)
1800 std::list< _PTR(SObject) > listSO;
1801 SALOME_ListIteratorOfListIO It(selected);
1802 for( ; It.More(); It.Next()) // loop on selected IO's
1804 Handle(SALOME_InteractiveObject) IObject = It.Value();
1805 if(IObject->hasEntry()) {
1806 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1808 // disable removal of "SMESH" component object
1809 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1811 if ( engineIOR() == anIOR->Value().c_str() )
1814 //Check the referenced object
1815 _PTR(SObject) aRefSObject;
1816 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1817 aSO = aRefSObject; // Delete main Object instead of reference
1819 listSO.push_back( aSO );
1820 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1821 for ( ; itSO != listSO.end(); ++itSO ) {
1822 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1823 for (it->InitEx(false); it->More(); it->Next())
1824 listSO.push_back( it->Value() );
1828 // Check if none of objects to delete is referred from outside
1829 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1830 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1832 _PTR(SObject) SO = *ritSO;
1833 if ( !SO ) continue;
1834 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1835 for (size_t i = 0; i < aReferences.size(); i++) {
1836 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1837 std::string type = aComponent->ComponentDataType();
1838 if ( type != "SMESH" )
1840 SUIT_MessageBox::warning( anApp->desktop(),
1841 QObject::tr("WRN_WARNING"),
1842 QObject::tr("DEP_OBJECT") );
1843 return; // outside SMESH, there is an object depending on a SMESH object
1848 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1849 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1851 Handle(SALOME_InteractiveObject) IObject = It.Value();
1852 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1853 if ( !mesh->_is_nil() )
1857 // Treat SO's in the list starting from the back
1858 aStudyBuilder->NewCommand(); // There is a transaction
1859 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1861 _PTR(SObject) SO = *ritSO;
1862 if ( !SO ) continue;
1863 std::string anEntry = SO->GetID();
1865 /** Erase graphical object and remove all its data **/
1866 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1867 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1869 /** Remove an object from data structures **/
1870 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1871 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1872 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1873 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1874 aMesh->RemoveGroup( aGroup );
1876 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1877 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1878 aMesh->RemoveSubMesh( aSubMesh );
1880 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1882 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1885 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1886 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1887 QString objType = CheckTypeObject(IObject);
1888 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1889 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1890 aStudyBuilder->RemoveObjectWithChildren( SO );
1892 else {// default action: remove SObject from the study
1893 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1894 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1896 aStudyBuilder->RemoveObjectWithChildren( SO );
1900 } /* listSO back loop */
1902 aStudyBuilder->CommitCommand();
1904 /* Clear any previous selection */
1906 aSel->setSelectedObjects( l1 );
1908 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1912 SMESHGUI_EXPORT CAM_Module* createModule()
1914 return new SMESHGUI();
1917 SMESHGUI_EXPORT char* getModuleVersion() {
1918 return (char*)SMESH_VERSION_STR;
1922 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1924 //=============================================================================
1928 //=============================================================================
1929 SMESHGUI::SMESHGUI() :
1930 SalomeApp_Module( "SMESH" )
1932 if ( CORBA::is_nil( myComponentSMESH ) )
1934 CORBA::Boolean anIsEmbeddedMode;
1935 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1936 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1938 // 0019923: EDF 765 SMESH : default values of hypothesis
1939 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1940 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1941 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1942 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1943 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1945 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1946 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1947 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1949 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1950 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1954 myActiveDialogBox = 0;
1955 myFilterLibraryDlg = 0;
1959 myEventCallbackCommand = vtkCallbackCommand::New();
1960 myEventCallbackCommand->Delete();
1961 myEventCallbackCommand->SetClientData( this );
1962 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1965 /* load resources for all available meshers */
1966 SMESH::InitAvailableHypotheses();
1969 //=============================================================================
1973 //=============================================================================
1974 SMESHGUI::~SMESHGUI()
1978 //=============================================================================
1982 //=============================================================================
1983 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1985 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1987 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1992 //=============================================================================
1996 //=============================================================================
1997 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1999 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2003 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2004 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2005 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2006 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2007 return autoUpdate && !exceeded;
2010 //=============================================================================
2014 //=============================================================================
2015 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2016 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2018 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2022 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2023 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2024 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2026 SMESH::long_array_var info = theMesh->GetMeshInfo();
2027 long nbOdElems = info[SMDSEntity_0D];
2028 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2029 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2030 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2031 info[SMDSEntity_Polygon];
2032 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2033 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2034 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2035 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] +
2036 info[SMDSEntity_Polyhedra] +
2037 info[SMDSEntity_Hexagonal_Prism];
2038 long nbBalls = info[SMDSEntity_Ball];
2040 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2041 *nbElements = requestedSize;
2043 *entities = SMESH_Actor::eAllEntity;
2046 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2048 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2050 if ( incrementalLimit ) {
2053 if ( nbOdElems > 0 ) {
2054 if ( total + nbOdElems > updateLimit ) {
2055 *entities = *entities & ~SMESH_Actor::e0DElements;
2056 *hidden = *hidden | SMESH_Actor::e0DElements;
2063 if ( nbEdges > 0 ) {
2064 if ( total + nbEdges > updateLimit ) {
2065 *entities = *entities & ~SMESH_Actor::eEdges;
2066 *hidden = *hidden | SMESH_Actor::eEdges;
2073 if ( nbFaces > 0 ) {
2074 if ( total + nbFaces > updateLimit ) {
2075 *entities = *entities & ~SMESH_Actor::eFaces;
2076 *hidden = *hidden | SMESH_Actor::eFaces;
2083 if ( nbVolumes > 0 ) {
2084 if ( total + nbVolumes > updateLimit ) {
2085 *entities = *entities & ~SMESH_Actor::eVolumes;
2086 *hidden = *hidden | SMESH_Actor::eVolumes;
2093 if ( nbBalls > 0 ) {
2094 if ( total + nbBalls > updateLimit ) {
2095 *entities = *entities & ~SMESH_Actor::eBallElem;
2096 *hidden = *hidden | SMESH_Actor::eBallElem;
2104 return autoUpdate && !exceeded;
2107 //=============================================================================
2111 //=============================================================================
2112 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2114 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2117 //=============================================================================
2121 //=============================================================================
2122 SMESHGUI* SMESHGUI::GetSMESHGUI()
2124 SMESHGUI* smeshMod = 0;
2125 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2128 CAM_Module* module = app->module( "Mesh" );
2129 smeshMod = dynamic_cast<SMESHGUI*>( module );
2132 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2134 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2137 _PTR(Study) aStudy = study->studyDS();
2139 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2148 Standard_EXPORT SMESHGUI* GetComponentGUI()
2150 return SMESHGUI::GetSMESHGUI();
2154 //=============================================================================
2158 //=============================================================================
2159 void SMESHGUI::SetState(int aState)
2164 //=============================================================================
2168 //=============================================================================
2169 void SMESHGUI::ResetState()
2174 //=============================================================================
2178 //=============================================================================
2179 void SMESHGUI::EmitSignalDeactivateDialog()
2181 emit SignalDeactivateActiveDialog();
2184 //=============================================================================
2188 //=============================================================================
2189 void SMESHGUI::EmitSignalStudyFrameChanged()
2191 emit SignalStudyFrameChanged();
2194 //=============================================================================
2198 //=============================================================================
2199 void SMESHGUI::EmitSignalCloseAllDialogs()
2201 emit SignalCloseAllDialogs();
2204 //=============================================================================
2208 //=============================================================================
2209 void SMESHGUI::EmitSignalVisibilityChanged()
2211 emit SignalVisibilityChanged();
2214 //=============================================================================
2218 //=============================================================================
2219 QDialog *SMESHGUI::GetActiveDialogBox()
2221 return myActiveDialogBox;
2224 //=============================================================================
2228 //=============================================================================
2229 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2231 myActiveDialogBox = (QDialog *) aDlg;
2235 //=============================================================================
2239 //=============================================================================
2240 SUIT_Desktop* SMESHGUI::desktop()
2242 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2244 return app->desktop();
2249 //=============================================================================
2253 //=============================================================================
2254 SalomeApp_Study* SMESHGUI::activeStudy()
2256 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2258 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2263 //=============================================================================
2267 //=============================================================================
2268 void SMESHGUI::Modified( bool theIsUpdateActions )
2270 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2271 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2272 appStudy->Modified();
2273 if( theIsUpdateActions )
2274 app->updateActions();
2279 //=============================================================================
2283 //=============================================================================
2284 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2286 /* Here the position is on the bottom right corner - 10 */
2287 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2289 SUIT_Desktop *PP = desktop();
2290 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2291 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2295 //=============================================================================
2299 //=============================================================================
2300 static int isStudyLocked(_PTR(Study) theStudy){
2301 return theStudy->GetProperties()->IsLocked();
2304 static bool checkLock(_PTR(Study) theStudy) {
2305 if (isStudyLocked(theStudy)) {
2306 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2307 QObject::tr("WRN_WARNING"),
2308 QObject::tr("WRN_STUDY_LOCKED") );
2314 //=======================================================================
2315 //function : CheckActiveStudyLocked
2317 //=======================================================================
2319 bool SMESHGUI::isActiveStudyLocked()
2321 _PTR(Study) aStudy = activeStudy()->studyDS();
2322 return checkLock( aStudy );
2325 //=============================================================================
2329 //=============================================================================
2330 bool SMESHGUI::OnGUIEvent( int theCommandID )
2332 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2336 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2337 SUIT_ResourceMgr* mgr = resourceMgr();
2341 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2342 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2345 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2346 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2348 //QAction* act = action( theCommandID );
2350 switch (theCommandID) {
2352 if(checkLock(aStudy)) break;
2364 if(checkLock(aStudy)) break;
2365 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2369 case 150: //MED FILE INFORMATION
2371 SALOME_ListIO selected;
2372 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2374 aSel->selectedObjects( selected );
2375 if( selected.Extent() )
2377 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2378 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2379 if ( !aMesh->_is_nil() )
2381 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2388 case 122: // EXPORT MED
2403 ::ExportMeshToFile(theCommandID);
2407 case 200: // SCALAR BAR
2409 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2410 SALOME_ListIO selected;
2412 aSel->selectedObjects( selected );
2414 if( selected.Extent() ) {
2415 Handle(SALOME_InteractiveObject) anIO = selected.First();
2416 if( anIO->hasEntry() ) {
2417 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2418 anActor->SetControlMode( SMESH_Actor::eNone );
2419 #ifndef DISABLE_PLOT2DVIEWER
2420 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2429 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2434 // dump control distribution data to the text file
2435 ::SaveDistribution();
2441 // show/ distribution
2442 ::ShowDistribution();
2446 #ifndef DISABLE_PLOT2DVIEWER
2449 // plot distribution
2450 ::PlotDistribution();
2461 ::DisableAutoColor();
2464 case 1134: // Clipping
2465 case 1133: // Tranparency
2466 case 1132: // Display preferences (colors, shrink size, line width, ...)
2473 ::SetDisplayMode(theCommandID, myMarkerMap);
2476 //2D quadratic representation
2479 ::SetDisplayMode(theCommandID, myMarkerMap);
2483 case 216: // 0D elements
2486 case 219: // Volumes
2487 case 220: // All Entity
2489 ::SetDisplayEntity(theCommandID);
2492 case 221: // Orientation of faces
2494 LightApp_SelectionMgr* mgr = selectionMgr();
2495 SALOME_ListIO selected; mgr->selectedObjects( selected );
2497 SALOME_ListIteratorOfListIO it(selected);
2498 for( ; it.More(); it.Next()) {
2499 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2500 if(anIObject->hasEntry()) {
2501 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2502 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2511 if(checkLock(aStudy)) break;
2512 SUIT_OverrideCursor wc;
2514 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2517 SMESH::UpdateView();
2519 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2520 SMESH::OnVisuException();
2522 catch (...) { // PAL16774 (Crash after display of many groups)
2523 SMESH::OnVisuException();
2527 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2528 aSel->selectedObjects( l );
2529 aSel->setSelectedObjects( l );
2534 case 301: // DISPLAY
2535 case 302: // DISPLAY ONLY
2537 SMESH::EDisplaing anAction;
2538 switch (theCommandID) {
2539 case 300: anAction = SMESH::eErase; break;
2540 case 301: anAction = SMESH::eDisplay; break;
2541 case 302: anAction = SMESH::eDisplayOnly; break;
2544 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2545 SALOME_ListIO sel_objects, to_process;
2547 aSel->selectedObjects( sel_objects );
2549 if( theCommandID==302 )
2551 MESSAGE("anAction = SMESH::eDisplayOnly");
2552 startOperation( myEraseAll );
2555 extractContainers( sel_objects, to_process );
2558 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2562 SALOME_ListIteratorOfListIO It( to_process );
2563 for ( ; It.More(); It.Next()) {
2565 Handle(SALOME_InteractiveObject) IOS = It.Value();
2566 if (IOS->hasEntry()) {
2568 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2569 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2570 break; // PAL16774 (Crash after display of many groups)
2572 if (anAction == SMESH::eDisplayOnly)
2574 MESSAGE("anAction = SMESH::eDisplayOnly");
2575 anAction = SMESH::eDisplay;
2581 // PAL13338 + PAL15161 -->
2582 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2583 MESSAGE("anAction = SMESH::eDisplayOnly");
2584 SMESH::UpdateView();
2585 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2587 // PAL13338 + PAL15161 <--
2589 catch (...) { // PAL16774 (Crash after display of many groups)
2590 SMESH::OnVisuException();
2593 if (anAction == SMESH::eErase) {
2594 MESSAGE("anAction == SMESH::eErase");
2596 aSel->setSelectedObjects( l1 );
2599 aSel->setSelectedObjects( to_process );
2606 if(checkLock(aStudy)) break;
2609 EmitSignalDeactivateDialog();
2611 ( new SMESHGUI_NodesDlg( this ) )->show();
2614 SUIT_MessageBox::warning(desktop(),
2615 tr("SMESH_WRN_WARNING"),
2616 tr("SMESH_WRN_VIEWER_VTK"));
2621 case 2151: // FILTER
2625 EmitSignalDeactivateDialog();
2626 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2631 case 701: // COMPUTE MESH
2632 case 711: // PRECOMPUTE MESH
2633 case 712: // EVALUATE MESH
2634 case 713: // MESH ORDER
2635 case 702: // Create mesh
2636 case 703: // Create sub-mesh
2637 case 704: // Edit mesh/sub-mesh
2638 startOperation( theCommandID );
2640 case 705: // copy mesh
2642 if (checkLock(aStudy)) break;
2643 EmitSignalDeactivateDialog();
2644 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2647 case 710: // Build compound mesh
2649 if (checkLock(aStudy)) break;
2650 EmitSignalDeactivateDialog();
2651 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2655 case 407: // DIAGONAL INVERSION
2656 case 408: // Delete diagonal
2660 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2661 tr( "NOT_A_VTK_VIEWER" ) );
2665 if ( checkLock( aStudy ) )
2668 /*Standard_Boolean aRes;
2669 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2670 if ( aMesh->_is_nil() )
2672 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2673 tr( "SMESH_BAD_SELECTION" ) );
2677 EmitSignalDeactivateDialog();
2678 if ( theCommandID == 407 )
2679 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2681 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2684 case 409: // Change orientation
2685 case 410: // Union of triangles
2686 case 411: // Cutting of quadrangles
2687 case 419: // Splitting volumes into tetrahedra
2691 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2692 tr( "NOT_A_VTK_VIEWER" ) );
2696 if ( checkLock( aStudy ) )
2699 EmitSignalDeactivateDialog();
2700 SMESHGUI_MultiEditDlg* aDlg = NULL;
2701 if ( theCommandID == 409 )
2702 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2703 else if ( theCommandID == 410 )
2704 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2705 else if ( theCommandID == 419 )
2706 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2708 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2713 case 412: // Smoothing
2715 if(checkLock(aStudy)) break;
2717 EmitSignalDeactivateDialog();
2718 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2721 SUIT_MessageBox::warning(desktop(),
2722 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2726 case 413: // Extrusion
2728 if (checkLock(aStudy)) break;
2730 EmitSignalDeactivateDialog();
2731 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2733 SUIT_MessageBox::warning(desktop(),
2734 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2738 case 414: // Revolution
2740 if(checkLock(aStudy)) break;
2742 EmitSignalDeactivateDialog();
2743 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2746 SUIT_MessageBox::warning(desktop(),
2747 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2751 case 415: // Pattern mapping
2753 if ( checkLock( aStudy ) )
2757 EmitSignalDeactivateDialog();
2758 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2761 SUIT_MessageBox::warning(desktop(),
2762 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2766 case 416: // Extrusion along a path
2768 if (checkLock(aStudy)) break;
2770 EmitSignalDeactivateDialog();
2771 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2773 SUIT_MessageBox::warning(desktop(),
2774 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2778 case 417: // Convert mesh to quadratic
2779 case 418: // create 2D mesh from 3D
2780 case 420: // Reorient faces
2781 case 806: // CREATE GEO GROUP
2783 startOperation( theCommandID );
2786 case 801: // CREATE GROUP
2790 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2791 tr( "NOT_A_VTK_VIEWER" ) );
2795 if(checkLock(aStudy)) break;
2796 EmitSignalDeactivateDialog();
2797 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2799 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2800 SALOME_ListIO selected;
2802 aSel->selectedObjects( selected );
2804 int nbSel = selected.Extent();
2806 // check if mesh is selected
2807 aMesh = SMESH::GetMeshByIO( selected.First() );
2809 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2814 case 802: // CONSTRUCT GROUP
2818 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2819 tr( "NOT_A_VTK_VIEWER" ) );
2823 if(checkLock(aStudy)) break;
2824 EmitSignalDeactivateDialog();
2826 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2827 SALOME_ListIO selected;
2829 aSel->selectedObjects( selected );
2831 int nbSel = selected.Extent();
2833 // check if submesh is selected
2834 Handle(SALOME_InteractiveObject) IObject = selected.First();
2835 if (IObject->hasEntry()) {
2836 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2838 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2839 if (!aSubMesh->_is_nil()) {
2841 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2842 // get submesh elements list by types
2843 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2844 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2845 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2846 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2847 // create group for each type o elements
2848 QString aName = IObject->getName();
2849 QStringList anEntryList;
2850 if (aNodes->length() > 0) {
2851 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2852 aGroup->Add(aNodes.inout());
2853 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2854 anEntryList.append( aSObject->GetID().c_str() );
2856 if (aEdges->length() > 0) {
2857 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2858 aGroup->Add(aEdges.inout());
2859 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2860 anEntryList.append( aSObject->GetID().c_str() );
2862 if (aFaces->length() > 0) {
2863 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2864 aGroup->Add(aFaces.inout());
2865 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2866 anEntryList.append( aSObject->GetID().c_str() );
2868 if (aVolumes->length() > 0) {
2869 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2870 aGroup->Add(aVolumes.inout());
2871 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2872 anEntryList.append( aSObject->GetID().c_str() );
2875 anApp->browseObjects( anEntryList );
2877 catch(const SALOME::SALOME_Exception & S_ex){
2878 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2885 SUIT_MessageBox::warning(desktop(),
2886 tr("SMESH_WRN_WARNING"),
2887 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2892 case 803: // EDIT GROUP
2896 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2897 tr( "NOT_A_VTK_VIEWER" ) );
2901 if(checkLock(aStudy)) break;
2902 EmitSignalDeactivateDialog();
2904 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2905 SALOME_ListIO selected;
2907 aSel->selectedObjects( selected );
2909 SALOME_ListIteratorOfListIO It (selected);
2910 int nbSelectedGroups = 0;
2911 for ( ; It.More(); It.Next() )
2913 SMESH::SMESH_GroupBase_var aGroup =
2914 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2915 if (!aGroup->_is_nil()) {
2917 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2921 if (nbSelectedGroups == 0)
2923 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2929 case 804: // Add elements to group
2931 if(checkLock(aStudy)) break;
2932 if (myState == 800) {
2933 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2934 if (aDlg) aDlg->onAdd();
2939 case 805: // Remove elements from group
2941 if(checkLock(aStudy)) break;
2942 if (myState == 800) {
2943 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2944 if (aDlg) aDlg->onRemove();
2949 case 815: // Edit GEOM GROUP as standalone
2953 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2954 tr( "NOT_A_VTK_VIEWER" ) );
2958 if(checkLock(aStudy)) break;
2959 EmitSignalDeactivateDialog();
2961 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2962 SALOME_ListIO selected;
2964 aSel->selectedObjects( selected );
2966 SALOME_ListIteratorOfListIO It (selected);
2967 for ( ; It.More(); It.Next() )
2969 SMESH::SMESH_GroupOnGeom_var aGroup =
2970 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2971 if (!aGroup->_is_nil()) {
2972 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2977 SMESH::SMESH_GroupOnFilter_var aGroup =
2978 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2979 if (!aGroup->_is_nil()) {
2980 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2988 case 810: // Union Groups
2989 case 811: // Intersect groups
2990 case 812: // Cut groups
2994 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2995 tr( "NOT_A_VTK_VIEWER" ) );
2999 if ( checkLock( aStudy ) )
3002 EmitSignalDeactivateDialog();
3004 SMESHGUI_GroupOpDlg* aDlg = 0;
3005 if ( theCommandID == 810 )
3006 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3007 else if ( theCommandID == 811 )
3008 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3010 aDlg = new SMESHGUI_CutGroupsDlg( this );
3017 case 814: // Create groups of entities from existing groups of superior dimensions
3019 if ( checkLock( aStudy ) )
3022 EmitSignalDeactivateDialog();
3023 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3029 case 813: // Delete groups with their contents
3033 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3034 tr( "NOT_A_VTK_VIEWER" ) );
3038 if ( checkLock( aStudy ) )
3041 EmitSignalDeactivateDialog();
3043 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3047 case 900: // MESH INFOS
3048 case 903: // WHAT IS
3050 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3051 EmitSignalDeactivateDialog();
3052 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3053 SALOME_ListIO selected;
3055 aSel->selectedObjects( selected );
3057 if ( selected.Extent() > 1 ) { // a dlg for each IO
3058 SALOME_ListIteratorOfListIO It( selected );
3059 for ( ; It.More(); It.Next() ) {
3060 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3061 dlg->showInfo( It.Value() );