1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
33 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
34 #include "SMESHGUI_AddMeshElementDlg.h"
35 #include "SMESHGUI_AddQuadraticElementDlg.h"
36 #include "SMESHGUI_BuildCompoundDlg.h"
37 #include "SMESHGUI_ClippingDlg.h"
38 #include "SMESHGUI_ComputeDlg.h"
39 #include "SMESHGUI_ConvToQuadOp.h"
40 #include "SMESHGUI_CopyMeshDlg.h"
41 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
42 #include "SMESHGUI_DeleteGroupDlg.h"
43 #include "SMESHGUI_Displayer.h"
44 #include "SMESHGUI_DuplicateNodesDlg.h"
45 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
46 #include "SMESHGUI_ExtrusionDlg.h"
47 #include "SMESHGUI_FieldSelectorWdg.h"
48 #include "SMESHGUI_FileInfoDlg.h"
49 #include "SMESHGUI_FileValidator.h"
50 #include "SMESHGUI_FilterDlg.h"
51 #include "SMESHGUI_FilterLibraryDlg.h"
52 #include "SMESHGUI_FindElemByPointDlg.h"
53 #include "SMESHGUI_GroupDlg.h"
54 #include "SMESHGUI_GroupOnShapeDlg.h"
55 #include "SMESHGUI_GroupOpDlg.h"
56 #include "SMESHGUI_Hypotheses.h"
57 #include "SMESHGUI_Make2DFrom3DOp.h"
58 #include "SMESHGUI_MakeNodeAtPointDlg.h"
59 #include "SMESHGUI_Measurements.h"
60 #include "SMESHGUI_MergeDlg.h"
61 #include "SMESHGUI_MeshInfo.h"
62 #include "SMESHGUI_MeshOp.h"
63 #include "SMESHGUI_MeshOrderOp.h"
64 #include "SMESHGUI_MeshPatternDlg.h"
65 #include "SMESHGUI_MultiEditDlg.h"
66 #include "SMESHGUI_NodesDlg.h"
67 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
68 #include "SMESHGUI_PropertiesDlg.h"
69 #include "SMESHGUI_RemoveElementsDlg.h"
70 #include "SMESHGUI_RemoveNodesDlg.h"
71 #include "SMESHGUI_RenumberingDlg.h"
72 #include "SMESHGUI_ReorientFacesDlg.h"
73 #include "SMESHGUI_RevolutionDlg.h"
74 #include "SMESHGUI_RotationDlg.h"
75 #include "SMESHGUI_ScaleDlg.h"
76 #include "SMESHGUI_Selection.h"
77 #include "SMESHGUI_SewingDlg.h"
78 #include "SMESHGUI_SingleEditDlg.h"
79 #include "SMESHGUI_SmoothingDlg.h"
80 #include "SMESHGUI_SymmetryDlg.h"
81 #include "SMESHGUI_TranslationDlg.h"
82 #include "SMESHGUI_TransparencyDlg.h"
84 #include "SMESHGUI_FilterUtils.h"
85 #include "SMESHGUI_GroupUtils.h"
86 #include "SMESHGUI_HypothesesUtils.h"
87 #include "SMESHGUI_MeshUtils.h"
88 #include "SMESHGUI_PatternUtils.h"
89 #include "SMESHGUI_Utils.h"
90 #include "SMESHGUI_VTKUtils.h"
92 #include <SMESH_version.h>
94 #include "SMESH_ControlsDef.hxx"
95 #include <SMESH_Actor.h>
96 #include <SMESH_ActorUtils.h>
97 #include <SMESH_Client.hxx>
98 #include <SMESH_ScalarBarActor.h>
99 #include <SMESH_TypeFilter.hxx>
101 // SALOME GUI includes
102 #include <SalomeApp_Application.h>
103 #include <SalomeApp_CheckFileDlg.h>
104 #include <SalomeApp_DataObject.h>
105 #include <SalomeApp_Study.h>
106 #include <SalomeApp_Tools.h>
108 #include <LightApp_DataOwner.h>
109 #include <LightApp_NameDlg.h>
110 #include <LightApp_Preferences.h>
111 #include <LightApp_SelectionMgr.h>
112 #include <LightApp_UpdateFlags.h>
114 #include <SVTK_ViewManager.h>
115 #include <SVTK_ViewModel.h>
116 #include <SVTK_ViewWindow.h>
118 #include <VTKViewer_Algorithm.h>
120 #include <PyInterp_Interp.h>
122 #include <SUIT_Desktop.h>
123 #include <SUIT_FileDlg.h>
124 #include <SUIT_MessageBox.h>
125 #include <SUIT_OverrideCursor.h>
126 #include <SUIT_ResourceMgr.h>
127 #include <SUIT_Session.h>
129 #include <QtxPopupMgr.h>
130 #include <QtxFontEdit.h>
132 #include <SALOME_ListIO.hxx>
133 #include <SALOME_ListIteratorOfListIO.hxx>
135 #ifndef DISABLE_PLOT2DVIEWER
136 #include <SPlot2d_ViewModel.h>
137 #include <SPlot2d_Histogram.h>
141 #include <SALOMEconfig.h>
142 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
143 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
144 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
147 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
148 #include <QApplication>
150 #include <QTextStream>
153 #include <boost/shared_ptr.hpp>
156 #include <vtkCallbackCommand.h>
157 #include <vtkCamera.h>
158 #include <vtkLookupTable.h>
159 #include <vtkPlane.h>
160 #include <vtkRenderer.h>
162 // SALOME KERNEL includes
163 #include <SALOMEDSClient_ClientFactory.hxx>
164 #include <SALOMEDSClient_IParameters.hxx>
165 #include <SALOMEDSClient_SComponent.hxx>
166 #include <SALOMEDSClient_StudyBuilder.hxx>
167 #include <SALOMEDS_Study.hxx>
168 #include <SALOMEDS_SObject.hxx>
171 #include <Standard_ErrorHandler.hxx>
172 #include <NCollection_DataMap.hxx>
174 #include <Basics_Utils.hxx>
176 //To disable automatic genericobj management, the following line should be commented.
177 //Otherwise, it should be uncommented.
178 //Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
179 #define WITHGENERICOBJ
181 // Below macro, when uncommented, switches on simplified (more performant) algorithm
182 // of auto-color picking up
183 #define SIMPLE_AUTOCOLOR
185 // REMOVE the code about MPLMathText_Disabler if it does not complite at porting to ParaView-4.1
186 #include <vtkMatplotlibMathTextUtilities.h>
189 // Creation of this class disables vtkMatplotlibMathTextUtilities
190 struct MPLMathText_Disabler : protected vtkMatplotlibMathTextUtilities
192 MPLMathText_Disabler()
194 vtkMatplotlibMathTextUtilities::MPLMathTextAvailable =
195 vtkMatplotlibMathTextUtilities::UNAVAILABLE;
203 //=============================================================
204 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
207 void ExportMeshToFile(int theCommandID);
209 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
211 void SetDisplayEntity(int theCommandID);
213 void Control( int theCommandID );
216 //================================================================================
218 * \brief Reads meshes from file
220 //================================================================================
222 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
226 std::string myExtension;
228 if ( theCommandID == 113 ) {
229 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
230 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
232 else if ( theCommandID == 112 ) {
233 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
235 else if ( theCommandID == 111 ) {
236 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
238 else if ( theCommandID == 115 ) {
239 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
241 else if ( theCommandID == 116 ) {
242 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
244 else if ( theCommandID == 117 ) {
245 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
246 filter.append( QObject::tr( "All files (*)" ) );
248 else if ( theCommandID == 118 ) {
249 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
250 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
253 QString anInitialPath = "";
254 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
255 anInitialPath = QDir::currentPath();
257 QStringList filenames;
258 bool toCreateGroups = true;
260 // if ( theCommandID == 118 ) { // GMF
261 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
262 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
263 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
264 // fd->setNameFilters( filter );
265 // fd->SetChecked( true );
267 // filenames << fd->selectedFile();
268 // toCreateGroups = fd->IsChecked();
274 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
277 QObject::tr( "SMESH_IMPORT_MESH" ) );
279 if ( filenames.count() > 0 ) {
280 SUIT_OverrideCursor wc;
281 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
284 QStringList anEntryList;
285 bool isEmpty = false;
286 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
287 QString filename = *it;
288 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
290 switch ( theCommandID ) {
293 // DAT format (currently unsupported)
294 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
295 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
301 aMeshes->length( 1 );
302 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
303 if ( aMeshes[0]->_is_nil() )
304 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
305 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
311 SMESH::DriverMED_ReadStatus res;
312 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
313 if ( res != SMESH::DRS_OK ) {
314 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
315 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
322 aMeshes->length( 1 );
323 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
324 if ( aMeshes[0]->_is_nil() ) {
325 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
326 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
333 SMESH::DriverMED_ReadStatus res;
334 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
335 if ( res != SMESH::DRS_OK ) {
336 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
337 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
344 SMESH::DriverMED_ReadStatus res;
345 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
346 if ( res != SMESH::DRS_OK ) {
347 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
348 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
355 SMESH::ComputeError_var res;
356 aMeshes->length( 1 );
357 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
360 if ( res->code != SMESH::DRS_OK ) {
361 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
362 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
363 if ( strlen( res->comment.in() ) > 0 ) {
364 errors.back() += ": ";
365 errors.back() += res->comment.in();
372 catch ( const SALOME::SALOME_Exception& S_ex ) {
373 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
374 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
377 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
378 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
380 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
381 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
382 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
383 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
384 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
386 anEntryList.append( aMeshSO->GetID().c_str() );
394 // update Object browser
395 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
397 // browse to the published meshes
398 if( LightApp_Application* anApp =
399 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
400 anApp->browseObjects( anEntryList );
402 // show Error message box if there were errors
403 if ( errors.count() > 0 ) {
404 SUIT_MessageBox::critical( SMESHGUI::desktop(),
405 QObject::tr( "SMESH_ERROR" ),
406 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
409 // show warning message box, if some imported mesh is empty
411 SUIT_MessageBox::warning( SMESHGUI::desktop(),
412 QObject::tr( "SMESH_WRN_WARNING" ),
413 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
418 //================================================================================
420 * \brief Export selected meshes or groups into a file
422 //================================================================================
424 void ExportMeshToFile( int theCommandID )
426 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
427 SALOME_ListIO selected;
429 aSel->selectedObjects( selected );
431 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
432 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
433 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
434 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
435 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
436 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
437 const bool isGMF = ( theCommandID == 146 || theCommandID == 147 );
439 // actually, the following condition can't be met (added for insurance)
440 if( selected.Extent() == 0 ||
441 ( selected.Extent() > 1 && !isMED && !isSTL ))
444 // get mesh object from selection and check duplication of their names
445 bool hasDuplicatedMeshNames = false;
446 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
447 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
448 SALOME_ListIteratorOfListIO It( selected );
449 for( ; It.More(); It.Next() )
451 Handle(SALOME_InteractiveObject) anIObject = It.Value();
452 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
453 if ( aMeshItem->_is_nil() ) {
454 SUIT_MessageBox::warning( SMESHGUI::desktop(),
455 QObject::tr( "SMESH_WRN_WARNING" ),
456 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
460 QString aMeshName = anIObject->getName();
462 // check for name duplications
463 if ( !hasDuplicatedMeshNames )
464 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
465 if( aMeshName == (*aMeshIter).second ) {
466 hasDuplicatedMeshNames = true;
471 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
474 if( hasDuplicatedMeshNames && isMED ) {
475 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
476 QObject::tr("SMESH_WRN_WARNING"),
477 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
478 QObject::tr("SMESH_BUT_YES"),
479 QObject::tr("SMESH_BUT_NO"), 0, 1);
484 aMeshIter = aMeshList.begin();
485 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
486 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
487 QString aMeshName = (*aMeshIter).second;
489 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
491 // check for equal group names within each mesh
492 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
493 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
494 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
495 int aRet = SUIT_MessageBox::warning
496 (SMESHGUI::desktop(),
497 QObject::tr("SMESH_WRN_WARNING"),
498 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
499 QObject::tr("SMESH_BUT_YES"),
500 QObject::tr("SMESH_BUT_NO"), 0, 1);
507 // Warn the user about presence of not supported elements
509 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
513 notSupportedElemTypes.push_back( SMESH::Entity_0D );
514 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
519 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
520 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
521 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
522 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
523 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
524 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
525 notSupportedElemTypes.push_back( SMESH::Entity_0D );
526 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
531 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
532 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
533 notSupportedElemTypes.push_back( SMESH::Entity_0D );
534 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
539 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
540 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
545 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
546 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
547 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
548 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
549 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
550 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
551 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
556 notSupportedElemTypes.push_back( SMESH::Entity_0D );
557 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
558 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
559 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
560 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
561 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
562 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
563 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
564 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
566 if ( ! notSupportedElemTypes.empty() )
568 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
569 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
570 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
571 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
573 if ( !presentNotSupported.empty() )
576 const char* typeMsg[SMESH::Entity_Last] = {
577 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
578 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
579 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
580 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
581 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
582 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
583 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
584 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
586 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
587 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
588 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
589 if ( iType != presentNotSupported.size() - 1 )
590 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
592 int aRet = SUIT_MessageBox::warning
593 (SMESHGUI::desktop(),
594 QObject::tr("SMESH_WRN_WARNING"),
595 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
596 QObject::tr("SMESH_BUT_YES"),
597 QObject::tr("SMESH_BUT_NO"), 0, 1);
602 // Get parameters of export operation
605 SMESH::MED_VERSION aFormat;
606 // Init the parameters with the default values
607 bool aIsASCII_STL = true;
608 bool toCreateGroups = false;
609 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
611 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
612 bool toOverwrite = true;
613 bool toFindOutDim = true;
615 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
616 QString anInitialPath = "";
617 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
618 anInitialPath = QDir::currentPath();
620 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
622 // Get a file name to write in and additional otions
623 if ( isUNV || isDAT || isGMF ) // Export w/o options
626 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
628 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
630 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
631 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
632 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
633 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
634 anInitialPath + QString("/") + aMeshName,
635 aFilter, aTitle, false);
637 else if ( isCGNS )// Export to CGNS
639 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
640 fd->setWindowTitle( aTitle );
641 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
642 if ( !anInitialPath.isEmpty() )
643 fd->setDirectory( anInitialPath );
644 fd->selectFile(aMeshName);
645 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
646 fd->setValidator( fv );
649 aFilename = fd->selectedFile();
650 toOverwrite = fv->isOverwrite();
654 else if ( isSTL ) // Export to STL
656 QMap<QString, int> aFilterMap;
657 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
658 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
661 QMap<QString, int>::const_iterator it = aFilterMap.begin();
662 for ( ; it != aFilterMap.end(); ++it )
663 filters.push_back( it.key() );
665 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
666 fd->setWindowTitle( aTitle );
667 fd->setNameFilters( filters );
668 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
669 if ( !anInitialPath.isEmpty() )
670 fd->setDirectory( anInitialPath );
671 fd->selectFile(aMeshName);
675 aFilename = fd->selectedFile();
676 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
681 else if ( isMED || isSAUV ) // Export to MED or SAUV
683 QMap<QString, SMESH::MED_VERSION> aFilterMap;
684 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
686 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
687 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
688 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
691 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
692 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
693 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
697 QString aDefaultFilter;
698 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
699 for ( ; it != aFilterMap.end(); ++it ) {
700 filters.push_back( it.key() );
701 if (it.value() == SMESH::MED_V2_2)
702 aDefaultFilter = it.key();
704 QStringList checkBoxes;
705 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
707 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
708 QList< QWidget* > wdgList;
709 if ( fieldSelWdg->GetAllFeilds( aMeshList, aFieldList ))
710 wdgList.append( fieldSelWdg );
712 SalomeApp_CheckFileDlg* fd =
713 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
714 fd->setWindowTitle( aTitle );
715 fd->setNameFilters( filters );
716 fd->selectNameFilter( aDefaultFilter );
717 fd->SetChecked( toCreateGroups, 0 );
718 fd->SetChecked( toFindOutDim, 1 );
719 if ( !anInitialPath.isEmpty() )
720 fd->setDirectory( anInitialPath );
721 fd->selectFile(aMeshName);
723 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
724 fd->setValidator( fv );
729 aFilename = fd->selectedFile();
731 aFilename = QString::null;
734 aFormat = aFilterMap[fd->selectedNameFilter()];
735 toOverwrite = fv->isOverwrite();
737 if ( !aFilename.isEmpty() ) {
738 // med-2.1 does not support poly elements
739 if ( aFormat==SMESH::MED_V2_1 )
740 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
741 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
742 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
743 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
744 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
746 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
747 QObject::tr("SMESH_WRN_WARNING"),
748 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
749 QObject::tr("SMESH_BUT_YES"),
750 QObject::tr("SMESH_BUT_NO"), 0, 1);
758 // can't append to an existing using other format
759 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
760 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
761 if( !isVersionOk || aVersion != aFormat ) {
762 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
763 QObject::tr("SMESH_WRN_WARNING"),
764 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
765 QObject::tr("SMESH_BUT_YES"),
766 QObject::tr("SMESH_BUT_NO"), 0, 1);
773 QStringList aMeshNamesCollisionList;
774 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
775 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
776 QString anExistingMeshName( aMeshNames[ i ] );
777 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
778 QString anExportMeshName = (*aMeshIter).second;
779 if( anExportMeshName == anExistingMeshName ) {
780 aMeshNamesCollisionList.append( anExportMeshName );
785 if( !aMeshNamesCollisionList.isEmpty() ) {
786 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
787 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
788 QObject::tr("SMESH_WRN_WARNING"),
789 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
790 QObject::tr("SMESH_BUT_YES"),
791 QObject::tr("SMESH_BUT_NO"),
792 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
801 toCreateGroups = fd->IsChecked(0);
802 toFindOutDim = fd->IsChecked(1);
803 fieldSelWdg->GetSelectedFeilds();
804 if ( !fieldSelWdg->parent() )
815 if ( !aFilename.isEmpty() ) {
816 // Check whether the file already exists and delete it if yes
817 QFile aFile( aFilename );
818 if ( aFile.exists() && toOverwrite )
820 SUIT_OverrideCursor wc;
823 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
824 // bool Renumber = false;
825 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
827 // Renumber= resMgr->booleanValue("renumbering");
829 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
830 // aMeshEditor->RenumberNodes();
831 // aMeshEditor->RenumberElements();
832 // if ( SMESHGUI::automaticUpdate() )
833 // SMESH::UpdateView();
837 aMeshIter = aMeshList.begin();
838 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
840 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
841 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
842 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
843 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
844 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
845 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
846 aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
847 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
849 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
850 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim,
851 fields, geoAssFields.toLatin1().data() );
856 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
858 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
859 if( !aMeshItem->_is_nil() )
860 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
865 if ( aMeshOrGroup->_is_equivalent( aMesh ))
866 aMesh->ExportDAT( aFilename.toUtf8().data() );
868 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
872 if ( aMeshOrGroup->_is_equivalent( aMesh ))
873 aMesh->ExportUNV( aFilename.toUtf8().data() );
875 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
879 if ( aMeshOrGroup->_is_equivalent( aMesh ))
880 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
882 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
886 aMeshIter = aMeshList.begin();
887 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
889 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
890 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
891 aMeshItem->ExportCGNS( aMeshOrGroup,
892 aFilename.toUtf8().data(),
893 toOverwrite && aMeshIndex == 0 );
898 toCreateGroups = true;
899 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
902 catch (const SALOME::SALOME_Exception& S_ex){
904 SUIT_MessageBox::warning(SMESHGUI::desktop(),
905 QObject::tr("SMESH_WRN_WARNING"),
906 QObject::tr("SMESH_EXPORT_FAILED"));
912 inline void InverseEntityMode(unsigned int& theOutputMode,
913 unsigned int theMode)
915 bool anIsNotPresent = ~theOutputMode & theMode;
917 theOutputMode |= theMode;
919 theOutputMode &= ~theMode;
922 void SetDisplayEntity(int theCommandID){
923 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
924 SALOME_ListIO selected;
926 aSel->selectedObjects( selected );
928 if(selected.Extent() >= 1){
929 SALOME_ListIteratorOfListIO It( selected );
930 for( ; It.More(); It.Next()){
931 Handle(SALOME_InteractiveObject) IObject = It.Value();
932 if(IObject->hasEntry()){
933 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
934 unsigned int aMode = anActor->GetEntityMode();
935 switch(theCommandID){
937 InverseEntityMode(aMode,SMESH_Actor::eBallElem);
940 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
943 InverseEntityMode(aMode,SMESH_Actor::eEdges);
946 InverseEntityMode(aMode,SMESH_Actor::eFaces);
949 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
952 aMode = SMESH_Actor::eAllEntity;
956 anActor->SetEntityMode(aMode);
965 SALOME_ListIO selected;
966 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
970 LightApp_SelectionMgr* aSel = app->selectionMgr();
971 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
972 if( !aSel || !appStudy )
975 aSel->selectedObjects( selected );
976 if( selected.IsEmpty() )
979 Handle(SALOME_InteractiveObject) anIObject = selected.First();
981 _PTR(Study) aStudy = appStudy->studyDS();
982 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
983 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
984 if( aMainObject->_is_nil() )
987 SUIT_OverrideCursor wc;
989 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
991 QList<SALOMEDS::Color> aReservedColors;
993 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
994 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
996 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
997 //SALOMEDS::Color aColor = aGroupObject->GetColor();
999 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1000 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1001 #else // old algorithm for auto-colors
1002 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1003 aReservedColors.append( aColor );
1004 #endif // SIMPLE_AUTOCOLOR
1005 aGroupObject->SetColor( aColor );
1007 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1008 if (aGroupSObject) {
1011 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1012 switch ( aGroupObject->GetType ()) {
1014 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1016 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1018 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1020 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1022 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1023 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1026 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1027 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1033 SMESH::RepaintCurrentView();
1036 void OverallMeshQuality() {
1037 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1038 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1039 SALOME_ListIO selected;
1041 aSel->selectedObjects( selected );
1043 if ( selected.IsEmpty() ) return;
1044 SALOME_ListIteratorOfListIO It( selected );
1045 for ( ; It.More(); It.Next() ) {
1046 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1047 ctrlDlg->showInfo( It.Value() );
1052 QString functorToString( SMESH::Controls::FunctorPtr f )
1054 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1055 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1056 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1057 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1058 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1059 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1060 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1061 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1062 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1063 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1064 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1065 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1066 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1067 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1068 type = QObject::tr( "WARP_ELEMENTS" );
1069 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1070 type = QObject::tr( "TAPER_ELEMENTS" );
1071 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1072 type = QObject::tr( "SKEW_ELEMENTS" );
1073 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1074 type = QObject::tr( "AREA_ELEMENTS" );
1075 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1076 type = QObject::tr( "LENGTH_EDGES" );
1077 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1078 type = QObject::tr( "LENGTH2D_EDGES" );
1079 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1080 type = QObject::tr( "MULTI_BORDERS" );
1081 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1082 type = QObject::tr( "MULTI2D_BORDERS" );
1083 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1084 type = QObject::tr( "FREE_NODES" );
1085 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1086 type = QObject::tr( "FREE_EDGES" );
1087 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1088 type = QObject::tr( "FREE_BORDERS" );
1089 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1090 type = QObject::tr( "FREE_FACES" );
1091 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1092 type = QObject::tr( "BARE_BORDER_VOLUME" );
1093 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1094 type = QObject::tr( "BARE_BORDER_FACE" );
1095 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1096 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1097 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1098 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1099 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1100 type = QObject::tr( "EQUAL_NODE" );
1101 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1102 type = QObject::tr( "EQUAL_EDGE" );
1103 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1104 type = QObject::tr( "EQUAL_FACE" );
1105 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1106 type = QObject::tr( "EQUAL_VOLUME" );
1110 void SaveDistribution()
1112 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1113 SALOME_ListIO selected;
1115 aSel->selectedObjects( selected );
1117 if ( selected.Extent() == 1 ) {
1118 Handle(SALOME_InteractiveObject) anIO = selected.First();
1119 if ( anIO->hasEntry() ) {
1120 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1121 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1122 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1123 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1124 if ( aScalarBarActor && aFunctor ) {
1125 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1127 std::vector<int> elements;
1128 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1129 if ( mesh->_is_nil() ) {
1130 SMESH::SMESH_IDSource_var idSource =
1131 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1132 if ( !idSource->_is_nil() )
1134 SMESH::long_array_var ids = idSource->GetIDs();
1135 elements.resize( ids->length() );
1136 for ( unsigned i = 0; i < elements.size(); ++i )
1137 elements[i] = ids[i];
1140 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1141 vtkLookupTable* lookupTable =
1142 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1143 double * minmax = lookupTable->GetRange();
1144 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1145 std::vector<int> nbEvents;
1146 std::vector<double> funValues;
1147 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax, isLogarithmic );
1148 QString anInitialPath = "";
1149 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1150 anInitialPath = QDir::currentPath();
1151 QString aMeshName = anIO->getName();
1153 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1154 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1155 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1156 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1157 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1160 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1162 if ( !aFilename.isEmpty() ) {
1163 QFile f( aFilename );
1164 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1165 QTextStream out( &f );
1166 out << "# Mesh: " << aMeshName << endl;
1167 out << "# Control: " << functorToString( aFunctor ) << endl;
1169 out.setFieldWidth( 10 );
1170 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1171 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1182 void ShowDistribution() {
1183 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1184 SALOME_ListIO selected;
1186 aSel->selectedObjects( selected );
1188 if ( selected.Extent() == 1 ) {
1189 Handle(SALOME_InteractiveObject) anIO = selected.First();
1190 if ( anIO->hasEntry() ) {
1191 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1192 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1193 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1194 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1200 #ifndef DISABLE_PLOT2DVIEWER
1201 void PlotDistribution() {
1202 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1206 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1207 SALOME_ListIO selected;
1209 aSel->selectedObjects( selected );
1211 if ( selected.Extent() == 1 ) {
1212 Handle(SALOME_InteractiveObject) anIO = selected.First();
1213 if ( anIO->hasEntry() ) {
1214 //Find Actor by entry before getting Plot2d viewer,
1215 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1216 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1218 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1223 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1227 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1231 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1232 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1233 QString functorName = functorToString( anActor->GetFunctor());
1234 QString aHistogramName("%1 : %2");
1235 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1236 aHistogram->setName(aHistogramName);
1237 aHistogram->setHorTitle(functorName);
1238 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1239 aPlot->displayObject(aHistogram, true);
1244 #endif //DISABLE_PLOT2DVIEWER
1246 void DisableAutoColor(){
1247 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1248 SALOME_ListIO selected;
1250 aSel->selectedObjects( selected );
1252 if(selected.Extent()){
1253 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1254 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1255 if ( !aMesh->_is_nil() ) {
1256 aMesh->SetAutoColor( false );
1261 void sortChildren(){
1262 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1263 SALOME_ListIO selected;
1265 aSel->selectedObjects( selected );
1267 if(selected.Extent()){
1268 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1269 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1270 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1272 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1273 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1280 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1282 SALOME_ListIO selected;
1283 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1287 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1288 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1289 if( !aSel || !appStudy )
1292 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1293 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1294 aModule->EmitSignalDeactivateDialog();
1295 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1296 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1301 _PTR(Study) aStudy = appStudy->studyDS();
1303 aSel->selectedObjects( selected );
1305 if(selected.Extent() >= 1){
1306 switch(theCommandID){
1308 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1309 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1314 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1315 QColor orientationColor, outlineColor, volumeColor;
1316 int deltaF = 0, deltaV = 0;
1321 int outlineWidth = 1;
1322 double shrinkCoef = 0.0;
1323 double orientationScale = 0.0;
1324 bool orientation3d = false;
1325 VTK::MarkerType markerType = VTK::MT_NONE;
1326 VTK::MarkerScale markerScale = VTK::MS_NONE;
1328 bool hasNodes = false;
1329 int presentEntities = 0;
1330 bool firstTime = true;
1332 SALOME_ListIteratorOfListIO It( selected );
1333 for ( ; It.More(); It.Next() ) {
1334 Handle(SALOME_InteractiveObject) IObject = It.Value();
1335 if ( !IObject->hasEntry() ) continue;
1336 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1337 if ( !anActor || !anActor->GetObject() ) continue;
1340 // nodes: color, marker
1341 anActor->GetNodeColor( color[0], color[1], color[2] );
1342 nodeColor.setRgbF( color[0], color[1], color[2] );
1343 markerType = anActor->GetMarkerType();
1344 markerScale = anActor->GetMarkerScale();
1345 markerId = anActor->GetMarkerTexture();
1346 // edges: color, width
1347 anActor->GetEdgeColor( color[0], color[1], color[2] );
1348 edgeColor.setRgbF( color[0], color[1], color[2] );
1349 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1350 // faces: front color, back color (delta)
1351 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1352 faceColor.setRgbF( color[0], color[1], color[2] );
1353 // faces: front color, back color (delta)
1354 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1355 volumeColor.setRgbF( color[0], color[1], color[2] );
1356 // 0d elements: color, size
1357 anActor->Get0DColor( color[0], color[1], color[2] );
1358 elem0dColor.setRgbF( color[0], color[1], color[2] );
1359 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1360 // balls: color, size
1361 anActor->GetBallColor( color[0], color[1], color[2] );
1362 ballColor.setRgbF( color[0], color[1], color[2] );
1363 ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1364 ballScale = qMax( (int)anActor->GetBallScale(), 1 ); // minimum allowed size is 1
1366 anActor->GetOutlineColor( color[0], color[1], color[2] );
1367 outlineColor.setRgbF( color[0], color[1], color[2] );
1368 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1369 // orientation vectors: color, scale, 3d flag
1370 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1371 orientationColor.setRgbF( color[0], color[1], color[2] );
1372 orientationScale = anActor->GetFacesOrientationScale();
1373 orientation3d = anActor->GetFacesOrientation3DVectors();
1375 shrinkCoef = anActor->GetShrinkFactor();
1378 firstTime = false; // we only take properties from first object (for performance reasons)
1381 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1382 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1383 presentEntities = presentEntities | SMESH_Actor::eEdges;
1384 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1385 presentEntities = presentEntities | SMESH_Actor::eFaces;
1386 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1387 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1388 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1389 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1390 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1391 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1393 // as we know that all types of elements are present, we can exit the loop
1394 if ( presentEntities == SMESH_Actor::eAllEntity )
1398 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1399 // nodes: color, marker
1400 dlg.setNodeColor( nodeColor );
1401 if( markerType != VTK::MT_USER )
1402 dlg.setNodeMarker( markerType, markerScale );
1404 dlg.setNodeCustomMarker( markerId );
1405 // edges: color, line width
1406 dlg.setEdgeColor( edgeColor );
1407 dlg.setEdgeWidth( edgeWidth );
1408 // faces: front color, back color
1409 dlg.setFaceColor( faceColor, deltaF );
1410 // volumes: normal color, reversed color
1411 dlg.setVolumeColor( volumeColor, deltaV );
1412 // outlines: color, line width
1413 dlg.setOutlineColor( outlineColor );
1414 dlg.setOutlineWidth( outlineWidth );
1415 // 0d elements: color, size
1416 dlg.setElem0dColor( elem0dColor );
1417 dlg.setElem0dSize( elem0dSize );
1418 // balls: color, size
1419 dlg.setBallColor( ballColor );
1420 dlg.setBallSize( ballSize );
1421 dlg.setBallScale( ballScale );
1422 // orientation: color, scale, 3d flag
1423 dlg.setOrientationColor( orientationColor );
1424 dlg.setOrientationSize( int( orientationScale * 100. ) );
1425 dlg.setOrientation3d( orientation3d );
1426 // shrink: scale factor
1427 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1428 // hide unused controls
1429 dlg.showControls( presentEntities, hasNodes );
1432 nodeColor = dlg.nodeColor();
1433 markerType = dlg.nodeMarkerType();
1434 markerScale = dlg.nodeMarkerScale();
1435 markerId = dlg.nodeMarkerId();
1436 edgeColor = dlg.edgeColor();
1437 edgeWidth = dlg.edgeWidth();
1438 faceColor = dlg.faceColor();
1439 deltaF = dlg.faceColorDelta();
1440 volumeColor = dlg.volumeColor();
1441 deltaV = dlg.volumeColorDelta();
1442 outlineColor = dlg.outlineColor();
1443 outlineWidth = dlg.outlineWidth();
1444 elem0dColor = dlg.elem0dColor();
1445 elem0dSize = dlg.elem0dSize();
1446 ballColor = dlg.ballColor();
1447 ballSize = dlg.ballSize();
1448 ballScale = dlg.ballScale();
1449 orientationColor = dlg.orientationColor();
1450 orientationScale = dlg.orientationSize() / 100.;
1451 orientation3d = dlg.orientation3d();
1452 shrinkCoef = dlg.shrinkCoef() / 100.;
1454 // store point markers map that might be changed by the user
1455 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1457 // set properties from dialog box to the presentations
1458 SALOME_ListIteratorOfListIO It( selected );
1459 for ( ; It.More(); It.Next() ) {
1460 Handle(SALOME_InteractiveObject) IObject = It.Value();
1461 if ( !IObject->hasEntry() ) continue;
1462 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1463 if ( !anActor ) continue;
1465 // nodes: color, marker
1466 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1467 if ( markerType != VTK::MT_USER ) {
1468 anActor->SetMarkerStd( markerType, markerScale );
1471 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1472 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1473 if ( iter != markerMap.end() )
1474 anActor->SetMarkerTexture( markerId, iter->second.second );
1476 // volumes: normal color, reversed color (delta)
1477 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1478 // faces: front color, back color (delta)
1479 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1480 // edges: color, width
1481 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1482 anActor->SetLineWidth( edgeWidth );
1484 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1485 anActor->SetOutlineWidth( outlineWidth );
1486 // 0D elements: color, size
1487 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1488 anActor->Set0DSize( elem0dSize );
1489 // balls: color, size
1490 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1491 anActor->SetBallSize( ballSize );
1492 anActor->SetBallScale( ballScale );
1493 // orientation: color, scale, 3d flag
1494 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1495 anActor->SetFacesOrientationScale( orientationScale );
1496 anActor->SetFacesOrientation3DVectors( orientation3d );
1498 anActor->SetShrinkFactor( shrinkCoef );
1500 // for groups, set also proper color
1501 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1502 if ( !aGroupObject->_is_nil() ) {
1503 SMESH::ElementType anElementType = aGroupObject->GetType();
1505 switch( anElementType ) {
1507 aColor = nodeColor; break;
1509 aColor = edgeColor; break;
1511 aColor = faceColor; break;
1513 aColor = volumeColor; break;
1515 aColor = elem0dColor; break;
1517 aColor = ballColor; break;
1521 if ( aColor.isValid() ) {
1522 SALOMEDS::Color aGroupColor;
1523 aGroupColor.R = aColor.redF();
1524 aGroupColor.G = aColor.greenF();
1525 aGroupColor.B = aColor.blueF();
1526 aGroupObject->SetColor( aGroupColor );
1528 } // if ( !aGroupObject->_is_nil() )
1529 } // for ( ; It.More(); It.Next() )
1530 SMESH::RepaintCurrentView();
1531 } // if ( dlg.exec() )
1534 } // switch(theCommandID)
1535 SALOME_ListIteratorOfListIO It( selected );
1536 for( ; It.More(); It.Next()){
1537 Handle(SALOME_InteractiveObject) IObject = It.Value();
1538 if(IObject->hasEntry()){
1539 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1540 switch(theCommandID){
1542 anActor->SetRepresentation(SMESH_Actor::eEdge);
1545 anActor->SetRepresentation(SMESH_Actor::eSurface);
1548 if(anActor->IsShrunk())
1549 anActor->UnShrink();
1551 anActor->SetShrink();
1554 anActor->SetRepresentation(SMESH_Actor::ePoint);
1557 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1558 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1561 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1562 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1568 SMESH::RepaintCurrentView();
1572 void Control( int theCommandID )
1574 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1575 SALOME_ListIO selected;
1577 aSel->selectedObjects( selected );
1579 if( !selected.IsEmpty() ){
1580 Handle(SALOME_InteractiveObject) anIO = selected.First();
1582 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1583 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1584 switch ( theCommandID ){
1586 aControl = SMESH_Actor::eLength;
1589 aControl = SMESH_Actor::eLength2D;
1592 aControl = SMESH_Actor::eFreeEdges;
1595 aControl = SMESH_Actor::eFreeBorders;
1598 aControl = SMESH_Actor::eMultiConnection;
1601 aControl = SMESH_Actor::eFreeNodes;
1604 aControl = SMESH_Actor::eMultiConnection2D;
1607 aControl = SMESH_Actor::eArea;
1610 aControl = SMESH_Actor::eTaper;
1613 aControl = SMESH_Actor::eAspectRatio;
1616 aControl = SMESH_Actor::eAspectRatio3D;
1619 aControl = SMESH_Actor::eMinimumAngle;
1622 aControl = SMESH_Actor::eWarping;
1625 aControl = SMESH_Actor::eSkew;
1628 aControl = SMESH_Actor::eVolume3D;
1631 aControl = SMESH_Actor::eFreeFaces;
1634 aControl = SMESH_Actor::eMaxElementLength2D;
1637 aControl = SMESH_Actor::eMaxElementLength3D;
1640 aControl = SMESH_Actor::eBareBorderVolume;
1643 aControl = SMESH_Actor::eBareBorderFace;
1646 aControl = SMESH_Actor::eOverConstrainedVolume;
1649 aControl = SMESH_Actor::eOverConstrainedFace;
1652 aControl = SMESH_Actor::eCoincidentNodes;
1655 aControl = SMESH_Actor::eCoincidentElems1D;
1658 aControl = SMESH_Actor:: eCoincidentElems2D;
1661 aControl = SMESH_Actor::eCoincidentElems3D;
1665 anActor->SetControlMode(aControl);
1666 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1667 SMESH::RepaintCurrentView();
1668 #ifndef DISABLE_PLOT2DVIEWER
1669 if(anActor->GetPlot2Histogram()) {
1670 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1671 QString functorName = functorToString( anActor->GetFunctor());
1672 QString aHistogramName("%1 : %2");
1673 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1674 aHistogram->setName(aHistogramName);
1675 aHistogram->setHorTitle(functorName);
1676 SMESH::ProcessIn2DViewers(anActor);
1685 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1686 SMESH::MeshObjectType theType,
1687 const QString theInTypeName,
1688 QString & theOutTypeName)
1690 SMESH_TypeFilter aTypeFilter( theType );
1692 if( !theIO.IsNull() )
1694 entry = theIO->getEntry();
1695 LightApp_DataOwner owner( entry );
1696 if ( aTypeFilter.isOk( &owner )) {
1697 theOutTypeName = theInTypeName;
1705 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1707 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1708 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1710 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1711 CORBA::String_var anID = aSComp->GetID().c_str();
1712 if (!strcmp(anID.in(),theIO->getEntry()))
1718 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1719 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1720 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1721 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1722 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1730 QString CheckHomogeneousSelection()
1732 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1733 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1734 SALOME_ListIO selected;
1736 aSel->selectedObjects( selected );
1738 QString RefType = CheckTypeObject(selected.First());
1739 SALOME_ListIteratorOfListIO It(selected);
1740 for ( ; It.More(); It.Next())
1742 Handle(SALOME_InteractiveObject) IObject = It.Value();
1743 QString Type = CheckTypeObject(IObject);
1744 if (Type.compare(RefType) != 0)
1745 return "Heterogeneous Selection";
1753 void SMESHGUI::OnEditDelete()
1755 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1756 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1757 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1759 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1760 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1761 _PTR(GenericAttribute) anAttr;
1762 _PTR(AttributeIOR) anIOR;
1764 int objectCount = 0;
1766 QString aParentComponent = QString::null;
1767 Handle(SALOME_InteractiveObject) anIO;
1768 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1770 anIO = anIt.Value();
1771 QString cur = anIO->getComponentDataType();
1772 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1774 // check if object is reference
1775 _PTR(SObject) aRefSObj;
1776 aNameList.append("\n - ");
1777 if ( aSO->ReferencedObject( aRefSObj ) ) {
1778 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1779 aNameList.append( aRefName );
1780 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1783 aNameList.append(anIO->getName());
1787 if( aParentComponent.isNull() )
1788 aParentComponent = cur;
1789 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1790 aParentComponent = "";
1793 if ( objectCount == 0 )
1794 return; // No Valid Objects Selected
1796 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1797 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1798 QObject::tr("ERR_ERROR"),
1799 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1802 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1803 if (SUIT_MessageBox::warning
1804 (SMESHGUI::desktop(),
1805 QObject::tr("SMESH_WRN_WARNING"),
1806 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1807 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1808 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1811 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1813 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1814 // then treat them all starting from the deepest objects (at list back)
1815 std::list< _PTR(SObject) > listSO;
1816 SALOME_ListIteratorOfListIO It(selected);
1817 for( ; It.More(); It.Next()) // loop on selected IO's
1819 Handle(SALOME_InteractiveObject) IObject = It.Value();
1820 if(IObject->hasEntry()) {
1821 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1823 // disable removal of "SMESH" component object
1824 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1826 if ( engineIOR() == anIOR->Value().c_str() )
1829 //Check the referenced object
1830 _PTR(SObject) aRefSObject;
1831 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1832 aSO = aRefSObject; // Delete main Object instead of reference
1834 listSO.push_back( aSO );
1835 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1836 for ( ; itSO != listSO.end(); ++itSO ) {
1837 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1838 for (it->InitEx(false); it->More(); it->Next())
1839 listSO.push_back( it->Value() );
1843 // Check if none of objects to delete is referred from outside
1844 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1845 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1847 _PTR(SObject) SO = *ritSO;
1848 if ( !SO ) continue;
1849 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1850 for (size_t i = 0; i < aReferences.size(); i++) {
1851 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1852 std::string type = aComponent->ComponentDataType();
1853 if ( type != "SMESH" )
1855 SUIT_MessageBox::warning( anApp->desktop(),
1856 QObject::tr("WRN_WARNING"),
1857 QObject::tr("DEP_OBJECT") );
1858 return; // outside SMESH, there is an object depending on a SMESH object
1863 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1864 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1866 Handle(SALOME_InteractiveObject) IObject = It.Value();
1867 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1868 if ( !mesh->_is_nil() )
1872 // Treat SO's in the list starting from the back
1873 aStudyBuilder->NewCommand(); // There is a transaction
1874 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1876 _PTR(SObject) SO = *ritSO;
1877 if ( !SO ) continue;
1878 std::string anEntry = SO->GetID();
1880 /** Erase graphical object and remove all its data **/
1881 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1882 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1884 /** Remove an object from data structures **/
1885 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1886 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1887 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1888 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1889 aMesh->RemoveGroup( aGroup );
1891 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1892 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1893 aMesh->RemoveSubMesh( aSubMesh );
1895 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1897 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1900 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1901 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1902 QString objType = CheckTypeObject(IObject);
1903 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1904 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1905 aStudyBuilder->RemoveObjectWithChildren( SO );
1907 else {// default action: remove SObject from the study
1908 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1909 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1911 aStudyBuilder->RemoveObjectWithChildren( SO );
1915 } /* listSO back loop */
1917 aStudyBuilder->CommitCommand();
1919 /* Clear any previous selection */
1921 aSel->setSelectedObjects( l1 );
1923 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1927 SMESHGUI_EXPORT CAM_Module* createModule()
1929 return new SMESHGUI();
1932 SMESHGUI_EXPORT char* getModuleVersion() {
1933 return (char*)SMESH_VERSION_STR;
1937 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1939 //=============================================================================
1943 //=============================================================================
1944 SMESHGUI::SMESHGUI() :
1945 SalomeApp_Module( "SMESH" )
1947 if ( CORBA::is_nil( myComponentSMESH ) )
1949 CORBA::Boolean anIsEmbeddedMode;
1950 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1951 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1953 // 0019923: EDF 765 SMESH : default values of hypothesis
1954 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1955 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1956 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1957 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1958 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1960 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1961 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1962 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1964 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1965 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1969 myActiveDialogBox = 0;
1970 myFilterLibraryDlg = 0;
1974 myEventCallbackCommand = vtkCallbackCommand::New();
1975 myEventCallbackCommand->Delete();
1976 myEventCallbackCommand->SetClientData( this );
1977 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1980 /* load resources for all available meshers */
1981 SMESH::InitAvailableHypotheses();
1983 MPLMathText_Disabler d; // disable vtkMatplotlibMathTextUtilities
1986 //=============================================================================
1990 //=============================================================================
1991 SMESHGUI::~SMESHGUI()
1995 //=============================================================================
1999 //=============================================================================
2000 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2002 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2004 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2009 //=============================================================================
2013 //=============================================================================
2014 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2016 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2020 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2021 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2022 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2023 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2024 return autoUpdate && !exceeded;
2027 //=============================================================================
2031 //=============================================================================
2032 bool SMESHGUI::automaticUpdate( SMESH::SMESH_Mesh_ptr theMesh,
2033 int* entities, bool* limitExceeded, int* hidden )
2035 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2039 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2040 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2041 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2043 long requestedSize = theMesh->NbElements();
2045 *entities = SMESH_Actor::eAllEntity;
2048 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2050 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2052 if ( incrementalLimit ) {
2053 long nbOdElems = theMesh->Nb0DElements();
2054 long nbEdges = theMesh->NbEdges();
2055 long nbFaces = theMesh->NbFaces();
2056 long nbVolumes = theMesh->NbVolumes();
2057 long nbBalls = theMesh->NbBalls();
2060 if ( nbOdElems > 0 ) {
2061 if ( total + nbOdElems > updateLimit ) {
2062 *entities = *entities & ~SMESH_Actor::e0DElements;
2063 *hidden = *hidden | SMESH_Actor::e0DElements;
2070 if ( nbEdges > 0 ) {
2071 if ( total + nbEdges > updateLimit ) {
2072 *entities = *entities & ~SMESH_Actor::eEdges;
2073 *hidden = *hidden | SMESH_Actor::eEdges;
2080 if ( nbFaces > 0 ) {
2081 if ( total + nbFaces > updateLimit ) {
2082 *entities = *entities & ~SMESH_Actor::eFaces;
2083 *hidden = *hidden | SMESH_Actor::eFaces;
2090 if ( nbVolumes > 0 ) {
2091 if ( total + nbVolumes > updateLimit ) {
2092 *entities = *entities & ~SMESH_Actor::eVolumes;
2093 *hidden = *hidden | SMESH_Actor::eVolumes;
2100 if ( nbBalls > 0 ) {
2101 if ( total + nbBalls > updateLimit ) {
2102 *entities = *entities & ~SMESH_Actor::eBallElem;
2103 *hidden = *hidden | SMESH_Actor::eBallElem;
2111 return autoUpdate && !exceeded;
2114 //=============================================================================
2118 //=============================================================================
2119 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2121 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2124 //=============================================================================
2128 //=============================================================================
2129 SMESHGUI* SMESHGUI::GetSMESHGUI()
2131 SMESHGUI* smeshMod = 0;
2132 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2135 CAM_Module* module = app->module( "Mesh" );
2136 smeshMod = dynamic_cast<SMESHGUI*>( module );
2139 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2141 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2144 _PTR(Study) aStudy = study->studyDS();
2146 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2155 Standard_EXPORT SMESHGUI* GetComponentGUI()
2157 return SMESHGUI::GetSMESHGUI();
2161 //=============================================================================
2165 //=============================================================================
2166 void SMESHGUI::SetState(int aState)
2171 //=============================================================================
2175 //=============================================================================
2176 void SMESHGUI::ResetState()
2181 //=============================================================================
2185 //=============================================================================
2186 void SMESHGUI::EmitSignalDeactivateDialog()
2188 emit SignalDeactivateActiveDialog();
2191 //=============================================================================
2195 //=============================================================================
2196 void SMESHGUI::EmitSignalStudyFrameChanged()
2198 emit SignalStudyFrameChanged();
2201 //=============================================================================
2205 //=============================================================================
2206 void SMESHGUI::EmitSignalCloseAllDialogs()
2208 emit SignalCloseAllDialogs();
2211 //=============================================================================
2215 //=============================================================================
2216 void SMESHGUI::EmitSignalVisibilityChanged()
2218 emit SignalVisibilityChanged();
2221 //=============================================================================
2225 //=============================================================================
2226 QDialog *SMESHGUI::GetActiveDialogBox()
2228 return myActiveDialogBox;
2231 //=============================================================================
2235 //=============================================================================
2236 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2238 myActiveDialogBox = (QDialog *) aDlg;
2242 //=============================================================================
2246 //=============================================================================
2247 SUIT_Desktop* SMESHGUI::desktop()
2249 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2251 return app->desktop();
2256 //=============================================================================
2260 //=============================================================================
2261 SalomeApp_Study* SMESHGUI::activeStudy()
2263 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2265 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2270 //=============================================================================
2274 //=============================================================================
2275 void SMESHGUI::Modified( bool theIsUpdateActions )
2277 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2278 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2279 appStudy->Modified();
2280 if( theIsUpdateActions )
2281 app->updateActions();
2286 //=============================================================================
2290 //=============================================================================
2291 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2293 /* Here the position is on the bottom right corner - 10 */
2294 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2296 SUIT_Desktop *PP = desktop();
2297 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2298 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2302 //=============================================================================
2306 //=============================================================================
2307 static int isStudyLocked(_PTR(Study) theStudy){
2308 return theStudy->GetProperties()->IsLocked();
2311 static bool checkLock(_PTR(Study) theStudy) {
2312 if (isStudyLocked(theStudy)) {
2313 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2314 QObject::tr("WRN_WARNING"),
2315 QObject::tr("WRN_STUDY_LOCKED") );
2321 //=======================================================================
2322 //function : CheckActiveStudyLocked
2324 //=======================================================================
2326 bool SMESHGUI::isActiveStudyLocked()
2328 _PTR(Study) aStudy = activeStudy()->studyDS();
2329 return checkLock( aStudy );
2332 //=============================================================================
2336 //=============================================================================
2337 bool SMESHGUI::OnGUIEvent( int theCommandID )
2339 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2343 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2344 SUIT_ResourceMgr* mgr = resourceMgr();
2348 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2349 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2352 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2353 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2355 //QAction* act = action( theCommandID );
2357 switch (theCommandID) {
2359 if(checkLock(aStudy)) break;
2371 if(checkLock(aStudy)) break;
2372 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2376 case 150: //MED FILE INFORMATION
2378 SALOME_ListIO selected;
2379 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2381 aSel->selectedObjects( selected );
2382 if( selected.Extent() )
2384 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2385 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2386 if ( !aMesh->_is_nil() )
2388 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2395 case 122: // EXPORT MED
2410 ::ExportMeshToFile(theCommandID);
2414 case 200: // SCALAR BAR
2416 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2417 SALOME_ListIO selected;
2419 aSel->selectedObjects( selected );
2421 if( selected.Extent() ) {
2422 Handle(SALOME_InteractiveObject) anIO = selected.First();
2423 if( anIO->hasEntry() ) {
2424 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2425 anActor->SetControlMode( SMESH_Actor::eNone );
2426 #ifndef DISABLE_PLOT2DVIEWER
2427 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2436 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2441 // dump control distribution data to the text file
2442 ::SaveDistribution();
2448 // show/ distribution
2449 ::ShowDistribution();
2453 #ifndef DISABLE_PLOT2DVIEWER
2456 // plot distribution
2457 ::PlotDistribution();
2468 ::DisableAutoColor();
2471 case 1134: // Clipping
2472 case 1133: // Tranparency
2473 case 1132: // Display preferences (colors, shrink size, line width, ...)
2480 ::SetDisplayMode(theCommandID, myMarkerMap);
2483 //2D quadratic representation
2486 ::SetDisplayMode(theCommandID, myMarkerMap);
2490 case 216: // 0D elements
2493 case 219: // Volumes
2494 case 220: // All Entity
2496 ::SetDisplayEntity(theCommandID);
2499 case 221: // Orientation of faces
2501 LightApp_SelectionMgr* mgr = selectionMgr();
2502 SALOME_ListIO selected; mgr->selectedObjects( selected );
2504 SALOME_ListIteratorOfListIO it(selected);
2505 for( ; it.More(); it.Next()) {
2506 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2507 if(anIObject->hasEntry()) {
2508 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2509 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2518 if(checkLock(aStudy)) break;
2519 SUIT_OverrideCursor wc;
2521 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2524 SMESH::UpdateView();
2526 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2527 SMESH::OnVisuException();
2529 catch (...) { // PAL16774 (Crash after display of many groups)
2530 SMESH::OnVisuException();
2534 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2535 aSel->selectedObjects( l );
2536 aSel->setSelectedObjects( l );
2541 case 301: // DISPLAY
2542 case 302: // DISPLAY ONLY
2544 SMESH::EDisplaing anAction;
2545 switch (theCommandID) {
2546 case 300: anAction = SMESH::eErase; break;
2547 case 301: anAction = SMESH::eDisplay; break;
2548 case 302: anAction = SMESH::eDisplayOnly; break;
2551 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2552 SALOME_ListIO sel_objects, to_process;
2554 aSel->selectedObjects( sel_objects );
2556 if( theCommandID==302 )
2558 MESSAGE("anAction = SMESH::eDisplayOnly");
2559 startOperation( myEraseAll );
2562 extractContainers( sel_objects, to_process );
2565 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2569 SALOME_ListIteratorOfListIO It( to_process );
2570 for ( ; It.More(); It.Next()) {
2572 Handle(SALOME_InteractiveObject) IOS = It.Value();
2573 if (IOS->hasEntry()) {
2575 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2576 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2577 break; // PAL16774 (Crash after display of many groups)
2579 if (anAction == SMESH::eDisplayOnly)
2581 MESSAGE("anAction = SMESH::eDisplayOnly");
2582 anAction = SMESH::eDisplay;
2588 // PAL13338 + PAL15161 -->
2589 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2590 MESSAGE("anAction = SMESH::eDisplayOnly");
2591 SMESH::UpdateView();
2592 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2594 // PAL13338 + PAL15161 <--
2596 catch (...) { // PAL16774 (Crash after display of many groups)
2597 SMESH::OnVisuException();
2600 if (anAction == SMESH::eErase) {
2601 MESSAGE("anAction == SMESH::eErase");
2603 aSel->setSelectedObjects( l1 );
2606 aSel->setSelectedObjects( to_process );
2613 if(checkLock(aStudy)) break;
2616 EmitSignalDeactivateDialog();
2618 ( new SMESHGUI_NodesDlg( this ) )->show();
2621 SUIT_MessageBox::warning(desktop(),
2622 tr("SMESH_WRN_WARNING"),
2623 tr("SMESH_WRN_VIEWER_VTK"));
2628 case 2151: // FILTER
2632 EmitSignalDeactivateDialog();
2633 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2638 case 701: // COMPUTE MESH
2639 case 711: // PRECOMPUTE MESH
2640 case 712: // EVALUATE MESH
2641 case 713: // MESH ORDER
2642 case 702: // Create mesh
2643 case 703: // Create sub-mesh
2644 case 704: // Edit mesh/sub-mesh
2645 startOperation( theCommandID );
2647 case 705: // copy mesh
2649 if (checkLock(aStudy)) break;
2650 EmitSignalDeactivateDialog();
2651 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2654 case 710: // Build compound mesh
2656 if (checkLock(aStudy)) break;
2657 EmitSignalDeactivateDialog();
2658 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2662 case 407: // DIAGONAL INVERSION
2663 case 408: // Delete diagonal
2667 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2668 tr( "NOT_A_VTK_VIEWER" ) );
2672 if ( checkLock( aStudy ) )
2675 /*Standard_Boolean aRes;
2676 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2677 if ( aMesh->_is_nil() )
2679 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2680 tr( "SMESH_BAD_SELECTION" ) );
2684 EmitSignalDeactivateDialog();
2685 if ( theCommandID == 407 )
2686 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2688 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2691 case 409: // Change orientation
2692 case 410: // Union of triangles
2693 case 411: // Cutting of quadrangles
2694 case 419: // Splitting volumes into tetrahedra
2698 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2699 tr( "NOT_A_VTK_VIEWER" ) );
2703 if ( checkLock( aStudy ) )
2706 EmitSignalDeactivateDialog();
2707 SMESHGUI_MultiEditDlg* aDlg = NULL;
2708 if ( theCommandID == 409 )
2709 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2710 else if ( theCommandID == 410 )
2711 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2712 else if ( theCommandID == 419 )
2713 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2715 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2720 case 412: // Smoothing
2722 if(checkLock(aStudy)) break;
2724 EmitSignalDeactivateDialog();
2725 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2728 SUIT_MessageBox::warning(desktop(),
2729 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2733 case 413: // Extrusion
2735 if (checkLock(aStudy)) break;
2737 EmitSignalDeactivateDialog();
2738 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2740 SUIT_MessageBox::warning(desktop(),
2741 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2745 case 414: // Revolution
2747 if(checkLock(aStudy)) break;
2749 EmitSignalDeactivateDialog();
2750 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2753 SUIT_MessageBox::warning(desktop(),
2754 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2758 case 415: // Pattern mapping
2760 if ( checkLock( aStudy ) )
2764 EmitSignalDeactivateDialog();
2765 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2768 SUIT_MessageBox::warning(desktop(),
2769 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2773 case 416: // Extrusion along a path
2775 if (checkLock(aStudy)) break;
2777 EmitSignalDeactivateDialog();
2778 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2780 SUIT_MessageBox::warning(desktop(),
2781 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2785 case 417: // Convert mesh to quadratic
2786 case 418: // create 2D mesh from 3D
2787 case 420: // Reorient faces
2788 case 806: // CREATE GEO GROUP
2790 startOperation( theCommandID );
2793 case 801: // CREATE GROUP
2797 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2798 tr( "NOT_A_VTK_VIEWER" ) );
2802 if(checkLock(aStudy)) break;
2803 EmitSignalDeactivateDialog();
2804 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2806 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2807 SALOME_ListIO selected;
2809 aSel->selectedObjects( selected );
2811 int nbSel = selected.Extent();
2813 // check if mesh is selected
2814 aMesh = SMESH::GetMeshByIO( selected.First() );
2816 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2821 case 802: // CONSTRUCT GROUP
2825 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2826 tr( "NOT_A_VTK_VIEWER" ) );
2830 if(checkLock(aStudy)) break;
2831 EmitSignalDeactivateDialog();
2833 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2834 SALOME_ListIO selected;
2836 aSel->selectedObjects( selected );
2838 int nbSel = selected.Extent();
2840 // check if submesh is selected
2841 Handle(SALOME_InteractiveObject) IObject = selected.First();
2842 if (IObject->hasEntry()) {
2843 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2845 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2846 if (!aSubMesh->_is_nil()) {
2848 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2849 // get submesh elements list by types
2850 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2851 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2852 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2853 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2854 // create group for each type o elements
2855 QString aName = IObject->getName();
2856 QStringList anEntryList;
2857 if (aNodes->length() > 0) {
2858 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2859 aGroup->Add(aNodes.inout());
2860 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2861 anEntryList.append( aSObject->GetID().c_str() );
2863 if (aEdges->length() > 0) {
2864 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2865 aGroup->Add(aEdges.inout());
2866 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2867 anEntryList.append( aSObject->GetID().c_str() );
2869 if (aFaces->length() > 0) {
2870 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2871 aGroup->Add(aFaces.inout());
2872 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2873 anEntryList.append( aSObject->GetID().c_str() );
2875 if (aVolumes->length() > 0) {
2876 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2877 aGroup->Add(aVolumes.inout());
2878 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2879 anEntryList.append( aSObject->GetID().c_str() );
2882 anApp->browseObjects( anEntryList );
2884 catch(const SALOME::SALOME_Exception & S_ex){
2885 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2892 SUIT_MessageBox::warning(desktop(),
2893 tr("SMESH_WRN_WARNING"),
2894 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2899 case 803: // EDIT GROUP
2903 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2904 tr( "NOT_A_VTK_VIEWER" ) );
2908 if(checkLock(aStudy)) break;
2909 EmitSignalDeactivateDialog();
2911 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2912 SALOME_ListIO selected;
2914 aSel->selectedObjects( selected );
2916 SALOME_ListIteratorOfListIO It (selected);
2917 int nbSelectedGroups = 0;
2918 for ( ; It.More(); It.Next() )
2920 SMESH::SMESH_GroupBase_var aGroup =
2921 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2922 if (!aGroup->_is_nil()) {
2924 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2928 if (nbSelectedGroups == 0)
2930 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2936 case 804: // Add elements to group
2938 if(checkLock(aStudy)) break;
2939 if (myState == 800) {
2940 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2941 if (aDlg) aDlg->onAdd();
2946 case 805: // Remove elements from group
2948 if(checkLock(aStudy)) break;
2949 if (myState == 800) {
2950 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2951 if (aDlg) aDlg->onRemove();
2956 case 815: // Edit GEOM GROUP as standalone
2960 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2961 tr( "NOT_A_VTK_VIEWER" ) );
2965 if(checkLock(aStudy)) break;
2966 EmitSignalDeactivateDialog();
2968 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2969 SALOME_ListIO selected;
2971 aSel->selectedObjects( selected );
2973 SALOME_ListIteratorOfListIO It (selected);
2974 for ( ; It.More(); It.Next() )
2976 SMESH::SMESH_GroupOnGeom_var aGroup =
2977 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2978 if (!aGroup->_is_nil()) {
2979 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2984 SMESH::SMESH_GroupOnFilter_var aGroup =
2985 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2986 if (!aGroup->_is_nil()) {
2987 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2995 case 810: // Union Groups
2996 case 811: // Intersect groups
2997 case 812: // Cut groups
3001 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3002 tr( "NOT_A_VTK_VIEWER" ) );
3006 if ( checkLock( aStudy ) )
3009 EmitSignalDeactivateDialog();
3011 SMESHGUI_GroupOpDlg* aDlg = 0;
3012 if ( theCommandID == 810 )
3013 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3014 else if ( theCommandID == 811 )
3015 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3017 aDlg = new SMESHGUI_CutGroupsDlg( this );
3024 case 814: // Create groups of entities from existing groups of superior dimensions
3026 if ( checkLock( aStudy ) )
3029 EmitSignalDeactivateDialog();
3030 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3036 case 813: // Delete groups with their contents
3040 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3041 tr( "NOT_A_VTK_VIEWER" ) );
3045 if ( checkLock( aStudy ) )
3048 EmitSignalDeactivateDialog();
3050 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3054 case 900: // MESH INFOS
3055 case 903: // WHAT IS
3057 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3058 EmitSignalDeactivateDialog();
3059 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3060 SALOME_ListIO selected;
3062 aSel->selectedObjects( selected );
3064 if ( selected.Extent() > 1 ) { // a dlg for each IO
3065 SALOME_ListIteratorOfListIO It( selected );
3066 for ( ; It.More(); It.Next() ) {
3067 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3068 dlg->showInfo( It.Value() );