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_Operations.h"
68 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
69 #include "SMESHGUI_PropertiesDlg.h"
70 #include "SMESHGUI_RemoveElementsDlg.h"
71 #include "SMESHGUI_RemoveNodesDlg.h"
72 #include "SMESHGUI_RenumberingDlg.h"
73 #include "SMESHGUI_ReorientFacesDlg.h"
74 #include "SMESHGUI_RevolutionDlg.h"
75 #include "SMESHGUI_RotationDlg.h"
76 #include "SMESHGUI_ScaleDlg.h"
77 #include "SMESHGUI_Selection.h"
78 #include "SMESHGUI_SewingDlg.h"
79 #include "SMESHGUI_SingleEditDlg.h"
80 #include "SMESHGUI_SmoothingDlg.h"
81 #include "SMESHGUI_SymmetryDlg.h"
82 #include "SMESHGUI_TranslationDlg.h"
83 #include "SMESHGUI_TransparencyDlg.h"
84 #include "SMESHGUI_DisplayEntitiesDlg.h"
86 #include "SMESHGUI_FilterUtils.h"
87 #include "SMESHGUI_GEOMGenUtils.h"
88 #include "SMESHGUI_GroupUtils.h"
89 #include "SMESHGUI_HypothesesUtils.h"
90 #include "SMESHGUI_MeshUtils.h"
91 #include "SMESHGUI_PatternUtils.h"
92 #include "SMESHGUI_Utils.h"
93 #include "SMESHGUI_VTKUtils.h"
95 #include <SMESH_version.h>
97 #include "SMESH_ControlsDef.hxx"
98 #include <SMESH_Actor.h>
99 #include <SMESH_ActorUtils.h>
100 #include <SMESH_Client.hxx>
101 #include <SMESH_ScalarBarActor.h>
102 #include <SMESH_TypeFilter.hxx>
104 // SALOME GUI includes
105 #include <SalomeApp_Application.h>
106 #include <SalomeApp_CheckFileDlg.h>
107 #include <SalomeApp_DataObject.h>
108 #include <SalomeApp_Study.h>
109 #include <SalomeApp_Tools.h>
111 #include <LightApp_DataOwner.h>
112 #include <LightApp_NameDlg.h>
113 #include <LightApp_Preferences.h>
114 #include <LightApp_SelectionMgr.h>
115 #include <LightApp_UpdateFlags.h>
117 #include <SVTK_ViewManager.h>
118 #include <SVTK_ViewModel.h>
119 #include <SVTK_ViewWindow.h>
121 #include <VTKViewer_Algorithm.h>
123 #include <PyInterp_Interp.h>
125 #include <SUIT_Desktop.h>
126 #include <SUIT_FileDlg.h>
127 #include <SUIT_MessageBox.h>
128 #include <SUIT_OverrideCursor.h>
129 #include <SUIT_ResourceMgr.h>
130 #include <SUIT_Session.h>
132 #include <QtxPopupMgr.h>
133 #include <QtxFontEdit.h>
135 #include <SALOME_ListIO.hxx>
136 #include <SALOME_ListIteratorOfListIO.hxx>
138 #ifndef DISABLE_PLOT2DVIEWER
139 #include <SPlot2d_ViewModel.h>
140 #include <SPlot2d_Histogram.h>
144 #include <SALOMEconfig.h>
145 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
146 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
147 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
150 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
151 #include <QApplication>
153 #include <QTextStream>
156 #include <boost/shared_ptr.hpp>
159 #include <vtkCallbackCommand.h>
160 #include <vtkCamera.h>
161 #include <vtkLookupTable.h>
162 #include <vtkPlane.h>
163 #include <vtkRenderer.h>
165 // SALOME KERNEL includes
166 #include <SALOMEDSClient_ClientFactory.hxx>
167 #include <SALOMEDSClient_IParameters.hxx>
168 #include <SALOMEDSClient_SComponent.hxx>
169 #include <SALOMEDSClient_StudyBuilder.hxx>
170 #include <SALOMEDS_Study.hxx>
171 #include <SALOMEDS_SObject.hxx>
174 #include <Standard_ErrorHandler.hxx>
175 #include <NCollection_DataMap.hxx>
177 #include <Basics_Utils.hxx>
179 //To disable automatic genericobj management, the following line should be commented.
180 //Otherwise, it should be uncommented.
181 //Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
182 #define WITHGENERICOBJ
184 // Below macro, when uncommented, switches on simplified (more performant) algorithm
185 // of auto-color picking up
186 #define SIMPLE_AUTOCOLOR
191 //=============================================================
192 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
195 void ExportMeshToFile(int theCommandID);
197 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
199 void SetDisplayEntity(int theCommandID);
201 void Control( int theCommandID );
204 //================================================================================
206 * \brief Reads meshes from file
208 //================================================================================
210 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
214 std::string myExtension;
216 if ( theCommandID == SMESHOp::OpImportMED ) {
217 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
218 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
220 else if ( theCommandID == SMESHOp::OpImportUNV ) {
221 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
223 else if ( theCommandID == SMESHOp::OpImportDAT ) {
224 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
226 else if ( theCommandID == SMESHOp::OpImportSTL ) {
227 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
230 else if ( theCommandID == SMESHOp::OpImportCGNS ) {
231 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
234 else if ( theCommandID == SMESHOp::OpImportSAUV ) {
235 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
236 filter.append( QObject::tr( "All files (*)" ) );
238 else if ( theCommandID == SMESHOp::OpImportGMF ) {
239 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
240 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
243 QString anInitialPath = "";
244 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
245 anInitialPath = QDir::currentPath();
247 QStringList filenames;
248 bool toCreateGroups = true;
250 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
251 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
252 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
253 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
254 // fd->setNameFilters( filter );
255 // fd->SetChecked( true );
257 // filenames << fd->selectedFile();
258 // toCreateGroups = fd->IsChecked();
264 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
267 QObject::tr( "SMESH_IMPORT_MESH" ) );
269 if ( filenames.count() > 0 ) {
270 SUIT_OverrideCursor wc;
271 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
274 QStringList anEntryList;
275 bool isEmpty = false;
276 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
277 QString filename = *it;
278 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
280 switch ( theCommandID ) {
281 case SMESHOp::OpImportDAT:
283 // DAT format (currently unsupported)
284 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
285 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
288 case SMESHOp::OpImportUNV:
291 aMeshes->length( 1 );
292 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
293 if ( aMeshes[0]->_is_nil() )
294 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
295 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
298 case SMESHOp::OpImportMED:
301 SMESH::DriverMED_ReadStatus res;
302 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
303 if ( res != SMESH::DRS_OK ) {
304 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
305 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
309 case SMESHOp::OpImportSTL:
312 aMeshes->length( 1 );
313 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
314 if ( aMeshes[0]->_is_nil() ) {
315 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
316 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
321 case SMESHOp::OpImportCGNS:
324 SMESH::DriverMED_ReadStatus res;
325 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
326 if ( res != SMESH::DRS_OK ) {
327 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
328 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
333 case SMESHOp::OpImportSAUV:
336 SMESH::DriverMED_ReadStatus res;
337 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
338 if ( res != SMESH::DRS_OK ) {
339 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
340 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
344 case SMESHOp::OpImportGMF:
347 SMESH::ComputeError_var res;
348 aMeshes->length( 1 );
349 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
352 if ( res->code != SMESH::DRS_OK ) {
353 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
354 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
355 if ( strlen( res->comment.in() ) > 0 ) {
356 errors.back() += ": ";
357 errors.back() += res->comment.in();
364 catch ( const SALOME::SALOME_Exception& S_ex ) {
365 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
366 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
369 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
370 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
372 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
373 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
374 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
375 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
376 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
378 anEntryList.append( aMeshSO->GetID().c_str() );
386 // update Object browser
387 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
389 // browse to the published meshes
390 if( LightApp_Application* anApp =
391 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
392 anApp->browseObjects( anEntryList );
394 // show Error message box if there were errors
395 if ( errors.count() > 0 ) {
396 SUIT_MessageBox::critical( SMESHGUI::desktop(),
397 QObject::tr( "SMESH_ERROR" ),
398 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
401 // show warning message box, if some imported mesh is empty
403 SUIT_MessageBox::warning( SMESHGUI::desktop(),
404 QObject::tr( "SMESH_WRN_WARNING" ),
405 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
410 //================================================================================
412 * \brief Export selected meshes or groups into a file
414 //================================================================================
416 void ExportMeshToFile( int theCommandID )
418 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
419 SALOME_ListIO selected;
421 aSel->selectedObjects( selected );
423 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT || theCommandID == SMESHOp::OpPopupExportDAT );
424 const bool isMED = ( theCommandID == SMESHOp::OpExportMED || theCommandID == SMESHOp::OpPopupExportMED );
425 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV || theCommandID == SMESHOp::OpPopupExportUNV );
426 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL || theCommandID == SMESHOp::OpPopupExportSTL );
428 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS || theCommandID == SMESHOp::OpPopupExportCGNS );
430 const bool isCGNS= false;
432 const bool isSAUV= ( theCommandID == SMESHOp::OpExportSAUV || theCommandID == SMESHOp::OpPopupExportSAUV );
433 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF || theCommandID == SMESHOp::OpPopupExportGMF );
435 // actually, the following condition can't be met (added for insurance)
436 if( selected.Extent() == 0 ||
437 ( selected.Extent() > 1 && !isMED && !isSTL ))
440 // get mesh object from selection and check duplication of their names
441 bool hasDuplicatedMeshNames = false;
442 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
443 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
444 SALOME_ListIteratorOfListIO It( selected );
445 for( ; It.More(); It.Next() )
447 Handle(SALOME_InteractiveObject) anIObject = It.Value();
448 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
449 if ( aMeshItem->_is_nil() ) {
450 SUIT_MessageBox::warning( SMESHGUI::desktop(),
451 QObject::tr( "SMESH_WRN_WARNING" ),
452 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
456 QString aMeshName = anIObject->getName();
458 // check for name duplications
459 if ( !hasDuplicatedMeshNames )
460 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
461 if( aMeshName == (*aMeshIter).second ) {
462 hasDuplicatedMeshNames = true;
467 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
470 if( hasDuplicatedMeshNames && isMED ) {
471 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
472 QObject::tr("SMESH_WRN_WARNING"),
473 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
474 QObject::tr("SMESH_BUT_YES"),
475 QObject::tr("SMESH_BUT_NO"), 0, 1);
480 aMeshIter = aMeshList.begin();
481 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
482 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
483 QString aMeshName = (*aMeshIter).second;
485 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
487 // check for equal group names within each mesh
488 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
489 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
490 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
491 int aRet = SUIT_MessageBox::warning
492 (SMESHGUI::desktop(),
493 QObject::tr("SMESH_WRN_WARNING"),
494 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
495 QObject::tr("SMESH_BUT_YES"),
496 QObject::tr("SMESH_BUT_NO"), 0, 1);
503 // Warn the user about presence of not supported elements
505 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
509 notSupportedElemTypes.push_back( SMESH::Entity_0D );
510 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
515 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
516 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
517 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
518 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
519 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
520 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
521 notSupportedElemTypes.push_back( SMESH::Entity_0D );
522 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
527 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
528 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
529 notSupportedElemTypes.push_back( SMESH::Entity_0D );
530 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
535 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
536 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
541 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
542 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
543 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
544 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
545 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
546 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
547 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
552 notSupportedElemTypes.push_back( SMESH::Entity_0D );
553 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
554 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
555 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
556 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
557 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
558 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
559 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
560 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
562 if ( ! notSupportedElemTypes.empty() )
564 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
565 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
566 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
567 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
569 if ( !presentNotSupported.empty() )
572 const char* typeMsg[SMESH::Entity_Last] = {
573 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
574 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
575 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
576 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
577 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
578 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
579 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
580 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
582 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
583 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
584 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
585 if ( iType != presentNotSupported.size() - 1 )
586 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
588 int aRet = SUIT_MessageBox::warning
589 (SMESHGUI::desktop(),
590 QObject::tr("SMESH_WRN_WARNING"),
591 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
592 QObject::tr("SMESH_BUT_YES"),
593 QObject::tr("SMESH_BUT_NO"), 0, 1);
598 // Get parameters of export operation
601 SMESH::MED_VERSION aFormat;
602 // Init the parameters with the default values
603 bool aIsASCII_STL = true;
604 bool toCreateGroups = false;
605 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
607 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
608 bool toOverwrite = true;
609 bool toFindOutDim = true;
611 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
612 QString anInitialPath = "";
613 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
614 anInitialPath = QDir::currentPath();
616 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
618 // Get a file name to write in and additional otions
619 if ( isUNV || isDAT || isGMF ) // Export w/o options
622 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
624 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
626 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
627 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
628 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
629 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
630 anInitialPath + QString("/") + aMeshName,
631 aFilter, aTitle, false);
633 else if ( isCGNS )// Export to CGNS
635 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
636 fd->setWindowTitle( aTitle );
637 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
638 if ( !anInitialPath.isEmpty() )
639 fd->setDirectory( anInitialPath );
640 fd->selectFile(aMeshName);
641 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
642 fd->setValidator( fv );
645 aFilename = fd->selectedFile();
646 toOverwrite = fv->isOverwrite();
650 else if ( isSTL ) // Export to STL
652 QMap<QString, int> aFilterMap;
653 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
654 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
657 QMap<QString, int>::const_iterator it = aFilterMap.begin();
658 for ( ; it != aFilterMap.end(); ++it )
659 filters.push_back( it.key() );
661 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
662 fd->setWindowTitle( aTitle );
663 fd->setNameFilters( filters );
664 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
665 if ( !anInitialPath.isEmpty() )
666 fd->setDirectory( anInitialPath );
667 fd->selectFile(aMeshName);
671 aFilename = fd->selectedFile();
672 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
677 else if ( isMED || isSAUV ) // Export to MED or SAUV
679 QMap<QString, SMESH::MED_VERSION> aFilterMap;
680 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
682 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
683 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
684 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
687 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
688 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
689 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
693 QString aDefaultFilter;
694 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
695 for ( ; it != aFilterMap.end(); ++it ) {
696 filters.push_back( it.key() );
697 if (it.value() == SMESH::MED_V2_2)
698 aDefaultFilter = it.key();
700 QStringList checkBoxes;
701 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
703 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
704 QList< QWidget* > wdgList;
705 if ( fieldSelWdg->GetAllFeilds( aMeshList, aFieldList ))
706 wdgList.append( fieldSelWdg );
708 SalomeApp_CheckFileDlg* fd =
709 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
710 fd->setWindowTitle( aTitle );
711 fd->setNameFilters( filters );
712 fd->selectNameFilter( aDefaultFilter );
713 fd->SetChecked( toCreateGroups, 0 );
714 fd->SetChecked( toFindOutDim, 1 );
715 if ( !anInitialPath.isEmpty() )
716 fd->setDirectory( anInitialPath );
717 fd->selectFile(aMeshName);
719 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
720 fd->setValidator( fv );
725 aFilename = fd->selectedFile();
727 aFilename = QString::null;
730 aFormat = aFilterMap[fd->selectedNameFilter()];
731 toOverwrite = fv->isOverwrite();
733 if ( !aFilename.isEmpty() ) {
734 // med-2.1 does not support poly elements
735 if ( aFormat==SMESH::MED_V2_1 )
736 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
737 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
738 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
739 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
740 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
742 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
743 QObject::tr("SMESH_WRN_WARNING"),
744 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
745 QObject::tr("SMESH_BUT_YES"),
746 QObject::tr("SMESH_BUT_NO"), 0, 1);
754 // can't append to an existing using other format
755 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
756 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
757 if( !isVersionOk || aVersion != aFormat ) {
758 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
759 QObject::tr("SMESH_WRN_WARNING"),
760 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
761 QObject::tr("SMESH_BUT_YES"),
762 QObject::tr("SMESH_BUT_NO"), 0, 1);
769 QStringList aMeshNamesCollisionList;
770 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
771 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
772 QString anExistingMeshName( aMeshNames[ i ] );
773 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
774 QString anExportMeshName = (*aMeshIter).second;
775 if( anExportMeshName == anExistingMeshName ) {
776 aMeshNamesCollisionList.append( anExportMeshName );
781 if( !aMeshNamesCollisionList.isEmpty() ) {
782 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
783 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
784 QObject::tr("SMESH_WRN_WARNING"),
785 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
786 QObject::tr("SMESH_BUT_YES"),
787 QObject::tr("SMESH_BUT_NO"),
788 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
797 toCreateGroups = fd->IsChecked(0);
798 toFindOutDim = fd->IsChecked(1);
799 fieldSelWdg->GetSelectedFeilds();
800 if ( !fieldSelWdg->parent() )
811 if ( !aFilename.isEmpty() ) {
812 // Check whether the file already exists and delete it if yes
813 QFile aFile( aFilename );
814 if ( aFile.exists() && toOverwrite )
816 SUIT_OverrideCursor wc;
819 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
820 // bool Renumber = false;
821 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
823 // Renumber= resMgr->booleanValue("renumbering");
825 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
826 // aMeshEditor->RenumberNodes();
827 // aMeshEditor->RenumberElements();
828 // if ( SMESHGUI::automaticUpdate() )
829 // SMESH::UpdateView();
833 aMeshIter = aMeshList.begin();
834 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
836 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
837 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
838 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
839 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
840 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
841 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
842 aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
843 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
845 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
846 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim,
847 fields, geoAssFields.toLatin1().data() );
852 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
854 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
855 if( !aMeshItem->_is_nil() )
856 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
861 if ( aMeshOrGroup->_is_equivalent( aMesh ))
862 aMesh->ExportDAT( aFilename.toUtf8().data() );
864 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
868 if ( aMeshOrGroup->_is_equivalent( aMesh ))
869 aMesh->ExportUNV( aFilename.toUtf8().data() );
871 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
875 if ( aMeshOrGroup->_is_equivalent( aMesh ))
876 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
878 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
882 aMeshIter = aMeshList.begin();
883 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
885 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
886 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
887 aMeshItem->ExportCGNS( aMeshOrGroup,
888 aFilename.toUtf8().data(),
889 toOverwrite && aMeshIndex == 0 );
894 toCreateGroups = true;
895 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
898 catch (const SALOME::SALOME_Exception& S_ex){
900 SUIT_MessageBox::warning(SMESHGUI::desktop(),
901 QObject::tr("SMESH_WRN_WARNING"),
902 QObject::tr("SMESH_EXPORT_FAILED"));
908 inline void InverseEntityMode(unsigned int& theOutputMode,
909 unsigned int theMode)
911 bool anIsNotPresent = ~theOutputMode & theMode;
913 theOutputMode |= theMode;
915 theOutputMode &= ~theMode;
918 void SetDisplayEntity(int theCommandID){
919 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
920 SALOME_ListIO selected;
922 aSel->selectedObjects( selected );
924 if(selected.Extent() >= 1){
925 SALOME_ListIteratorOfListIO It( selected );
926 for( ; It.More(); It.Next()){
927 Handle(SALOME_InteractiveObject) IObject = It.Value();
928 if(IObject->hasEntry()){
929 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
930 unsigned int aMode = anActor->GetEntityMode();
931 switch(theCommandID){
932 case SMESHOp::OpDE0DElements:
933 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
935 case SMESHOp::OpDEEdges:
936 InverseEntityMode(aMode,SMESH_Actor::eEdges);
938 case SMESHOp::OpDEFaces:
939 InverseEntityMode(aMode,SMESH_Actor::eFaces);
941 case SMESHOp::OpDEVolumes:
942 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
944 case SMESHOp::OpDEBalls:
945 InverseEntityMode(aMode,SMESH_Actor::eBallElem);
947 case SMESHOp::OpDEAllEntity:
948 aMode = SMESH_Actor::eAllEntity;
952 anActor->SetEntityMode(aMode);
961 SALOME_ListIO selected;
962 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
966 LightApp_SelectionMgr* aSel = app->selectionMgr();
967 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
968 if( !aSel || !appStudy )
971 aSel->selectedObjects( selected );
972 if( selected.IsEmpty() )
975 Handle(SALOME_InteractiveObject) anIObject = selected.First();
977 _PTR(Study) aStudy = appStudy->studyDS();
978 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
979 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
980 if( aMainObject->_is_nil() )
983 SUIT_OverrideCursor wc;
985 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
987 QList<SALOMEDS::Color> aReservedColors;
989 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
990 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
992 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
993 //SALOMEDS::Color aColor = aGroupObject->GetColor();
995 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
996 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
997 #else // old algorithm for auto-colors
998 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
999 aReservedColors.append( aColor );
1000 #endif // SIMPLE_AUTOCOLOR
1001 aGroupObject->SetColor( aColor );
1003 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1004 if (aGroupSObject) {
1007 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1008 switch ( aGroupObject->GetType ()) {
1010 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1012 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1014 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1016 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1018 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1019 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1022 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1023 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1029 SMESH::RepaintCurrentView();
1032 void OverallMeshQuality() {
1033 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1034 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1035 SALOME_ListIO selected;
1037 aSel->selectedObjects( selected );
1039 if ( selected.IsEmpty() ) return;
1040 SALOME_ListIteratorOfListIO It( selected );
1041 for ( ; It.More(); It.Next() ) {
1042 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1043 ctrlDlg->showInfo( It.Value() );
1048 QString functorToString( SMESH::Controls::FunctorPtr f )
1050 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1051 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1052 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1053 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1054 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1055 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1056 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1057 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1058 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1059 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1060 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1061 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1062 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1063 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1064 type = QObject::tr( "WARP_ELEMENTS" );
1065 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1066 type = QObject::tr( "TAPER_ELEMENTS" );
1067 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1068 type = QObject::tr( "SKEW_ELEMENTS" );
1069 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1070 type = QObject::tr( "AREA_ELEMENTS" );
1071 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1072 type = QObject::tr( "LENGTH_EDGES" );
1073 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1074 type = QObject::tr( "LENGTH2D_EDGES" );
1075 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1076 type = QObject::tr( "MULTI_BORDERS" );
1077 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1078 type = QObject::tr( "MULTI2D_BORDERS" );
1079 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1080 type = QObject::tr( "FREE_NODES" );
1081 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1082 type = QObject::tr( "FREE_EDGES" );
1083 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1084 type = QObject::tr( "FREE_BORDERS" );
1085 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1086 type = QObject::tr( "FREE_FACES" );
1087 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1088 type = QObject::tr( "BARE_BORDER_VOLUME" );
1089 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1090 type = QObject::tr( "BARE_BORDER_FACE" );
1091 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1092 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1093 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1094 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1095 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1096 type = QObject::tr( "EQUAL_NODE" );
1097 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1098 type = QObject::tr( "EQUAL_EDGE" );
1099 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1100 type = QObject::tr( "EQUAL_FACE" );
1101 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1102 type = QObject::tr( "EQUAL_VOLUME" );
1106 void SaveDistribution()
1108 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1109 SALOME_ListIO selected;
1111 aSel->selectedObjects( selected );
1113 if ( selected.Extent() == 1 ) {
1114 Handle(SALOME_InteractiveObject) anIO = selected.First();
1115 if ( anIO->hasEntry() ) {
1116 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1117 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1118 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1119 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1120 if ( aScalarBarActor && aFunctor ) {
1121 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1123 std::vector<int> elements;
1124 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1125 if ( mesh->_is_nil() ) {
1126 SMESH::SMESH_IDSource_var idSource =
1127 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1128 if ( !idSource->_is_nil() )
1130 SMESH::long_array_var ids = idSource->GetIDs();
1131 elements.resize( ids->length() );
1132 for ( unsigned i = 0; i < elements.size(); ++i )
1133 elements[i] = ids[i];
1136 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1137 vtkLookupTable* lookupTable =
1138 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1139 double * minmax = lookupTable->GetRange();
1140 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1141 std::vector<int> nbEvents;
1142 std::vector<double> funValues;
1143 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax, isLogarithmic );
1144 QString anInitialPath = "";
1145 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1146 anInitialPath = QDir::currentPath();
1147 QString aMeshName = anIO->getName();
1149 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1150 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1151 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1152 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1153 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1156 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1158 if ( !aFilename.isEmpty() ) {
1159 QFile f( aFilename );
1160 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1161 QTextStream out( &f );
1162 out << "# Mesh: " << aMeshName << endl;
1163 out << "# Control: " << functorToString( aFunctor ) << endl;
1165 out.setFieldWidth( 10 );
1166 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1167 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1178 void ShowDistribution() {
1179 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1180 SALOME_ListIO selected;
1182 aSel->selectedObjects( selected );
1184 if ( selected.Extent() == 1 ) {
1185 Handle(SALOME_InteractiveObject) anIO = selected.First();
1186 if ( anIO->hasEntry() ) {
1187 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1188 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1189 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1190 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1196 #ifndef DISABLE_PLOT2DVIEWER
1197 void PlotDistribution() {
1198 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1202 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1203 SALOME_ListIO selected;
1205 aSel->selectedObjects( selected );
1207 if ( selected.Extent() == 1 ) {
1208 Handle(SALOME_InteractiveObject) anIO = selected.First();
1209 if ( anIO->hasEntry() ) {
1210 //Find Actor by entry before getting Plot2d viewer,
1211 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1212 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1214 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1219 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1223 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1227 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1228 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1229 QString functorName = functorToString( anActor->GetFunctor());
1230 QString aHistogramName("%1 : %2");
1231 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1232 aHistogram->setName(aHistogramName);
1233 aHistogram->setHorTitle(functorName);
1234 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1235 aPlot->displayObject(aHistogram, true);
1240 #endif //DISABLE_PLOT2DVIEWER
1242 void DisableAutoColor(){
1243 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1244 SALOME_ListIO selected;
1246 aSel->selectedObjects( selected );
1248 if(selected.Extent()){
1249 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1250 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1251 if ( !aMesh->_is_nil() ) {
1252 aMesh->SetAutoColor( false );
1257 void sortChildren(){
1258 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1259 SALOME_ListIO selected;
1261 aSel->selectedObjects( selected );
1263 if(selected.Extent()){
1264 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1265 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1266 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1268 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1269 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1276 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1278 SALOME_ListIO selected;
1279 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1283 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1284 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1285 if( !aSel || !appStudy )
1288 if( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1289 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1290 aModule->EmitSignalDeactivateDialog();
1291 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1292 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1297 _PTR(Study) aStudy = appStudy->studyDS();
1299 aSel->selectedObjects( selected );
1301 if(selected.Extent() >= 1){
1302 switch(theCommandID){
1303 case SMESHOp::OpTransparency:{
1304 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1305 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1308 case SMESHOp::OpProperties: {
1310 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1311 QColor orientationColor, outlineColor, volumeColor;
1312 int deltaF = 0, deltaV = 0;
1315 double ballScale = 1.0;
1317 int outlineWidth = 1;
1318 double shrinkCoef = 0.0;
1319 double orientationScale = 0.0;
1320 bool orientation3d = false;
1321 VTK::MarkerType markerType = VTK::MT_NONE;
1322 VTK::MarkerScale markerScale = VTK::MS_NONE;
1324 bool hasNodes = false;
1325 int presentEntities = 0;
1326 bool firstTime = true;
1328 SALOME_ListIteratorOfListIO It( selected );
1329 for ( ; It.More(); It.Next() ) {
1330 Handle(SALOME_InteractiveObject) IObject = It.Value();
1331 if ( !IObject->hasEntry() ) continue;
1332 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1333 if ( !anActor || !anActor->GetObject() ) continue;
1336 // nodes: color, marker
1337 anActor->GetNodeColor( color[0], color[1], color[2] );
1338 nodeColor.setRgbF( color[0], color[1], color[2] );
1339 markerType = anActor->GetMarkerType();
1340 markerScale = anActor->GetMarkerScale();
1341 markerId = anActor->GetMarkerTexture();
1342 // edges: color, width
1343 anActor->GetEdgeColor( color[0], color[1], color[2] );
1344 edgeColor.setRgbF( color[0], color[1], color[2] );
1345 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1346 // faces: front color, back color (delta)
1347 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1348 faceColor.setRgbF( color[0], color[1], color[2] );
1349 // faces: front color, back color (delta)
1350 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1351 volumeColor.setRgbF( color[0], color[1], color[2] );
1352 // 0d elements: color, size
1353 anActor->Get0DColor( color[0], color[1], color[2] );
1354 elem0dColor.setRgbF( color[0], color[1], color[2] );
1355 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1356 // balls: color, size
1357 anActor->GetBallColor( color[0], color[1], color[2] );
1358 ballColor.setRgbF( color[0], color[1], color[2] );
1359 ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1360 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1362 anActor->GetOutlineColor( color[0], color[1], color[2] );
1363 outlineColor.setRgbF( color[0], color[1], color[2] );
1364 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1365 // orientation vectors: color, scale, 3d flag
1366 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1367 orientationColor.setRgbF( color[0], color[1], color[2] );
1368 orientationScale = anActor->GetFacesOrientationScale();
1369 orientation3d = anActor->GetFacesOrientation3DVectors();
1371 shrinkCoef = anActor->GetShrinkFactor();
1374 firstTime = false; // we only take properties from first object (for performance reasons)
1377 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1378 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1379 presentEntities = presentEntities | SMESH_Actor::eEdges;
1380 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1381 presentEntities = presentEntities | SMESH_Actor::eFaces;
1382 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1383 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1384 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1385 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1386 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1387 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1389 // as we know that all types of elements are present, we can exit the loop
1390 if ( presentEntities == SMESH_Actor::eAllEntity )
1394 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1395 // nodes: color, marker
1396 dlg.setNodeColor( nodeColor );
1397 if( markerType != VTK::MT_USER )
1398 dlg.setNodeMarker( markerType, markerScale );
1400 dlg.setNodeCustomMarker( markerId );
1401 // edges: color, line width
1402 dlg.setEdgeColor( edgeColor );
1403 dlg.setEdgeWidth( edgeWidth );
1404 // faces: front color, back color
1405 dlg.setFaceColor( faceColor, deltaF );
1406 // volumes: normal color, reversed color
1407 dlg.setVolumeColor( volumeColor, deltaV );
1408 // outlines: color, line width
1409 dlg.setOutlineColor( outlineColor );
1410 dlg.setOutlineWidth( outlineWidth );
1411 // 0d elements: color, size
1412 dlg.setElem0dColor( elem0dColor );
1413 dlg.setElem0dSize( elem0dSize );
1414 // balls: color, size
1415 dlg.setBallColor( ballColor );
1416 dlg.setBallSize( ballSize );
1417 dlg.setBallScale( ballScale );
1418 // orientation: color, scale, 3d flag
1419 dlg.setOrientationColor( orientationColor );
1420 dlg.setOrientationSize( int( orientationScale * 100. ) );
1421 dlg.setOrientation3d( orientation3d );
1422 // shrink: scale factor
1423 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1424 // hide unused controls
1425 dlg.showControls( presentEntities, hasNodes );
1428 nodeColor = dlg.nodeColor();
1429 markerType = dlg.nodeMarkerType();
1430 markerScale = dlg.nodeMarkerScale();
1431 markerId = dlg.nodeMarkerId();
1432 edgeColor = dlg.edgeColor();
1433 edgeWidth = dlg.edgeWidth();
1434 faceColor = dlg.faceColor();
1435 deltaF = dlg.faceColorDelta();
1436 volumeColor = dlg.volumeColor();
1437 deltaV = dlg.volumeColorDelta();
1438 outlineColor = dlg.outlineColor();
1439 outlineWidth = dlg.outlineWidth();
1440 elem0dColor = dlg.elem0dColor();
1441 elem0dSize = dlg.elem0dSize();
1442 ballColor = dlg.ballColor();
1443 ballSize = dlg.ballSize();
1444 ballScale = dlg.ballScale();
1445 orientationColor = dlg.orientationColor();
1446 orientationScale = dlg.orientationSize() / 100.;
1447 orientation3d = dlg.orientation3d();
1448 shrinkCoef = dlg.shrinkCoef() / 100.;
1450 // store point markers map that might be changed by the user
1451 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1453 // set properties from dialog box to the presentations
1454 SALOME_ListIteratorOfListIO It( selected );
1455 for ( ; It.More(); It.Next() ) {
1456 Handle(SALOME_InteractiveObject) IObject = It.Value();
1457 if ( !IObject->hasEntry() ) continue;
1458 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1459 if ( !anActor ) continue;
1461 // nodes: color, marker
1462 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1463 if ( markerType != VTK::MT_USER ) {
1464 anActor->SetMarkerStd( markerType, markerScale );
1467 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1468 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1469 if ( iter != markerMap.end() )
1470 anActor->SetMarkerTexture( markerId, iter->second.second );
1472 // volumes: normal color, reversed color (delta)
1473 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1474 // faces: front color, back color (delta)
1475 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1476 // edges: color, width
1477 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1478 anActor->SetLineWidth( edgeWidth );
1480 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1481 anActor->SetOutlineWidth( outlineWidth );
1482 // 0D elements: color, size
1483 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1484 anActor->Set0DSize( elem0dSize );
1485 // balls: color, size
1486 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1487 anActor->SetBallSize( ballSize );
1488 anActor->SetBallScale( ballScale );
1489 // orientation: color, scale, 3d flag
1490 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1491 anActor->SetFacesOrientationScale( orientationScale );
1492 anActor->SetFacesOrientation3DVectors( orientation3d );
1494 anActor->SetShrinkFactor( shrinkCoef );
1496 // for groups, set also proper color
1497 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1498 if ( !aGroupObject->_is_nil() ) {
1499 SMESH::ElementType anElementType = aGroupObject->GetType();
1501 switch( anElementType ) {
1503 aColor = nodeColor; break;
1505 aColor = edgeColor; break;
1507 aColor = faceColor; break;
1509 aColor = volumeColor; break;
1511 aColor = elem0dColor; break;
1513 aColor = ballColor; break;
1517 if ( aColor.isValid() ) {
1518 SALOMEDS::Color aGroupColor;
1519 aGroupColor.R = aColor.redF();
1520 aGroupColor.G = aColor.greenF();
1521 aGroupColor.B = aColor.blueF();
1522 aGroupObject->SetColor( aGroupColor );
1524 } // if ( !aGroupObject->_is_nil() )
1525 } // for ( ; It.More(); It.Next() )
1526 SMESH::RepaintCurrentView();
1527 } // if ( dlg.exec() )
1529 } // case SMESHOp::OpProperties:
1530 } // switch(theCommandID)
1531 SALOME_ListIteratorOfListIO It( selected );
1532 for( ; It.More(); It.Next()){
1533 Handle(SALOME_InteractiveObject) IObject = It.Value();
1534 if(IObject->hasEntry()){
1535 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1536 switch(theCommandID){
1537 case SMESHOp::OpDMWireframe:
1538 anActor->SetRepresentation(SMESH_Actor::eEdge);
1540 case SMESHOp::OpDMShading:
1541 anActor->SetRepresentation(SMESH_Actor::eSurface);
1543 case SMESHOp::OpDMShrink:
1544 if(anActor->IsShrunk())
1545 anActor->UnShrink();
1547 anActor->SetShrink();
1549 case SMESHOp::OpDMNodes:
1550 anActor->SetRepresentation(SMESH_Actor::ePoint);
1552 case SMESHOp::OpRepresentationLines:
1553 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1554 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1556 case SMESHOp::OpRepresentationArcs:
1557 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1558 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1564 SMESH::RepaintCurrentView();
1568 void Control( int theCommandID )
1570 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1571 switch ( theCommandID ){
1572 case SMESHOp::OpFreeNode:
1573 aControl = SMESH_Actor::eFreeNodes;
1575 case SMESHOp::OpEqualNode:
1576 aControl = SMESH_Actor::eCoincidentNodes;
1578 case SMESHOp::OpFreeEdge:
1579 aControl = SMESH_Actor::eFreeEdges;
1581 case SMESHOp::OpFreeBorder:
1582 aControl = SMESH_Actor::eFreeBorders;
1584 case SMESHOp::OpLength:
1585 aControl = SMESH_Actor::eLength;
1587 case SMESHOp::OpConnection:
1588 aControl = SMESH_Actor::eMultiConnection;
1590 case SMESHOp::OpEqualEdge:
1591 aControl = SMESH_Actor::eCoincidentElems1D;
1593 case SMESHOp::OpFreeFace:
1594 aControl = SMESH_Actor::eFreeFaces;
1596 case SMESHOp::OpBareBorderFace:
1597 aControl = SMESH_Actor::eBareBorderFace;
1599 case SMESHOp::OpOverConstrainedFace:
1600 aControl = SMESH_Actor::eOverConstrainedFace;
1602 case SMESHOp::OpLength2D:
1603 aControl = SMESH_Actor::eLength2D;
1605 case SMESHOp::OpConnection2D:
1606 aControl = SMESH_Actor::eMultiConnection2D;
1608 case SMESHOp::OpArea:
1609 aControl = SMESH_Actor::eArea;
1611 case SMESHOp::OpTaper:
1612 aControl = SMESH_Actor::eTaper;
1614 case SMESHOp::OpAspectRatio:
1615 aControl = SMESH_Actor::eAspectRatio;
1617 case SMESHOp::OpMinimumAngle:
1618 aControl = SMESH_Actor::eMinimumAngle;
1620 case SMESHOp::OpWarpingAngle:
1621 aControl = SMESH_Actor::eWarping;
1623 case SMESHOp::OpSkew:
1624 aControl = SMESH_Actor::eSkew;
1626 case SMESHOp::OpMaxElementLength2D:
1627 aControl = SMESH_Actor::eMaxElementLength2D;
1629 case SMESHOp::OpEqualFace:
1630 aControl = SMESH_Actor:: eCoincidentElems2D;
1632 case SMESHOp::OpAspectRatio3D:
1633 aControl = SMESH_Actor::eAspectRatio3D;
1635 case SMESHOp::OpVolume:
1636 aControl = SMESH_Actor::eVolume3D;
1638 case SMESHOp::OpMaxElementLength3D:
1639 aControl = SMESH_Actor::eMaxElementLength3D;
1641 case SMESHOp::OpBareBorderVolume:
1642 aControl = SMESH_Actor::eBareBorderVolume;
1644 case SMESHOp::OpOverConstrainedVolume:
1645 aControl = SMESH_Actor::eOverConstrainedVolume;
1647 case SMESHOp::OpEqualVolume:
1648 aControl = SMESH_Actor::eCoincidentElems3D;
1651 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1652 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1653 SALOME_ListIO selected;
1655 aSel->selectedObjects( selected );
1657 if( !selected.IsEmpty() ){
1658 SALOME_ListIteratorOfListIO It(selected);
1659 for ( ; It.More(); It.Next())
1661 Handle(SALOME_InteractiveObject) anIO = It.Value();
1663 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1665 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1666 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
1667 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
1668 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
1669 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
1670 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1671 anActor->SetControlMode(aControl);
1672 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1673 SMESH::RepaintCurrentView();
1674 #ifndef DISABLE_PLOT2DVIEWER
1675 if(anActor->GetPlot2Histogram()) {
1676 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1677 QString functorName = functorToString( anActor->GetFunctor());
1678 QString aHistogramName("%1 : %2");
1679 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1680 aHistogram->setName(aHistogramName);
1681 aHistogram->setHorTitle(functorName);
1682 SMESH::ProcessIn2DViewers(anActor);
1694 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1695 SMESH::MeshObjectType theType,
1696 const QString theInTypeName,
1697 QString & theOutTypeName)
1699 SMESH_TypeFilter aTypeFilter( theType );
1701 if( !theIO.IsNull() )
1703 entry = theIO->getEntry();
1704 LightApp_DataOwner owner( entry );
1705 if ( aTypeFilter.isOk( &owner )) {
1706 theOutTypeName = theInTypeName;
1714 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1716 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1717 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1719 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1720 CORBA::String_var anID = aSComp->GetID().c_str();
1721 if (!strcmp(anID.in(),theIO->getEntry()))
1727 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1728 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1729 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1730 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1731 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1739 QString CheckHomogeneousSelection()
1741 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1742 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1743 SALOME_ListIO selected;
1745 aSel->selectedObjects( selected );
1747 QString RefType = CheckTypeObject(selected.First());
1748 SALOME_ListIteratorOfListIO It(selected);
1749 for ( ; It.More(); It.Next())
1751 Handle(SALOME_InteractiveObject) IObject = It.Value();
1752 QString Type = CheckTypeObject(IObject);
1753 if (Type.compare(RefType) != 0)
1754 return "Heterogeneous Selection";
1762 void SMESHGUI::OnEditDelete()
1764 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1765 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1766 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1768 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1769 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1770 _PTR(GenericAttribute) anAttr;
1771 _PTR(AttributeIOR) anIOR;
1773 int objectCount = 0;
1775 QString aParentComponent = QString::null;
1776 Handle(SALOME_InteractiveObject) anIO;
1777 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1779 anIO = anIt.Value();
1780 QString cur = anIO->getComponentDataType();
1781 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1783 // check if object is reference
1784 _PTR(SObject) aRefSObj;
1785 aNameList.append("\n - ");
1786 if ( aSO->ReferencedObject( aRefSObj ) ) {
1787 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1788 aNameList.append( aRefName );
1789 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1792 aNameList.append(anIO->getName());
1796 if( aParentComponent.isNull() )
1797 aParentComponent = cur;
1798 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1799 aParentComponent = "";
1802 if ( objectCount == 0 )
1803 return; // No Valid Objects Selected
1805 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1806 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1807 QObject::tr("ERR_ERROR"),
1808 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1811 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1812 if (SUIT_MessageBox::warning
1813 (SMESHGUI::desktop(),
1814 QObject::tr("SMESH_WRN_WARNING"),
1815 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1816 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1817 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1820 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1822 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1823 // then treat them all starting from the deepest objects (at list back)
1824 std::list< _PTR(SObject) > listSO;
1825 SALOME_ListIteratorOfListIO It(selected);
1826 for( ; It.More(); It.Next()) // loop on selected IO's
1828 Handle(SALOME_InteractiveObject) IObject = It.Value();
1829 if(IObject->hasEntry()) {
1830 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1832 // disable removal of "SMESH" component object
1833 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1835 if ( engineIOR() == anIOR->Value().c_str() )
1838 //Check the referenced object
1839 _PTR(SObject) aRefSObject;
1840 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1841 aSO = aRefSObject; // Delete main Object instead of reference
1843 listSO.push_back( aSO );
1844 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1845 for ( ; itSO != listSO.end(); ++itSO ) {
1846 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1847 for (it->InitEx(false); it->More(); it->Next())
1848 listSO.push_back( it->Value() );
1852 // Check if none of objects to delete is referred from outside
1853 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1854 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1856 _PTR(SObject) SO = *ritSO;
1857 if ( !SO ) continue;
1858 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1859 for (size_t i = 0; i < aReferences.size(); i++) {
1860 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1861 std::string type = aComponent->ComponentDataType();
1862 if ( type != "SMESH" )
1864 SUIT_MessageBox::warning( anApp->desktop(),
1865 QObject::tr("WRN_WARNING"),
1866 QObject::tr("DEP_OBJECT") );
1867 return; // outside SMESH, there is an object depending on a SMESH object
1872 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1873 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1875 Handle(SALOME_InteractiveObject) IObject = It.Value();
1876 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1877 if ( !mesh->_is_nil() )
1881 // Treat SO's in the list starting from the back
1882 aStudyBuilder->NewCommand(); // There is a transaction
1883 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1885 _PTR(SObject) SO = *ritSO;
1886 if ( !SO ) continue;
1887 std::string anEntry = SO->GetID();
1889 /** Erase graphical object and remove all its data **/
1890 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1891 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1893 /** Remove an object from data structures **/
1894 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1895 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1896 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1897 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1898 aMesh->RemoveGroup( aGroup );
1900 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1901 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1902 aMesh->RemoveSubMesh( aSubMesh );
1904 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1906 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1909 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1910 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1911 QString objType = CheckTypeObject(IObject);
1912 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1913 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1914 aStudyBuilder->RemoveObjectWithChildren( SO );
1916 else {// default action: remove SObject from the study
1917 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1918 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1920 aStudyBuilder->RemoveObjectWithChildren( SO );
1924 } /* listSO back loop */
1926 aStudyBuilder->CommitCommand();
1928 /* Clear any previous selection */
1930 aSel->setSelectedObjects( l1 );
1932 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1936 SMESHGUI_EXPORT CAM_Module* createModule()
1938 return new SMESHGUI();
1941 SMESHGUI_EXPORT char* getModuleVersion() {
1942 return (char*)SMESH_VERSION_STR;
1946 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1948 //=============================================================================
1952 //=============================================================================
1953 SMESHGUI::SMESHGUI() :
1954 SalomeApp_Module( "SMESH" )
1956 if ( CORBA::is_nil( myComponentSMESH ) )
1958 CORBA::Boolean anIsEmbeddedMode;
1959 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1960 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1962 // 0019923: EDF 765 SMESH : default values of hypothesis
1963 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1964 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1965 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1966 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1967 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1969 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1970 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1971 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1973 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1974 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1978 myActiveDialogBox = 0;
1979 myFilterLibraryDlg = 0;
1983 myEventCallbackCommand = vtkCallbackCommand::New();
1984 myEventCallbackCommand->Delete();
1985 myEventCallbackCommand->SetClientData( this );
1986 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1989 /* load resources for all available meshers */
1990 SMESH::InitAvailableHypotheses();
1993 //=============================================================================
1997 //=============================================================================
1998 SMESHGUI::~SMESHGUI()
2002 //=============================================================================
2006 //=============================================================================
2007 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2009 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2011 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2016 //=============================================================================
2020 //=============================================================================
2021 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2023 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2027 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2028 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2029 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2030 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2031 return autoUpdate && !exceeded;
2034 //=============================================================================
2038 //=============================================================================
2039 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2040 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2042 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2046 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2047 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2048 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2050 SMESH::long_array_var info = theMesh->GetMeshInfo();
2051 long nbOdElems = info[SMDSEntity_0D];
2052 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2053 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2054 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2055 info[SMDSEntity_Polygon];
2056 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2057 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2058 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2059 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] +
2060 info[SMDSEntity_Polyhedra] +
2061 info[SMDSEntity_Hexagonal_Prism];
2062 long nbBalls = info[SMDSEntity_Ball];
2064 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2065 *nbElements = requestedSize;
2067 *entities = SMESH_Actor::eAllEntity;
2070 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2072 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2074 if ( incrementalLimit ) {
2077 if ( nbOdElems > 0 ) {
2078 if ( total + nbOdElems > updateLimit ) {
2079 *entities = *entities & ~SMESH_Actor::e0DElements;
2080 *hidden = *hidden | SMESH_Actor::e0DElements;
2087 if ( nbEdges > 0 ) {
2088 if ( total + nbEdges > updateLimit ) {
2089 *entities = *entities & ~SMESH_Actor::eEdges;
2090 *hidden = *hidden | SMESH_Actor::eEdges;
2097 if ( nbFaces > 0 ) {
2098 if ( total + nbFaces > updateLimit ) {
2099 *entities = *entities & ~SMESH_Actor::eFaces;
2100 *hidden = *hidden | SMESH_Actor::eFaces;
2107 if ( nbVolumes > 0 ) {
2108 if ( total + nbVolumes > updateLimit ) {
2109 *entities = *entities & ~SMESH_Actor::eVolumes;
2110 *hidden = *hidden | SMESH_Actor::eVolumes;
2117 if ( nbBalls > 0 ) {
2118 if ( total + nbBalls > updateLimit ) {
2119 *entities = *entities & ~SMESH_Actor::eBallElem;
2120 *hidden = *hidden | SMESH_Actor::eBallElem;
2128 return autoUpdate && !exceeded;
2131 //=============================================================================
2135 //=============================================================================
2136 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2138 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2141 //=============================================================================
2145 //=============================================================================
2146 SMESHGUI* SMESHGUI::GetSMESHGUI()
2148 SMESHGUI* smeshMod = 0;
2149 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2152 CAM_Module* module = app->module( "Mesh" );
2153 smeshMod = dynamic_cast<SMESHGUI*>( module );
2156 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2158 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2161 _PTR(Study) aStudy = study->studyDS();
2163 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2172 Standard_EXPORT SMESHGUI* GetComponentGUI()
2174 return SMESHGUI::GetSMESHGUI();
2178 //=============================================================================
2182 //=============================================================================
2183 void SMESHGUI::SetState(int aState)
2188 //=============================================================================
2192 //=============================================================================
2193 void SMESHGUI::ResetState()
2198 //=============================================================================
2202 //=============================================================================
2203 void SMESHGUI::EmitSignalDeactivateDialog()
2205 emit SignalDeactivateActiveDialog();
2208 //=============================================================================
2212 //=============================================================================
2213 void SMESHGUI::EmitSignalStudyFrameChanged()
2215 emit SignalStudyFrameChanged();
2218 //=============================================================================
2222 //=============================================================================
2223 void SMESHGUI::EmitSignalCloseAllDialogs()
2225 emit SignalCloseAllDialogs();
2228 //=============================================================================
2232 //=============================================================================
2233 void SMESHGUI::EmitSignalVisibilityChanged()
2235 emit SignalVisibilityChanged();
2238 //=============================================================================
2242 //=============================================================================
2243 QDialog *SMESHGUI::GetActiveDialogBox()
2245 return myActiveDialogBox;
2248 //=============================================================================
2252 //=============================================================================
2253 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2255 myActiveDialogBox = (QDialog *) aDlg;
2259 //=============================================================================
2263 //=============================================================================
2264 SUIT_Desktop* SMESHGUI::desktop()
2266 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2268 return app->desktop();
2273 //=============================================================================
2277 //=============================================================================
2278 SalomeApp_Study* SMESHGUI::activeStudy()
2280 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2282 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2287 //=============================================================================
2291 //=============================================================================
2292 void SMESHGUI::Modified( bool theIsUpdateActions )
2294 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2295 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2296 appStudy->Modified();
2297 if( theIsUpdateActions )
2298 app->updateActions();
2303 //=============================================================================
2307 //=============================================================================
2308 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2310 /* Here the position is on the bottom right corner - 10 */
2311 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2313 SUIT_Desktop *PP = desktop();
2314 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2315 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2319 //=============================================================================
2323 //=============================================================================
2324 static int isStudyLocked(_PTR(Study) theStudy){
2325 return theStudy->GetProperties()->IsLocked();
2328 static bool checkLock(_PTR(Study) theStudy) {
2329 if (isStudyLocked(theStudy)) {
2330 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2331 QObject::tr("WRN_WARNING"),
2332 QObject::tr("WRN_STUDY_LOCKED") );
2338 //=======================================================================
2339 //function : CheckActiveStudyLocked
2341 //=======================================================================
2343 bool SMESHGUI::isActiveStudyLocked()
2345 _PTR(Study) aStudy = activeStudy()->studyDS();
2346 return checkLock( aStudy );
2349 //=============================================================================
2353 //=============================================================================
2354 bool SMESHGUI::OnGUIEvent( int theCommandID )
2356 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2360 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2361 SUIT_ResourceMgr* mgr = resourceMgr();
2365 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2366 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2369 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2370 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2372 //QAction* act = action( theCommandID );
2374 switch (theCommandID) {
2375 case SMESHOp::OpDelete:
2376 if(checkLock(aStudy)) break;
2379 case SMESHOp::OpImportDAT:
2380 case SMESHOp::OpImportUNV:
2381 case SMESHOp::OpImportMED:
2382 case SMESHOp::OpImportSTL:
2384 case SMESHOp::OpImportCGNS:
2386 case SMESHOp::OpImportSAUV:
2387 case SMESHOp::OpImportGMF:
2389 if(checkLock(aStudy)) break;
2390 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2394 case SMESHOp::OpFileInformation:
2396 SALOME_ListIO selected;
2397 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2399 aSel->selectedObjects( selected );
2400 if( selected.Extent() )
2402 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2403 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2404 if ( !aMesh->_is_nil() )
2406 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2412 case SMESHOp::OpExportDAT:
2413 case SMESHOp::OpExportMED:
2414 case SMESHOp::OpExportUNV:
2415 case SMESHOp::OpExportSTL:
2417 case SMESHOp::OpExportCGNS:
2419 case SMESHOp::OpExportSAUV:
2420 case SMESHOp::OpExportGMF:
2421 case SMESHOp::OpPopupExportDAT:
2422 case SMESHOp::OpPopupExportMED:
2423 case SMESHOp::OpPopupExportUNV:
2424 case SMESHOp::OpPopupExportSTL:
2426 case SMESHOp::OpPopupExportCGNS:
2428 case SMESHOp::OpPopupExportSAUV:
2429 case SMESHOp::OpPopupExportGMF:
2431 ::ExportMeshToFile(theCommandID);
2435 case SMESHOp::OpReset: // SCALAR BAR
2437 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2438 SALOME_ListIO selected;
2440 aSel->selectedObjects( selected );
2442 if( selected.Extent() ) {
2443 Handle(SALOME_InteractiveObject) anIO = selected.First();
2444 if( anIO->hasEntry() ) {
2445 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2446 anActor->SetControlMode( SMESH_Actor::eNone );
2447 #ifndef DISABLE_PLOT2DVIEWER
2448 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2455 case SMESHOp::OpScalarBarProperties:
2457 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2460 case SMESHOp::OpSaveDistribution:
2462 // dump control distribution data to the text file
2463 ::SaveDistribution();
2467 case SMESHOp::OpShowDistribution:
2469 // show/ distribution
2470 ::ShowDistribution();
2474 #ifndef DISABLE_PLOT2DVIEWER
2475 case SMESHOp::OpPlotDistribution:
2477 // plot distribution
2478 ::PlotDistribution();
2484 case SMESHOp::OpAutoColor:
2488 case SMESHOp::OpDisableAutoColor:
2489 ::DisableAutoColor();
2492 case SMESHOp::OpClipping:
2493 case SMESHOp::OpTransparency:
2494 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2497 case SMESHOp::OpDMWireframe:
2498 case SMESHOp::OpDMShading:
2499 case SMESHOp::OpDMNodes:
2500 case SMESHOp::OpDMShrink:
2501 ::SetDisplayMode(theCommandID, myMarkerMap);
2504 //2D quadratic representation
2505 case SMESHOp::OpRepresentationLines:
2506 case SMESHOp::OpRepresentationArcs:
2507 ::SetDisplayMode(theCommandID, myMarkerMap);
2511 case SMESHOp::OpDE0DElements:
2512 case SMESHOp::OpDEEdges:
2513 case SMESHOp::OpDEFaces:
2514 case SMESHOp::OpDEVolumes:
2515 case SMESHOp::OpDEBalls:
2516 case SMESHOp::OpDEAllEntity:
2517 ::SetDisplayEntity(theCommandID);
2520 // Choose entities to be displayed
2521 case SMESHOp::OpDEChoose:
2523 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2527 case SMESHOp::OpOrientationOnFaces:
2529 LightApp_SelectionMgr* mgr = selectionMgr();
2530 SALOME_ListIO selected; mgr->selectedObjects( selected );
2532 SALOME_ListIteratorOfListIO it(selected);
2533 for( ; it.More(); it.Next()) {
2534 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2535 if(anIObject->hasEntry()) {
2536 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2537 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2544 case SMESHOp::OpUpdate:
2546 if(checkLock(aStudy)) break;
2547 SUIT_OverrideCursor wc;
2549 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2552 SMESH::UpdateView();
2554 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2555 SMESH::OnVisuException();
2557 catch (...) { // PAL16774 (Crash after display of many groups)
2558 SMESH::OnVisuException();
2562 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2563 aSel->selectedObjects( l );
2564 aSel->setSelectedObjects( l );
2568 case SMESHOp::OpHide:
2569 case SMESHOp::OpShow:
2570 case SMESHOp::OpShowOnly:
2572 SMESH::EDisplaing anAction;
2573 switch (theCommandID) {
2574 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2575 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2576 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2579 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2580 SALOME_ListIO sel_objects, to_process;
2582 aSel->selectedObjects( sel_objects );
2584 if( theCommandID==SMESHOp::OpShowOnly )
2586 MESSAGE("anAction = SMESH::eDisplayOnly");
2587 startOperation( myEraseAll );
2590 extractContainers( sel_objects, to_process );
2593 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2597 SALOME_ListIteratorOfListIO It( to_process );
2598 for ( ; It.More(); It.Next()) {
2600 Handle(SALOME_InteractiveObject) IOS = It.Value();
2601 if (IOS->hasEntry()) {
2603 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2604 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2605 break; // PAL16774 (Crash after display of many groups)
2607 if (anAction == SMESH::eDisplayOnly)
2609 MESSAGE("anAction = SMESH::eDisplayOnly");
2610 anAction = SMESH::eDisplay;
2616 // PAL13338 + PAL15161 -->
2617 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !checkLock(aStudy)) {
2618 MESSAGE("anAction = SMESH::eDisplayOnly");
2619 SMESH::UpdateView();
2620 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2622 // PAL13338 + PAL15161 <--
2624 catch (...) { // PAL16774 (Crash after display of many groups)
2625 SMESH::OnVisuException();
2628 if (anAction == SMESH::eErase) {
2629 MESSAGE("anAction == SMESH::eErase");
2631 aSel->setSelectedObjects( l1 );
2634 aSel->setSelectedObjects( to_process );
2639 case SMESHOp::OpNode:
2641 if(checkLock(aStudy)) break;
2644 EmitSignalDeactivateDialog();
2646 ( new SMESHGUI_NodesDlg( this ) )->show();
2649 SUIT_MessageBox::warning(desktop(),
2650 tr("SMESH_WRN_WARNING"),
2651 tr("SMESH_WRN_VIEWER_VTK"));
2656 case SMESHOp::OpCreateMesh:
2657 case SMESHOp::OpCreateSubMesh:
2658 case SMESHOp::OpEditMeshOrSubMesh:
2659 case SMESHOp::OpCompute:
2660 case SMESHOp::OpPreCompute:
2661 case SMESHOp::OpEvaluate:
2662 case SMESHOp::OpMeshOrder:
2663 startOperation( theCommandID );
2665 case SMESHOp::OpCopyMesh:
2667 if (checkLock(aStudy)) break;
2668 EmitSignalDeactivateDialog();
2669 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2672 case SMESHOp::OpBuildCompoundMesh:
2674 if (checkLock(aStudy)) break;
2675 EmitSignalDeactivateDialog();
2676 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2680 case SMESHOp::OpDiagonalInversion:
2681 case SMESHOp::OpUnionOfTwoTriangle:
2685 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2686 tr( "NOT_A_VTK_VIEWER" ) );
2690 if ( checkLock( aStudy ) )
2693 /*Standard_Boolean aRes;
2694 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2695 if ( aMesh->_is_nil() )
2697 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2698 tr( "SMESH_BAD_SELECTION" ) );
2702 EmitSignalDeactivateDialog();
2703 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2704 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2706 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2709 case SMESHOp::OpOrientation:
2710 case SMESHOp::OpUnionOfTriangles:
2711 case SMESHOp::OpCuttingOfQuadrangles:
2712 case SMESHOp::OpSplitVolumes:
2716 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2717 tr( "NOT_A_VTK_VIEWER" ) );
2721 if ( checkLock( aStudy ) )
2724 EmitSignalDeactivateDialog();
2725 SMESHGUI_MultiEditDlg* aDlg = NULL;
2726 if ( theCommandID == SMESHOp::OpOrientation )
2727 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2728 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2729 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2730 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2731 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2733 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2738 case SMESHOp::OpSmoothing:
2740 if(checkLock(aStudy)) break;
2742 EmitSignalDeactivateDialog();
2743 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2746 SUIT_MessageBox::warning(desktop(),
2747 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2751 case SMESHOp::OpExtrusion:
2753 if (checkLock(aStudy)) break;
2755 EmitSignalDeactivateDialog();
2756 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2758 SUIT_MessageBox::warning(desktop(),
2759 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2763 case SMESHOp::OpExtrusionAlongAPath:
2765 if (checkLock(aStudy)) break;
2767 EmitSignalDeactivateDialog();
2768 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2770 SUIT_MessageBox::warning(desktop(),
2771 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2775 case SMESHOp::OpRevolution:
2777 if(checkLock(aStudy)) break;
2779 EmitSignalDeactivateDialog();
2780 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2783 SUIT_MessageBox::warning(desktop(),
2784 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2788 case SMESHOp::OpPatternMapping:
2790 if ( checkLock( aStudy ) )
2794 EmitSignalDeactivateDialog();
2795 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2798 SUIT_MessageBox::warning(desktop(),
2799 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2803 case SMESHOp::OpConvertMeshToQuadratic:
2804 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
2805 case SMESHOp::OpReorientFaces:
2806 case SMESHOp::OpCreateGeometryGroup:
2808 startOperation( theCommandID );
2811 case SMESHOp::OpCreateGroup:
2815 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2816 tr( "NOT_A_VTK_VIEWER" ) );
2820 if(checkLock(aStudy)) break;
2821 EmitSignalDeactivateDialog();
2822 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2824 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2825 SALOME_ListIO selected;
2827 aSel->selectedObjects( selected );
2829 int nbSel = selected.Extent();
2831 // check if mesh is selected
2832 aMesh = SMESH::GetMeshByIO( selected.First() );
2834 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2839 case SMESHOp::OpConstructGroup:
2843 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2844 tr( "NOT_A_VTK_VIEWER" ) );
2848 if(checkLock(aStudy)) break;
2849 EmitSignalDeactivateDialog();
2851 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2852 SALOME_ListIO selected;
2854 aSel->selectedObjects( selected );
2856 int nbSel = selected.Extent();
2858 // check if submesh is selected
2859 Handle(SALOME_InteractiveObject) IObject = selected.First();
2860 if (IObject->hasEntry()) {
2861 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2863 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2864 if (!aSubMesh->_is_nil()) {
2866 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2867 // get submesh elements list by types
2868 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2869 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2870 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2871 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2872 // create group for each type o elements
2873 QString aName = IObject->getName();
2874 QStringList anEntryList;
2875 if (aNodes->length() > 0) {
2876 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2877 aGroup->Add(aNodes.inout());
2878 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2879 anEntryList.append( aSObject->GetID().c_str() );
2881 if (aEdges->length() > 0) {
2882 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2883 aGroup->Add(aEdges.inout());
2884 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2885 anEntryList.append( aSObject->GetID().c_str() );
2887 if (aFaces->length() > 0) {
2888 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2889 aGroup->Add(aFaces.inout());
2890 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2891 anEntryList.append( aSObject->GetID().c_str() );
2893 if (aVolumes->length() > 0) {
2894 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2895 aGroup->Add(aVolumes.inout());
2896 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2897 anEntryList.append( aSObject->GetID().c_str() );
2900 anApp->browseObjects( anEntryList );
2902 catch(const SALOME::SALOME_Exception & S_ex){
2903 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2910 SUIT_MessageBox::warning(desktop(),
2911 tr("SMESH_WRN_WARNING"),
2912 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2917 case SMESHOp::OpEditGroup:
2921 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2922 tr( "NOT_A_VTK_VIEWER" ) );
2926 if(checkLock(aStudy)) break;
2927 EmitSignalDeactivateDialog();
2929 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2930 SALOME_ListIO selected;
2932 aSel->selectedObjects( selected );
2934 SALOME_ListIteratorOfListIO It (selected);
2935 int nbSelectedGroups = 0;
2936 for ( ; It.More(); It.Next() )
2938 SMESH::SMESH_GroupBase_var aGroup =
2939 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2940 if (!aGroup->_is_nil()) {
2942 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2946 if (nbSelectedGroups == 0)
2948 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2954 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
2956 if(checkLock(aStudy)) break;
2957 if (myState == 800) {
2958 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2959 if (aDlg) aDlg->onAdd();
2964 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
2966 if(checkLock(aStudy)) break;
2967 if (myState == 800) {
2968 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2969 if (aDlg) aDlg->onRemove();
2974 case SMESHOp::OpEditGeomGroupAsGroup:
2978 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2979 tr( "NOT_A_VTK_VIEWER" ) );
2983 if(checkLock(aStudy)) break;
2984 EmitSignalDeactivateDialog();
2986 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2987 SALOME_ListIO selected;
2989 aSel->selectedObjects( selected );
2991 SALOME_ListIteratorOfListIO It (selected);
2992 for ( ; It.More(); It.Next() )
2994 SMESH::SMESH_GroupOnGeom_var aGroup =
2995 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2996 if (!aGroup->_is_nil()) {
2997 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3002 SMESH::SMESH_GroupOnFilter_var aGroup =
3003 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3004 if (!aGroup->_is_nil()) {
3005 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3013 case SMESHOp::OpUnionGroups:
3014 case SMESHOp::OpIntersectGroups:
3015 case SMESHOp::OpCutGroups:
3019 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3020 tr( "NOT_A_VTK_VIEWER" ) );
3024 if ( checkLock( aStudy ) )
3027 EmitSignalDeactivateDialog();
3029 SMESHGUI_GroupOpDlg* aDlg = 0;
3030 if ( theCommandID == SMESHOp::OpUnionGroups )
3031 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3032 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3033 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3035 aDlg = new SMESHGUI_CutGroupsDlg( this );
3042 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3044 if ( checkLock( aStudy ) )
3047 EmitSignalDeactivateDialog();
3048 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3054 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3058 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3059 tr( "NOT_A_VTK_VIEWER" ) );
3063 if ( checkLock( aStudy ) )
3066 EmitSignalDeactivateDialog();
3068 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3072 case SMESHOp::OpMeshInformation:
3073 case SMESHOp::OpWhatIs:
3075 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3076 EmitSignalDeactivateDialog();
3077 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3078 SALOME_ListIO selected;
3080 aSel->selectedObjects( selected );
3082 if ( selected.Extent() > 1 ) { // a dlg for each IO
3083 SALOME_ListIteratorOfListIO It( selected );
3084 for ( ; It.More(); It.Next() ) {
3085 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3086 dlg->showInfo( It.Value() );
3091 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3097 case SMESHOp::OpFindElementByPoint:
3099 startOperation( theCommandID );
3103 case SMESHOp::OpEditHypothesis:
3105 if(checkLock(aStudy)) break;
3107 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3108 SALOME_ListIO selected;
3110 aSel->selectedObjects( selected );
3112 int nbSel = selected.Extent();
3115 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3116 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3118 if ( !aHypothesis->_is_nil() )
3120 SMESHGUI_GenericHypothesisCreator* aCreator =
3121 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3124 // set geometry of mesh and sub-mesh to aCreator
3125 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3126 if ( selected.Extent() == 1 )
3128 QString subGeomID, meshGeomID;
3129 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3130 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3132 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3133 aCreator->setShapeEntry( subGeomID );
3134 aCreator->setMainShapeEntry( meshGeomID );
3138 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3148 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3150 if(checkLock(aStudy)) break;
3151 SUIT_OverrideCursor wc;
3153 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3154 SALOME_ListIO selected;
3156 aSel->selectedObjects( selected, QString::null, false );
3158 SALOME_ListIteratorOfListIO It(selected);
3159 for (int i = 0; It.More(); It.Next(), i++) {
3160 Handle(SALOME_InteractiveObject) IObject = It.Value();
3161 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3164 aSel->setSelectedObjects( l1 );
3169 case SMESHOp::OpElem0D:
3170 case SMESHOp::OpBall:
3171 case SMESHOp::OpEdge:
3172 case SMESHOp::OpTriangle:
3173 case SMESHOp::OpQuadrangle:
3174 case SMESHOp::OpPolygon:
3175 case SMESHOp::OpTetrahedron:
3176 case SMESHOp::OpHexahedron:
3177 case SMESHOp::OpPentahedron:
3178 case SMESHOp::OpPyramid:
3179 case SMESHOp::OpHexagonalPrism:
3181 if(checkLock(aStudy)) break;
3183 EmitSignalDeactivateDialog();
3184 SMDSAbs_EntityType type = SMDSEntity_Edge;
3185 switch (theCommandID) {
3186 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3187 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3188 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3189 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3190 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3191 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3192 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3193 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3194 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3195 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3198 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3201 SUIT_MessageBox::warning(desktop(),
3202 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3206 case SMESHOp::OpPolyhedron:
3208 if(checkLock(aStudy)) break;
3210 EmitSignalDeactivateDialog();
3211 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3214 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3215 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3219 case SMESHOp::OpQuadraticEdge:
3220 case SMESHOp::OpQuadraticTriangle:
3221 case SMESHOp::OpBiQuadraticTriangle:
3222 case SMESHOp::OpQuadraticQuadrangle:
3223 case SMESHOp::OpBiQuadraticQuadrangle:
3224 case SMESHOp::OpQuadraticTetrahedron:
3225 case SMESHOp::OpQuadraticPyramid:
3226 case SMESHOp::OpQuadraticPentahedron:
3227 case SMESHOp::OpQuadraticHexahedron:
3228 case SMESHOp::OpTriQuadraticHexahedron:
3230 if(checkLock(aStudy)) break;
3232 EmitSignalDeactivateDialog();
3233 SMDSAbs_EntityType type = SMDSEntity_Last;
3235 switch (theCommandID) {
3236 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3237 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3238 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3239 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3240 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3241 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3242 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3243 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3244 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3245 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3248 if ( type != SMDSEntity_Last )
3249 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3252 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3253 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3257 case SMESHOp::OpRemoveNodes:
3259 if(checkLock(aStudy)) break;
3261 EmitSignalDeactivateDialog();
3262 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3265 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3266 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3270 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3272 if(checkLock(aStudy)) break;
3274 EmitSignalDeactivateDialog();
3275 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3279 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3280 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3284 case SMESHOp::OpClearMesh: {
3286 if(checkLock(aStudy)) break;
3288 SALOME_ListIO selected;
3289 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3290 aSel->selectedObjects( selected );
3292 SUIT_OverrideCursor wc;
3293 SALOME_ListIteratorOfListIO It (selected);
3294 for ( ; It.More(); It.Next() )
3296 Handle(SALOME_InteractiveObject) IOS = It.Value();
3297 SMESH::SMESH_Mesh_var aMesh =
3298 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3299 if ( aMesh->_is_nil()) continue;
3301 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3303 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3304 SMESH::ModifiedMesh( aMeshSObj, false, true);
3305 // hide groups and submeshes
3306 _PTR(ChildIterator) anIter =
3307 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3308 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3310 _PTR(SObject) so = anIter->Value();
3311 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3314 catch (const SALOME::SALOME_Exception& S_ex){
3316 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3320 SMESH::UpdateView();
3324 case SMESHOp::OpRemoveOrphanNodes:
3326 if(checkLock(aStudy)) break;
3327 SALOME_ListIO selected;
3328 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3329 aSel->selectedObjects( selected );
3330 if ( selected.Extent() == 1 ) {
3331 Handle(SALOME_InteractiveObject) anIO = selected.First();
3332 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3333 if ( !aMesh->_is_nil() ) {
3334 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3335 tr( "SMESH_WARNING" ),
3336 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3337 SUIT_MessageBox::Yes |
3338 SUIT_MessageBox::No,
3339 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3342 SUIT_OverrideCursor wc;
3343 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3344 int removed = aMeshEditor->RemoveOrphanNodes();
3345 SUIT_MessageBox::information(SMESHGUI::desktop(),
3346 tr("SMESH_INFORMATION"),
3347 tr("NB_NODES_REMOVED").arg(removed));
3348 if ( removed > 0 ) {
3349 SMESH::UpdateView();
3350 SMESHGUI::Modified();
3353 catch (const SALOME::SALOME_Exception& S_ex) {
3354 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3363 case SMESHOp::OpRenumberingNodes:
3365 if(checkLock(aStudy)) break;
3367 EmitSignalDeactivateDialog();
3368 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3372 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3373 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3377 case SMESHOp::OpRenumberingElements:
3379 if(checkLock(aStudy)) break;
3381 EmitSignalDeactivateDialog();
3382 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3386 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3387 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3391 case SMESHOp::OpTranslation:
3393 if(checkLock(aStudy)) break;
3395 EmitSignalDeactivateDialog();
3396 ( new SMESHGUI_TranslationDlg( this ) )->show();
3399 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3400 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3404 case SMESHOp::OpRotation:
3406 if(checkLock(aStudy)) break;
3408 EmitSignalDeactivateDialog();
3409 ( new SMESHGUI_RotationDlg( this ) )->show();
3412 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3413 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3417 case SMESHOp::OpSymmetry:
3419 if(checkLock(aStudy)) break;
3421 EmitSignalDeactivateDialog();
3422 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3425 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3426 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3430 case SMESHOp::OpScale:
3432 if(checkLock(aStudy)) break;
3434 EmitSignalDeactivateDialog();
3435 ( new SMESHGUI_ScaleDlg( this ) )->show();
3438 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3439 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3444 case SMESHOp::OpSewing:
3446 if(checkLock(aStudy)) break;
3448 EmitSignalDeactivateDialog();
3449 ( new SMESHGUI_SewingDlg( this ) )->show();
3452 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3453 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3457 case SMESHOp::OpMergeNodes:
3459 if(checkLock(aStudy)) break;
3461 EmitSignalDeactivateDialog();
3462 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3465 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3466 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3470 case SMESHOp::OpMergeElements:
3472 if (checkLock(aStudy)) break;
3474 EmitSignalDeactivateDialog();
3475 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3477 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3478 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3483 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3484 startOperation( SMESHOp::OpMoveNode );
3487 case SMESHOp::OpDuplicateNodes:
3489 if(checkLock(aStudy)) break;
3491 EmitSignalDeactivateDialog();
3492 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3495 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3496 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3501 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3502 startOperation( SMESHOp::OpElem0DOnElemNodes );
3505 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3507 static QList<int> aTypes;
3508 if ( aTypes.isEmpty() )
3510 aTypes.append( SMESH::NODE );
3511 aTypes.append( SMESH::EDGE );
3512 aTypes.append( SMESH::FACE );
3513 aTypes.append( SMESH::VOLUME );
3515 if (!myFilterLibraryDlg)
3516 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3517 else if (myFilterLibraryDlg->isHidden())
3518 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3519 myFilterLibraryDlg->raise();
3523 case SMESHOp::OpFreeNode:
3524 case SMESHOp::OpEqualNode:
3525 case SMESHOp::OpFreeEdge:
3526 case SMESHOp::OpFreeBorder:
3527 case SMESHOp::OpLength:
3528 case SMESHOp::OpConnection:
3529 case SMESHOp::OpEqualEdge:
3530 case SMESHOp::OpFreeFace:
3531 case SMESHOp::OpBareBorderFace:
3532 case SMESHOp::OpOverConstrainedFace:
3533 case SMESHOp::OpLength2D:
3534 case SMESHOp::OpConnection2D:
3535 case SMESHOp::OpArea:
3536 case SMESHOp::OpTaper:
3537 case SMESHOp::OpAspectRatio:
3538 case SMESHOp::OpMinimumAngle:
3539 case SMESHOp::OpWarpingAngle:
3540 case SMESHOp::OpSkew:
3541 case SMESHOp::OpMaxElementLength2D:
3542 case SMESHOp::OpEqualFace:
3543 case SMESHOp::OpAspectRatio3D:
3544 case SMESHOp::OpVolume:
3545 case SMESHOp::OpMaxElementLength3D:
3546 case SMESHOp::OpBareBorderVolume:
3547 case SMESHOp::OpOverConstrainedVolume:
3548 case SMESHOp::OpEqualVolume:
3551 LightApp_SelectionMgr* mgr = selectionMgr();
3552 SALOME_ListIO selected; mgr->selectedObjects( selected );
3554 if( !selected.IsEmpty() ) {
3555 SUIT_OverrideCursor wc;
3556 ::Control( theCommandID );
3559 SUIT_MessageBox::warning(desktop(),
3560 tr( "SMESH_WRN_WARNING" ),
3561 tr( "SMESH_BAD_SELECTION" ) );
3565 SUIT_MessageBox::warning(desktop(),
3566 tr( "SMESH_WRN_WARNING" ),
3567 tr( "NOT_A_VTK_VIEWER" ) );
3570 case SMESHOp::OpOverallMeshQuality:
3571 OverallMeshQuality();
3573 case SMESHOp::OpNumberingNodes:
3575 SUIT_OverrideCursor wc;
3576 LightApp_SelectionMgr* mgr = selectionMgr();
3577 SALOME_ListIO selected; mgr->selectedObjects( selected );
3579 SALOME_ListIteratorOfListIO it(selected);
3580 for( ; it.More(); it.Next()) {
3581 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3582 if(anIObject->hasEntry()) {
3583 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3584 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3590 case SMESHOp::OpNumberingElements:
3592 SUIT_OverrideCursor wc;
3593 LightApp_SelectionMgr* mgr = selectionMgr();
3594 SALOME_ListIO selected; mgr->selectedObjects( selected );
3596 SALOME_ListIteratorOfListIO it(selected);
3597 for( ; it.More(); it.Next()) {
3598 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3599 if(anIObject->hasEntry())
3600 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3601 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3606 case SMESHOp::OpPropertiesLength:
3607 case SMESHOp::OpPropertiesArea:
3608 case SMESHOp::OpPropertiesVolume:
3609 case SMESHOp::OpMinimumDistance:
3610 case SMESHOp::OpBoundingBox:
3612 int page = SMESHGUI_MeasureDlg::MinDistance;
3613 if ( theCommandID == SMESHOp::OpBoundingBox )
3614 page = SMESHGUI_MeasureDlg::BoundingBox;
3615 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3616 page = SMESHGUI_MeasureDlg::Length;
3617 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3618 page = SMESHGUI_MeasureDlg::Area;
3619 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3620 page = SMESHGUI_MeasureDlg::Volume;
3622 EmitSignalDeactivateDialog();
3623 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3627 case SMESHOp::OpSortChild:
3633 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3634 //updateObjBrowser();
3638 //=============================================================================
3642 //=============================================================================
3643 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3648 //=============================================================================
3652 //=============================================================================
3653 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3658 //=============================================================================
3662 //=============================================================================
3663 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3668 //=============================================================================
3669 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3670 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3672 //=============================================================================
3673 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3674 SUIT_ViewWindow* wnd )
3676 if(theIO->hasEntry()){
3677 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3678 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3682 //=======================================================================
3683 // function : createSMESHAction
3685 //=======================================================================
3686 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3687 const int key, const bool toggle, const QString& shortcutAction )
3690 QWidget* parent = application()->desktop();
3691 SUIT_ResourceMgr* resMgr = resourceMgr();
3693 if ( !icon_id.isEmpty() )
3694 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3696 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3697 if ( !pix.isNull() )
3698 icon = QIcon( pix );
3700 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3701 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3702 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3704 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3705 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3708 //=======================================================================
3709 // function : createPopupItem
3711 //=======================================================================
3712 void SMESHGUI::createPopupItem( const int id,
3713 const QString& clients,
3714 const QString& types,
3715 const QString& theRule,
3718 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3719 popupMgr()->insert( action( id ), pId, 0 );
3721 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3722 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3723 QString rule = "(%1) and (%2) and (%3)";
3724 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3725 if( clients.isEmpty() )
3726 rule = rule.arg( QString( "true" ) );
3728 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3729 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3732 bool cont = myRules.contains( id );
3734 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3736 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3737 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3740 //=======================================================================
3741 // function : initialize
3743 //=======================================================================
3744 void SMESHGUI::initialize( CAM_Application* app )
3746 SalomeApp_Module::initialize( app );
3748 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3750 /* Automatic Update flag */
3751 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3753 // ----- create actions --------------
3755 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3756 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_U) );
3757 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3758 //createSMESHAction( 114, "NUM" );
3759 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
3761 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
3763 createSMESHAction( SMESHOp::OpImportSAUV, "IMPORT_SAUV" );
3764 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
3765 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
3766 createSMESHAction( SMESHOp::OpExportMED, "MED" );
3767 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
3768 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
3770 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
3772 createSMESHAction( SMESHOp::OpExportSAUV, "SAUV");
3773 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
3774 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
3775 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
3776 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
3777 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
3779 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
3781 createSMESHAction( SMESHOp::OpPopupExportSAUV, "SAUV");
3782 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
3783 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
3784 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3785 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
3786 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3787 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3788 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
3789 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3790 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
3791 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
3792 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3793 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_COMPUTE" );
3794 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_COMPUTE" );
3795 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3796 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
3797 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3798 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3799 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3800 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
3801 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
3802 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
3803 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
3804 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD" );
3805 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE" );
3806 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
3807 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
3808 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
3809 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3810 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
3812 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3813 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3814 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3815 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3816 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
3817 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
3818 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3819 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3820 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3821 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3822 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3823 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3824 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
3825 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
3826 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
3827 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
3828 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
3829 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
3830 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3831 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3832 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3833 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3834 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3835 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3836 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3837 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3838 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY" );
3840 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
3841 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
3842 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3843 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
3844 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
3845 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3846 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
3847 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
3848 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
3849 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
3850 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
3851 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
3852 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
3853 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3854 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3855 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3856 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3857 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3858 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3859 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3860 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3861 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3862 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3863 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3865 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3866 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3867 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3868 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
3870 createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3871 createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3873 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3874 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
3875 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3876 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
3877 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3878 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
3879 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3880 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3881 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3882 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
3883 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
3884 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3885 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
3886 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
3887 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
3888 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3889 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
3890 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
3891 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3892 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
3893 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
3894 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3895 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3897 createSMESHAction( SMESHOp::OpReset, "RESET" );
3898 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
3899 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
3900 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
3901 #ifndef DISABLE_PLOT2DVIEWER
3902 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
3904 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
3905 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
3906 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
3907 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
3908 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
3909 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3910 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
3911 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3912 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3913 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
3914 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
3915 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
3916 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
3918 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
3919 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
3921 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
3922 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
3923 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
3924 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
3925 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
3926 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
3927 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
3928 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
3929 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
3931 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3932 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3933 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
3934 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
3935 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
3937 createSMESHAction( SMESHOp::OpHide, "HIDE" );
3938 createSMESHAction( SMESHOp::OpShow, "SHOW" );
3939 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
3941 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
3943 QList<int> aCtrlActions;
3944 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode // node controls
3945 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
3946 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
3947 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
3948 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
3949 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
3950 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
3951 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
3952 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
3953 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
3954 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls
3955 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
3956 aCtrlGroup->setExclusive( true );
3957 for( int i = 0; i < aCtrlActions.size(); i++ )
3958 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
3960 // ----- create menu --------------
3961 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3962 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3963 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3964 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3965 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3966 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3967 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3968 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3970 createMenu( separator(), fileId );
3972 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3973 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3974 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3975 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3976 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3977 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3978 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3979 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3980 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3981 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
3982 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
3984 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
3985 createMenu( SMESHOp::OpImportUNV, importId, -1 );
3986 createMenu( SMESHOp::OpImportMED, importId, -1 );
3987 createMenu( SMESHOp::OpImportSTL, importId, -1 );
3989 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
3991 createMenu( SMESHOp::OpImportSAUV, importId, -1 );
3992 createMenu( SMESHOp::OpImportGMF, importId, -1 );
3993 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
3994 createMenu( SMESHOp::OpExportMED, exportId, -1 );
3995 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
3996 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
3998 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4000 createMenu( SMESHOp::OpExportSAUV, exportId, -1 );
4001 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4002 createMenu( separator(), fileId, 10 );
4004 createMenu( SMESHOp::OpDelete, editId, -1 );
4006 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4008 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4009 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4010 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4011 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4012 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4013 createMenu( separator(), meshId, -1 );
4014 createMenu( SMESHOp::OpCompute, meshId, -1 );
4015 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4016 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4017 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4018 createMenu( separator(), meshId, -1 );
4019 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4020 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4021 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4022 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4023 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4024 createMenu( separator(), meshId, -1 );
4025 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4026 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4027 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4028 createMenu( separator(), meshId, -1 );
4029 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4030 createMenu( separator(), meshId, -1 );
4031 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4032 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4033 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4034 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4035 createMenu( separator(), meshId, -1 );
4037 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4038 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4039 createMenu( SMESHOp::OpFreeEdge, edgeId, -1 );
4040 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4041 createMenu( SMESHOp::OpLength, edgeId, -1 );
4042 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4043 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4044 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4045 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4046 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4047 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4048 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4049 createMenu( SMESHOp::OpArea, faceId, -1 );
4050 createMenu( SMESHOp::OpTaper, faceId, -1 );
4051 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4052 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4053 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4054 createMenu( SMESHOp::OpSkew, faceId, -1 );
4055 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4056 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4057 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4058 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4059 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4060 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4061 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4062 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4063 createMenu( separator(), ctrlId, -1 );
4064 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4065 createMenu( separator(), ctrlId, -1 );
4066 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4068 createMenu( SMESHOp::OpNode, addId, -1 );
4069 createMenu( SMESHOp::OpElem0D, addId, -1 );
4070 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4071 createMenu( SMESHOp::OpBall, addId, -1 );
4072 createMenu( SMESHOp::OpEdge, addId, -1 );
4073 createMenu( SMESHOp::OpTriangle, addId, -1 );
4074 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4075 createMenu( SMESHOp::OpPolygon, addId, -1 );
4076 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4077 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4078 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4079 createMenu( SMESHOp::OpPyramid, addId, -1 );
4080 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4081 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4082 createMenu( separator(), addId, -1 );
4083 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4084 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4085 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4086 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4087 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4088 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4089 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4090 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4091 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4092 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4094 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4095 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4096 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4097 createMenu( separator(), removeId, -1 );
4098 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4099 createMenu( separator(), removeId, -1 );
4100 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4102 createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4103 createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4105 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4106 createMenu( SMESHOp::OpRotation, transfId, -1 );
4107 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4108 createMenu( SMESHOp::OpScale, transfId, -1 );
4109 createMenu( SMESHOp::OpSewing, transfId, -1 );
4110 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4111 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4112 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4114 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4115 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4116 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4117 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4118 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4119 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4120 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4121 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4122 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4123 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4124 createMenu( SMESHOp::OpExtrusionAlongAPath , modifyId, -1 );
4125 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4126 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4127 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4128 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4130 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4131 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4132 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4133 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4134 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4135 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4137 // ----- create toolbars --------------
4138 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ),
4139 info = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ),
4140 groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ),
4141 ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ),
4142 ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ),
4143 ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ),
4144 ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ),
4145 addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ),
4146 addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ),
4147 remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ),
4148 renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ),
4149 transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ),
4150 modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ),
4151 measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ),
4152 dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4154 createTool( SMESHOp::OpCreateMesh, meshTb );
4155 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4156 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4157 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4158 createTool( SMESHOp::OpCopyMesh, meshTb );
4159 createTool( separator(), meshTb );
4160 createTool( SMESHOp::OpCompute, meshTb );
4161 createTool( SMESHOp::OpPreCompute, meshTb );
4162 createTool( SMESHOp::OpEvaluate, meshTb );
4163 createTool( SMESHOp::OpMeshOrder, meshTb );
4165 createTool( SMESHOp::OpCreateGroup, groupTb );
4166 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4167 createTool( SMESHOp::OpConstructGroup, groupTb );
4168 createTool( SMESHOp::OpEditGroup, groupTb );
4170 createTool( SMESHOp::OpMeshInformation, info );
4171 //createTool( SMESHOp::OpStdInfo, meshTb );
4172 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4173 createTool( SMESHOp::OpFindElementByPoint, info );
4175 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4176 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4178 createTool( SMESHOp::OpFreeEdge, ctrl1dTb );
4179 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4180 createTool( SMESHOp::OpLength, ctrl1dTb );
4181 createTool( SMESHOp::OpConnection, ctrl1dTb );
4182 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4184 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4185 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4186 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4187 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4188 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4189 createTool( SMESHOp::OpArea, ctrl2dTb );
4190 createTool( SMESHOp::OpTaper, ctrl2dTb );
4191 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4192 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4193 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4194 createTool( SMESHOp::OpSkew, ctrl2dTb );
4195 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4196 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4198 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4199 createTool( SMESHOp::OpVolume, ctrl3dTb );
4200 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4201 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4202 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4203 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4205 createTool( SMESHOp::OpNode, addElemTb );
4206 createTool( SMESHOp::OpElem0D, addElemTb );
4207 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4208 createTool( SMESHOp::OpBall, addElemTb );
4209 createTool( SMESHOp::OpEdge, addElemTb );
4210 createTool( SMESHOp::OpTriangle, addElemTb );
4211 createTool( SMESHOp::OpQuadrangle, addElemTb );
4212 createTool( SMESHOp::OpPolygon, addElemTb );
4213 createTool( SMESHOp::OpTetrahedron, addElemTb );
4214 createTool( SMESHOp::OpHexahedron, addElemTb );
4215 createTool( SMESHOp::OpPentahedron, addElemTb );
4216 createTool( SMESHOp::OpPyramid, addElemTb );
4217 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4218 createTool( SMESHOp::OpPolyhedron, addElemTb );
4220 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4221 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4222 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4223 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4224 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4225 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4226 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4227 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4228 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4229 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4231 createTool( SMESHOp::OpRemoveNodes, remTb );
4232 createTool( SMESHOp::OpRemoveElements, remTb );
4233 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4234 createTool( SMESHOp::OpClearMesh, remTb );
4236 createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4237 createTool( SMESHOp::OpRenumberingElements, renumbTb );
4239 createTool( SMESHOp::OpTranslation, transformTb );
4240 createTool( SMESHOp::OpRotation, transformTb );
4241 createTool( SMESHOp::OpSymmetry, transformTb );
4242 createTool( SMESHOp::OpScale, transformTb );
4243 createTool( SMESHOp::OpSewing, transformTb );
4244 createTool( SMESHOp::OpMergeNodes, transformTb );
4245 createTool( SMESHOp::OpMergeElements, transformTb );
4246 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4248 createTool( SMESHOp::OpMoveNode, modifyTb );
4249 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4250 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4251 createTool( SMESHOp::OpOrientation, modifyTb );
4252 createTool( SMESHOp::OpReorientFaces, modifyTb );
4253 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4254 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4255 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4256 createTool( SMESHOp::OpSmoothing, modifyTb );
4257 createTool( SMESHOp::OpExtrusion, modifyTb );
4258 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4259 createTool( SMESHOp::OpRevolution, modifyTb );
4260 createTool( SMESHOp::OpPatternMapping, modifyTb );
4261 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4262 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4264 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4266 createTool( SMESHOp::OpUpdate, dispModeTb );
4268 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4269 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4272 QString OB = "'ObjectBrowser'",
4273 View = "'" + SVTK_Viewer::Type() + "'",
4275 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4276 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4277 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4278 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4279 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4280 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4281 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4282 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4283 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4284 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4285 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4287 mesh_part = mesh + " " + subMesh + " " + group,
4288 mesh_group = mesh + " " + group,
4289 hyp_alg = hypo + " " + algo;
4291 // popup for object browser
4293 isInvisible("not( isVisible )"),
4294 isEmpty("numberOfNodes = 0"),
4295 isNotEmpty("numberOfNodes <> 0"),
4297 // has nodes, edges, etc in VISIBLE! actor
4298 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
4299 hasElems("(count( elemTypes ) > 0)"),
4300 hasDifferentElems("(count( elemTypes ) > 1)"),
4301 hasBalls("({'BallElem'} in elemTypes)"),
4302 hasElems0d("({'Elem0d'} in elemTypes)"),
4303 hasEdges("({'Edge'} in elemTypes)"),
4304 hasFaces("({'Face'} in elemTypes)"),
4305 hasVolumes("({'Volume'} in elemTypes)");
4307 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4308 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& isComputable");
4309 createPopupItem( SMESHOp::OpEditMeshOrSubMesh, OB, mesh, "&& isComputable");
4310 createPopupItem( SMESHOp::OpEditMeshOrSubMesh, OB, subMesh, "&& isComputable" );
4311 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4312 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4314 popupMgr()->insert( separator(), -1, 0 );
4315 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& isComputable" );
4316 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& isComputable && isPreComputable" );
4317 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& isComputable" );
4318 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& isComputable" );
4319 createPopupItem( SMESHOp::OpUpdate, OB, mesh_part );
4320 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4321 createPopupItem( SMESHOp::OpFindElementByPoint, OB, mesh_group );
4322 createPopupItem( SMESHOp::OpOverallMeshQuality, OB, mesh_part );
4323 popupMgr()->insert( separator(), -1, 0 );
4324 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh );
4325 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh );
4326 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4327 popupMgr()->insert( separator(), -1, 0 );
4328 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo);
4329 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
4330 popupMgr()->insert( separator(), -1, 0 );
4331 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4332 popupMgr()->insert( separator(), -1, 0 );
4333 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh + " " + subMesh ); // convert to quadratic
4334 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh + " " + group, // create 2D mesh from 3D
4336 popupMgr()->insert( separator(), -1, 0 );
4338 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4339 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4340 QString only_one_2D = only_one_non_empty + " && dim>1";
4342 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4343 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4344 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4345 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4347 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4349 createPopupItem( SMESHOp::OpPopupExportSAUV, OB, mesh_group, multiple_non_empty, anId );
4350 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, multiple_non_empty, anId );
4351 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, multiple_non_empty, anId );
4352 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4353 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4354 popupMgr()->insert( separator(), -1, 0 );
4357 createPopupItem( SMESHOp::OpEditGroup, View, group );
4358 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems );
4359 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems );
4361 popupMgr()->insert( separator(), -1, 0 );
4362 createPopupItem( SMESHOp::OpUpdate, View, mesh_part );
4363 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4364 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4365 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh );
4366 popupMgr()->insert( separator(), -1, 0 );
4368 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4369 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4370 popupMgr()->insert( separator(), -1, 0 );
4372 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4373 QString aType = QString( "%1type in {%2}" ).arg( lc );
4374 aType = aType.arg( mesh_part );
4375 QString aMeshInVTK = aClient + "&&" + aType;
4377 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4378 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4379 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4381 //-------------------------------------------------
4383 //-------------------------------------------------
4384 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4386 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4387 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4388 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4390 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4391 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4392 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4394 popupMgr()->insert( separator(), -1, -1 );
4396 //-------------------------------------------------
4398 //-------------------------------------------------
4399 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4401 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4402 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4403 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4405 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4406 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4407 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4409 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4410 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4411 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4413 popupMgr()->insert( separator(), anId, -1 );
4415 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4416 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4417 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4419 //-------------------------------------------------
4421 //-------------------------------------------------
4422 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4424 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4426 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4427 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4428 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4430 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4431 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4432 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4434 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4435 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4436 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4438 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4439 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4440 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4442 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4443 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4444 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4446 popupMgr()->insert( separator(), anId, -1 );
4448 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4449 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&&" + aType + "&&" + isNotEmpty, QtxPopupMgr::VisibleRule );
4451 popupMgr()->insert( separator(), anId, -1 );
4453 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4454 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4457 //-------------------------------------------------
4458 // Representation of the 2D Quadratic elements
4459 //-------------------------------------------------
4460 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4461 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4462 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4463 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4465 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4466 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4467 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4469 //-------------------------------------------------
4470 // Orientation of faces
4471 //-------------------------------------------------
4472 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4473 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4474 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4476 //-------------------------------------------------
4478 //-------------------------------------------------
4479 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4480 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4482 //-------------------------------------------------
4484 //-------------------------------------------------
4485 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4486 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4488 //-------------------------------------------------
4490 //-------------------------------------------------
4492 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4493 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4494 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4495 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4497 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4499 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
4500 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4502 popupMgr()->insert( separator(), anId, -1 );
4504 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4506 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
4507 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4508 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4510 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
4511 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4512 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4514 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4516 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
4517 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4518 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4520 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
4521 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4522 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4524 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
4525 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4526 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4528 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
4529 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4530 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4531 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
4532 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4533 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4535 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4537 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
4538 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4539 QtxPopupMgr::VisibleRule );
4540 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4542 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
4543 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4544 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4546 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
4547 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4548 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4550 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
4551 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4552 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4554 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
4555 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4556 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4558 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
4559 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4560 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4562 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
4563 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4564 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4566 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
4567 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4568 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4570 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
4571 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4572 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4574 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
4575 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4576 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4578 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
4579 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4580 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4582 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
4583 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4584 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4585 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
4586 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4587 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4589 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4591 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
4592 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4593 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4595 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
4596 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4597 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4599 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
4600 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4601 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4603 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
4604 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4605 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4607 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
4608 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4609 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4611 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
4612 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4613 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4615 popupMgr()->insert( separator(), anId, -1 );
4617 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
4618 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4620 popupMgr()->insert( separator(), anId, -1 );
4622 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4624 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
4625 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4627 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
4628 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4629 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4631 #ifndef DISABLE_PLOT2DVIEWER
4632 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
4633 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4636 //-------------------------------------------------
4638 //-------------------------------------------------
4639 popupMgr()->insert( separator(), -1, -1 );
4640 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4641 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4642 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
4643 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4645 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
4646 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4648 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
4649 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4651 popupMgr()->insert( separator(), -1, -1 );
4653 //-------------------------------------------------
4655 //-------------------------------------------------
4656 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
4657 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4659 popupMgr()->insert( separator(), -1, -1 );
4661 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
4662 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4663 popupMgr()->insert( separator(), -1, -1 );
4665 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4666 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4668 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4669 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4672 //================================================================================
4674 * \brief Return true if SMESH or GEOM objects are selected.
4675 * Is called form LightApp_Module::activateModule() which clear selection if
4676 * not isSelectionCompatible()
4678 //================================================================================
4680 bool SMESHGUI::isSelectionCompatible()
4682 bool isCompatible = true;
4683 SALOME_ListIO selected;
4684 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4685 Sel->selectedObjects( selected );
4687 SALOME_ListIteratorOfListIO It( selected );
4688 for ( ; isCompatible && It.More(); It.Next())
4690 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4691 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4693 return isCompatible;
4697 bool SMESHGUI::reusableOperation( const int id )
4699 // compute, evaluate and precompute are not reusable operations
4700 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate ) ? false : SalomeApp_Module::reusableOperation( id );
4703 bool SMESHGUI::activateModule( SUIT_Study* study )
4705 bool res = SalomeApp_Module::activateModule( study );
4707 setMenuShown( true );
4708 setToolShown( true );
4710 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4711 PyGILState_STATE gstate = PyGILState_Ensure();
4712 PyObjWrapper pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4713 if ( !pluginsmanager ) {
4717 PyObjWrapper result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4721 PyGILState_Release(gstate);
4722 // end of SMESH plugins loading
4724 // Reset actions accelerator keys
4725 //action(SMESHOp::OpImportDAT)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B));
4726 action(SMESHOp::OpImportUNV)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U));
4727 action(SMESHOp::OpImportMED)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
4729 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
4731 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4732 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4733 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4734 if ( _PTR(Study) aStudy = s->studyDS()) {
4735 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4736 updateObjBrowser(); // objects can be removed
4739 // get all view currently opened in the study and connect their signals to
4740 // the corresponding slots of the class.
4741 SUIT_Desktop* aDesk = study->application()->desktop();
4743 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4744 SUIT_ViewWindow* wnd;
4745 foreach ( wnd, wndList )
4752 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4754 setMenuShown( false );
4755 setToolShown( false );
4757 EmitSignalCloseAllDialogs();
4759 // Unset actions accelerator keys
4760 //action(SMESHOp::OpImportDAT)->setShortcut(QKeySequence());
4761 action(SMESHOp::OpImportUNV)->setShortcut(QKeySequence());
4762 action(SMESHOp::OpImportMED)->setShortcut(QKeySequence());
4764 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
4766 return SalomeApp_Module::deactivateModule( study );
4769 void SMESHGUI::studyClosed( SUIT_Study* s )
4771 SMESH::RemoveVisuData( s->id() );
4772 SalomeApp_Module::studyClosed( s );
4775 void SMESHGUI::OnGUIEvent()
4777 const QObject* obj = sender();
4778 if ( !obj || !obj->inherits( "QAction" ) )
4780 int id = actionId((QAction*)obj);
4785 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4787 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4788 if ( CORBA::is_nil( myComponentSMESH ) )
4790 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4792 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4793 return aGUI.myComponentSMESH;
4796 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4797 return myComponentSMESH;
4800 QString SMESHGUI::engineIOR() const
4802 CORBA::ORB_var anORB = getApp()->orb();
4803 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4804 return QString( anIOR.in() );
4807 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4809 SalomeApp_Module::contextMenuPopup( client, menu, title );
4811 selectionMgr()->selectedObjects( lst );
4812 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4813 Handle(SALOME_InteractiveObject) io = lst.First();
4814 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4815 _PTR(Study) study = appStudy->studyDS();
4816 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4818 QString aName = QString( QString::fromUtf8(obj->GetName().c_str()) );
4819 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4820 aName.remove( (aName.length() - 1), 1 );
4826 LightApp_Selection* SMESHGUI::createSelection() const
4828 return new SMESHGUI_Selection();
4831 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4833 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4834 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
4835 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4838 void SMESHGUI::viewManagers( QStringList& list ) const
4840 list.append( SVTK_Viewer::Type() );
4843 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4845 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4846 SMESH::UpdateSelectionProp( this );
4848 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4849 for(int i = 0; i < aViews.count() ; i++){
4850 SUIT_ViewWindow *sf = aViews[i];
4856 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4858 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4859 myClippingPlaneInfoMap.erase( theViewManager );
4862 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4864 theActor->AddObserver( SMESH::DeleteActorEvent,
4865 myEventCallbackCommand.GetPointer(),
4869 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4870 unsigned long theEvent,
4871 void* theClientData,
4874 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4875 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4876 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4877 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4878 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4879 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4880 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4881 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4882 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4883 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4884 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4885 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4886 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4887 if( anActor == *anIter3 ) {
4888 anActorList.erase( anIter3 );
4899 void SMESHGUI::createPreferences()
4901 // General tab ------------------------------------------------------------------------
4902 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4904 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4905 setPreferenceProperty( autoUpdate, "columns", 2 );
4906 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4907 setPreferenceProperty( lim, "min", 0 );
4908 setPreferenceProperty( lim, "max", 100000000 );
4909 setPreferenceProperty( lim, "step", 1000 );
4910 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4911 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
4913 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4914 setPreferenceProperty( qaGroup, "columns", 2 );
4915 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4916 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4917 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4918 setPreferenceProperty( prec, "min", 0 );
4919 setPreferenceProperty( prec, "max", 16 );
4920 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
4921 setPreferenceProperty( doubleNodesTol, "precision", 10 );
4922 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
4923 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
4924 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
4926 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4927 setPreferenceProperty( dispgroup, "columns", 2 );
4928 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4930 modes.append( tr("MEN_WIRE") );
4931 modes.append( tr("MEN_SHADE") );
4932 modes.append( tr("MEN_NODES") );
4933 modes.append( tr("MEN_SHRINK") );
4934 QList<QVariant> indices;
4935 indices.append( 0 );
4936 indices.append( 1 );
4937 indices.append( 2 );
4938 indices.append( 3 );
4939 setPreferenceProperty( dispmode, "strings", modes );
4940 setPreferenceProperty( dispmode, "indexes", indices );
4942 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4943 setPreferenceProperty( arcgroup, "columns", 2 );
4944 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4945 QStringList quadraticModes;
4946 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4947 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4949 indices.append( 0 );
4950 indices.append( 1 );
4951 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4952 setPreferenceProperty( quadraticmode, "indexes", indices );
4954 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4955 "SMESH", "max_angle" );
4956 setPreferenceProperty( maxAngle, "min", 1 );
4957 setPreferenceProperty( maxAngle, "max", 90 );
4961 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4962 setPreferenceProperty( exportgroup, "columns", 2 );
4963 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4964 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4966 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4967 setPreferenceProperty( computeGroup, "columns", 2 );
4968 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4970 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4971 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4972 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4974 indices.append( 0 );
4975 indices.append( 1 );
4976 indices.append( 2 );
4977 setPreferenceProperty( notifyMode, "strings", modes );
4978 setPreferenceProperty( notifyMode, "indexes", indices );
4980 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4981 setPreferenceProperty( infoGroup, "columns", 2 );
4982 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4984 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4985 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4987 indices.append( 0 );
4988 indices.append( 1 );
4989 setPreferenceProperty( elemInfo, "strings", modes );
4990 setPreferenceProperty( elemInfo, "indexes", indices );
4991 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4992 setPreferenceProperty( nodesLim, "min", 0 );
4993 setPreferenceProperty( nodesLim, "max", 10000000 );
4994 setPreferenceProperty( nodesLim, "step", 10000 );
4995 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4996 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
4997 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4998 setPreferenceProperty( ctrlLim, "min", 0 );
4999 setPreferenceProperty( ctrlLim, "max", 10000000 );
5000 setPreferenceProperty( ctrlLim, "step", 1000 );
5001 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5002 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5003 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5004 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5005 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5007 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5008 setPreferenceProperty( segGroup, "columns", 2 );
5009 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5010 "SMESH", "segmentation" );
5011 setPreferenceProperty( segLen, "min", 1 );
5012 setPreferenceProperty( segLen, "max", 10000000 );
5013 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5014 "SMESH", "nb_segments_per_edge" );
5015 setPreferenceProperty( nbSeg, "min", 1 );
5016 setPreferenceProperty( nbSeg, "max", 10000000 );
5018 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5019 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5020 "SMESH", "forget_mesh_on_hyp_modif" );
5023 // Quantities with individual precision settings
5024 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5025 setPreferenceProperty( precGroup, "columns", 2 );
5027 const int nbQuantities = 6;
5028 int precs[nbQuantities], ii = 0;
5029 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5030 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5031 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5032 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5033 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5034 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5035 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5036 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5037 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5038 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5039 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5040 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5042 // Set property for precision value for spinboxes
5043 for ( ii = 0; ii < nbQuantities; ii++ ){
5044 setPreferenceProperty( precs[ii], "min", -14 );
5045 setPreferenceProperty( precs[ii], "max", 14 );
5046 setPreferenceProperty( precs[ii], "precision", 2 );
5049 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5050 setPreferenceProperty( previewGroup, "columns", 2 );
5051 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5052 setPreferenceProperty( chunkSize, "min", 1 );
5053 setPreferenceProperty( chunkSize, "max", 1000 );
5054 setPreferenceProperty( chunkSize, "step", 50 );
5056 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5057 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5059 // Mesh tab ------------------------------------------------------------------------
5060 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5061 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5062 setPreferenceProperty( nodeGroup, "columns", 3 );
5064 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5066 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5068 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5069 QList<QVariant> aMarkerTypeIndicesList;
5070 QList<QVariant> aMarkerTypeIconsList;
5071 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5072 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5073 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5074 aMarkerTypeIndicesList << i;
5075 aMarkerTypeIconsList << pixmap;
5077 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5078 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5080 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5082 QList<QVariant> aMarkerScaleIndicesList;
5083 QStringList aMarkerScaleValuesList;
5084 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5085 aMarkerScaleIndicesList << i;
5086 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5088 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5089 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5091 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5092 //setPreferenceProperty( elemGroup, "columns", 2 );
5094 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5095 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5096 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5097 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5098 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5099 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5100 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5101 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5102 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5105 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5106 setPreferenceProperty( grpGroup, "columns", 2 );
5108 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5109 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5111 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5112 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5113 int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5114 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size");
5115 double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5116 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5117 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5118 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5119 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5120 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5121 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5122 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5124 setPreferenceProperty( size0d, "min", 1 );
5125 setPreferenceProperty( size0d, "max", 10 );
5127 setPreferenceProperty( ballSize, "min", 1 );
5128 setPreferenceProperty( ballSize, "max", 10 );
5130 setPreferenceProperty( ballScale, "min", 1e-2 );
5131 setPreferenceProperty( ballScale, "max", 1e7 );
5132 setPreferenceProperty( ballScale, "step", 0.5 );
5134 setPreferenceProperty( elemW, "min", 1 );
5135 setPreferenceProperty( elemW, "max", 5 );
5137 setPreferenceProperty( outW, "min", 1 );
5138 setPreferenceProperty( outW, "max", 5 );
5140 setPreferenceProperty( shrink, "min", 0 );
5141 setPreferenceProperty( shrink, "max", 100 );
5143 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5144 setPreferenceProperty( numGroup, "columns", 2 );
5146 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5147 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5149 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5150 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5152 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5153 setPreferenceProperty( orientGroup, "columns", 1 );
5155 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5156 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5158 setPreferenceProperty( orientScale, "min", 0.05 );
5159 setPreferenceProperty( orientScale, "max", 0.5 );
5160 setPreferenceProperty( orientScale, "step", 0.05 );
5162 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5164 // Selection tab ------------------------------------------------------------------------
5165 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5167 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5168 setPreferenceProperty( selGroup, "columns", 2 );
5170 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5171 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5173 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5174 setPreferenceProperty( preGroup, "columns", 2 );
5176 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5178 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5179 setPreferenceProperty( precSelGroup, "columns", 2 );
5181 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5182 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5183 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5185 // Scalar Bar tab ------------------------------------------------------------------------
5186 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5187 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5188 setPreferenceProperty( fontGr, "columns", 2 );
5190 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5191 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5193 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5194 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5196 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5197 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5199 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5200 setPreferenceProperty( numcol, "min", 2 );
5201 setPreferenceProperty( numcol, "max", 256 );
5203 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5204 setPreferenceProperty( numlab, "min", 2 );
5205 setPreferenceProperty( numlab, "max", 65 );
5207 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5208 setPreferenceProperty( orientGr, "columns", 2 );
5209 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5210 QStringList orients;
5211 orients.append( tr( "SMESH_VERTICAL" ) );
5212 orients.append( tr( "SMESH_HORIZONTAL" ) );
5213 indices.clear(); indices.append( 0 ); indices.append( 1 );
5214 setPreferenceProperty( orient, "strings", orients );
5215 setPreferenceProperty( orient, "indexes", indices );
5217 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5218 setPreferenceProperty( posVSizeGr, "columns", 2 );
5219 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5220 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5221 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5222 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5223 setPreferenceProperty( xv, "step", 0.1 );
5224 setPreferenceProperty( xv, "min", 0.0 );
5225 setPreferenceProperty( xv, "max", 1.0 );
5226 setPreferenceProperty( yv, "step", 0.1 );
5227 setPreferenceProperty( yv, "min", 0.0 );
5228 setPreferenceProperty( yv, "max", 1.0 );
5229 setPreferenceProperty( wv, "step", 0.1 );
5230 setPreferenceProperty( wv, "min", 0.0 );
5231 setPreferenceProperty( wv, "max", 1.0 );
5232 setPreferenceProperty( hv, "min", 0.0 );
5233 setPreferenceProperty( hv, "max", 1.0 );
5234 setPreferenceProperty( hv, "step", 0.1 );
5236 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5237 setPreferenceProperty( posHSizeGr, "columns", 2 );
5238 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5239 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5240 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5241 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5242 setPreferenceProperty( xv, "min", 0.0 );
5243 setPreferenceProperty( xv, "max", 1.0 );
5244 setPreferenceProperty( xv, "step", 0.1 );
5245 setPreferenceProperty( xh, "min", 0.0 );
5246 setPreferenceProperty( xh, "max", 1.0 );
5247 setPreferenceProperty( xh, "step", 0.1 );
5248 setPreferenceProperty( yh, "min", 0.0 );
5249 setPreferenceProperty( yh, "max", 1.0 );
5250 setPreferenceProperty( yh, "step", 0.1 );
5251 setPreferenceProperty( wh, "min", 0.0 );
5252 setPreferenceProperty( wh, "max", 1.0 );
5253 setPreferenceProperty( wh, "step", 0.1 );
5254 setPreferenceProperty( hh, "min", 0.0 );
5255 setPreferenceProperty( hh, "max", 1.0 );
5256 setPreferenceProperty( hh, "step", 0.1 );
5258 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5259 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5260 setPreferenceProperty( distributionGr, "columns", 3 );
5262 types.append( tr( "SMESH_MONOCOLOR" ) );
5263 types.append( tr( "SMESH_MULTICOLOR" ) );
5264 indices.clear(); indices.append( 0 ); indices.append( 1 );
5265 setPreferenceProperty( coloringType, "strings", types );
5266 setPreferenceProperty( coloringType, "indexes", indices );
5267 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5271 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5273 if( sect=="SMESH" ) {
5274 float sbX1,sbY1,sbW,sbH;
5275 float aTol = 1.00000009999999;
5276 std::string aWarning;
5277 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5278 if( name=="selection_object_color" || name=="selection_element_color" ||
5279 name=="highlight_color" ||
5280 name=="selection_precision_node" || name=="selection_precision_element" ||
5281 name=="selection_precision_object")
5282 SMESH::UpdateSelectionProp( this );
5283 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
5284 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5285 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5286 if(sbX1+sbW > aTol){
5287 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5290 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5291 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5294 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
5295 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5296 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5297 if(sbY1+sbH > aTol){
5298 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5299 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5300 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5303 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
5304 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5305 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5306 if(sbX1+sbW > aTol){
5307 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5310 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5311 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5314 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
5315 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5316 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5317 if(sbY1+sbH > aTol){
5318 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5321 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5322 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5325 else if ( name == "segmentation" ) {
5326 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5327 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5329 else if ( name == "nb_segments_per_edge" ) {
5330 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5331 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5333 else if ( name == "historical_python_dump" ||
5334 name == "forget_mesh_on_hyp_modif") {
5335 QString val = aResourceMgr->stringValue( "SMESH", name );
5336 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5338 else if ( name == QString( "numbering_node_color" ) || name == QString( "numbering_node_font" ) ) {
5339 SMESH::UpdateFontProp( this );
5341 else if ( name == QString( "numbering_elem_color" ) || name == QString( "numbering_elem_font" ) ) {
5342 SMESH::UpdateFontProp( this );
5345 if(aWarning.size() != 0){
5346 aWarning += "The default values are applied instead.";
5347 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5348 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5349 QObject::tr(aWarning.c_str()));
5354 //================================================================================
5356 * \brief Update something in accordance with update flags
5357 * \param theFlags - update flags
5359 * Update viewer or/and object browser etc. in accordance with update flags ( see
5360 * LightApp_UpdateFlags enumeration ).
5362 //================================================================================
5363 void SMESHGUI::update( const int flags )
5365 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5366 SMESH::UpdateView();
5368 SalomeApp_Module::update( flags );
5371 //================================================================================
5373 * \brief Set default selection mode
5375 * SLOT called when operation commited. Sets default selection mode
5377 //================================================================================
5378 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5380 SVTK_ViewWindow* vtkWnd =
5381 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5383 vtkWnd->SetSelectionMode( ActorSelection );
5386 //================================================================================
5388 * \brief Set default selection mode
5390 * SLOT called when operation aborted. Sets default selection mode
5392 //================================================================================
5393 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5395 SVTK_ViewWindow* vtkWnd =
5396 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5398 vtkWnd->SetSelectionMode( ActorSelection );
5401 //================================================================================
5403 * \brief Creates operation with given identifier
5404 * \param id - identifier of operation to be started
5405 * \return Pointer on created operation or NULL if operation is not created
5407 * Virtual method redefined from the base class creates operation with given id.
5408 * It is called called automatically from startOperation method of base class.
5410 //================================================================================
5411 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5413 LightApp_Operation* op = 0;
5414 // to do : create operation here
5417 case SMESHOp::OpConvertMeshToQuadratic:
5418 op = new SMESHGUI_ConvToQuadOp();
5420 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
5421 op = new SMESHGUI_Make2DFrom3DOp();
5423 case SMESHOp::OpReorientFaces:
5424 op = new SMESHGUI_ReorientFacesOp();
5426 case SMESHOp::OpCreateMesh:
5427 op = new SMESHGUI_MeshOp( true, true );
5429 case SMESHOp::OpCreateSubMesh:
5430 op = new SMESHGUI_MeshOp( true, false );
5432 case SMESHOp::OpEditMeshOrSubMesh:
5433 op = new SMESHGUI_MeshOp( false );
5435 case SMESHOp::OpCompute:
5436 op = new SMESHGUI_ComputeOp();
5438 case SMESHOp::OpPreCompute:
5439 op = new SMESHGUI_PrecomputeOp();
5441 case SMESHOp::OpEvaluate:
5442 op = new SMESHGUI_EvaluateOp();
5444 case SMESHOp::OpMeshOrder:
5445 op = new SMESHGUI_MeshOrderOp();
5447 case SMESHOp::OpCreateGeometryGroup:
5448 op = new SMESHGUI_GroupOnShapeOp();
5450 case SMESHOp::OpFindElementByPoint:
5451 op = new SMESHGUI_FindElemByPointOp();
5453 case SMESHOp::OpMoveNode: // Make mesh pass through point
5454 op = new SMESHGUI_MakeNodeAtPointOp();
5456 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
5457 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5464 op = SalomeApp_Module::createOperation( id );
5468 //================================================================================
5470 * \brief Stops current operations and starts a given one
5471 * \param id - The id of the operation to start
5473 //================================================================================
5475 void SMESHGUI::switchToOperation(int id)
5477 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5478 activeStudy()->abortAllOperations();
5479 startOperation( id );
5482 LightApp_Displayer* SMESHGUI::displayer()
5485 myDisplayer = new SMESHGUI_Displayer( getApp() );
5489 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5492 int aTolerance = 64;
5493 int anIterations = 0;
5499 if( anIterations % aPeriod == 0 )
5502 if( aTolerance < 1 )
5506 aHue = (int)( 360.0 * rand() / RAND_MAX );
5509 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5510 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5511 for( ; it != itEnd; ++it )
5513 SALOMEDS::Color anAutoColor = *it;
5514 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5517 aQColor.getHsv( &h, &s, &v );
5518 if( abs( h - aHue ) < aTolerance )
5530 aColor.setHsv( aHue, 255, 255 );
5532 SALOMEDS::Color aSColor;
5533 aSColor.R = aColor.redF();
5534 aSColor.G = aColor.greenF();
5535 aSColor.B = aColor.blueF();
5540 const char* gSeparator = "_"; // character used to separate parameter names
5541 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5542 const char* gPathSep = "|"; // character used to separate paths
5545 * \brief Store visual parameters
5547 * This method is called just before the study document is saved.
5548 * Store visual parameters in AttributeParameter attribue(s)
5550 void SMESHGUI::storeVisualParameters (int savePoint)
5553 Kernel_Utils::Localizer loc;
5555 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5556 if (!appStudy || !appStudy->studyDS())
5558 _PTR(Study) studyDS = appStudy->studyDS();
5560 // componentName is used for encoding of entries when storing them in IParameters
5561 std::string componentName = myComponentSMESH->ComponentDataType();
5562 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5563 //if (!aSComponent) return;
5566 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5567 componentName.c_str(),
5569 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5571 // store map of custom markers
5572 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5573 if( !aMarkerMap.empty() )
5575 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5576 for( ; anIter != aMarkerMap.end(); anIter++ )
5578 int anId = anIter->first;
5579 VTK::MarkerData aMarkerData = anIter->second;
5580 std::string aMarkerFileName = aMarkerData.first;
5581 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5582 if( aMarkerTexture.size() < 3 )
5583 continue; // should contain at least width, height and the first value
5585 QString aPropertyName( "texture" );
5586 aPropertyName += gSeparator;
5587 aPropertyName += QString::number( anId );
5589 QString aPropertyValue = aMarkerFileName.c_str();
5590 aPropertyValue += gPathSep;
5592 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5593 ushort aWidth = *aTextureIter++;
5594 ushort aHeight = *aTextureIter++;
5595 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5596 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5597 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5598 aPropertyValue += QString::number( *aTextureIter );
5600 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5604 // viewers counters are used for storing view_numbers in IParameters
5607 // main cycle to store parameters of displayed objects
5608 QList<SUIT_ViewManager*> lst;
5609 QList<SUIT_ViewManager*>::Iterator it;
5610 getApp()->viewManagers(lst);
5611 for (it = lst.begin(); it != lst.end(); it++)
5613 SUIT_ViewManager* vman = *it;
5614 QString vType = vman->getType();
5616 // saving VTK actors properties
5617 if (vType == SVTK_Viewer::Type())
5619 // store the clipping planes attached to the view manager
5620 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5621 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5622 if( anIter != myClippingPlaneInfoMap.end() )
5623 aClippingPlaneInfoList = anIter->second;
5625 if( !aClippingPlaneInfoList.empty() ) {
5626 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5627 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5629 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5630 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5632 QString aPropertyName( "ClippingPlane" );
5633 aPropertyName += gSeparator;
5634 aPropertyName += QString::number( vtkViewers );
5635 aPropertyName += gSeparator;
5636 aPropertyName += QString::number( anId );
5638 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
5639 aPropertyValue += gDigitsSep;
5640 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
5641 aPropertyValue += gDigitsSep;
5642 if ( aPlane->PlaneMode == SMESH::Absolute ) {
5643 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
5644 aPropertyValue += gDigitsSep;
5645 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
5646 aPropertyValue += gDigitsSep;
5647 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
5648 aPropertyValue += gDigitsSep;
5649 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
5650 aPropertyValue += gDigitsSep;
5651 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
5652 aPropertyValue += gDigitsSep;
5653 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
5654 aPropertyValue += gDigitsSep;
5655 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
5657 else if ( aPlane->PlaneMode == SMESH::Relative ) {
5658 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
5659 aPropertyValue += gDigitsSep;
5660 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5661 aPropertyValue += gDigitsSep;
5662 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5663 aPropertyValue += gDigitsSep;
5664 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5667 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5671 QVector<SUIT_ViewWindow*> views = vman->getViews();
5672 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5674 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5676 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5677 vtkActorCollection* allActors = aCopy.GetActors();
5678 allActors->InitTraversal();
5679 while (vtkActor* actor = allActors->GetNextActor())
5681 if (actor->GetVisibility()) // store only visible actors
5683 SMESH_Actor* aSmeshActor = 0;
5684 if (actor->IsA("SMESH_Actor"))
5685 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5686 if (aSmeshActor && aSmeshActor->hasIO())
5688 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5691 // entry is "encoded" = it does NOT contain component adress,
5692 // since it is a subject to change on next component loading
5693 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5695 std::string param, vtkParam = vType.toLatin1().data();
5696 vtkParam += gSeparator;
5697 vtkParam += QString::number(vtkViewers).toLatin1().data();
5698 vtkParam += gSeparator;
5701 param = vtkParam + "Visibility";
5702 ip->setParameter(entry, param, "On");
5705 param = vtkParam + "Representation";
5706 ip->setParameter(entry, param, QString::number
5707 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5710 param = vtkParam + "IsShrunk";
5711 ip->setParameter(entry, param, QString::number
5712 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5714 // Displayed entities
5715 unsigned int aMode = aSmeshActor->GetEntityMode();
5716 bool isE = aMode & SMESH_Actor::eEdges;
5717 bool isF = aMode & SMESH_Actor::eFaces;
5718 bool isV = aMode & SMESH_Actor::eVolumes;
5719 bool is0d = aMode & SMESH_Actor::e0DElements;
5720 bool isB = aMode & SMESH_Actor::eBallElem;
5722 QString modeStr ("e");
5723 modeStr += gDigitsSep; modeStr += QString::number(isE);
5724 modeStr += gDigitsSep; modeStr += "f";
5725 modeStr += gDigitsSep; modeStr += QString::number(isF);
5726 modeStr += gDigitsSep; modeStr += "v";
5727 modeStr += gDigitsSep; modeStr += QString::number(isV);
5728 modeStr += gDigitsSep; modeStr += "0d";
5729 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5730 modeStr += gDigitsSep; modeStr += "b";
5731 modeStr += gDigitsSep; modeStr += QString::number(isB);
5733 param = vtkParam + "Entities";
5734 ip->setParameter(entry, param, modeStr.toLatin1().data());
5740 aSmeshActor->GetSufaceColor(r, g, b, delta);
5741 QStringList colorStr;
5742 colorStr << "surface";
5743 colorStr << QString::number(r);
5744 colorStr << QString::number(g);
5745 colorStr << QString::number(b);
5747 colorStr << "backsurface";
5748 colorStr << QString::number(delta);
5750 aSmeshActor->GetVolumeColor(r, g, b, delta);
5751 colorStr << "volume";
5752 colorStr << QString::number(r);
5753 colorStr << QString::number(g);
5754 colorStr << QString::number(b);
5755 colorStr << QString::number(delta);
5757 aSmeshActor->GetEdgeColor(r, g, b);
5759 colorStr << QString::number(r);
5760 colorStr << QString::number(g);
5761 colorStr << QString::number(b);
5763 aSmeshActor->GetNodeColor(r, g, b);
5765 colorStr << QString::number(r);
5766 colorStr << QString::number(g);
5767 colorStr << QString::number(b);
5769 aSmeshActor->GetOutlineColor(r, g, b);
5770 colorStr << "outline";
5771 colorStr << QString::number(r);
5772 colorStr << QString::number(g);
5773 colorStr << QString::number(b);
5775 aSmeshActor->Get0DColor(r, g, b);
5776 colorStr << "elem0d";
5777 colorStr << QString::number(r);
5778 colorStr << QString::number(g);
5779 colorStr << QString::number(b);
5781 aSmeshActor->GetBallColor(r, g, b);
5783 colorStr << QString::number(r);
5784 colorStr << QString::number(g);
5785 colorStr << QString::number(b);
5787 aSmeshActor->GetFacesOrientationColor(r, g, b);
5788 colorStr << "orientation";
5789 colorStr << QString::number(r);
5790 colorStr << QString::number(g);
5791 colorStr << QString::number(b);
5793 param = vtkParam + "Colors";
5794 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5797 QStringList sizeStr;
5799 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
5800 sizeStr << "outline";
5801 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
5802 sizeStr << "elem0d";
5803 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
5805 sizeStr << QString::number((int)aSmeshActor->GetBallSize());
5806 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
5807 sizeStr << "shrink";
5808 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
5809 sizeStr << "orientation";
5810 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
5811 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
5813 param = vtkParam + "Sizes";
5814 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
5819 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5820 if( aMarkerType == VTK::MT_USER ) {
5821 markerStr += "custom";
5822 markerStr += gDigitsSep;
5823 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5827 markerStr += gDigitsSep;
5828 markerStr += QString::number( (int)aMarkerType );
5829 markerStr += gDigitsSep;
5830 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5833 param = vtkParam + "PointMarker";
5834 ip->setParameter(entry, param, markerStr.toLatin1().data());
5837 param = vtkParam + "Opacity";
5838 ip->setParameter(entry, param,
5839 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5842 param = vtkParam + "ClippingPlane";
5844 if( !aClippingPlaneInfoList.empty() ) {
5845 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5846 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5848 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5849 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5850 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5851 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5852 if( aSmeshActor == *anIter2 ) {
5853 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5854 QString::number( anId ).toLatin1().constData() );
5861 ip->setParameter( entry, param, "Off" );
5862 } // if (io->hasEntry())
5863 } // SMESH_Actor && hasIO
5865 } // while.. actors traversal
5869 } // if (SVTK view model)
5870 } // for (viewManagers)
5873 // data structures for clipping planes processing
5877 bool isOpenGLClipping;
5878 vtkIdType RelativeOrientation;
5881 int AbsoluteOrientation;
5882 double X, Y, Z, Dx, Dy, Dz;
5884 typedef std::list<TPlaneData> TPlaneDataList;
5885 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5887 typedef std::list<vtkActor*> TActorList;
5890 TActorList ActorList;
5891 SUIT_ViewManager* ViewManager;
5893 typedef std::list<TPlaneInfo> TPlaneInfoList;
5894 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5897 * \brief Restore visual parameters
5899 * This method is called after the study document is opened.
5900 * Restore visual parameters from AttributeParameter attribue(s)
5902 void SMESHGUI::restoreVisualParameters (int savePoint)
5905 Kernel_Utils::Localizer loc;
5907 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5908 if (!appStudy || !appStudy->studyDS())
5910 _PTR(Study) studyDS = appStudy->studyDS();
5912 // componentName is used for encoding of entries when storing them in IParameters
5913 std::string componentName = myComponentSMESH->ComponentDataType();
5914 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5915 //if (!aSComponent) return;
5918 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5919 componentName.c_str(),
5921 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5923 // restore map of custom markers and map of clipping planes
5924 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5925 TPlaneDataMap aPlaneDataMap;
5927 std::vector<std::string> properties = ip->getProperties();
5928 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5930 std::string property = *propIt;
5931 QString aPropertyName( property.c_str() );
5932 QString aPropertyValue( ip->getProperty( property ).c_str() );
5934 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5935 if( aPropertyNameList.isEmpty() )
5938 QString aPropertyType = aPropertyNameList[0];
5939 if( aPropertyType == "texture" )
5941 if( aPropertyNameList.size() != 2 )
5945 int anId = aPropertyNameList[1].toInt( &ok );
5946 if( !ok || anId < 1 )
5949 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5950 if( aPropertyValueList.size() != 2 )
5953 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5954 QString aMarkerTextureString = aPropertyValueList[1];
5955 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5956 if( aMarkerTextureStringList.size() != 3 )
5960 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5965 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5969 VTK::MarkerTexture aMarkerTexture;
5970 aMarkerTexture.push_back( aWidth );
5971 aMarkerTexture.push_back( aHeight );
5973 QString aMarkerTextureData = aMarkerTextureStringList[2];
5974 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5976 QChar aChar = aMarkerTextureData.at( i );
5977 if( aChar.isDigit() )
5978 aMarkerTexture.push_back( aChar.digitValue() );
5981 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5983 else if( aPropertyType == "ClippingPlane" )
5985 if( aPropertyNameList.size() != 3 )
5989 int aViewId = aPropertyNameList[1].toInt( &ok );
5990 if( !ok || aViewId < 0 )
5994 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5995 if( !ok || aClippingPlaneId < 0 )
5998 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5999 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6002 TPlaneData aPlaneData;
6003 aPlaneData.Id = aClippingPlaneId;
6006 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6011 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6015 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6018 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6023 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6028 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6033 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6038 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6043 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6048 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6052 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6054 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6059 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6064 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6069 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6074 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6075 aPlaneDataList.push_back( aPlaneData );
6079 TPlaneInfoMap aPlaneInfoMap;
6081 std::vector<std::string> entries = ip->getEntries();
6083 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6085 // entry is a normal entry - it should be "decoded" (setting base adress of component)
6086 QString entry (ip->decodeEntry(*entIt).c_str());
6088 // Check that the entry corresponds to a real object in the Study
6089 // as the object may be deleted or modified after the visual state is saved.
6090 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
6091 if (!so) continue; //Skip the not existent entry
6093 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6094 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6096 std::vector<std::string>::iterator namesIt = paramNames.begin();
6097 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6099 // actors are stored in a map after displaying of them for
6100 // quicker access in the future: map < viewID to actor >
6101 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6103 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6105 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6106 // '_' is used as separator and should not be used in viewer type or parameter names.
6107 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6108 if (lst.size() != 3)
6111 QString viewerTypStr = lst[0];
6112 QString viewIndexStr = lst[1];
6113 QString paramNameStr = lst[2];
6116 int viewIndex = viewIndexStr.toUInt(&ok);
6117 if (!ok) // bad conversion of view index to integer
6121 if (viewerTypStr == SVTK_Viewer::Type())
6123 SMESH_Actor* aSmeshActor = 0;
6124 if (vtkActors.IsBound(viewIndex))
6125 aSmeshActor = vtkActors.Find(viewIndex);
6127 QList<SUIT_ViewManager*> lst;
6128 getApp()->viewManagers(viewerTypStr, lst);
6130 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6131 SUIT_ViewManager* vman = NULL;
6132 if (viewIndex >= 0 && viewIndex < lst.count())
6133 vman = lst.at(viewIndex);
6135 if (paramNameStr == "Visibility")
6137 if (!aSmeshActor && displayer() && vman)
6139 SUIT_ViewModel* vmodel = vman->getViewModel();
6140 // SVTK view model can be casted to SALOME_View
6141 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6143 // store displayed actor in a temporary map for quicker
6144 // access later when restoring other parameters
6145 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6146 vtkRenderer* Renderer = vtkView->getRenderer();
6147 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6148 vtkActorCollection* theActors = aCopy.GetActors();
6149 theActors->InitTraversal();
6150 bool isFound = false;
6151 vtkActor *ac = theActors->GetNextActor();
6152 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6153 if (ac->IsA("SMESH_Actor")) {
6154 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6155 if (aGeomAc->hasIO()) {
6156 Handle(SALOME_InteractiveObject) io =
6157 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
6158 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
6160 vtkActors.Bind(viewIndex, aGeomAc);
6166 } // if (paramNameStr == "Visibility")
6169 // the rest properties "work" with SMESH_Actor
6172 QString val ((*valuesIt).c_str());
6175 if (paramNameStr == "Representation") {
6176 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6179 else if (paramNameStr == "IsShrunk") {
6181 if (!aSmeshActor->IsShrunk())
6182 aSmeshActor->SetShrink();
6185 if (aSmeshActor->IsShrunk())
6186 aSmeshActor->UnShrink();
6189 // Displayed entities
6190 else if (paramNameStr == "Entities") {
6191 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6192 int aEntityMode = SMESH_Actor::eAllEntity;
6193 for ( int i = 0; i < mode.count(); i+=2 ) {
6194 if ( i < mode.count()-1 ) {
6195 QString type = mode[i];
6196 bool val = mode[i+1].toInt();
6197 if ( type == "e" && !val )
6198 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6199 else if ( type == "f" && !val )
6200 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6201 else if ( type == "v" && !val )
6202 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6203 else if ( type == "0d" && !val )
6204 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6205 else if ( type == "b" && !val )
6206 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6209 aSmeshActor->SetEntityMode( aEntityMode );
6212 else if (paramNameStr == "Colors") {
6213 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6220 QColor outlineColor;
6221 QColor orientationColor;
6227 // below lines are required to get default values for delta coefficients
6228 // of backface color for faces and color of reversed volumes
6229 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6230 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6231 for ( int i = 0; i < colors.count(); i++ ) {
6232 QString type = colors[i];
6233 if ( type == "surface" ) {
6234 // face color is set by 3 values r:g:b, where
6235 // - r,g,b - is rgb color components
6236 if ( i+1 >= colors.count() ) break; // format error
6237 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6238 if ( i+2 >= colors.count() ) break; // format error
6239 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6240 if ( i+3 >= colors.count() ) break; // format error
6241 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6242 faceColor.setRgbF( r, g, b );
6245 else if ( type == "backsurface" ) {
6246 // backface color can be defined in several ways
6247 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6248 // - in latest versions, it is set as delta coefficient
6249 bool rgbOk = false, deltaOk;
6250 if ( i+1 >= colors.count() ) break; // format error
6251 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6252 int delta = colors[i+1].toInt( &deltaOk );
6254 if ( i+1 < colors.count() ) // index is shifted to 1
6255 g = colors[i+1].toDouble( &rgbOk );
6256 if ( rgbOk ) i++; // shift index
6257 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6258 b = colors[i+1].toDouble( &rgbOk );
6260 // - as currently there's no way to set directly backsurface color as it was before,
6261 // we ignore old dump where r,g,b triple was set
6262 // - also we check that delta parameter is set properly
6263 if ( !rgbOk && deltaOk )
6266 else if ( type == "volume" ) {
6267 // volume color is set by 4 values r:g:b:delta, where
6268 // - r,g,b - is a normal volume rgb color components
6269 // - delta - is a reversed volume color delta coefficient
6270 if ( i+1 >= colors.count() ) break; // format error
6271 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6272 if ( i+2 >= colors.count() ) break; // format error
6273 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6274 if ( i+3 >= colors.count() ) break; // format error
6275 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6276 if ( i+4 >= colors.count() ) break; // format error
6277 int delta = colors[i+4].toInt( &bOk );
6278 if ( !bOk ) break; // format error
6279 volumeColor.setRgbF( r, g, b );
6283 else if ( type == "edge" ) {
6284 // edge color is set by 3 values r:g:b, where
6285 // - r,g,b - is rgb color components
6286 if ( i+1 >= colors.count() ) break; // format error
6287 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6288 if ( i+2 >= colors.count() ) break; // format error
6289 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6290 if ( i+3 >= colors.count() ) break; // format error
6291 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6292 edgeColor.setRgbF( r, g, b );
6295 else if ( type == "node" ) {
6296 // node color is set by 3 values r:g:b, where
6297 // - r,g,b - is rgb color components
6298 if ( i+1 >= colors.count() ) break; // format error
6299 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6300 if ( i+2 >= colors.count() ) break; // format error
6301 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6302 if ( i+3 >= colors.count() ) break; // format error
6303 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6304 nodeColor.setRgbF( r, g, b );
6307 else if ( type == "elem0d" ) {
6308 // 0d element color is set by 3 values r:g:b, where
6309 // - r,g,b - is rgb color components
6310 if ( i+1 >= colors.count() ) break; // format error
6311 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6312 if ( i+2 >= colors.count() ) break; // format error
6313 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6314 if ( i+3 >= colors.count() ) break; // format error
6315 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6316 elem0dColor.setRgbF( r, g, b );
6319 else if ( type == "ball" ) {
6320 // ball color is set by 3 values r:g:b, where
6321 // - r,g,b - is rgb color components
6322 if ( i+1 >= colors.count() ) break; // format error
6323 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6324 if ( i+2 >= colors.count() ) break; // format error
6325 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6326 if ( i+3 >= colors.count() ) break; // format error
6327 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6328 ballColor.setRgbF( r, g, b );
6331 else if ( type == "outline" ) {
6332 // outline color is set by 3 values r:g:b, where
6333 // - r,g,b - is rgb color components
6334 if ( i+1 >= colors.count() ) break; // format error
6335 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6336 if ( i+2 >= colors.count() ) break; // format error
6337 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6338 if ( i+3 >= colors.count() ) break; // format error
6339 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6340 outlineColor.setRgbF( r, g, b );
6343 else if ( type == "orientation" ) {
6344 // orientation color is set by 3 values r:g:b, where
6345 // - r,g,b - is rgb color components
6346 if ( i+1 >= colors.count() ) break; // format error
6347 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6348 if ( i+2 >= colors.count() ) break; // format error
6349 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6350 if ( i+3 >= colors.count() ) break; // format error
6351 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6352 orientationColor.setRgbF( r, g, b );
6357 if ( nodeColor.isValid() )
6358 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6360 if ( edgeColor.isValid() )
6361 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6363 if ( faceColor.isValid() )
6364 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6366 if ( volumeColor.isValid() )
6367 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6368 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6369 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6371 if ( elem0dColor.isValid() )
6372 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6374 if ( ballColor.isValid() )
6375 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6377 if ( outlineColor.isValid() )
6378 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6379 // orientation color
6380 if ( orientationColor.isValid() )
6381 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6384 else if (paramNameStr == "Sizes") {
6385 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6388 int outlineWidth = -1;
6389 int elem0dSize = -1;
6391 double ballScale = -1.0;
6392 double shrinkSize = -1;
6393 double orientationSize = -1;
6394 bool orientation3d = false;
6395 for ( int i = 0; i < sizes.count(); i++ ) {
6396 QString type = sizes[i];
6397 if ( type == "line" ) {
6398 // line (wireframe) width is given as single integer value
6399 if ( i+1 >= sizes.count() ) break; // format error
6400 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6404 if ( type == "outline" ) {
6405 // outline width is given as single integer value
6406 if ( i+1 >= sizes.count() ) break; // format error
6407 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6411 else if ( type == "elem0d" ) {
6412 // 0d element size is given as single integer value
6413 if ( i+1 >= sizes.count() ) break; // format error
6414 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6418 else if ( type == "ball" ) {
6419 // balls are specified by two values: size:scale, where
6420 // - size - is a integer value specifying size
6421 // - scale - is a double value specifying scale factor
6422 if ( i+1 >= sizes.count() ) break; // format error
6423 int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6424 if ( i+2 >= sizes.count() ) break; // format error
6425 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6430 else if ( type == "shrink" ) {
6431 // shrink factor is given as single floating point value
6432 if ( i+1 >= sizes.count() ) break; // format error
6433 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6437 else if ( type == "orientation" ) {
6438 // orientation vectors are specified by two values size:3d, where
6439 // - size - is a floating point value specifying scale factor
6440 // - 3d - is a boolean
6441 if ( i+1 >= sizes.count() ) break; // format error
6442 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6443 if ( i+2 >= sizes.count() ) break; // format error
6444 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6445 orientationSize = v1;
6446 orientation3d = (bool)v2;
6450 // line (wireframe) width
6451 if ( lineWidth > 0 )
6452 aSmeshActor->SetLineWidth( lineWidth );
6454 if ( outlineWidth > 0 )
6455 aSmeshActor->SetOutlineWidth( outlineWidth );
6456 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6457 aSmeshActor->SetOutlineWidth( lineWidth );
6459 if ( elem0dSize > 0 )
6460 aSmeshActor->Set0DSize( elem0dSize );
6463 aSmeshActor->SetBallSize( ballSize );
6465 if ( ballScale > 0.0 )
6466 aSmeshActor->SetBallScale( ballScale );
6468 if ( shrinkSize > 0 )
6469 aSmeshActor->SetShrinkFactor( shrinkSize );
6470 // orientation vectors
6471 if ( orientationSize > 0 ) {
6472 aSmeshActor->SetFacesOrientationScale( orientationSize );
6473 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6477 else if (paramNameStr == "PointMarker") {
6478 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6479 if( data.count() >= 2 ) {
6481 int aParam1 = data[1].toInt( &ok );
6483 if( data[0] == "std" && data.count() == 3 ) {
6484 int aParam2 = data[2].toInt( &ok );
6485 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6487 else if( data[0] == "custom" ) {
6488 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
6489 if( markerIt != aMarkerMap.end() ) {
6490 VTK::MarkerData aMarkerData = markerIt->second;
6491 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6498 else if (paramNameStr == "Opacity") {
6499 aSmeshActor->SetOpacity(val.toFloat());
6502 else if (paramNameStr.startsWith("ClippingPlane")) {
6503 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6504 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
6505 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
6506 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
6507 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
6508 // new format - val looks like "Off" or "0" (plane id)
6509 // (note: in new format "Off" value is used only for consistency,
6510 // so it is processed together with values in old format)
6511 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
6512 if( anIsOldFormat ) {
6513 if (paramNameStr == "ClippingPlane1" || val == "Off")
6514 aSmeshActor->RemoveAllClippingPlanes();
6516 QList<SUIT_ViewManager*> lst;
6517 getApp()->viewManagers(viewerTypStr, lst);
6518 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6519 if (viewIndex >= 0 && viewIndex < lst.count()) {
6520 SUIT_ViewManager* vman = lst.at(viewIndex);
6521 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6523 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6525 SMESH::TActorList anActorList;
6526 anActorList.push_back( aSmeshActor );
6527 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
6528 aPlane->myViewWindow = vtkView;
6529 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
6530 aPlane->PlaneMode = aMode;
6531 bool isOpenGLClipping = ( bool )vals[1].toInt();
6532 aPlane->IsOpenGLClipping = isOpenGLClipping;
6533 if ( aMode == SMESH::Absolute ) {
6534 aPlane->myAbsoluteOrientation = vals[2].toInt();
6535 aPlane->X = vals[3].toFloat();
6536 aPlane->Y = vals[4].toFloat();
6537 aPlane->Z = vals[5].toFloat();
6538 aPlane->Dx = vals[6].toFloat();
6539 aPlane->Dy = vals[7].toFloat();
6540 aPlane->Dz = vals[8].toFloat();
6542 else if ( aMode == SMESH::Relative ) {
6543 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
6544 aPlane->myDistance = vals[3].toFloat();
6545 aPlane->myAngle[0] = vals[4].toFloat();
6546 aPlane->myAngle[1] = vals[5].toFloat();
6550 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6551 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6552 aClippingPlaneInfo.Plane = aPlane;
6553 aClippingPlaneInfo.ActorList = anActorList;
6554 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6562 int aPlaneId = val.toInt( &ok );
6563 if( ok && aPlaneId >= 0 ) {
6564 bool anIsDefinedPlane = false;
6565 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6566 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6567 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6568 TPlaneInfo& aPlaneInfo = *anIter;
6569 if( aPlaneInfo.PlaneId == aPlaneId ) {
6570 aPlaneInfo.ActorList.push_back( aSmeshActor );
6571 anIsDefinedPlane = true;
6575 if( !anIsDefinedPlane ) {
6576 TPlaneInfo aPlaneInfo;
6577 aPlaneInfo.PlaneId = aPlaneId;
6578 aPlaneInfo.ActorList.push_back( aSmeshActor );
6579 aPlaneInfo.ViewManager = vman;
6581 // to make the list sorted by plane id
6582 anIter = aPlaneInfoList.begin();
6583 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6584 const TPlaneInfo& aPlaneInfoRef = *anIter;
6585 if( aPlaneInfoRef.PlaneId > aPlaneId )
6588 aPlaneInfoList.insert( anIter, aPlaneInfo );
6593 } // if (aSmeshActor)
6594 } // other parameters than Visibility
6596 } // for names/parameters iterator
6597 } // for entries iterator
6599 // take into account planes with empty list of actors referred to them
6600 QList<SUIT_ViewManager*> aVMList;
6601 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6603 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6604 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6605 int aViewId = aPlaneDataIter->first;
6606 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6607 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6609 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6611 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6612 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6613 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6614 const TPlaneData& aPlaneData = *anIter2;
6615 int aPlaneId = aPlaneData.Id;
6617 bool anIsFound = false;
6618 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6619 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6620 const TPlaneInfo& aPlaneInfo = *anIter3;
6621 if( aPlaneInfo.PlaneId == aPlaneId ) {
6628 TPlaneInfo aPlaneInfo; // ActorList field is empty
6629 aPlaneInfo.PlaneId = aPlaneId;
6630 aPlaneInfo.ViewManager = aViewManager;
6632 // to make the list sorted by plane id
6633 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6634 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6635 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6636 if( aPlaneInfoRef.PlaneId > aPlaneId )
6639 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6645 // add clipping planes to actors according to the restored parameters
6646 // and update the clipping plane map
6647 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6648 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6649 int aViewId = anIter1->first;
6650 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6652 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6653 if( anIter2 == aPlaneDataMap.end() )
6655 const TPlaneDataList& aPlaneDataList = anIter2->second;
6657 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6658 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6659 const TPlaneInfo& aPlaneInfo = *anIter3;
6660 int aPlaneId = aPlaneInfo.PlaneId;
6661 const TActorList& anActorList = aPlaneInfo.ActorList;
6662 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6666 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6670 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6672 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6673 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6674 const TPlaneData& aPlaneData = *anIter4;
6675 if( aPlaneData.Id == aPlaneId ) {
6676 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
6677 aPlane->myViewWindow = aViewWindow;
6678 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
6679 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
6680 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6681 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
6682 aPlane->X = aPlaneData.X;
6683 aPlane->Y = aPlaneData.Y;
6684 aPlane->Z = aPlaneData.Z;
6685 aPlane->Dx = aPlaneData.Dx;
6686 aPlane->Dy = aPlaneData.Dy;
6687 aPlane->Dz = aPlaneData.Dz;
6689 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6690 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
6691 aPlane->myDistance = aPlaneData.Distance;
6692 aPlane->myAngle[0] = aPlaneData.Angle[0];
6693 aPlane->myAngle[1] = aPlaneData.Angle[1];
6696 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6697 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6698 aClippingPlaneInfo.Plane = aPlane;
6699 aClippingPlaneInfo.ActorList = anActorList;
6700 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6711 // update all VTK views
6712 QList<SUIT_ViewManager*> lst;
6713 getApp()->viewManagers(lst);
6714 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6715 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6716 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6717 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6718 // set OpenGL clipping planes
6719 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
6720 vtkActorCollection* anAllActors = aCopy.GetActors();
6721 anAllActors->InitTraversal();
6722 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
6723 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
6724 anActor->SetOpenGLClippingPlane();
6726 vtkView->getRenderer()->ResetCameraClippingRange();
6733 \brief Adds preferences for dfont of VTK viewer
6735 \param pIf group identifier
6736 \param param parameter
6737 \return identifier of preferences
6739 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6741 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6743 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6746 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6747 fam.append( tr( "SMESH_FONT_COURIER" ) );
6748 fam.append( tr( "SMESH_FONT_TIMES" ) );
6750 setPreferenceProperty( tfont, "fonts", fam );
6752 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6753 if ( needSize ) f = f | QtxFontEdit::Size;
6754 setPreferenceProperty( tfont, "features", f );
6760 \brief Actions after hypothesis edition
6761 Updates object browser after hypothesis edition
6763 void SMESHGUI::onHypothesisEdit( int result )
6766 SMESHGUI::Modified();
6767 updateObjBrowser( true );
6772 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6773 \param pview view being closed
6775 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6776 #ifndef DISABLE_PLOT2DVIEWER
6777 //Crear all Plot2d Viewers if need.
6778 SMESH::ClearPlot2Viewers(pview);
6782 void SMESHGUI::message( const QString& msg )
6785 QStringList data = msg.split("/");
6786 if ( data.count() > 0 ) {
6787 if ( data.first() == "mesh_loading" ) {
6789 QString entry = data.count() > 1 ? data[1] : QString();
6790 if ( entry.isEmpty() )
6793 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
6795 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
6798 name = QString::fromUtf8(obj->GetName().c_str());
6799 if ( name.isEmpty() )
6802 if ( data.last() == "stop" )
6803 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
6805 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
6806 QApplication::processEvents();
6812 \brief Connects or disconnects signals about activating and cloning view on the module slots
6813 \param pview view which is connected/disconnected
6815 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
6819 SUIT_ViewManager* viewMgr = pview->getViewManager();
6821 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6822 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6824 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6825 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6830 \brief Return \c true if object can be renamed
6832 bool SMESHGUI::renameAllowed( const QString& entry) const {
6833 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6837 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6841 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
6846 if(appStudy->isComponent(entry) || obj->isReference())
6849 // check type to prevent renaming of inappropriate objects
6850 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
6851 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6852 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6853 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6854 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6855 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
6862 Rename object by entry.
6863 \param entry entry of the object
6864 \param name new name of the object
6865 \brief Return \c true if rename operation finished successfully, \c false otherwise.
6867 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
6869 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6873 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6878 _PTR(Study) aStudy = appStudy->studyDS();
6883 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
6885 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
6890 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
6891 _PTR(GenericAttribute) anAttr;
6892 _PTR(AttributeName) aName;
6894 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
6896 // check type to prevent renaming of inappropriate objects
6897 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
6898 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6899 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6900 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6901 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6902 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
6903 if ( !name.isEmpty() ) {
6904 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
6906 // update name of group object and its actor
6907 Handle(SALOME_InteractiveObject) IObject =
6908 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
6910 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
6911 if( !aGroupObject->_is_nil() ) {
6912 aGroupObject->SetName( qPrintable(name) );
6913 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
6914 anActor->setName( qPrintable(name) );
6924 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
6926 static QList<QColor> colors;
6928 if ( colors.isEmpty() ) {
6930 for (int s = 0; s < 2 ; s++)
6932 for (int v = 100; v >= 40; v = v - 20)
6934 for (int h = 0; h < 359 ; h = h + 60)
6936 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
6941 static int currentColor = 0;
6943 SALOMEDS::Color color;
6944 color.R = (double)colors[currentColor].red() / 255.0;
6945 color.G = (double)colors[currentColor].green() / 255.0;
6946 color.B = (double)colors[currentColor].blue() / 255.0;
6948 currentColor = (currentColor+1) % colors.count();