1 // Copyright (C) 2007-2021 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_AddNodeOnSegmentDlg.h"
36 #include "SMESHGUI_AddNodeOnFaceDlg.h"
37 #include "SMESHGUI_AddQuadraticElementDlg.h"
38 #include "SMESHGUI_BuildCompoundDlg.h"
39 #include "SMESHGUI_ClippingDlg.h"
40 #include "SMESHGUI_ComputeDlg.h"
41 #include "SMESHGUI_ConvToQuadOp.h"
42 #include "SMESHGUI_CopyMeshDlg.h"
43 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
44 #include "SMESHGUI_DeleteGroupDlg.h"
45 #include "SMESHGUI_DisplayEntitiesDlg.h"
46 #include "SMESHGUI_Displayer.h"
47 #include "SMESHGUI_DuplicateNodesDlg.h"
48 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
49 #include "SMESHGUI_ExtrusionDlg.h"
50 #include "SMESHGUI_FaceGroupsSeparatedByEdgesDlg.h"
51 #include "SMESHGUI_FieldSelectorWdg.h"
52 #include "SMESHGUI_FileInfoDlg.h"
53 #include "SMESHGUI_FileValidator.h"
54 #include "SMESHGUI_FilterDlg.h"
55 #include "SMESHGUI_FilterLibraryDlg.h"
56 #include "SMESHGUI_FilterUtils.h"
57 #include "SMESHGUI_FindElemByPointDlg.h"
58 #include "SMESHGUI_GEOMGenUtils.h"
59 #include "SMESHGUI_GroupDlg.h"
60 #include "SMESHGUI_GroupOnShapeDlg.h"
61 #include "SMESHGUI_GroupOpDlg.h"
62 #include "SMESHGUI_GroupUtils.h"
63 #include "SMESHGUI_Hypotheses.h"
64 #include "SMESHGUI_HypothesesUtils.h"
65 #include "SMESHGUI_MG_ADAPTDRIVER.h"
66 #include "SMESHGUI_HomardAdaptDlg.h"
67 #include "SMESHGUI_Make2DFrom3DOp.h"
68 #include "SMESHGUI_MakeNodeAtPointDlg.h"
69 #include "SMESHGUI_Measurements.h"
70 #include "SMESHGUI_MergeDlg.h"
71 #include "SMESHGUI_MeshInfo.h"
72 #include "SMESHGUI_MeshOp.h"
73 #include "SMESHGUI_MeshOrderOp.h"
74 #include "SMESHGUI_MeshPatternDlg.h"
75 #include "SMESHGUI_MeshUtils.h"
76 #include "SMESHGUI_MultiEditDlg.h"
77 #include "SMESHGUI_NodesDlg.h"
78 #include "SMESHGUI_OffsetDlg.h"
79 #include "SMESHGUI_Operations.h"
80 #include "SMESHGUI_PatternUtils.h"
81 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
82 #include "SMESHGUI_PropertiesDlg.h"
83 #include "SMESHGUI_RemoveElementsDlg.h"
84 #include "SMESHGUI_RemoveNodeReconnectionDlg.h"
85 #include "SMESHGUI_RemoveNodesDlg.h"
86 #include "SMESHGUI_RenumberingDlg.h"
87 #include "SMESHGUI_ReorientFacesDlg.h"
88 #include "SMESHGUI_RevolutionDlg.h"
89 #include "SMESHGUI_RotationDlg.h"
90 #include "SMESHGUI_ScaleDlg.h"
91 #include "SMESHGUI_Selection.h"
92 #include "SMESHGUI_SewingDlg.h"
93 #include "SMESHGUI_SingleEditDlg.h"
94 #include "SMESHGUI_SmoothingDlg.h"
95 #include "SMESHGUI_SpinBox.h"
96 #include "SMESHGUI_SplitBiQuad.h"
97 #include "SMESHGUI_SymmetryDlg.h"
98 #include "SMESHGUI_TranslationDlg.h"
99 #include "SMESHGUI_TransparencyDlg.h"
100 #include "SMESHGUI_Utils.h"
101 #include "SMESHGUI_VTKUtils.h"
103 #include "SMESH_version.h"
105 #include "SMESH_Actor.h"
106 #include "SMESH_ActorUtils.h"
107 #include "SMESH_Client.hxx"
108 #include "SMESH_Comment.hxx"
109 #include "SMESH_ControlsDef.hxx"
110 #include "SMESH_ScalarBarActor.h"
111 #include "SMESH_TypeFilter.hxx"
112 #include "SMESH_Component_Generator.hxx"
114 // SALOME GUI includes
115 #include <LightApp_DataOwner.h>
116 #include <LightApp_NameDlg.h>
117 #include <LightApp_Preferences.h>
118 #include <LightApp_SelectionMgr.h>
119 #include <LightApp_UpdateFlags.h>
120 #include <QtxFontEdit.h>
121 #include <QtxPopupMgr.h>
122 #include <QtxInfoPanel.h>
123 #include <SALOME_ListIO.hxx>
124 #include <SUIT_Desktop.h>
125 #include <SUIT_FileDlg.h>
126 #include <SUIT_MessageBox.h>
127 #include <SUIT_OverrideCursor.h>
128 #include <SUIT_ResourceMgr.h>
129 #include <SUIT_Session.h>
130 #include <SVTK_Renderer.h>
131 #include <SVTK_ViewManager.h>
132 #include <SVTK_ViewModel.h>
133 #include <SVTK_ViewWindow.h>
134 #include <SalomeApp_Application.h>
135 #include <SalomeApp_CheckFileDlg.h>
136 #include <SalomeApp_DataObject.h>
137 #include <SalomeApp_Study.h>
138 #include <SalomeApp_Tools.h>
139 #include <VTKViewer_Algorithm.h>
141 #ifndef DISABLE_PLOT2DVIEWER
142 #include <SPlot2d_ViewModel.h>
143 #include <SPlot2d_Histogram.h>
147 #include <SALOMEconfig.h>
148 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
149 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
150 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
151 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
152 #include CORBA_CLIENT_HEADER(SMESH_Homard)
155 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
156 #include <QApplication>
158 #include <QDialogButtonBox>
162 #include <QTextStream>
166 #include <boost/shared_ptr.hpp>
169 #include <vtkCallbackCommand.h>
170 #include <vtkCamera.h>
171 #include <vtkLookupTable.h>
172 #include <vtkPlane.h>
173 #include <vtkRenderer.h>
175 // SALOME KERNEL includes
176 #include <Basics_Utils.hxx>
177 #include <SALOMEDSClient_ClientFactory.hxx>
178 #include <SALOMEDSClient_IParameters.hxx>
179 #include <SALOMEDSClient_SComponent.hxx>
180 #include <SALOMEDSClient_StudyBuilder.hxx>
181 #include <SALOMEDS_SObject.hxx>
182 #include <SALOMEDS_Study.hxx>
183 #include <SALOME_GenericObj_wrap.hxx>
184 #include <SALOME_LifeCycleCORBA.hxx>
185 #include <utilities.h>
188 #include <Standard_ErrorHandler.hxx>
189 #include <NCollection_DataMap.hxx>
190 #include <NCollection_DoubleMap.hxx>
192 // Below macro, when uncommented, switches on simplified (more performant) algorithm
193 // of auto-color picking up
194 #define SIMPLE_AUTOCOLOR
199 //=============================================================
200 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
203 void ExportMeshToFile(int theCommandID);
205 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap);
207 void SetDisplayEntity(int theCommandID);
209 int ActionToControl( int theID, bool theReversed = false );
211 void Control( int theCommandID );
214 //================================================================================
216 * \brief Reads meshes from file
218 //================================================================================
220 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
224 std::string myExtension;
226 if ( theCommandID == SMESHOp::OpImportMED ||
227 theCommandID == SMESHOp::OpPopupImportMED ) {
228 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
229 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
231 else if ( theCommandID == SMESHOp::OpImportUNV ||
232 theCommandID == SMESHOp::OpPopupImportUNV ) {
233 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
235 else if ( theCommandID == SMESHOp::OpImportDAT ||
236 theCommandID == SMESHOp::OpPopupImportDAT ) {
237 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
239 else if ( theCommandID == SMESHOp::OpImportSTL ||
240 theCommandID == SMESHOp::OpPopupImportSTL ) {
241 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
243 else if ( theCommandID == SMESHOp::OpImportCGNS ||
244 theCommandID == SMESHOp::OpPopupImportCGNS ) {
245 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
247 else if ( theCommandID == SMESHOp::OpImportGMF ||
248 theCommandID == SMESHOp::OpPopupImportGMF ) {
249 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
250 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
253 QString anInitialPath = "";
254 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
255 anInitialPath = QDir::currentPath();
257 QStringList filenames;
258 bool toCreateGroups = true;
260 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
261 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
262 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
263 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
264 // fd->setNameFilters( filter );
265 // fd->SetChecked( true );
267 // filenames << fd->selectedFile();
268 // toCreateGroups = fd->IsChecked();
274 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
277 QObject::tr( "SMESH_IMPORT_MESH" ) );
279 if ( filenames.count() > 0 )
281 SUIT_OverrideCursor wc;
282 _PTR(Study) aStudy = SMESH::getStudy();
285 QStringList anEntryList;
286 bool isEmpty = false;
287 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it )
289 QString filename = *it;
290 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
292 switch ( theCommandID ) {
293 case SMESHOp::OpImportDAT:
294 case SMESHOp::OpPopupImportDAT:
296 // DAT format (currently unsupported)
297 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
298 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
301 case SMESHOp::OpImportUNV:
302 case SMESHOp::OpPopupImportUNV:
305 aMeshes->length( 1 );
306 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
307 if ( aMeshes[0]->_is_nil() )
308 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
309 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
312 case SMESHOp::OpImportMED:
313 case SMESHOp::OpPopupImportMED:
316 SMESH::DriverMED_ReadStatus res;
317 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
318 if ( res != SMESH::DRS_OK ) {
319 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
320 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
324 case SMESHOp::OpImportSTL:
325 case SMESHOp::OpPopupImportSTL:
328 aMeshes->length( 1 );
329 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
330 if ( aMeshes[0]->_is_nil() ) {
331 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
332 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
336 case SMESHOp::OpImportCGNS:
337 case SMESHOp::OpPopupImportCGNS:
340 SMESH::DriverMED_ReadStatus res;
341 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
342 if ( res != SMESH::DRS_OK ) {
343 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
344 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
348 case SMESHOp::OpImportGMF:
349 case SMESHOp::OpPopupImportGMF:
352 SMESH::ComputeError_var res;
353 aMeshes->length( 1 );
354 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
357 if ( res->code != SMESH::DRS_OK ) {
358 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
359 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
360 if ( strlen( res->comment.in() ) > 0 ) {
361 errors.back() += ": ";
362 errors.back() += res->comment.in();
369 catch ( const SALOME::SALOME_Exception& S_ex ) {
370 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
371 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
374 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ )
376 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
378 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
379 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
380 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
381 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
382 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
384 anEntryList.append( aMeshSO->GetID().c_str() );
392 // update Object browser
393 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
395 // browse to the published meshes
396 if( LightApp_Application* anApp =
397 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
398 anApp->browseObjects( anEntryList );
400 // show Error message box if there were errors
401 if ( errors.count() > 0 ) {
402 SUIT_MessageBox::critical( SMESHGUI::desktop(),
403 QObject::tr( "SMESH_ERROR" ),
404 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
407 // show warning message box, if some imported mesh is empty
409 SUIT_MessageBox::warning( SMESHGUI::desktop(),
410 QObject::tr( "SMESH_WRN_WARNING" ),
411 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
416 //================================================================================
418 * \brief Export selected meshes or groups into a file
420 //================================================================================
422 void ExportMeshToFile( int theCommandID )
424 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
425 SALOME_ListIO selected;
427 aSel->selectedObjects( selected );
429 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT ||
430 theCommandID == SMESHOp::OpPopupExportDAT );
431 const bool isMED = ( theCommandID == SMESHOp::OpExportMED ||
432 theCommandID == SMESHOp::OpPopupExportMED );
433 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV ||
434 theCommandID == SMESHOp::OpPopupExportUNV );
435 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL ||
436 theCommandID == SMESHOp::OpPopupExportSTL );
437 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS ||
438 theCommandID == SMESHOp::OpPopupExportCGNS );
439 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF ||
440 theCommandID == SMESHOp::OpPopupExportGMF );
442 const bool multiMeshSupported = ( isMED || isCGNS ); // file can hold several meshes
443 if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
445 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
446 bool aCheckWarn = true;
448 aCheckWarn = resMgr->booleanValue( "SMESH", "show_warning", false );
450 // get mesh object from selection and check duplication of their names
451 bool hasDuplicatedMeshNames = false;
452 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
453 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
454 SALOME_ListIteratorOfListIO It( selected );
455 for( ; It.More(); It.Next() )
457 Handle(SALOME_InteractiveObject) anIObject = It.Value();
458 SMESH::SMESH_IDSource_var aMeshItem =
459 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
460 if ( aMeshItem->_is_nil() ) {
461 SUIT_MessageBox::warning( SMESHGUI::desktop(),
462 QObject::tr( "SMESH_WRN_WARNING" ),
463 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
466 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aMeshItem );
467 if ( aCheckWarn && !aGroup->_is_nil() )
469 QMessageBox msgBox(SUIT_MessageBox::Warning,
470 QObject::tr("SMESH_WRN_WARNING"),
471 QObject::tr("SMESH_EXPORT_ONLY_GPOUP"),
472 QMessageBox::StandardButton::NoButton,
473 SMESHGUI::desktop());
474 QCheckBox dontShowCheckBox(QObject::tr("SMESH_WRN_SHOW_DLG_CHECKBOX"));
475 msgBox.addButton(QMessageBox::Ok);
476 msgBox.addButton(QMessageBox::Cancel);
477 msgBox.setDefaultButton(QMessageBox::Cancel);
478 QGridLayout* lt = qobject_cast<QGridLayout*>(msgBox.layout());
479 QDialogButtonBox* btnbox = msgBox.findChild<QDialogButtonBox*>();
480 lt->addWidget(&dontShowCheckBox, lt->rowCount(), lt->columnCount()-1, lt->rowCount(), lt->columnCount());
481 lt->addWidget(btnbox, lt->rowCount(), 0, lt->rowCount(), lt->columnCount());
482 if ( msgBox.exec() != QMessageBox::Ok )
485 if ( dontShowCheckBox.checkState() == Qt::Checked && resMgr )
486 resMgr->setValue( "SMESH", "show_warning", false);
489 QString aMeshName = anIObject->getName();
491 // check for name duplications
492 if ( !hasDuplicatedMeshNames )
493 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
494 if( aMeshName == (*aMeshIter).second ) {
495 hasDuplicatedMeshNames = true;
500 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
503 if( hasDuplicatedMeshNames && isMED ) {
504 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
505 QObject::tr("SMESH_WRN_WARNING"),
506 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
507 QObject::tr("SMESH_BUT_YES"),
508 QObject::tr("SMESH_BUT_NO"), 0, 1);
513 aMeshIter = aMeshList.begin();
514 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
515 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
516 QString aMeshName = (*aMeshIter).second;
518 if ( isMED || isCGNS ) // formats where group names must be unique
520 // check for equal group names within each mesh
521 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
522 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
523 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
524 int aRet = SUIT_MessageBox::warning
525 (SMESHGUI::desktop(),
526 QObject::tr("SMESH_WRN_WARNING"),
527 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
528 QObject::tr("SMESH_BUT_YES"),
529 QObject::tr("SMESH_BUT_NO"), 0, 1);
536 // Warn the user about presence of not supported elements
538 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
542 notSupportedElemTypes.push_back( SMESH::Entity_0D );
543 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
548 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
549 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
550 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
551 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
552 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
553 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
554 notSupportedElemTypes.push_back( SMESH::Entity_0D );
555 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
560 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
561 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
562 notSupportedElemTypes.push_back( SMESH::Entity_0D );
563 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
568 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
573 notSupportedElemTypes.push_back( SMESH::Entity_0D );
574 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
575 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
576 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
577 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
578 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Penta );
579 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
580 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
581 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
582 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
584 if ( ! notSupportedElemTypes.empty() )
586 SMESH::smIdType_array_var nbElems = aMeshOrGroup->GetMeshInfo();
587 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
588 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
589 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
591 if ( !presentNotSupported.empty() )
594 const char* typeMsg[] = {
595 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
596 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
597 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
598 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
599 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
600 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
601 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
602 "SMESH_BIQUADRATIC_PENTAHEDRONS",
603 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
605 // is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
606 static_assert( sizeof(typeMsg) / sizeof(const char*) == SMESH::Entity_Last,
607 "Update names of EntityType's!!!" );
609 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
610 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
611 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
612 if ( iType != presentNotSupported.size() - 1 )
613 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
615 int aRet = SUIT_MessageBox::warning
616 (SMESHGUI::desktop(),
617 QObject::tr("SMESH_WRN_WARNING"),
618 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
619 QObject::tr("SMESH_BUT_YES"),
620 QObject::tr("SMESH_BUT_NO"), 0, 1);
625 // Get parameters of export operation
628 int aFormat =-1; // for MED version used for write
629 bool isOkToWrite = true; // to check MED file version compatibility before adding a mesh in an existing file
631 // Init the parameters with the default values
632 bool aIsASCII_STL = true;
633 bool toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
634 bool toOverwrite = true;
635 bool toFindOutDim = true;
636 bool saveNumbers = resMgr->booleanValue( "SMESH", "med_save_numbers", true );
637 bool toRenumber = true;
638 double zTol = resMgr->doubleValue( "SMESH", "med_ztolerance", 0. );
640 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
641 QString anInitialPath = "";
642 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
643 anInitialPath = QDir::currentPath();
645 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
647 // Get a file name to write in and additional options
648 if ( isGMF ) // Export w/o options
650 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
651 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
652 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
654 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
655 anInitialPath + QString("/") + aMeshName,
656 aFilter, aTitle, false);
658 else if ( isCGNS || isUNV || isDAT ) // Export to [ CGNS | UNV | DAT ] - one option
660 const char* theOptionResource = isCGNS ? "cgns_group_elems_by_type" : "export_renumber";
661 bool option = resMgr->booleanValue( "SMESH", theOptionResource, false );
663 QStringList checkBoxes;
664 checkBoxes << QObject::tr( isCGNS ? "CGNS_EXPORT_ELEMS_BY_TYPE" : "SMESH_RENUMBER" );
666 SalomeApp_CheckFileDlg* fd =
667 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
668 fd->setWindowTitle( aTitle );
670 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
672 fd->setNameFilter( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
674 fd->setNameFilter( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
675 if ( !anInitialPath.isEmpty() )
676 fd->setDirectory( anInitialPath );
677 fd->selectFile( aMeshName );
678 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
679 fd->setValidator( fv );
680 fd->SetChecked( option, 0 );
683 aFilename = fd->selectedFile();
684 toOverwrite = fv->isOverwrite( aFilename );
685 option = fd->IsChecked( 0 );
686 SMESHGUI::resourceMgr()->setValue("SMESH", theOptionResource, option );
687 ( isCGNS ? toCreateGroups : toRenumber ) = option;
691 else if ( isSTL ) // Export to STL
693 QMap<QString, int> aFilterMap;
694 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
695 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
698 QMap<QString, int>::const_iterator it = aFilterMap.begin();
699 for ( ; it != aFilterMap.end(); ++it )
700 filters.push_back( it.key() );
702 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
703 fd->setWindowTitle( aTitle );
704 fd->setNameFilters( filters );
705 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
706 if ( !anInitialPath.isEmpty() )
707 fd->setDirectory( anInitialPath );
708 fd->selectFile(aMeshName);
712 aFilename = fd->selectedFile();
713 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
718 else if ( isMED ) // Export to MED
720 int defaultVersion = 0;
721 QMap<QString, int> aFilterMap;
722 //filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
723 //QString vmed (aMesh->GetVersionString(-1, 2));
724 SMESH::long_array_var mvok = aMesh->GetMEDVersionsCompatibleForAppend();
725 if ( mvok->length() > 0)
726 defaultVersion = mvok[0]; // the current version to set the default filter on it
727 for ( CORBA::ULong i = 0; i < mvok->length(); ++i )
729 QString vs = (char*)( SMESH_Comment( mvok[i]/10 ) << "." << mvok[i]%10 );
730 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vs ) + " (*.med)", mvok[i]);
733 QMap<QString, int>::const_iterator it = aFilterMap.begin();
734 QString aDefaultFilter = it.key();
735 for ( ; it != aFilterMap.end(); ++it ) {
736 filters.push_back( it.key() );
737 if (it.value() == defaultVersion) // explicit default for MED = current MED version
738 aDefaultFilter = it.key();
740 QStringList checkBoxes;
741 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS")
742 << QObject::tr("SMESH_AUTO_DIM")
743 << QObject::tr("SMESH_MED_SAVE_NUMS");
745 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
746 QList< QWidget* > wdgList;
747 if ( fieldSelWdg->GetAllFields( aMeshList, aFieldList ))
748 wdgList.append( fieldSelWdg );
750 QWidget* zTolWdg = new QWidget();
751 QCheckBox* zTolCheck = new QCheckBox( QObject::tr( "SMESH_ZTOLERANCE" ), zTolWdg );
752 SMESHGUI_SpinBox* zTolSpin = new SMESHGUI_SpinBox( zTolWdg );
753 QHBoxLayout* zTolLayout = new QHBoxLayout( zTolWdg );
754 zTolLayout->addWidget( zTolCheck );
755 zTolLayout->addWidget( zTolSpin );
756 zTolLayout->setMargin( 0 );
757 zTolSpin->RangeStepAndValidator( 0, 1e+100, 1., "length_precision" );
758 zTolSpin->setValue( zTol );
759 QObject::connect( zTolCheck, SIGNAL( toggled(bool)), zTolSpin, SLOT( setEnabled(bool)));
760 zTolCheck->setChecked( resMgr->booleanValue( "SMESH", "enable_ztolerance", false ));
761 zTolSpin ->setEnabled( zTolCheck->isChecked() );
762 wdgList.append( zTolWdg );
764 SalomeApp_CheckFileDlg* fd =
765 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
766 fd->setWindowTitle( aTitle );
767 fd->setNameFilters( filters );
768 fd->selectNameFilter( aDefaultFilter );
769 fd->SetChecked( toCreateGroups, 0 );
770 fd->SetChecked( toFindOutDim, 1 );
771 fd->SetChecked( saveNumbers, 2 );
772 if ( !anInitialPath.isEmpty() )
773 fd->setDirectory( anInitialPath );
774 fd->selectFile(aMeshName);
777 QListView *lview = fd->findChild<QListView*>("listView");
779 lview->setMinimumHeight(200);
781 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
783 tview->setMinimumHeight(200);
786 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
787 fd->setValidator( fv );
792 //MESSAGE("******* Loop on file dialog ***********");
795 aFilename = fd->selectedFile();
797 aFilename = QString::null;
800 aFormat = aFilterMap[fd->selectedNameFilter()];
801 //MESSAGE("selected version: " << aFormat << " file: " << aFilename.toUtf8().constData());
802 toOverwrite = fv->isOverwrite(aFilename);
803 //MESSAGE("toOverwrite:" << toOverwrite);
805 if ( !aFilename.isEmpty() ) {
807 // append is only possible if the existing file format is compatible
808 bool isVersionOk = SMESHGUI::GetSMESHGen()->CheckWriteCompatibility( aFilename.toUtf8().constData() );
809 MESSAGE("Append check, isVersionOk:" << isVersionOk);
810 if ( !isVersionOk ) {
811 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
812 QObject::tr("SMESH_WRN_WARNING"),
813 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
814 QObject::tr("SMESH_BUT_YES"),
815 QObject::tr("SMESH_BUT_NO"), 0, 1);
819 //MESSAGE("incompatible MED file version for add, overwrite accepted");
825 //MESSAGE("incompatible MED file version for add, overwrite refused");
828 QStringList aMeshNamesCollisionList;
829 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
830 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
831 QString anExistingMeshName( aMeshNames[ i ] );
832 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
833 QString anExportMeshName = (*aMeshIter).second;
834 if( anExportMeshName == anExistingMeshName ) {
835 aMeshNamesCollisionList.append( anExportMeshName );
840 if( !aMeshNamesCollisionList.isEmpty() ) {
842 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
843 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
844 QObject::tr("SMESH_WRN_WARNING"),
845 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
846 QObject::tr("SMESH_BUT_YES"),
847 QObject::tr("SMESH_BUT_NO"),
848 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
849 MESSAGE("answer collision name " << aRet);
860 toCreateGroups = fd->IsChecked(0);
861 toFindOutDim = fd->IsChecked(1);
862 saveNumbers = fd->IsChecked(2);
863 zTol = zTolCheck->isChecked() ? zTolSpin->value() : -1;
864 fieldSelWdg->GetSelectedFields();
865 if ( resMgr ) resMgr->setValue( "SMESH", "enable_ztolerance", zTolCheck->isChecked() );
867 if ( !fieldSelWdg->parent() )
869 if ( !zTolWdg->parent() )
880 if ( !aFilename.isEmpty() ) {
881 // Check whether the file already exists and delete it if yes
882 QFile aFile( aFilename );
883 if ( aFile.exists() && toOverwrite )
885 SUIT_OverrideCursor wc;
888 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
889 // bool Renumber = false;
890 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
892 // Renumber= resMgr->booleanValue("renumbering");
894 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
895 // aMeshEditor->RenumberNodes();
896 // aMeshEditor->RenumberElements();
897 // if ( SMESHGUI::automaticUpdate() )
898 // SMESH::UpdateView();
900 if ( isMED && isOkToWrite )
902 aMeshIter = aMeshList.begin();
903 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
905 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
906 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
907 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
908 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
910 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(),
911 toCreateGroups, aFormat,
912 toOverwrite && aMeshIndex == 0, toFindOutDim,
913 fields, geoAssFields.toLatin1().data(), zTol, saveNumbers );
918 if ( aMeshOrGroup->_is_equivalent( aMesh ))
919 aMesh->ExportDAT( aFilename.toUtf8().data(), toRenumber );
921 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
925 if ( aMeshOrGroup->_is_equivalent( aMesh ))
926 aMesh->ExportUNV( aFilename.toUtf8().data(), toRenumber );
928 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
932 if ( aMeshOrGroup->_is_equivalent( aMesh ))
933 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
935 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
939 aMeshIter = aMeshList.begin();
940 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
942 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
943 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
944 aMeshItem->ExportCGNS( aMeshOrGroup,
945 aFilename.toUtf8().data(),
946 toOverwrite && aMeshIndex == 0,
952 toCreateGroups = true;
953 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
956 catch (const SALOME::SALOME_Exception& S_ex)
959 if ( S_ex.details.type == SALOME::COMM && // communicate about too large mesh
960 strncmp( "format=", S_ex.details.sourceFile.in(), 7 ) == 0 )
962 SUIT_MessageBox::critical(SMESHGUI::desktop(),
963 QObject::tr("SMESH_WRN_WARNING"),
964 QObject::tr(S_ex.details.text.in() ));
966 SUIT_MessageBox::warning(SMESHGUI::desktop(),
967 QObject::tr("SMESH_WRN_WARNING"),
968 QObject::tr("SMESH_EXPORT_FAILED") + SalomeApp_Tools::ExceptionToString(S_ex));
974 inline void InverseEntityMode(unsigned int& theOutputMode,
975 unsigned int theMode)
977 bool anIsNotPresent = ~theOutputMode & theMode;
979 theOutputMode |= theMode;
981 theOutputMode &= ~theMode;
984 void SetDisplayEntity(int theCommandID)
986 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
987 SALOME_ListIO selected;
989 aSel->selectedObjects( selected );
991 if ( selected.Extent() >= 1 ) {
992 SUIT_OverrideCursor wc;
993 SALOME_ListIteratorOfListIO It( selected );
994 for( ; It.More(); It.Next()){
995 Handle(SALOME_InteractiveObject) IObject = It.Value();
996 if(IObject->hasEntry()){
997 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
998 unsigned int aMode = anActor->GetEntityMode();
999 switch(theCommandID){
1000 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
1001 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
1002 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
1003 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
1004 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
1005 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
1008 anActor->SetEntityMode(aMode);
1017 SalomeApp_Application* app =
1018 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1022 LightApp_SelectionMgr* aSel = app->selectionMgr();
1023 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1024 if ( !aSel || !appStudy )
1027 SALOME_ListIO selected;
1028 aSel->selectedObjects( selected );
1029 if ( selected.IsEmpty() )
1032 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1034 _PTR(Study) aStudy = appStudy->studyDS();
1035 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
1036 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1037 if ( aMainObject->_is_nil() )
1040 SUIT_OverrideCursor wc;
1042 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
1044 QList<SALOMEDS::Color> aReservedColors;
1046 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1047 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1049 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1051 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1052 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1053 #else // old algorithm for auto-colors
1054 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1055 aReservedColors.append( aColor );
1056 #endif // SIMPLE_AUTOCOLOR
1057 aGroupObject->SetColor( aColor );
1059 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1060 if ( aGroupSObject ) {
1063 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1064 switch ( aGroupObject->GetType ()) {
1066 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1068 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1070 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1072 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1074 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1075 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1078 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1079 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1085 SMESH::RepaintCurrentView();
1088 void OverallMeshQuality()
1090 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1091 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1092 SALOME_ListIO selected;
1094 aSel->selectedObjects( selected );
1096 if ( selected.IsEmpty() ) return;
1097 SALOME_ListIteratorOfListIO It( selected );
1098 for ( ; It.More(); It.Next() ) {
1099 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1100 ctrlDlg->showInfo( It.Value() );
1105 QString functorToString( SMESH::Controls::FunctorPtr f )
1107 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1108 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1109 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1110 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1111 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1112 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1113 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1114 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1115 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1116 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1117 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1118 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1119 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1120 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1121 type = QObject::tr( "WARP_ELEMENTS" );
1122 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1123 type = QObject::tr( "TAPER_ELEMENTS" );
1124 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1125 type = QObject::tr( "SKEW_ELEMENTS" );
1126 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1127 type = QObject::tr( "AREA_ELEMENTS" );
1128 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1129 type = QObject::tr( "LENGTH_EDGES" );
1130 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1131 type = QObject::tr( "LENGTH2D_EDGES" );
1132 else if ( dynamic_cast< SMESH::Controls::Deflection2D* >( f.get() ) )
1133 type = QObject::tr( "DEFLECTION2D_FACES" );
1134 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1135 type = QObject::tr( "MULTI_BORDERS" );
1136 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1137 type = QObject::tr( "MULTI2D_BORDERS" );
1138 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1139 type = QObject::tr( "FREE_NODES" );
1140 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1141 type = QObject::tr( "FREE_EDGES" );
1142 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1143 type = QObject::tr( "FREE_BORDERS" );
1144 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1145 type = QObject::tr( "FREE_FACES" );
1146 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1147 type = QObject::tr( "BARE_BORDER_VOLUME" );
1148 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1149 type = QObject::tr( "BARE_BORDER_FACE" );
1150 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1151 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1152 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1153 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1154 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1155 type = QObject::tr( "EQUAL_NODE" );
1156 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1157 type = QObject::tr( "EQUAL_EDGE" );
1158 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1159 type = QObject::tr( "EQUAL_FACE" );
1160 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1161 type = QObject::tr( "EQUAL_VOLUME" );
1162 else if ( dynamic_cast< SMESH::Controls::NodeConnectivityNumber* >( f.get() ) )
1163 type = QObject::tr( "NODE_CONNECTIVITY_NB" );
1167 void SaveDistribution()
1169 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1170 SALOME_ListIO selected;
1172 aSel->selectedObjects( selected );
1174 if ( selected.Extent() == 1 ) {
1175 Handle(SALOME_InteractiveObject) anIO = selected.First();
1176 if ( anIO->hasEntry() ) {
1177 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1179 anActor->GetScalarBarActor() &&
1180 anActor->GetControlMode() != SMESH_Actor::eNone )
1182 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1183 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1184 if ( aScalarBarActor && aFunctor ) {
1185 SMESH::Controls::NumericalFunctor* aNumFun =
1186 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1188 std::vector<smIdType> elements;
1189 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1190 if ( mesh->_is_nil() ) {
1191 SMESH::SMESH_IDSource_var idSource =
1192 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1193 if ( !idSource->_is_nil() )
1195 SMESH::smIdType_array_var ids = idSource->GetIDs();
1196 elements.resize( ids->length() );
1197 for ( unsigned i = 0; i < elements.size(); ++i )
1198 elements[i] = ids[i];
1201 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1202 vtkLookupTable* lookupTable =
1203 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1204 double * minmax = lookupTable->GetRange();
1205 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1206 std::vector<int> nbEvents;
1207 std::vector<double> funValues;
1208 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1209 elements, minmax, isLogarithmic );
1210 QString anInitialPath = "";
1211 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1212 anInitialPath = QDir::currentPath();
1213 QString aMeshName = anIO->getName();
1215 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1216 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1217 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1218 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1219 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1222 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1224 if ( !aFilename.isEmpty() ) {
1225 QFile f( aFilename );
1226 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1227 QTextStream out( &f );
1228 out << "# Mesh: " << aMeshName << endl;
1229 out << "# Control: " << functorToString( aFunctor ) << endl;
1231 out.setFieldWidth( 10 );
1232 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1233 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1244 void ShowElement( int theCommandID )
1246 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1247 SALOME_ListIO selected;
1249 aSel->selectedObjects( selected );
1251 if ( selected.Extent() == 1 ) {
1252 Handle(SALOME_InteractiveObject) anIO = selected.First();
1253 if ( anIO->hasEntry() ) {
1254 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1256 anActor->GetScalarBarActor() &&
1257 anActor->GetControlMode() != SMESH_Actor::eNone )
1259 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1260 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1261 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1263 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1264 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1271 #ifndef DISABLE_PLOT2DVIEWER
1272 void PlotDistribution()
1274 SalomeApp_Application* app =
1275 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1279 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1280 SALOME_ListIO selected;
1282 aSel->selectedObjects( selected );
1284 if ( selected.Extent() == 1 ) {
1285 Handle(SALOME_InteractiveObject) anIO = selected.First();
1286 if ( anIO->hasEntry() ) {
1287 //Find Actor by entry before getting Plot2d viewer,
1288 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1289 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1291 SUIT_ViewManager* aViewManager =
1292 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1296 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1300 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1304 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1306 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1307 QString functorName = functorToString( anActor->GetFunctor());
1308 QString aHistogramName("%1 : %2");
1309 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1310 aHistogram->setName(aHistogramName);
1311 aHistogram->setHorTitle(functorName);
1312 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1313 aPlot->displayObject(aHistogram, true);
1318 #endif //DISABLE_PLOT2DVIEWER
1320 void DisableAutoColor()
1322 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1323 SALOME_ListIO selected;
1325 aSel->selectedObjects( selected );
1327 if ( selected.Extent() ) {
1328 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1329 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1330 if ( !aMesh->_is_nil() ) {
1331 aMesh->SetAutoColor( false );
1338 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1339 SALOME_ListIO selected;
1341 aSel->selectedObjects( selected );
1342 if ( selected.Extent() )
1344 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1345 _PTR(Study) aStudy = SMESH::getStudy();
1346 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1348 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1349 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1356 // Break link with Shaper model
1357 void breakShaperLink()
1359 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1360 SALOME_ListIO selected;
1362 aSel->selectedObjects(selected);
1363 if (selected.Extent()) {
1364 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1365 _PTR(Study) aStudy = SMESH::getStudy();
1366 std::string aEntry = anIObject->getEntry();
1367 _PTR(SObject) aSObj = aStudy->FindObjectID(aEntry);
1369 std::string aName = aSObj->GetName();
1370 QMessageBox::StandardButton aRes = SUIT_MessageBox::warning(SMESHGUI::desktop(),
1371 QObject::tr("SMESH_WRN_WARNING"),
1372 QObject::tr("MSG_BREAK_SHAPER_LINK").arg(aName.c_str()),
1373 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No);
1374 if (aRes == SUIT_MessageBox::Yes) {
1375 SUIT_DataOwnerPtrList aList;
1376 aSel->selected(aList, "ObjectBrowser", true);
1377 SUIT_DataOwner* aOwn = aList.first();
1378 LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>(aOwn);
1379 QString aREntry = sowner->entry();
1381 static GEOM::GEOM_Gen_var geomGen;
1382 if (CORBA::is_nil(geomGen)) {
1383 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
1384 (SUIT_Session::session()->activeApplication());
1386 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
1387 Engines::EngineComponent_var comp =
1388 ls->FindOrLoad_Component("FactoryServer", "SHAPERSTUDY");
1389 geomGen = GEOM::GEOM_Gen::_narrow(comp);
1392 if (!CORBA::is_nil(geomGen))
1394 geomGen->BreakLink(aREntry.toStdString().c_str());
1395 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1397 // remove actors whose objects are removed by BreakLink()
1398 QList<SUIT_ViewWindow*> wndList = SMESHGUI::desktop()->windows();
1399 SUIT_ViewWindow* wnd;
1400 foreach(wnd, wndList)
1401 SMESH::UpdateActorsAfterUpdateStudy(wnd);
1409 //================================================================================
1411 * \brief Return true if a mesh icon == ICON_SMESH_TREE_GEOM_MODIF
1412 * which means that the mesh can't be modified. It should be either re-computed
1413 * or breakShaperLink()'ed. Warn the user about it.
1415 //================================================================================
1417 bool warnOnGeomModif()
1419 SALOME_ListIO selected;
1420 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1421 aSel->selectedObjects(selected,"",/*convertReferences=*/false);
1423 SALOME_ListIteratorOfListIO It( selected );
1424 for ( ; It.More(); It.Next() )
1426 Handle(SALOME_InteractiveObject) io = It.Value();
1427 if ( !io->hasEntry() ) continue;
1428 _PTR(SObject) so = SMESH::getStudy()->FindObjectID( io->getEntry() );
1429 SMESH::SMESH_Mesh_var mesh;
1430 while ( mesh->_is_nil() && so && so->GetID() != "0:" )
1432 CORBA::Object_var obj = SMESH::SObjectToObject( so );
1433 SMESH::SMESH_IDSource_var isrc = SMESH::SMESH_IDSource::_narrow( obj );
1434 if ( isrc->_is_nil() )
1435 so = so->GetFather();
1437 mesh = isrc->GetMesh();
1439 if ( mesh->_is_nil() ) continue;
1440 so = SMESH::FindSObject( mesh );
1441 if ( !so ) continue;
1442 _PTR(GenericAttribute) attr;
1443 so->FindAttribute( attr, "AttributePixMap" );
1444 _PTR(AttributePixMap) pixmap = attr;
1445 if ( !pixmap ) continue;
1447 if ( pixmap->GetPixMap() == "ICON_SMESH_TREE_GEOM_MODIF" )
1449 SUIT_MessageBox::warning(SMESHGUI::desktop(),
1450 QObject::tr("SMESH_WRN_WARNING"),
1451 QObject::tr("MSG_WARN_ON_GEOM_MODIF"));
1458 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap)
1460 SALOME_ListIO selected;
1461 SalomeApp_Application* app =
1462 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1466 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1467 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1468 if ( !aSel || !appStudy )
1471 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1472 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1473 aModule->EmitSignalDeactivateDialog();
1474 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1475 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1480 aSel->selectedObjects( selected );
1482 if ( selected.Extent() >= 1 )
1484 switch ( theCommandID ) {
1485 case SMESHOp::OpTransparency:
1487 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1488 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1491 case SMESHOp::OpProperties:
1494 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1495 QColor orientationColor, outlineColor, volumeColor;
1496 int deltaF = 0, deltaV = 0;
1499 double ballScale = 1.0;
1501 int outlineWidth = 1;
1502 double shrinkCoef = 0.0;
1503 double orientationScale = 0.0;
1504 bool orientation3d = false;
1505 VTK::MarkerType markerType = VTK::MT_NONE;
1506 VTK::MarkerScale markerScale = VTK::MS_NONE;
1508 bool hasNodes = false;
1509 int presentEntities = 0;
1510 bool firstTime = true;
1512 SALOME_ListIteratorOfListIO It( selected );
1513 for ( ; It.More(); It.Next() ) {
1514 Handle(SALOME_InteractiveObject) IObject = It.Value();
1515 if ( !IObject->hasEntry() ) continue;
1516 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1517 if ( !anActor || !anActor->GetObject() ) continue;
1520 // nodes: color, marker
1521 anActor->GetNodeColor( color[0], color[1], color[2] );
1522 nodeColor.setRgbF( color[0], color[1], color[2] );
1523 markerType = anActor->GetMarkerType();
1524 markerScale = anActor->GetMarkerScale();
1525 markerId = anActor->GetMarkerTexture();
1526 // edges: color, width
1527 anActor->GetEdgeColor( color[0], color[1], color[2] );
1528 edgeColor.setRgbF( color[0], color[1], color[2] );
1529 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1530 // faces: front color, back color (delta)
1531 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1532 faceColor.setRgbF( color[0], color[1], color[2] );
1533 // faces: front color, back color (delta)
1534 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1535 volumeColor.setRgbF( color[0], color[1], color[2] );
1536 // 0d elements: color, size
1537 anActor->Get0DColor( color[0], color[1], color[2] );
1538 elem0dColor.setRgbF( color[0], color[1], color[2] );
1539 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1540 // balls: color, size
1541 anActor->GetBallColor( color[0], color[1], color[2] );
1542 ballColor.setRgbF( color[0], color[1], color[2] );
1543 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1544 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1546 anActor->GetOutlineColor( color[0], color[1], color[2] );
1547 outlineColor.setRgbF( color[0], color[1], color[2] );
1548 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1549 // orientation vectors: color, scale, 3d flag
1550 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1551 orientationColor.setRgbF( color[0], color[1], color[2] );
1552 orientationScale = anActor->GetFacesOrientationScale();
1553 orientation3d = anActor->GetFacesOrientation3DVectors();
1555 shrinkCoef = anActor->GetShrinkFactor();
1558 firstTime = false; // we only take properties from first object (for performance reasons)
1561 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1562 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1563 presentEntities = presentEntities | SMESH_Actor::eEdges;
1564 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1565 presentEntities = presentEntities | SMESH_Actor::eFaces;
1566 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1567 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1568 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1569 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1570 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1571 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1573 // as we know that all types of elements are present, we can exit the loop
1574 if ( presentEntities == SMESH_Actor::eAllEntity )
1578 SMESHGUI_PropertiesDlg dlg( theMarkerMap, SMESHGUI::desktop() );
1579 // nodes: color, marker
1580 dlg.setNodeColor( nodeColor );
1581 if( markerType != VTK::MT_USER )
1582 dlg.setNodeMarker( markerType, markerScale );
1584 dlg.setNodeCustomMarker( markerId );
1585 // edges: color, line width
1586 dlg.setEdgeColor( edgeColor );
1587 dlg.setEdgeWidth( edgeWidth );
1588 // faces: front color, back color
1589 dlg.setFaceColor( faceColor, deltaF );
1590 // volumes: normal color, reversed color
1591 dlg.setVolumeColor( volumeColor, deltaV );
1592 // outlines: color, line width
1593 dlg.setOutlineColor( outlineColor );
1594 dlg.setOutlineWidth( outlineWidth );
1595 // 0d elements: color, size
1596 dlg.setElem0dColor( elem0dColor );
1597 dlg.setElem0dSize( elem0dSize );
1598 // balls: color, size
1599 dlg.setBallColor( ballColor );
1600 //dlg.setBallSize( ballSize );
1601 dlg.setBallScale( ballScale );
1602 // orientation: color, scale, 3d flag
1603 dlg.setOrientationColor( orientationColor );
1604 dlg.setOrientationSize( int( orientationScale * 100. ) );
1605 dlg.setOrientation3d( orientation3d );
1606 // shrink: scale factor
1607 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1608 // hide unused controls
1609 dlg.showControls( presentEntities, hasNodes );
1612 nodeColor = dlg.nodeColor();
1613 markerType = dlg.nodeMarkerType();
1614 markerScale = dlg.nodeMarkerScale();
1615 markerId = dlg.nodeMarkerId();
1616 edgeColor = dlg.edgeColor();
1617 edgeWidth = dlg.edgeWidth();
1618 faceColor = dlg.faceColor();
1619 deltaF = dlg.faceColorDelta();
1620 volumeColor = dlg.volumeColor();
1621 deltaV = dlg.volumeColorDelta();
1622 outlineColor = dlg.outlineColor();
1623 outlineWidth = dlg.outlineWidth();
1624 elem0dColor = dlg.elem0dColor();
1625 elem0dSize = dlg.elem0dSize();
1626 ballColor = dlg.ballColor();
1627 // ballSize = dlg.ballSize();
1628 ballScale = dlg.ballScale();
1629 orientationColor = dlg.orientationColor();
1630 orientationScale = dlg.orientationSize() / 100.;
1631 orientation3d = dlg.orientation3d();
1632 shrinkCoef = dlg.shrinkCoef() / 100.;
1634 // store point markers that might be changed by the user
1635 theMarkerMap = dlg.customMarkers();
1637 // set properties from dialog box to the presentations
1638 SALOME_ListIteratorOfListIO It( selected );
1639 for ( ; It.More(); It.Next() ) {
1640 Handle(SALOME_InteractiveObject) IObject = It.Value();
1641 if ( !IObject->hasEntry() ) continue;
1642 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1643 if ( !anActor ) continue;
1645 // nodes: color, marker
1646 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1647 if ( markerType != VTK::MT_USER ) {
1648 anActor->SetMarkerStd( markerType, markerScale );
1651 VTK::MarkerMap::const_iterator iter = theMarkerMap.find( markerId );
1652 if ( iter != theMarkerMap.end() )
1653 anActor->SetMarkerTexture( markerId, iter->second.second );
1655 // volumes: normal color, reversed color (delta)
1656 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1657 // faces: front color, back color (delta)
1658 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1659 // edges: color, width
1660 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1661 anActor->SetLineWidth( edgeWidth );
1663 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1664 anActor->SetOutlineWidth( outlineWidth );
1665 // 0D elements: color, size
1666 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1667 anActor->Set0DSize( elem0dSize );
1668 // balls: color, size
1669 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1670 // anActor->SetBallSize( ballSize );
1671 anActor->SetBallScale( ballScale );
1672 // orientation: color, scale, 3d flag
1673 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1674 anActor->SetFacesOrientationScale( orientationScale );
1675 anActor->SetFacesOrientation3DVectors( orientation3d );
1677 anActor->SetShrinkFactor( shrinkCoef );
1679 // for groups, set also proper color
1680 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1681 if ( !aGroupObject->_is_nil() ) {
1682 SMESH::ElementType anElementType = aGroupObject->GetType();
1684 switch( anElementType ) {
1686 aColor = nodeColor; break;
1688 aColor = edgeColor; break;
1690 aColor = faceColor; break;
1692 aColor = volumeColor; break;
1694 aColor = elem0dColor; break;
1696 aColor = ballColor; break;
1700 if ( aColor.isValid() ) {
1701 SALOMEDS::Color aGroupColor;
1702 aGroupColor.R = aColor.redF();
1703 aGroupColor.G = aColor.greenF();
1704 aGroupColor.B = aColor.blueF();
1705 aGroupObject->SetColor( aGroupColor );
1707 } // if ( !aGroupObject->_is_nil() )
1708 } // for ( ; It.More(); It.Next() )
1709 SMESH::RepaintCurrentView();
1710 } // if ( dlg.exec() )
1712 } // case SMESHOp::OpProperties:
1713 } // switch(theCommandID)
1714 SUIT_OverrideCursor wc;
1715 SALOME_ListIteratorOfListIO It( selected );
1716 for( ; It.More(); It.Next()){
1717 Handle(SALOME_InteractiveObject) IObject = It.Value();
1718 if(IObject->hasEntry()){
1719 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1720 switch(theCommandID){
1721 case SMESHOp::OpDMWireframe:
1722 anActor->SetRepresentation(SMESH_Actor::eEdge);
1724 case SMESHOp::OpDMShading:
1725 anActor->SetRepresentation(SMESH_Actor::eSurface);
1727 case SMESHOp::OpDMShrink:
1728 if(anActor->IsShrunk())
1729 anActor->UnShrink();
1731 anActor->SetShrink();
1733 case SMESHOp::OpDMNodes:
1734 anActor->SetRepresentation(SMESH_Actor::ePoint);
1736 case SMESHOp::OpRepresentationLines:
1737 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1738 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1740 case SMESHOp::OpRepresentationArcs:
1741 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1742 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1748 SMESH::RepaintCurrentView();
1752 int ActionToControl( int theID, bool theReversed )
1754 NCollection_DoubleMap<int,int> ActionControl;
1755 ActionControl.Bind( 0, SMESH_Actor::eNone );
1756 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1757 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1758 ActionControl.Bind( SMESHOp::OpNodeConnectivityNb, SMESH_Actor::eNodeConnectivityNb );
1759 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1760 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1761 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1762 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1763 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1764 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1765 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1766 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1767 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1768 ActionControl.Bind( SMESHOp::OpDeflection2D, SMESH_Actor::eDeflection2D );
1769 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1770 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1771 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1772 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1773 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1774 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1775 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1776 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1777 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1778 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1779 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1780 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1781 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1782 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1783 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1786 return ActionControl.IsBound2( theID ) ? ActionControl.Find2( theID ) : 0;
1787 return ActionControl.IsBound1( theID ) ? ActionControl.Find1( theID ) : 0;
1790 void Control( int theCommandID )
1792 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1793 _PTR(Study) aStudy = SMESH::getStudy();
1795 SALOME_ListIO selected;
1796 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1797 aSel->selectedObjects( selected );
1799 if ( !selected.IsEmpty() ) {
1800 SALOME_ListIteratorOfListIO It(selected);
1801 for ( ; It.More(); It.Next())
1803 Handle(SALOME_InteractiveObject) anIO = It.Value();
1804 if ( !anIO.IsNull() ) {
1805 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1807 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1808 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1809 if ( !anIDSrc->_is_nil() ) {
1810 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1811 if (( !anActor && selected.Extent() == 1 ) &&
1812 ( anActor = SMESH::CreateActor( anIO->getEntry() )))
1814 anActor->SetControlMode( aControl );
1815 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1816 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1820 if ( anActor->GetControlMode() != aControl )
1821 anActor->SetControlMode( aControl );
1822 QString functorName = functorToString( anActor->GetFunctor() );
1823 smIdType anEntitiesCount = anActor->GetNumberControlEntities();
1824 if (anEntitiesCount >= 0)
1825 functorName = functorName + ": " + QString::number(anEntitiesCount);
1826 anActor->GetScalarBarActor()->SetTitle( functorName.toUtf8().constData() );
1827 SMESH::RepaintCurrentView();
1828 #ifndef DISABLE_PLOT2DVIEWER
1829 if ( anActor->GetPlot2Histogram() ) {
1830 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1831 QString aHistogramName("%1 : %2");
1832 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1833 aHistogram->setName( aHistogramName );
1834 aHistogram->setHorTitle( functorName );
1835 SMESH::ProcessIn2DViewers( anActor );
1847 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1848 SMESH::MeshObjectType theType,
1849 const QString theInTypeName,
1850 QString & theOutTypeName)
1852 SMESH_TypeFilter aTypeFilter( theType );
1854 if ( !theIO.IsNull() )
1856 entry = theIO->getEntry();
1857 LightApp_DataOwner owner( entry );
1858 if ( aTypeFilter.isOk( &owner )) {
1859 theOutTypeName = theInTypeName;
1867 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1869 _PTR(Study) aStudy = SMESH::getStudy();
1870 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1872 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1873 CORBA::String_var anID = aSComp->GetID().c_str();
1874 if ( !strcmp(anID.in(),theIO->getEntry()) )
1880 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1881 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1882 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1883 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1884 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1892 // QString CheckHomogeneousSelection()
1894 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1895 // SALOME_ListIO selected;
1897 // aSel->selectedObjects( selected );
1899 // QString RefType = CheckTypeObject(selected.First());
1900 // SALOME_ListIteratorOfListIO It(selected);
1901 // for ( ; It.More(); It.Next())
1903 // Handle(SALOME_InteractiveObject) IObject = It.Value();
1904 // QString Type = CheckTypeObject(IObject);
1905 // if ( Type.compare(RefType) != 0 )
1906 // return "Heterogeneous Selection";
1912 uint randomize( uint size )
1914 static bool initialized = false;
1915 if ( !initialized ) {
1916 qsrand( QDateTime::currentDateTime().toTime_t() );
1920 v = uint( (double)( v ) / RAND_MAX * size );
1921 v = qMax( uint(0), qMin ( v, size-1 ) );
1927 void SMESHGUI::OnEditDelete()
1929 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1930 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1931 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1933 _PTR(Study) aStudy = SMESH::getStudy();
1934 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1935 _PTR(GenericAttribute) anAttr;
1936 _PTR(AttributeIOR) anIOR;
1938 const int objectCountLimit = 30; // PAL23599
1939 int objectCount = 0;
1941 QString aParentComponent = QString::null;
1943 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1945 Handle(SALOME_InteractiveObject) anIO = anIt.Value();
1946 if ( anIO.IsNull() ) continue;
1948 QString father = "unknown", name;
1950 _PTR(SObject) aSO = aStudy->FindObjectID( anIO->getEntry() );
1952 father = QString::fromStdString( aSO->GetFatherComponent()->ComponentDataType() );
1953 // check if object is reference
1954 _PTR(SObject) aRefSObj;
1955 if ( aSO->ReferencedObject( aRefSObj ) ) {
1956 name = QString::fromStdString ( aRefSObj->GetName() );
1957 father = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1960 name = anIO->getName();
1963 if ( objectCount < objectCountLimit ) { // avoid occupying the whole screen
1964 aNameList.append("\n - ");
1965 aNameList.append( name );
1968 if( aParentComponent.isNull() )
1969 aParentComponent = father;
1970 else if( !aParentComponent.isEmpty() && aParentComponent!=father )
1971 aParentComponent = "";
1973 if ( objectCount >= objectCountLimit )
1974 aNameList.append("\n - ...");
1976 if ( objectCount == 0 )
1977 return; // No Valid Objects Selected
1979 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1980 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1981 QObject::tr("ERR_ERROR"),
1982 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1985 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1986 if (SUIT_MessageBox::warning
1987 (SMESHGUI::desktop(),
1988 QObject::tr("SMESH_WRN_WARNING"),
1989 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1990 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1991 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1994 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1996 // Put one level of sub-objects of the selected SO's into a list
1997 // in order to get objects inside folders like "Assigned Algorithms"
1998 std::list< _PTR(SObject) > listSO;
1999 SALOME_ListIteratorOfListIO It(selected);
2000 for( ; It.More(); It.Next()) // loop on selected IO's
2002 Handle(SALOME_InteractiveObject) IObject = It.Value();
2003 if(IObject->hasEntry()) {
2004 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
2006 // disable removal of "SMESH" component object
2007 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
2009 if ( engineIOR() == anIOR->Value().c_str() )
2012 //Check the referenced object
2013 _PTR(SObject) aRefSObject;
2014 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
2015 aSO = aRefSObject; // Delete main Object instead of reference
2017 listSO.push_back( aSO );
2019 _PTR(ChildIterator) it = aStudy->NewChildIterator( aSO );
2020 for (it->InitEx(false); it->More(); it->Next())
2021 listSO.push_back( it->Value() );
2024 // Check if none of objects to delete is referred from outside
2025 std::list< _PTR(SObject) >::reverse_iterator ritSO;
2026 std::vector< _PTR(SObject) > subSO;
2027 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2029 _PTR(SObject) SO = *ritSO;
2030 if ( !SO ) continue;
2032 int nbChildren = SO->GetLastChildTag();
2034 subSO.reserve( 1 + nbChildren );
2035 subSO.push_back( SO );
2036 if ( nbChildren > 0 )
2038 _PTR(ChildIterator) it = aStudy->NewChildIterator( SO );
2039 for ( it->InitEx( true ); it->More(); it->Next() )
2040 subSO.push_back( it->Value() );
2042 for ( size_t i = 0; i < subSO.size(); ++i )
2044 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( subSO[i] );
2045 for ( size_t j = 0; j < aReferences.size(); j++ ) {
2046 _PTR(SComponent) aComponent = aReferences[j]->GetFatherComponent();
2047 std::string type = aComponent->ComponentDataType();
2048 if ( type != "SMESH" )
2050 SUIT_MessageBox::warning( anApp->desktop(),
2051 QObject::tr("WRN_WARNING"),
2052 QObject::tr("DEP_OBJECT") );
2053 return; // outside SMESH, there is an object depending on a SMESH object
2059 // Treat SO's in the list starting from the back
2060 aStudyBuilder->NewCommand(); // There is a transaction
2061 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2063 _PTR(SObject) SO = *ritSO;
2064 if ( !SO ) continue;
2065 std::string anEntry = SO->GetID();
2067 /** Erase graphical object and remove all its data **/
2068 if ( SO->FindAttribute( anAttr, "AttributeIOR" )) {
2069 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
2071 /** Remove an object from data structures **/
2072 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
2073 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
2074 if ( !aGroup->_is_nil() ) { // DELETE GROUP
2075 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
2076 aMesh->RemoveGroup( aGroup );
2078 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
2079 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2080 aMesh->RemoveSubMesh( aSubMesh );
2083 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
2084 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
2085 QString objType = CheckTypeObject(IObject);
2086 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
2087 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2088 aStudyBuilder->RemoveObjectWithChildren( SO );
2090 else {// default action: remove SObject from the study
2091 // Find Sub-Meshes and Group and delete corresopning visual objects and actors
2092 _PTR(ChildIterator) it1 = aStudy->NewChildIterator(SO);
2093 for (it1->InitEx(false); it1->More(); it1->Next()) {
2094 _PTR(SObject) SObj = it1->Value();
2095 if (!SObj) continue;
2096 if (SObj->FindAttribute(anAttr, "AttributeIOR")) {
2097 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(SMESH::SObjectToObject(SObj));
2098 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(SMESH::SObjectToObject(SObj));
2099 if (!aGroup->_is_nil() || !aSubMesh->_is_nil()) {
2100 SMESH::RemoveVisualObjectWithActors(SObj->GetID().c_str(), true);
2104 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
2105 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
2107 aStudyBuilder->RemoveObjectWithChildren( SO );
2111 } /* listSO back loop */
2113 aStudyBuilder->CommitCommand();
2115 /* Clear any previous selection */
2117 aSel->setSelectedObjects( l1 );
2119 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
2123 SMESHGUI_EXPORT CAM_Module* createModule()
2125 return new SMESHGUI();
2128 SMESHGUI_EXPORT char* getModuleVersion() {
2129 return (char*)SMESH_VERSION_STR;
2133 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
2135 //=============================================================================
2139 //=============================================================================
2140 SMESHGUI::SMESHGUI() : SalomeApp_Module( "SMESH" )
2142 if ( CORBA::is_nil( myComponentSMESH ) )
2144 CORBA::Boolean anIsEmbeddedMode;
2145 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
2147 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2149 // 0019923: EDF 765 SMESH : default values of hypothesis
2150 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2151 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2152 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2153 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2154 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2156 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2157 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2158 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2160 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2161 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2165 myActiveDialogBox = 0;
2166 myFilterLibraryDlg = 0;
2170 myEventCallbackCommand = vtkCallbackCommand::New();
2171 myEventCallbackCommand->Delete();
2172 myEventCallbackCommand->SetClientData( this );
2173 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2176 /* load resources for all available meshers */
2177 SMESH::InitAvailableHypotheses();
2180 //=============================================================================
2184 //=============================================================================
2185 SMESHGUI::~SMESHGUI()
2189 //=============================================================================
2193 //=============================================================================
2194 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2196 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2198 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2203 //=============================================================================
2207 //=============================================================================
2208 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2210 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2214 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2215 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2216 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2217 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2218 return autoUpdate && !exceeded;
2221 //=============================================================================
2225 //=============================================================================
2226 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2227 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2229 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2233 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2234 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2235 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2237 SMESH::smIdType_array_var info = theMesh->GetMeshInfo();
2238 long nbOdElems = info[SMDSEntity_0D];
2239 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2240 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2241 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2242 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2243 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2244 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2245 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2246 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
2247 info[SMDSEntity_Polyhedra] +
2248 info[SMDSEntity_Hexagonal_Prism];
2249 long nbBalls = info[SMDSEntity_Ball];
2251 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2252 *nbElements = requestedSize;
2254 *entities = SMESH_Actor::eAllEntity;
2257 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2259 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2261 if ( incrementalLimit ) {
2264 if ( nbOdElems > 0 ) {
2265 if ( total + nbOdElems > updateLimit ) {
2266 *entities = *entities & ~SMESH_Actor::e0DElements;
2267 *hidden = *hidden | SMESH_Actor::e0DElements;
2274 if ( nbEdges > 0 ) {
2275 if ( total + nbEdges > updateLimit ) {
2276 *entities = *entities & ~SMESH_Actor::eEdges;
2277 *hidden = *hidden | SMESH_Actor::eEdges;
2284 if ( nbFaces > 0 ) {
2285 if ( total + nbFaces > updateLimit ) {
2286 *entities = *entities & ~SMESH_Actor::eFaces;
2287 *hidden = *hidden | SMESH_Actor::eFaces;
2294 if ( nbVolumes > 0 ) {
2295 if ( total + nbVolumes > updateLimit ) {
2296 *entities = *entities & ~SMESH_Actor::eVolumes;
2297 *hidden = *hidden | SMESH_Actor::eVolumes;
2304 if ( nbBalls > 0 ) {
2305 if ( total + nbBalls > updateLimit ) {
2306 *entities = *entities & ~SMESH_Actor::eBallElem;
2307 *hidden = *hidden | SMESH_Actor::eBallElem;
2315 return autoUpdate && !exceeded;
2318 //=============================================================================
2322 //=============================================================================
2323 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2325 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2328 //=============================================================================
2332 //=============================================================================
2333 SMESHGUI* SMESHGUI::GetSMESHGUI()
2335 SMESHGUI* smeshMod = 0;
2336 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2339 CAM_Module* module = app->module( "Mesh" );
2340 smeshMod = dynamic_cast<SMESHGUI*>( module );
2348 Standard_EXPORT SMESHGUI* GetComponentGUI()
2350 return SMESHGUI::GetSMESHGUI();
2354 //=============================================================================
2358 //=============================================================================
2359 void SMESHGUI::SetState(int aState)
2364 //=============================================================================
2368 //=============================================================================
2369 void SMESHGUI::ResetState()
2374 //=============================================================================
2378 //=============================================================================
2379 void SMESHGUI::EmitSignalDeactivateDialog()
2381 emit SignalDeactivateActiveDialog();
2384 //=============================================================================
2388 //=============================================================================
2389 void SMESHGUI::EmitSignalStudyFrameChanged()
2391 emit SignalStudyFrameChanged();
2394 //=============================================================================
2398 //=============================================================================
2399 void SMESHGUI::EmitSignalCloseAllDialogs()
2401 emit SignalCloseAllDialogs();
2404 //=============================================================================
2408 //=============================================================================
2409 void SMESHGUI::EmitSignalVisibilityChanged()
2411 emit SignalVisibilityChanged();
2414 //=============================================================================
2418 //=============================================================================
2419 void SMESHGUI::EmitSignalCloseView()
2421 emit SignalCloseView();
2424 //=============================================================================
2428 //=============================================================================
2429 void SMESHGUI::EmitSignalActivatedViewManager()
2431 emit SignalActivatedViewManager();
2434 //=============================================================================
2438 //=============================================================================
2439 QDialog *SMESHGUI::GetActiveDialogBox()
2441 return myActiveDialogBox;
2444 //=============================================================================
2448 //=============================================================================
2449 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2451 myActiveDialogBox = (QDialog *) aDlg;
2455 //=============================================================================
2459 //=============================================================================
2460 SUIT_Desktop* SMESHGUI::desktop()
2462 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2464 return app->desktop();
2469 //=============================================================================
2473 //=============================================================================
2474 SalomeApp_Study* SMESHGUI::activeStudy()
2476 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2478 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2483 //=============================================================================
2487 //=============================================================================
2488 void SMESHGUI::Modified( bool theIsUpdateActions )
2490 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2491 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2492 appStudy->Modified();
2493 if( theIsUpdateActions )
2494 app->updateActions();
2499 //=============================================================================
2503 //=============================================================================
2504 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2506 /* Here the position is on the bottom right corner - 10 */
2507 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2509 SUIT_Desktop *PP = desktop();
2510 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2511 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2516 * \brief Verifies whether study of operation is locked
2517 * \param theMess - specifies whether message box must be shown if study is locked
2518 * \return State of study.
2520 * Verifies whether study of operation is locked. If second parameter is TRUE and study
2521 * is locked when corresponding message box appears
2523 bool SMESHGUI::isStudyLocked( bool theMessage )
2525 if ( SMESH::getStudy()->GetProperties()->IsLocked() )
2528 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2529 QObject::tr( "WRN_WARNING" ),
2530 QObject::tr( "WRN_STUDY_LOCKED" ) );
2536 //=============================================================================
2540 //=============================================================================
2541 bool SMESHGUI::OnGUIEvent( int theCommandID )
2543 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2547 SUIT_ResourceMgr* mgr = resourceMgr();
2551 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2552 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2554 //QAction* act = action( theCommandID );
2556 switch (theCommandID) {
2557 case SMESHOp::OpDelete:
2558 if(isStudyLocked()) break;
2561 case SMESHOp::OpImportDAT:
2562 case SMESHOp::OpImportUNV:
2563 case SMESHOp::OpImportMED:
2564 case SMESHOp::OpImportSTL:
2565 case SMESHOp::OpImportCGNS:
2566 case SMESHOp::OpImportGMF:
2567 case SMESHOp::OpPopupImportDAT:
2568 case SMESHOp::OpPopupImportUNV:
2569 case SMESHOp::OpPopupImportMED:
2570 case SMESHOp::OpPopupImportSTL:
2571 case SMESHOp::OpPopupImportCGNS:
2572 case SMESHOp::OpPopupImportGMF:
2574 if(isStudyLocked()) break;
2575 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2579 case SMESHOp::OpFileInformation:
2581 SALOME_ListIO selected;
2582 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2584 aSel->selectedObjects( selected );
2585 if( selected.Extent() )
2587 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2588 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2589 if ( !aMesh->_is_nil() )
2591 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2597 case SMESHOp::OpExportDAT:
2598 case SMESHOp::OpExportMED:
2599 case SMESHOp::OpExportUNV:
2600 case SMESHOp::OpExportSTL:
2601 case SMESHOp::OpExportCGNS:
2602 case SMESHOp::OpExportGMF:
2603 case SMESHOp::OpPopupExportDAT:
2604 case SMESHOp::OpPopupExportMED:
2605 case SMESHOp::OpPopupExportUNV:
2606 case SMESHOp::OpPopupExportSTL:
2607 case SMESHOp::OpPopupExportCGNS:
2608 case SMESHOp::OpPopupExportGMF:
2610 ::ExportMeshToFile(theCommandID);
2614 case SMESHOp::OpReset: // SCALAR BAR
2616 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2617 SALOME_ListIO selected;
2619 aSel->selectedObjects( selected );
2621 SALOME_ListIteratorOfListIO it(selected);
2622 for( ; it.More(); it.Next()) {
2623 Handle(SALOME_InteractiveObject) anIO = it.Value();
2624 if( anIO->hasEntry() ) {
2625 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2626 anActor->SetControlMode( SMESH_Actor::eNone );
2627 #ifndef DISABLE_PLOT2DVIEWER
2628 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2630 anActor->UpdateFilter();
2634 SMESH::UpdateView();
2637 case SMESHOp::OpScalarBarProperties:
2639 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2642 case SMESHOp::OpShowScalarBar:
2644 // show/hide scalar bar
2645 ::ShowElement(theCommandID);
2648 case SMESHOp::OpSaveDistribution:
2650 // dump control distribution data to the text file
2651 ::SaveDistribution();
2655 case SMESHOp::OpShowDistribution:
2657 // show/hide distribution
2658 ::ShowElement(theCommandID);
2662 #ifndef DISABLE_PLOT2DVIEWER
2663 case SMESHOp::OpPlotDistribution:
2665 // plot distribution
2666 ::PlotDistribution();
2672 case SMESHOp::OpAutoColor:
2676 case SMESHOp::OpDisableAutoColor:
2677 ::DisableAutoColor();
2680 case SMESHOp::OpClipping:
2681 case SMESHOp::OpTransparency:
2682 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2685 case SMESHOp::OpDMWireframe:
2686 case SMESHOp::OpDMShading:
2687 case SMESHOp::OpDMNodes:
2688 case SMESHOp::OpDMShrink:
2689 ::SetDisplayMode(theCommandID, myMarkerMap);
2692 //2D quadratic representation
2693 case SMESHOp::OpRepresentationLines:
2694 case SMESHOp::OpRepresentationArcs:
2695 ::SetDisplayMode(theCommandID, myMarkerMap);
2699 case SMESHOp::OpDE0DElements:
2700 case SMESHOp::OpDEEdges:
2701 case SMESHOp::OpDEFaces:
2702 case SMESHOp::OpDEVolumes:
2703 case SMESHOp::OpDEBalls:
2704 case SMESHOp::OpDEAllEntity:
2705 ::SetDisplayEntity(theCommandID);
2708 // Choose entities to be displayed
2709 case SMESHOp::OpDEChoose:
2711 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2715 case SMESHOp::OpOrientationOnFaces:
2717 SUIT_OverrideCursor wc;
2718 LightApp_SelectionMgr* mgr = selectionMgr();
2719 SALOME_ListIO selected; mgr->selectedObjects( selected );
2721 SALOME_ListIteratorOfListIO it(selected);
2722 for( ; it.More(); it.Next()) {
2723 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2724 if(anIObject->hasEntry()) {
2725 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2726 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2733 case SMESHOp::OpUpdate:
2735 if(isStudyLocked()) break;
2736 SUIT_OverrideCursor wc;
2739 SMESH::UpdateView();
2741 catch (std::bad_alloc&) { // PAL16774 (Crash after display of many groups)
2742 SMESH::OnVisuException();
2744 catch (...) { // PAL16774 (Crash after display of many groups)
2745 SMESH::OnVisuException();
2749 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2750 aSel->selectedObjects( l );
2751 aSel->setSelectedObjects( l );
2755 case SMESHOp::OpHide:
2756 case SMESHOp::OpShow:
2757 case SMESHOp::OpShowOnly:
2759 SUIT_OverrideCursor wc;
2760 SMESH::EDisplaing anAction;
2761 switch (theCommandID) {
2762 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2763 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2764 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2767 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2768 SALOME_ListIO sel_objects, to_process;
2770 aSel->selectedObjects( sel_objects );
2772 if ( theCommandID==SMESHOp::OpShowOnly )
2774 //MESSAGE("anAction = SMESH::eDisplayOnly");
2775 startOperation( myEraseAll );
2778 extractContainers( sel_objects, to_process );
2783 SALOME_ListIteratorOfListIO It( to_process );
2784 for ( ; It.More(); It.Next())
2786 Handle(SALOME_InteractiveObject) IOS = It.Value();
2787 if ( IOS->hasEntry() )
2789 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2790 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2791 break; // PAL16774 (Crash after display of many groups)
2793 if (anAction == SMESH::eDisplayOnly)
2794 anAction = SMESH::eDisplay;
2799 // PAL13338 + PAL15161 -->
2800 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !isStudyLocked()) {
2801 SMESH::UpdateView();
2802 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2804 // PAL13338 + PAL15161 <--
2806 catch (...) { // PAL16774 (Crash after display of many groups)
2807 SMESH::OnVisuException();
2810 if (anAction == SMESH::eErase) {
2812 aSel->setSelectedObjects( l1 );
2815 aSel->setSelectedObjects( to_process );
2817 if ( vtkwnd && vtkwnd->GetRenderer() && !isStudyLocked() &&
2818 ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) )
2819 vtkwnd->GetRenderer()->AdjustActors();
2824 case SMESHOp::OpNode:
2826 if(isStudyLocked()) break;
2829 EmitSignalDeactivateDialog();
2831 ( new SMESHGUI_NodesDlg( this ) )->show();
2834 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2839 case SMESHOp::OpEditMeshOrSubMesh:
2840 case SMESHOp::OpEditMesh:
2841 case SMESHOp::OpEditSubMesh:
2842 case SMESHOp::OpMeshOrder:
2843 case SMESHOp::OpCreateSubMesh:
2844 if ( warnOnGeomModif() )
2845 break; // action forbidden as geometry modified
2847 case SMESHOp::OpCreateMesh:
2848 case SMESHOp::OpCompute:
2849 case SMESHOp::OpComputeSubMesh:
2850 case SMESHOp::OpPreCompute:
2851 case SMESHOp::OpEvaluate:
2852 case SMESHOp::OpShowErrors:
2853 startOperation( theCommandID );
2855 case SMESHOp::OpRecompute:
2857 if ( isStudyLocked() )
2859 SALOME_ListIO selected;
2860 if ( LightApp_SelectionMgr *sel = selectionMgr() )
2861 sel->selectedObjects( selected );
2862 if ( selected.Extent() == 1 ) {
2863 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( selected.First() );
2864 if ( !aMesh->_is_nil() )
2866 startOperation( SMESHOp::OpCompute );
2870 case SMESHOp::OpCopyMesh:
2872 if (isStudyLocked()) break;
2873 EmitSignalDeactivateDialog();
2874 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2877 case SMESHOp::OpBuildCompoundMesh:
2879 if (isStudyLocked()) break;
2880 EmitSignalDeactivateDialog();
2881 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2885 case SMESHOp::OpDiagonalInversion:
2886 case SMESHOp::OpUnionOfTwoTriangle:
2890 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2894 if ( isStudyLocked() )
2896 if ( warnOnGeomModif() )
2897 break; // action forbidden as geometry modified
2899 /*Standard_Boolean aRes;
2900 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2901 if ( aMesh->_is_nil() )
2903 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2904 tr( "SMESH_BAD_SELECTION" ) );
2908 EmitSignalDeactivateDialog();
2909 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2910 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2912 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2915 case SMESHOp::OpOrientation:
2916 case SMESHOp::OpUnionOfTriangles:
2917 case SMESHOp::OpCuttingOfQuadrangles:
2918 case SMESHOp::OpSplitVolumes:
2922 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2926 if ( isStudyLocked() )
2928 if ( warnOnGeomModif() )
2929 break; // action forbidden as geometry modified
2931 EmitSignalDeactivateDialog();
2932 SMESHGUI_MultiEditDlg* aDlg = NULL;
2933 if ( theCommandID == SMESHOp::OpOrientation )
2934 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2935 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2936 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2937 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2938 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2940 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2945 case SMESHOp::OpSmoothing:
2947 if(isStudyLocked()) break;
2948 if ( warnOnGeomModif() )
2949 break; // action forbidden as geometry modified
2951 EmitSignalDeactivateDialog();
2952 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2955 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2959 case SMESHOp::OpExtrusion:
2961 if (isStudyLocked()) break;
2962 if ( warnOnGeomModif() )
2963 break; // action forbidden as geometry modified
2965 EmitSignalDeactivateDialog();
2966 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2968 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2972 case SMESHOp::OpExtrusionAlongAPath:
2974 if (isStudyLocked()) break;
2975 if ( warnOnGeomModif() )
2976 break; // action forbidden as geometry modified
2978 EmitSignalDeactivateDialog();
2979 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2981 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2985 case SMESHOp::OpRevolution:
2987 if(isStudyLocked()) break;
2988 if ( warnOnGeomModif() )
2989 break; // action forbidden as geometry modified
2991 EmitSignalDeactivateDialog();
2992 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2995 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2999 case SMESHOp::OpPatternMapping:
3001 if ( isStudyLocked() )
3003 if ( warnOnGeomModif() )
3004 break; // action forbidden as geometry modified
3007 EmitSignalDeactivateDialog();
3008 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
3011 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3015 // Adaptation - begin
3016 #ifndef DISABLE_MG_ADAPT
3017 case SMESHOp::OpMGAdapt:
3019 if ( isStudyLocked() )
3021 EmitSignalDeactivateDialog();
3023 SALOME::GenericObj_wrap< SMESH::MG_ADAPT > model = GetSMESHGen()->CreateMG_ADAPT();
3024 bool isCreation = false;
3025 ( new SMESHGUI_MG_ADAPTDRIVER( this, model, isCreation ))->show();
3029 #ifndef DISABLE_HOMARD_ADAPT
3030 case SMESHOp::OpHomardAdapt:
3032 if ( isStudyLocked() )
3034 EmitSignalDeactivateDialog();
3036 SALOME::GenericObj_wrap< SMESHHOMARD::HOMARD_Gen > homardGen;
3038 homardGen = GetSMESHGen()->CreateHOMARD_ADAPT();
3040 catch ( const SALOME::SALOME_Exception& S_ex ) {
3041 SUIT_MessageBox::critical(SMESHGUI::desktop(),
3042 QObject::tr("SMESH_ERROR"),
3043 QObject::tr(S_ex.details.text.in()));
3045 if (!homardGen->_is_nil()) {
3046 SMESHGUI_HomardAdaptDlg *aDlg = new SMESHGUI_HomardAdaptDlg(homardGen);
3053 case SMESHOp::OpSplitBiQuadratic:
3054 case SMESHOp::OpConvertMeshToQuadratic:
3055 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
3056 case SMESHOp::OpReorientFaces:
3057 case SMESHOp::OpCreateGeometryGroup:
3059 if ( warnOnGeomModif() )
3060 break; // action forbidden as geometry modified
3061 startOperation( theCommandID );
3064 case SMESHOp::OpCreateGroup:
3068 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3072 if(isStudyLocked()) break;
3073 if ( warnOnGeomModif() )
3074 break; // action forbidden as geometry modified
3075 EmitSignalDeactivateDialog();
3076 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
3078 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3079 SALOME_ListIO selected;
3081 aSel->selectedObjects( selected );
3083 int nbSel = selected.Extent();
3085 // check if mesh is selected
3086 aMesh = SMESH::GetMeshByIO( selected.First() );
3088 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
3093 case SMESHOp::OpConstructGroup:
3097 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3101 if(isStudyLocked()) break;
3102 if ( warnOnGeomModif() )
3103 break; // action forbidden as geometry modified
3104 EmitSignalDeactivateDialog();
3106 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3107 SALOME_ListIO selected;
3109 aSel->selectedObjects( selected );
3111 int nbSel = selected.Extent();
3113 // check if submesh is selected
3114 Handle(SALOME_InteractiveObject) IObject = selected.First();
3115 if (IObject->hasEntry()) {
3116 _PTR(SObject) aSObj = SMESH::getStudy()->FindObjectID(IObject->getEntry());
3118 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
3119 if (!aSubMesh->_is_nil()) {
3121 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
3122 // get submesh elements list by types
3123 SMESH::smIdType_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
3124 SMESH::smIdType_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
3125 SMESH::smIdType_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
3126 SMESH::smIdType_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
3127 // create group for each type o elements
3128 QString aName = IObject->getName();
3129 QStringList anEntryList;
3130 if (aNodes->length() > 0) {
3131 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
3132 aGroup->Add(aNodes.inout());
3133 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3134 anEntryList.append( aSObject->GetID().c_str() );
3136 if (aEdges->length() > 0) {
3137 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
3138 aGroup->Add(aEdges.inout());
3139 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3140 anEntryList.append( aSObject->GetID().c_str() );
3142 if (aFaces->length() > 0) {
3143 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
3144 aGroup->Add(aFaces.inout());
3145 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3146 anEntryList.append( aSObject->GetID().c_str() );
3148 if (aVolumes->length() > 0) {
3149 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
3150 aGroup->Add(aVolumes.inout());
3151 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3152 anEntryList.append( aSObject->GetID().c_str() );
3155 anApp->browseObjects( anEntryList );
3157 catch(const SALOME::SALOME_Exception & S_ex){
3158 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3165 SUIT_MessageBox::warning(desktop(),
3166 tr("SMESH_WRN_WARNING"),
3167 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
3172 case SMESHOp::OpEditGroup:
3176 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3180 if(isStudyLocked()) break;
3181 if ( warnOnGeomModif() )
3182 break; // action forbidden as geometry modified
3183 EmitSignalDeactivateDialog();
3185 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3186 SALOME_ListIO selected;
3188 aSel->selectedObjects( selected );
3190 SALOME_ListIteratorOfListIO It (selected);
3191 int nbSelectedGroups = 0;
3192 for ( ; It.More(); It.Next() )
3194 SMESH::SMESH_GroupBase_var aGroup =
3195 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3196 if (!aGroup->_is_nil()) {
3198 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3202 if (nbSelectedGroups == 0)
3204 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3210 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3212 if(isStudyLocked()) break;
3213 if (myState == 800) {
3214 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3215 if (aDlg) aDlg->onAdd();
3220 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3222 if(isStudyLocked()) break;
3223 if (myState == 800) {
3224 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3225 if (aDlg) aDlg->onRemove();
3230 case SMESHOp::OpEditGeomGroupAsGroup:
3234 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3238 if(isStudyLocked()) break;
3239 EmitSignalDeactivateDialog();
3241 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3242 SALOME_ListIO selected;
3244 aSel->selectedObjects( selected );
3246 SALOME_ListIteratorOfListIO It (selected);
3247 for ( ; It.More(); It.Next() )
3249 SMESH::SMESH_GroupOnGeom_var aGroup =
3250 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3251 if (!aGroup->_is_nil()) {
3252 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3257 SMESH::SMESH_GroupOnFilter_var aGroup =
3258 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3259 if (!aGroup->_is_nil()) {
3260 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3268 case SMESHOp::OpUnionGroups:
3269 case SMESHOp::OpIntersectGroups:
3270 case SMESHOp::OpCutGroups:
3274 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3278 if ( isStudyLocked() )
3280 if ( warnOnGeomModif() )
3281 break; // action forbidden as geometry modified
3283 EmitSignalDeactivateDialog();
3285 SMESHGUI_GroupOpDlg* aDlg = 0;
3286 if ( theCommandID == SMESHOp::OpUnionGroups )
3287 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3288 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3289 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3291 aDlg = new SMESHGUI_CutGroupsDlg( this );
3298 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3300 if ( isStudyLocked() )
3302 if ( warnOnGeomModif() )
3303 break; // action forbidden as geometry modified
3305 EmitSignalDeactivateDialog();
3306 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3312 case SMESHOp::OpFaceGroupsByEdges: // Create face groups separated by sharp edges
3314 if ( isStudyLocked() )
3316 if ( warnOnGeomModif() )
3317 break; // action forbidden as geometry modified
3319 EmitSignalDeactivateDialog();
3320 SMESHGUI_FaceGroupsSeparatedByEdgesDlg* aDlg = new SMESHGUI_FaceGroupsSeparatedByEdgesDlg( this );
3326 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3330 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3334 if ( isStudyLocked() )
3337 EmitSignalDeactivateDialog();
3339 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3343 case SMESHOp::OpMeshInformation:
3344 case SMESHOp::OpWhatIs:
3346 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3347 EmitSignalDeactivateDialog();
3348 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3349 SALOME_ListIO selected;
3351 aSel->selectedObjects( selected );
3353 if ( selected.Extent() > 1 ) { // a dlg for each IO
3354 SALOME_ListIteratorOfListIO It( selected );
3355 for ( ; It.More(); It.Next() ) {
3356 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3357 dlg->showInfo( It.Value() );
3362 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3368 case SMESHOp::OpFindElementByPoint:
3370 startOperation( theCommandID );
3374 case SMESHOp::OpEditHypothesis:
3376 if(isStudyLocked()) break;
3377 if ( warnOnGeomModif() )
3378 break; // action forbidden as geometry modified
3380 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3381 SALOME_ListIO selected;
3383 aSel->selectedObjects( selected );
3385 int nbSel = selected.Extent();
3388 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3389 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3391 if ( !aHypothesis->_is_nil() )
3393 SMESHGUI_GenericHypothesisCreator* aCreator =
3394 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3397 // set geometry of mesh and sub-mesh to aCreator
3398 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3399 if ( selected.Extent() == 1 )
3401 QString subGeomID, meshGeomID;
3402 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3403 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3405 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3406 aCreator->setShapeEntry( subGeomID );
3407 aCreator->setMainShapeEntry( meshGeomID );
3411 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3421 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3423 if(isStudyLocked()) break;
3424 if ( warnOnGeomModif() )
3425 break; // action forbidden as geometry modified
3426 SUIT_OverrideCursor wc;
3428 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3429 SALOME_ListIO selected;
3431 aSel->selectedObjects( selected, QString::null, false );
3433 SALOME_ListIteratorOfListIO It(selected);
3434 for (int i = 0; It.More(); It.Next(), i++) {
3435 Handle(SALOME_InteractiveObject) IObject = It.Value();
3436 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3439 aSel->setSelectedObjects( l1 );
3444 case SMESHOp::OpElem0D:
3445 case SMESHOp::OpBall:
3446 case SMESHOp::OpEdge:
3447 case SMESHOp::OpTriangle:
3448 case SMESHOp::OpQuadrangle:
3449 case SMESHOp::OpPolygon:
3450 case SMESHOp::OpTetrahedron:
3451 case SMESHOp::OpHexahedron:
3452 case SMESHOp::OpPentahedron:
3453 case SMESHOp::OpPyramid:
3454 case SMESHOp::OpHexagonalPrism:
3456 if(isStudyLocked()) break;
3457 if ( warnOnGeomModif() )
3458 break; // action forbidden as geometry modified
3460 EmitSignalDeactivateDialog();
3461 SMDSAbs_EntityType type = SMDSEntity_Edge;
3462 switch (theCommandID) {
3463 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3464 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3465 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3466 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3467 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3468 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3469 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3470 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3471 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3472 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3475 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3478 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3482 case SMESHOp::OpPolyhedron:
3484 if(isStudyLocked()) break;
3485 if ( warnOnGeomModif() )
3486 break; // action forbidden as geometry modified
3488 EmitSignalDeactivateDialog();
3489 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3492 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3496 case SMESHOp::OpQuadraticEdge:
3497 case SMESHOp::OpQuadraticTriangle:
3498 case SMESHOp::OpBiQuadraticTriangle:
3499 case SMESHOp::OpQuadraticQuadrangle:
3500 case SMESHOp::OpBiQuadraticQuadrangle:
3501 case SMESHOp::OpQuadraticPolygon:
3502 case SMESHOp::OpQuadraticTetrahedron:
3503 case SMESHOp::OpQuadraticPyramid:
3504 case SMESHOp::OpQuadraticPentahedron:
3505 case SMESHOp::OpBiQuadraticPentahedron:
3506 case SMESHOp::OpQuadraticHexahedron:
3507 case SMESHOp::OpTriQuadraticHexahedron:
3509 if(isStudyLocked()) break;
3510 if ( warnOnGeomModif() )
3511 break; // action forbidden as geometry modified
3513 EmitSignalDeactivateDialog();
3514 SMDSAbs_EntityType type = SMDSEntity_Last;
3516 switch (theCommandID) {
3517 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3518 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3519 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3520 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3521 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3522 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3523 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3524 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3525 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3526 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3527 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3528 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3531 if ( type != SMDSEntity_Last )
3532 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3535 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3536 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3540 case SMESHOp::OpRemoveNodes:
3542 if(isStudyLocked()) break;
3543 if ( warnOnGeomModif() )
3544 break; // action forbidden as geometry modified
3546 EmitSignalDeactivateDialog();
3547 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3550 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3551 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3555 case SMESHOp::OpRemoveNodeWithReconn:
3557 if(isStudyLocked()) break;
3558 if ( warnOnGeomModif() )
3559 break; // action forbidden as geometry modified
3560 startOperation( SMESHOp::OpRemoveNodeWithReconn );
3563 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3565 if(isStudyLocked()) break;
3566 if ( warnOnGeomModif() )
3567 break; // action forbidden as geometry modified
3569 EmitSignalDeactivateDialog();
3570 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3574 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3575 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3579 case SMESHOp::OpClearMesh: {
3581 if(isStudyLocked()) break;
3582 if ( warnOnGeomModif() )
3583 break; // action forbidden as geometry modified
3585 SALOME_ListIO selected;
3586 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3587 aSel->selectedObjects( selected );
3589 SUIT_OverrideCursor wc;
3590 SALOME_ListIteratorOfListIO It (selected);
3591 for ( ; It.More(); It.Next() )
3593 Handle(SALOME_InteractiveObject) IOS = It.Value();
3594 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3595 if ( aMesh->_is_nil()) continue;
3598 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3599 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3600 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3601 // hide groups and submeshes
3602 _PTR(ChildIterator) anIter =
3603 SMESH::getStudy()->NewChildIterator( aMeshSObj );
3604 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3606 _PTR(SObject) so = anIter->Value();
3607 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3610 catch (const SALOME::SALOME_Exception& S_ex){
3612 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3616 SMESH::UpdateView();
3620 case SMESHOp::OpRemoveOrphanNodes:
3622 if(isStudyLocked()) break;
3623 if ( warnOnGeomModif() )
3624 break; // action forbidden as geometry modified
3625 SALOME_ListIO selected;
3626 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3627 aSel->selectedObjects( selected );
3628 if ( selected.Extent() == 1 ) {
3629 Handle(SALOME_InteractiveObject) anIO = selected.First();
3630 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3631 if ( !aMesh->_is_nil() ) {
3632 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3633 tr( "SMESH_WARNING" ),
3634 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3635 SUIT_MessageBox::Yes |
3636 SUIT_MessageBox::No,
3637 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3640 SUIT_OverrideCursor wc;
3641 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3642 smIdType removed = aMeshEditor->RemoveOrphanNodes();
3643 SUIT_MessageBox::information(SMESHGUI::desktop(),
3644 tr("SMESH_INFORMATION"),
3645 tr("NB_NODES_REMOVED").arg(removed));
3646 if ( removed > 0 ) {
3647 SMESH::UpdateView();
3648 SMESHGUI::Modified();
3651 catch (const SALOME::SALOME_Exception& S_ex) {
3652 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3661 case SMESHOp::OpRenumberingNodes:
3663 if(isStudyLocked()) break;
3664 if ( warnOnGeomModif() )
3665 break; // action forbidden as geometry modified
3667 EmitSignalDeactivateDialog();
3668 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3672 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3673 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3677 case SMESHOp::OpRenumberingElements:
3679 if(isStudyLocked()) break;
3680 if ( warnOnGeomModif() )
3681 break; // action forbidden as geometry modified
3683 EmitSignalDeactivateDialog();
3684 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3688 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3689 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3693 case SMESHOp::OpTranslation:
3695 if(isStudyLocked()) break;
3696 if ( warnOnGeomModif() )
3697 break; // action forbidden as geometry modified
3699 EmitSignalDeactivateDialog();
3700 ( new SMESHGUI_TranslationDlg( this ) )->show();
3703 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3704 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3708 case SMESHOp::OpRotation:
3710 if(isStudyLocked()) break;
3711 if ( warnOnGeomModif() )
3712 break; // action forbidden as geometry modified
3714 EmitSignalDeactivateDialog();
3715 ( new SMESHGUI_RotationDlg( this ) )->show();
3718 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3719 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3723 case SMESHOp::OpSymmetry:
3725 if(isStudyLocked()) break;
3726 if ( warnOnGeomModif() )
3727 break; // action forbidden as geometry modified
3729 EmitSignalDeactivateDialog();
3730 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3733 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3734 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3738 case SMESHOp::OpScale:
3740 if(isStudyLocked()) break;
3741 if ( warnOnGeomModif() )
3742 break; // action forbidden as geometry modified
3744 EmitSignalDeactivateDialog();
3745 ( new SMESHGUI_ScaleDlg( this ) )->show();
3748 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3749 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3754 case SMESHOp::OpOffset:
3756 if(isStudyLocked()) break;
3757 if ( warnOnGeomModif() )
3758 break; // action forbidden as geometry modified
3760 EmitSignalDeactivateDialog();
3761 ( new SMESHGUI_OffsetDlg( this ) )->show();
3764 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3765 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3770 case SMESHOp::OpSewing:
3772 if(isStudyLocked()) break;
3773 if ( warnOnGeomModif() )
3774 break; // action forbidden as geometry modified
3776 EmitSignalDeactivateDialog();
3777 ( new SMESHGUI_SewingDlg( this ) )->show();
3780 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3781 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3785 case SMESHOp::OpMergeNodes:
3787 if(isStudyLocked()) break;
3788 if ( warnOnGeomModif() )
3789 break; // action forbidden as geometry modified
3791 EmitSignalDeactivateDialog();
3792 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3795 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3796 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3800 case SMESHOp::OpMergeElements:
3802 if (isStudyLocked()) break;
3803 if ( warnOnGeomModif() )
3804 break; // action forbidden as geometry modified
3806 EmitSignalDeactivateDialog();
3807 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3809 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3810 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3815 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3816 if ( warnOnGeomModif() )
3817 break; // action forbidden as geometry modified
3818 startOperation( SMESHOp::OpMoveNode );
3821 case SMESHOp::OpMoveNodeInteractive:
3822 if ( warnOnGeomModif() )
3823 break; // action forbidden as geometry modified
3824 startOperation( SMESHOp::OpMoveNodeInteractive );
3827 case SMESHOp::OpSplitEdgeInteract:
3828 if ( warnOnGeomModif() )
3829 break; // action forbidden as geometry modified
3830 startOperation( SMESHOp::OpSplitEdgeInteract );
3833 case SMESHOp::OpSplitFaceInteract:
3834 if ( warnOnGeomModif() )
3835 break; // action forbidden as geometry modified
3836 startOperation( SMESHOp::OpSplitFaceInteract );
3839 case SMESHOp::OpDuplicateNodes:
3841 if(isStudyLocked()) break;
3842 if ( warnOnGeomModif() )
3843 break; // action forbidden as geometry modified
3845 EmitSignalDeactivateDialog();
3846 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3849 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3850 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3855 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3856 if ( warnOnGeomModif() )
3857 break; // action forbidden as geometry modified
3858 startOperation( SMESHOp::OpElem0DOnElemNodes );
3861 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3863 static QList<int> aTypes;
3864 if ( aTypes.isEmpty() )
3866 aTypes.append( SMESH::NODE );
3867 aTypes.append( SMESH::EDGE );
3868 aTypes.append( SMESH::FACE );
3869 aTypes.append( SMESH::VOLUME );
3871 if (!myFilterLibraryDlg)
3872 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3873 else if (myFilterLibraryDlg->isHidden())
3874 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3875 myFilterLibraryDlg->raise();
3879 case SMESHOp::OpFreeNode:
3880 case SMESHOp::OpEqualNode:
3881 case SMESHOp::OpNodeConnectivityNb:
3882 case SMESHOp::OpFreeEdge:
3883 case SMESHOp::OpFreeBorder:
3884 case SMESHOp::OpLength:
3885 case SMESHOp::OpConnection:
3886 case SMESHOp::OpEqualEdge:
3887 case SMESHOp::OpFreeFace:
3888 case SMESHOp::OpBareBorderFace:
3889 case SMESHOp::OpOverConstrainedFace:
3890 case SMESHOp::OpLength2D:
3891 case SMESHOp::OpDeflection2D:
3892 case SMESHOp::OpConnection2D:
3893 case SMESHOp::OpArea:
3894 case SMESHOp::OpTaper:
3895 case SMESHOp::OpAspectRatio:
3896 case SMESHOp::OpMinimumAngle:
3897 case SMESHOp::OpWarpingAngle:
3898 case SMESHOp::OpSkew:
3899 case SMESHOp::OpMaxElementLength2D:
3900 case SMESHOp::OpEqualFace:
3901 case SMESHOp::OpAspectRatio3D:
3902 case SMESHOp::OpVolume:
3903 case SMESHOp::OpMaxElementLength3D:
3904 case SMESHOp::OpBareBorderVolume:
3905 case SMESHOp::OpOverConstrainedVolume:
3906 case SMESHOp::OpEqualVolume:
3909 LightApp_SelectionMgr* mgr = selectionMgr();
3910 SALOME_ListIO selected; mgr->selectedObjects( selected );
3912 if( !selected.IsEmpty() ) {
3913 SUIT_OverrideCursor wc;
3914 ::Control( theCommandID );
3917 SUIT_MessageBox::warning(desktop(),
3918 tr( "SMESH_WRN_WARNING" ),
3919 tr( "SMESH_BAD_SELECTION" ) );
3923 SUIT_MessageBox::warning(desktop(),
3924 tr( "SMESH_WRN_WARNING" ),
3925 tr( "NOT_A_VTK_VIEWER" ) );
3928 case SMESHOp::OpOverallMeshQuality:
3929 OverallMeshQuality();
3931 case SMESHOp::OpNumberingNodes:
3933 SUIT_OverrideCursor wc;
3934 LightApp_SelectionMgr* mgr = selectionMgr();
3935 SALOME_ListIO selected; mgr->selectedObjects( selected );
3937 SALOME_ListIteratorOfListIO it(selected);
3938 for( ; it.More(); it.Next()) {
3939 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3940 if(anIObject->hasEntry()) {
3941 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3942 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3948 case SMESHOp::OpNumberingElements:
3950 SUIT_OverrideCursor wc;
3951 LightApp_SelectionMgr* mgr = selectionMgr();
3952 SALOME_ListIO selected; mgr->selectedObjects( selected );
3954 SALOME_ListIteratorOfListIO it(selected);
3955 for( ; it.More(); it.Next()) {
3956 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3957 if(anIObject->hasEntry())
3958 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3959 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3964 case SMESHOp::OpPropertiesLength:
3965 case SMESHOp::OpPropertiesArea:
3966 case SMESHOp::OpPropertiesVolume:
3967 case SMESHOp::OpMinimumDistance:
3968 case SMESHOp::OpBoundingBox:
3969 case SMESHOp::OpAngle:
3971 int page = SMESHGUI_MeasureDlg::MinDistance;
3972 if ( theCommandID == SMESHOp::OpBoundingBox )
3973 page = SMESHGUI_MeasureDlg::BoundingBox;
3974 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3975 page = SMESHGUI_MeasureDlg::Length;
3976 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3977 page = SMESHGUI_MeasureDlg::Area;
3978 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3979 page = SMESHGUI_MeasureDlg::Volume;
3980 else if ( theCommandID == SMESHOp::OpAngle )
3981 page = SMESHGUI_MeasureDlg::Angle;
3983 EmitSignalDeactivateDialog();
3984 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3988 case SMESHOp::OpSortChild:
3991 case SMESHOp::OpBreakLink:
3992 ::breakShaperLink();
3997 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3998 //updateObjBrowser();
4002 //=============================================================================
4006 //=============================================================================
4007 bool SMESHGUI::OnMousePress( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4012 //=============================================================================
4016 //=============================================================================
4017 bool SMESHGUI::OnMouseMove( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4022 //=============================================================================
4026 //=============================================================================
4027 bool SMESHGUI::OnKeyPress( QKeyEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4032 //=============================================================================
4033 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
4034 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
4036 //=============================================================================
4037 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
4038 SUIT_ViewWindow* wnd )
4040 if(theIO->hasEntry()){
4041 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
4042 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
4046 //=======================================================================
4047 // function : createSMESHAction
4049 //=======================================================================
4050 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
4051 const int key, const bool toggle, const QString& shortcutAction )
4054 QWidget* parent = application()->desktop();
4055 SUIT_ResourceMgr* resMgr = resourceMgr();
4057 if ( !icon_id.isEmpty() )
4058 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
4060 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICON_%1" ).arg( po_id ).toLatin1().data() ), false );
4061 if ( !pix.isNull() )
4062 icon = QIcon( pix );
4064 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
4065 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
4066 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
4068 createAction( id, tooltip, icon, menu, status_bar, key, parent,
4069 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
4072 //=======================================================================
4073 // function : createPopupItem
4075 //=======================================================================
4076 void SMESHGUI::createPopupItem( const int id,
4077 const QString& clients,
4078 const QString& types,
4079 const QString& theRule,
4082 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
4083 popupMgr()->insert( action( id ), pId, 0 );
4085 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4086 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4087 QString rule = "(%1) and (%2) and (%3)";
4088 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
4089 if( clients.isEmpty() )
4090 rule = rule.arg( QString( "true" ) );
4092 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
4093 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
4096 bool cont = myRules.contains( id );
4098 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
4100 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
4101 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
4104 //=======================================================================
4105 // function : initialize
4107 //=======================================================================
4108 void SMESHGUI::initialize( CAM_Application* app )
4110 SalomeApp_Module::initialize( app );
4112 // SUIT_ResourceMgr* mgr = app->resourceMgr();
4114 /* Automatic Update flag */
4115 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
4117 // ----- create actions --------------
4119 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
4120 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
4121 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
4122 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
4124 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
4126 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
4127 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
4128 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
4129 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
4131 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
4133 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
4135 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
4136 createSMESHAction( SMESHOp::OpExportMED, "MED" );
4137 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
4138 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
4140 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
4142 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
4143 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
4144 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
4145 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
4146 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
4148 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
4150 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
4151 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
4152 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
4153 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
4154 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
4155 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
4156 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
4157 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
4158 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
4159 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
4160 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
4161 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
4162 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
4163 createSMESHAction( SMESHOp::OpRecompute, "RE_COMPUTE", "ICON_COMPUTE" );
4164 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
4165 createSMESHAction( SMESHOp::OpShowErrors, "SHOW_ERRORS", "ICON_SHOW_ERRORS" );
4166 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
4167 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
4168 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
4169 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
4170 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
4171 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
4172 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
4173 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
4174 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
4175 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
4176 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
4177 createSMESHAction( SMESHOp::OpFaceGroupsByEdges, "FACE_GROUPS_BY_EDGES", "ICON_FACE_GROUPS_BY_EDGES" );
4178 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
4179 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
4180 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
4181 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
4182 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
4183 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4184 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
4186 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
4187 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
4188 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
4189 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
4190 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
4191 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
4192 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
4193 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
4194 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
4195 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
4196 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
4197 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
4198 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
4199 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
4200 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
4201 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
4202 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
4203 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
4204 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
4205 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
4206 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
4207 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
4208 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
4209 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
4210 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
4211 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
4212 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
4213 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
4214 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
4216 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
4217 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
4218 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
4219 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
4220 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
4221 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
4222 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
4223 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
4224 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
4225 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
4226 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
4227 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
4228 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
4229 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
4230 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
4231 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
4232 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
4233 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
4234 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
4235 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
4236 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
4237 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
4238 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
4239 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
4240 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
4241 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
4243 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
4244 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
4245 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
4246 createSMESHAction( SMESHOp::OpRemoveNodeWithReconn, "REMOVE_NODE_RECON", "ICON_REM_NODE_RECON" );
4247 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
4249 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
4250 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
4252 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
4253 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
4254 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
4255 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
4256 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
4257 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
4258 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
4259 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
4260 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
4261 createSMESHAction( SMESHOp::OpMoveNodeInteractive, "MOVE_NODE_INTRCT","ICON_DLG_MOVE_NODE_INTERACTIVE" );
4262 createSMESHAction( SMESHOp::OpSplitEdgeInteract, "SPLIT_DIAG_INTRC","ICON_SPLIT_DIAG_INTERACTIVE" );
4263 createSMESHAction( SMESHOp::OpSplitFaceInteract, "SPLIT_FACE_INTRC","ICON_SPLIT_FACE_INTERACTIVE" );
4264 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
4265 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
4266 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
4267 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
4268 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
4269 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
4270 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
4271 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
4272 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
4273 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
4274 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
4275 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
4276 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
4277 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
4278 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
4279 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
4281 createSMESHAction( SMESHOp::OpReset, "RESET" );
4282 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
4283 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
4284 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
4285 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
4286 #ifndef DISABLE_PLOT2DVIEWER
4287 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
4289 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
4290 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
4291 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
4292 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
4293 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
4294 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4295 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4296 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4297 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4298 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4299 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4300 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4301 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4303 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4304 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4306 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4307 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4308 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4309 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4310 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4311 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4312 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4313 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4314 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4316 // Adaptation - begin
4317 #ifndef DISABLE_MG_ADAPT
4318 createSMESHAction( SMESHOp::OpMGAdapt, "MG_ADAPT", "ICON_MG_ADAPT" );
4320 #ifndef DISABLE_HOMARD_ADAPT
4321 createSMESHAction( SMESHOp::OpHomardAdapt, "HOMARD_ADAPT", "ICON_HOMARD_ADAPT" );
4325 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4326 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4327 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4328 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4329 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4330 createSMESHAction( SMESHOp::OpAngle, "MEASURE_ANGLE", "ICON_MEASURE_ANGLE" );
4332 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
4333 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
4334 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4336 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4338 createSMESHAction( SMESHOp::OpBreakLink, "BREAK_SHAPER_LINK" );
4340 QList<int> aCtrlActions;
4341 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4342 << SMESHOp::OpNodeConnectivityNb // node controls
4343 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4344 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4345 << SMESHOp::OpDeflection2D
4346 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4347 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4348 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4349 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4350 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4351 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
4352 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4353 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls
4354 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4355 aCtrlGroup->setExclusive( true );
4356 for( int i = 0; i < aCtrlActions.size(); i++ )
4357 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4359 // ----- create menu --------------
4360 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4361 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4362 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4363 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4364 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4365 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4366 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4367 adaptId = createMenu( tr( "MEN_ADAPT" ), -1, 80, 10 ),
4369 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4370 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4372 createMenu( separator(), fileId );
4374 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4375 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4376 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4377 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4378 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4379 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4380 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4381 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4382 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4383 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4384 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4385 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4386 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4388 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4389 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4390 createMenu( SMESHOp::OpImportMED, importId, -1 );
4391 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4393 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4395 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4396 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4397 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4398 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4399 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4401 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4403 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4404 createMenu( separator(), fileId, 10 );
4406 createMenu( SMESHOp::OpDelete, editId, -1 );
4408 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4410 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4411 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4412 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4413 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4414 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4415 createMenu( separator(), meshId, -1 );
4416 createMenu( SMESHOp::OpCompute, meshId, -1 );
4417 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4418 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4419 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4420 createMenu( separator(), meshId, -1 );
4421 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4422 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4423 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4424 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4425 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4426 createMenu( separator(), meshId, -1 );
4427 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4428 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4429 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4430 createMenu( separator(), meshId, -1 );
4431 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4432 createMenu( SMESHOp::OpFaceGroupsByEdges, meshId, -1 );
4433 createMenu( separator(), meshId, -1 );
4434 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4435 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4436 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4437 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4438 createMenu( separator(), meshId, -1 );
4440 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4441 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4442 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4443 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4444 createMenu( SMESHOp::OpLength, edgeId, -1 );
4445 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4446 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4447 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4448 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4449 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4450 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4451 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4452 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4453 createMenu( SMESHOp::OpArea, faceId, -1 );
4454 createMenu( SMESHOp::OpTaper, faceId, -1 );
4455 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4456 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4457 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4458 createMenu( SMESHOp::OpSkew, faceId, -1 );
4459 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4460 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4461 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4462 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4463 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4464 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4465 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4466 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4467 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4468 createMenu( separator(), ctrlId, -1 );
4469 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4470 createMenu( separator(), ctrlId, -1 );
4471 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4473 createMenu( SMESHOp::OpNode, addId, -1 );
4474 createMenu( SMESHOp::OpElem0D, addId, -1 );
4475 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4476 createMenu( SMESHOp::OpBall, addId, -1 );
4477 createMenu( SMESHOp::OpEdge, addId, -1 );
4478 createMenu( SMESHOp::OpTriangle, addId, -1 );
4479 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4480 createMenu( SMESHOp::OpPolygon, addId, -1 );
4481 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4482 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4483 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4484 createMenu( SMESHOp::OpPyramid, addId, -1 );
4485 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4486 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4487 createMenu( separator(), addId, -1 );
4488 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4489 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4490 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4491 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4492 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4493 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4494 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4495 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4496 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4497 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4498 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4499 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4500 createMenu( separator(), addId, -1 );
4501 createMenu( SMESHOp::OpSplitEdgeInteract, addId, -1 );
4502 createMenu( SMESHOp::OpSplitFaceInteract, addId, -1 );
4504 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4505 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4506 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4507 createMenu( SMESHOp::OpRemoveNodeWithReconn, removeId, -1 );
4508 createMenu( separator(), removeId, -1 );
4509 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4510 createMenu( separator(), removeId, -1 );
4511 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4513 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4514 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4516 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4517 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4518 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4519 createMenu( SMESHOp::OpRotation, transfId, -1 );
4520 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4521 createMenu( SMESHOp::OpScale, transfId, -1 );
4522 createMenu( SMESHOp::OpOffset, transfId, -1 );
4523 createMenu( SMESHOp::OpSewing, transfId, -1 );
4524 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4526 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4527 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4528 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4529 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4530 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4531 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4532 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4533 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4534 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4535 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4536 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4537 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4538 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4539 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4540 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4541 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4543 // Adaptation - begin
4544 #ifndef DISABLE_MG_ADAPT
4545 createMenu( SMESHOp::OpMGAdapt, adaptId, -1 );
4547 #ifndef DISABLE_HOMARD_ADAPT
4548 createMenu( SMESHOp::OpHomardAdapt, adaptId, -1 );
4552 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4553 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4554 createMenu( SMESHOp::OpAngle, measureId, -1 );
4555 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4556 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4557 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4558 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4560 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4561 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4562 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4563 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4565 // ----- create toolbars --------------
4566 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ) ;
4567 createTool( SMESHOp::OpCreateMesh, meshTb );
4568 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4569 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4570 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4571 createTool( SMESHOp::OpCopyMesh, meshTb );
4572 createTool( separator(), meshTb );
4573 createTool( SMESHOp::OpCompute, meshTb );
4574 createTool( SMESHOp::OpPreCompute, meshTb );
4575 createTool( SMESHOp::OpEvaluate, meshTb );
4576 createTool( SMESHOp::OpMeshOrder, meshTb );
4578 int infoTb = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ) ;
4579 createTool( SMESHOp::OpMeshInformation, infoTb );
4580 //createTool( SMESHOp::OpStdInfo, meshTb );
4581 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4582 createTool( SMESHOp::OpFindElementByPoint, infoTb );
4584 int groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ) ;
4585 createTool( SMESHOp::OpCreateGroup, groupTb );
4586 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4587 createTool( SMESHOp::OpConstructGroup, groupTb );
4588 createTool( SMESHOp::OpEditGroup, groupTb );
4590 int ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ) ;
4591 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4592 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4593 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4595 int ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ) ;
4596 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4597 createTool( SMESHOp::OpLength, ctrl1dTb );
4598 createTool( SMESHOp::OpConnection, ctrl1dTb );
4599 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4601 int ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ) ;
4602 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4603 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4604 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4605 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4606 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4607 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4608 createTool( SMESHOp::OpArea, ctrl2dTb );
4609 createTool( SMESHOp::OpTaper, ctrl2dTb );
4610 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4611 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4612 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4613 createTool( SMESHOp::OpSkew, ctrl2dTb );
4614 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4615 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4616 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4618 int ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ) ;
4619 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4620 createTool( SMESHOp::OpVolume, ctrl3dTb );
4621 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4622 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4623 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4624 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4626 int addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ) ;
4627 createTool( SMESHOp::OpNode, addElemTb );
4628 createTool( SMESHOp::OpElem0D, addElemTb );
4629 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4630 createTool( SMESHOp::OpBall, addElemTb );
4631 createTool( SMESHOp::OpEdge, addElemTb );
4632 createTool( SMESHOp::OpTriangle, addElemTb );
4633 createTool( SMESHOp::OpQuadrangle, addElemTb );
4634 createTool( SMESHOp::OpPolygon, addElemTb );
4635 createTool( SMESHOp::OpTetrahedron, addElemTb );
4636 createTool( SMESHOp::OpHexahedron, addElemTb );
4637 createTool( SMESHOp::OpPentahedron, addElemTb );
4638 createTool( SMESHOp::OpPyramid, addElemTb );
4639 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4640 createTool( SMESHOp::OpPolyhedron, addElemTb );
4642 int addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ) ;
4643 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4644 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4645 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4646 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4647 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4648 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4649 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4650 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4651 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4652 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4653 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4654 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4656 int remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ) ;
4657 createTool( SMESHOp::OpRemoveNodes, remTb );
4658 createTool( SMESHOp::OpRemoveElements, remTb );
4659 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4660 createTool( SMESHOp::OpClearMesh, remTb );
4662 // int renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ) ;
4663 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4664 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4666 int transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ) ;
4667 createTool( SMESHOp::OpMergeNodes, transformTb );
4668 createTool( SMESHOp::OpMergeElements, transformTb );
4669 createTool( SMESHOp::OpTranslation, transformTb );
4670 createTool( SMESHOp::OpRotation, transformTb );
4671 createTool( SMESHOp::OpSymmetry, transformTb );
4672 createTool( SMESHOp::OpScale, transformTb );
4673 createTool( SMESHOp::OpOffset, transformTb );
4674 createTool( SMESHOp::OpSewing, transformTb );
4675 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4677 int modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ) ;
4678 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4679 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4680 createTool( SMESHOp::OpExtrusion, modifyTb );
4681 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4682 createTool( SMESHOp::OpRevolution, modifyTb );
4683 createTool( SMESHOp::OpOrientation, modifyTb );
4684 createTool( SMESHOp::OpReorientFaces, modifyTb );
4685 createTool( SMESHOp::OpMoveNode, modifyTb );
4686 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4687 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4688 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4689 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4690 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4691 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4692 createTool( SMESHOp::OpSmoothing, modifyTb );
4693 createTool( SMESHOp::OpPatternMapping, modifyTb );
4695 int interactTb = createTool( tr( "TB_INTERACT" ), QString( "SMESHInteractiveToolbar" ) ) ;
4696 createTool( SMESHOp::OpMoveNodeInteractive, interactTb );
4697 createTool( SMESHOp::OpRemoveNodeWithReconn, interactTb );
4698 createTool( SMESHOp::OpSplitEdgeInteract, interactTb );
4699 createTool( SMESHOp::OpSplitFaceInteract, interactTb );
4701 // Adaptation - begin
4702 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4703 int adaptTb = createTool( tr( "TB_ADAPTATION" ), QString( "SMESHAdaptationToolbar" ) ) ;
4705 #ifndef DISABLE_MG_ADAPT
4706 createTool( SMESHOp::OpMGAdapt, adaptTb );
4708 #ifndef DISABLE_HOMARD_ADAPT
4709 createTool( SMESHOp::OpHomardAdapt, adaptTb );
4713 int measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ) ;
4714 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4716 int dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4717 createTool( SMESHOp::OpUpdate, dispModeTb );
4719 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4720 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4724 OB = "'ObjectBrowser'",
4725 View = "'" + SVTK_Viewer::Type() + "'",
4727 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4728 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4729 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4730 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4731 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4732 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4733 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4734 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4735 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4736 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4737 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4738 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4740 mesh_part = mesh + " " + subMesh + " " + group,
4741 mesh_group = mesh + " " + group,
4742 mesh_submesh = mesh + " " + subMesh,
4743 hyp_alg = hypo + " " + algo;
4745 // popup for object browser
4747 isInvisible("not( isVisible )"),
4748 isEmpty("numberOfNodes = 0"),
4749 isNotEmpty("numberOfNodes <> 0"),
4751 // has nodes, edges, etc in VISIBLE! actor
4752 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4753 hasElems("(count( elemTypes ) > 0)"),
4754 hasDifferentElems("(count( elemTypes ) > 1)"),
4755 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4756 hasBalls("({'BallElem'} in elemTypes)"),
4757 hasElems0d("({'Elem0d'} in elemTypes)"),
4758 hasEdges("({'Edge'} in elemTypes)"),
4759 hasFaces("({'Face'} in elemTypes)"),
4760 hasVolumes("({'Volume'} in elemTypes)"),
4761 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4763 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4764 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4765 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && hasAlgo && hasGeomReference" );
4766 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4767 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4768 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4770 popupMgr()->insert( separator(), -1, 0 );
4771 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4772 createPopupItem( SMESHOp::OpRecompute, OB, mesh, "&& selcount=1 && hasAlgo && (" + isNotEmpty + " || hasErrors )");
4773 createPopupItem( SMESHOp::OpShowErrors, OB, mesh, "&& selcount=1 && hasErrors" );
4774 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && hasAlgo && isComputable" );
4775 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && hasAlgo && isPreComputable" );
4776 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4777 popupMgr()->insert( separator(), -1, 0 );
4778 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4779 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4780 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1 && " + hasElems );
4781 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4782 popupMgr()->insert( separator(), -1, 0 );
4783 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4784 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4785 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4786 popupMgr()->insert( separator(), -1, 0 );
4787 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4788 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4789 popupMgr()->insert( separator(), -1, 0 );
4790 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems );
4791 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4793 // Adaptation - begin
4794 popupMgr()->insert( separator(), -1, 0 );
4795 #ifndef DISABLE_MG_ADAPT
4796 createPopupItem( SMESHOp::OpMGAdapt, OB, mesh );
4798 #ifndef DISABLE_HOMARD_ADAPT
4799 createPopupItem( SMESHOp::OpHomardAdapt, OB, mesh );
4801 popupMgr()->insert( separator(), -1, 0 );
4804 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4805 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4806 QString only_one_2D = only_one_non_empty + " && dim>1";
4808 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4809 popupMgr()->findMenu( anId )->menuAction()->setIcon( resourceMgr()->loadPixmap( "SMESH", tr( "ICON_EXPORT" )));
4810 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4811 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4812 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4814 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4816 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4817 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4819 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4820 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4821 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4822 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4824 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4826 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4827 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4828 popupMgr()->insert( separator(), -1, 0 );
4830 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4831 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4832 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4835 createPopupItem( SMESHOp::OpEditGroup, View, group );
4836 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4837 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4839 popupMgr()->insert( separator(), -1, 0 );
4840 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4841 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4842 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh, "&& " + hasElems);
4843 popupMgr()->insert( separator(), -1, 0 );
4845 createPopupItem( SMESHOp::OpUpdate, OB + " " + View, mesh_part );
4846 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4847 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4848 popupMgr()->insert( separator(), -1, 0 );
4850 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4851 QString aType = QString( "%1type in {%2}" ).arg( lc );
4852 aType = aType.arg( mesh_part );
4853 QString aMeshInVTK = aClient + "&&" + aType;
4855 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4856 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4857 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4859 //-------------------------------------------------
4861 //-------------------------------------------------
4862 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4864 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4865 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4866 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4868 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4869 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4870 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4872 popupMgr()->insert( separator(), -1, -1 );
4874 //-------------------------------------------------
4876 //-------------------------------------------------
4877 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4879 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4880 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4881 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4883 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4884 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4885 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4887 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4888 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4889 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4891 popupMgr()->insert( separator(), anId, -1 );
4893 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4894 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4895 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4897 //-------------------------------------------------
4899 //-------------------------------------------------
4900 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4902 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4904 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4905 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4906 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4908 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4909 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4910 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4912 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4913 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4914 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4916 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4917 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4918 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4920 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4921 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4922 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4924 popupMgr()->insert( separator(), anId, -1 );
4926 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4927 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
4929 popupMgr()->insert( separator(), anId, -1 );
4931 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4932 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4935 //-------------------------------------------------
4936 // Representation of the 2D Quadratic elements
4937 //-------------------------------------------------
4938 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4939 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4940 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4941 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4943 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4944 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4945 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4947 //-------------------------------------------------
4948 // Orientation of faces
4949 //-------------------------------------------------
4950 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4951 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4952 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4954 //-------------------------------------------------
4956 //-------------------------------------------------
4957 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4958 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4960 //-------------------------------------------------
4962 //-------------------------------------------------
4963 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4964 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4966 //-------------------------------------------------
4968 //-------------------------------------------------
4970 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4971 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4972 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4973 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4975 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4977 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
4978 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4980 popupMgr()->insert( separator(), anId, -1 );
4982 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4984 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
4985 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4986 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4988 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
4989 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4990 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4992 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
4993 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4994 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
4996 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4998 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
4999 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
5000 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
5002 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
5003 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5004 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
5006 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
5007 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5008 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
5009 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
5010 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5011 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
5013 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
5015 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
5016 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5017 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
5019 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
5020 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
5021 QtxPopupMgr::VisibleRule );
5022 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
5024 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
5025 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5026 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
5028 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
5029 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5030 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
5032 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
5033 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5034 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
5036 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
5037 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5038 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
5040 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
5041 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5042 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
5044 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
5045 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5046 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
5048 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
5049 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5050 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
5052 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
5053 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5054 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
5056 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
5057 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5058 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
5060 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
5061 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5062 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
5064 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
5065 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5066 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
5068 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
5069 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5070 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
5072 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
5073 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
5074 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
5076 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
5078 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
5079 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5080 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
5082 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
5083 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5084 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
5086 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
5087 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5088 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
5090 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
5091 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5092 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
5094 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
5095 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5096 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
5098 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
5099 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5100 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
5102 popupMgr()->insert( separator(), anId, -1 );
5104 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
5105 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5106 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
5107 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
5108 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5110 popupMgr()->insert( separator(), anId, -1 );
5112 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
5114 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
5115 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5117 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
5118 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5119 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
5121 #ifndef DISABLE_PLOT2DVIEWER
5122 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
5123 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5126 //-------------------------------------------------
5128 //-------------------------------------------------
5129 popupMgr()->insert( separator(), -1, -1 );
5130 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
5131 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
5132 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
5133 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
5135 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
5136 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
5138 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
5139 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
5141 popupMgr()->insert( separator(), -1, -1 );
5143 //-------------------------------------------------
5145 //-------------------------------------------------
5146 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
5147 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
5149 popupMgr()->insert( separator(), -1, -1 );
5151 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
5152 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
5153 popupMgr()->insert( separator(), -1, -1 );
5155 popupMgr()->insert( action( SMESHOp::OpBreakLink), -1, -1 );
5156 popupMgr()->setRule( action( SMESHOp::OpBreakLink), "$component={'SHAPERSTUDY'} and client='ObjectBrowser' and canBreakLink", QtxPopupMgr::VisibleRule );
5158 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
5159 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
5161 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
5162 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
5165 //================================================================================
5167 * \brief Return true if SMESH or GEOM objects are selected.
5168 * Is called form LightApp_Module::activateModule() which clear selection if
5169 * not isSelectionCompatible()
5171 //================================================================================
5173 bool SMESHGUI::isSelectionCompatible()
5175 bool isCompatible = true;
5176 SALOME_ListIO selected;
5177 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
5178 Sel->selectedObjects( selected );
5180 SALOME_ListIteratorOfListIO It( selected );
5181 for ( ; isCompatible && It.More(); It.Next())
5183 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
5184 ( strcmp("SHAPERSTUDY", It.Value()->getComponentDataType()) == 0 ) ||
5185 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
5187 return isCompatible;
5191 bool SMESHGUI::reusableOperation( const int id )
5193 // compute, evaluate and precompute are not reusable operations
5194 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate || id == SMESHOp::OpRecompute ) ? false : SalomeApp_Module::reusableOperation( id );
5199 QString wrap(const QString& text, const QString& tag)
5200 { return QString("<%1>%2</%3>").arg(tag).arg(text).arg(tag);}
5203 bool SMESHGUI::activateModule( SUIT_Study* study )
5205 bool res = SalomeApp_Module::activateModule( study );
5207 setMenuShown( true );
5208 setToolShown( true );
5210 // Fill in Help Panel
5211 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
5212 app->infoPanel()->setTitle(tr("INFO_WELCOME_TO_SMESH"));
5214 int gb = app->infoPanel()->addGroup(tr("INFO_GRP_CREATE_MESH"));
5217 lab = tr("INFO_DEFINE_ALGOS") + "<br/>";
5218 lab = lab + tr("INFO_DEFINE_HYPOS") + "<br/>";
5219 lab = lab + tr("INFO_COMPUTE") + "<br/>";
5220 lab = lab + tr("INFO_REFINE") + ":";
5221 items << wrap(tr("INFO_REFINE_LOCAL_SIZE"), "li")
5222 << wrap(tr("INFO_REFINE_SUBMESH"), "li");
5223 lab = lab + wrap(items.join(""), "ul");
5226 app->infoPanel()->addLabel(lab, gb);
5228 gb = app->infoPanel()->addGroup(tr("INFO_GRP_IMPORT_MESH"));
5229 items << wrap("UNV", "li")
5230 << wrap("MED", "li")
5231 << wrap("STL", "li")
5232 << wrap("CGNS", "li")
5233 << wrap("GMF", "li");
5234 lab = tr("INFO_AVAILABLE_FORMATS") + ":" + wrap(items.join(""), "ul");
5237 app->infoPanel()->addLabel(lab, gb);
5239 gb = app->infoPanel()->addGroup(tr("INFO_GRP_CHECK_MESH"));
5240 lab = tr("INFO_DISPLAY") + "<br/>";
5241 items << wrap(tr("INFO_QUALITY_AREA"), "li")
5242 << wrap(tr("INFO_QUALITY_VOLUME"), "li")
5243 << wrap(tr("INFO_QUALITY_ASPECT_RATION"), "li")
5244 << wrap("...", "li");
5245 lab = lab + tr("INFO_QUALITY_INFO") + ":" + wrap(items.join(""), "ul");
5247 lab = lab + tr("INFO_CLIPPING");
5249 app->infoPanel()->addLabel(lab, gb);
5252 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
5253 PyGILState_STATE gstate = PyGILState_Ensure();
5254 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
5255 if ( !pluginsmanager ) {
5259 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
5264 PyGILState_Release(gstate);
5265 // end of SMESH plugins loading
5267 // Reset actions accelerator keys
5268 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
5270 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
5271 GetSMESHGen()->UpdateStudy();
5273 // get all view currently opened in the study and connect their signals to
5274 // the corresponding slots of the class.
5275 SUIT_Desktop* aDesk = study->application()->desktop();
5277 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
5278 SUIT_ViewWindow* wnd;
5279 foreach ( wnd, wndList )
5283 // remove actors whose objects are removed in GetSMESHGen()->UpdateStudy()
5284 SMESH::UpdateActorsAfterUpdateStudy(wnd);
5290 Py_XDECREF(pluginsmanager);
5294 bool SMESHGUI::deactivateModule( SUIT_Study* study )
5296 setMenuShown( false );
5297 setToolShown( false );
5299 EmitSignalCloseAllDialogs();
5301 // Unset actions accelerator keys
5302 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
5304 return SalomeApp_Module::deactivateModule( study );
5307 void SMESHGUI::studyClosed( SUIT_Study* s )
5311 SMESH::RemoveVisuData();
5312 SalomeApp_Module::studyClosed( s );
5315 void SMESHGUI::OnGUIEvent()
5317 const QObject* obj = sender();
5318 if ( !obj || !obj->inherits( "QAction" ) )
5320 int id = actionId((QAction*)obj);
5325 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
5327 if ( CORBA::is_nil( myComponentSMESH ) )
5329 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
5330 return aGUI.myComponentSMESH;
5332 return myComponentSMESH;
5335 QString SMESHGUI::engineIOR() const
5337 CORBA::ORB_var anORB = getApp()->orb();
5338 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
5339 return QString( anIOR.in() );
5342 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
5344 SalomeApp_Module::contextMenuPopup( client, menu, title );
5346 selectionMgr()->selectedObjects( lst );
5347 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
5348 Handle(SALOME_InteractiveObject) io = lst.First();
5349 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
5350 _PTR(Study) study = appStudy->studyDS();
5351 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
5353 QString aName = SMESH::fromUtf8( obj->GetName());
5354 while ( !aName.isEmpty() && aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
5355 aName.remove(( aName.length() - 1 ), 1 );
5361 LightApp_Selection* SMESHGUI::createSelection() const
5363 return new SMESHGUI_Selection();
5366 void SMESHGUI::windows( QMap<int, int>& aMap ) const
5368 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
5369 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
5370 aMap.insert( SalomeApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea);
5371 #ifndef DISABLE_PYCONSOLE
5372 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
5376 void SMESHGUI::viewManagers( QStringList& list ) const
5378 list.append( SVTK_Viewer::Type() );
5381 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
5383 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
5384 SMESH::UpdateSelectionProp( this );
5386 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
5387 for(int i = 0; i < aViews.count() ; i++){
5388 SUIT_ViewWindow *sf = aViews[i];
5391 EmitSignalActivatedViewManager();
5395 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
5397 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
5398 myClippingPlaneInfoMap.erase( theViewManager );
5401 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
5403 theActor->AddObserver( SMESH::DeleteActorEvent,
5404 myEventCallbackCommand.GetPointer(),
5408 void SMESHGUI::ProcessEvents( vtkObject* theObject,
5409 unsigned long theEvent,
5410 void* theClientData,
5411 void* /*theCallData*/ )
5413 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
5414 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
5415 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
5416 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5417 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5418 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5419 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5420 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5421 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5422 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5423 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5424 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5425 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5426 if( anActor == *anIter3 ) {
5427 anActorList.erase( anIter3 );
5438 void SMESHGUI::createPreferences()
5440 // General tab ------------------------------------------------------------------------
5441 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5443 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5444 setPreferenceProperty( autoUpdate, "columns", 2 );
5445 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5446 setPreferenceProperty( lim, "min", 0 );
5447 setPreferenceProperty( lim, "max", 100000000 );
5448 setPreferenceProperty( lim, "step", 1000 );
5449 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5450 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5452 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5453 setPreferenceProperty( dispgroup, "columns", 2 );
5455 addPreference( tr( "PREF_FITALL_ON_DISPLAYONLY" ), dispgroup, LightApp_Preferences::Bool, "SMESH", "fitall_on_displayonly" );
5457 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5459 modes.append( tr("MEN_WIRE") );
5460 modes.append( tr("MEN_SHADE") );
5461 modes.append( tr("MEN_NODES") );
5462 modes.append( tr("MEN_SHRINK") );
5463 QList<QVariant> indices;
5464 indices.append( 0 );
5465 indices.append( 1 );
5466 indices.append( 2 );
5467 indices.append( 3 );
5468 setPreferenceProperty( dispmode, "strings", modes );
5469 setPreferenceProperty( dispmode, "indexes", indices );
5471 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5472 setPreferenceProperty( arcgroup, "columns", 2 );
5473 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5474 QStringList quadraticModes;
5475 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5476 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5478 indices.append( 0 );
5479 indices.append( 1 );
5480 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5481 setPreferenceProperty( quadraticmode, "indexes", indices );
5483 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5484 "SMESH", "max_angle" );
5485 setPreferenceProperty( maxAngle, "min", 1 );
5486 setPreferenceProperty( maxAngle, "max", 90 );
5488 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5489 setPreferenceProperty( qaGroup, "columns", 2 );
5490 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5491 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5492 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5493 setPreferenceProperty( prec, "min", 0 );
5494 setPreferenceProperty( prec, "max", 100 );
5495 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5496 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5497 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5498 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5499 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5502 int cinc = addPreference(tr("PREF_CONTROLS_INCREMENT"), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_increment");
5503 setPreferenceProperty( cinc, "min", 0 );
5504 setPreferenceProperty( cinc, "max", 5 );
5507 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5508 setPreferenceProperty( exportgroup, "columns", 2 );
5509 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5510 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5511 addPreference( tr( "PREF_MED_SAVE_NUMS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "med_save_numbers" );
5512 int zTol = addPreference( tr( "PREF_ZTOLERANCE" ), exportgroup, LightApp_Preferences::DblSpin, "SMESH", "med_ztolerance" );
5513 setPreferenceProperty( zTol, "precision", 10 );
5514 setPreferenceProperty( zTol, "min", 0.0000000001 );
5515 setPreferenceProperty( zTol, "max", 1000000.0 );
5516 setPreferenceProperty( zTol, "step", 1. );
5517 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5519 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5520 setPreferenceProperty( computeGroup, "columns", 2 );
5521 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5523 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5524 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5525 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5527 indices.append( 0 );
5528 indices.append( 1 );
5529 indices.append( 2 );
5530 setPreferenceProperty( notifyMode, "strings", modes );
5531 setPreferenceProperty( notifyMode, "indexes", indices );
5533 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5534 setPreferenceProperty( infoGroup, "columns", 2 );
5535 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5537 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5538 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5540 indices.append( 0 );
5541 indices.append( 1 );
5542 setPreferenceProperty( elemInfo, "strings", modes );
5543 setPreferenceProperty( elemInfo, "indexes", indices );
5544 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5545 setPreferenceProperty( nodesLim, "min", 0 );
5546 setPreferenceProperty( nodesLim, "max", 10000000 );
5547 setPreferenceProperty( nodesLim, "step", 10000 );
5548 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5549 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5550 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5551 setPreferenceProperty( ctrlLim, "min", 0 );
5552 setPreferenceProperty( ctrlLim, "max", 10000000 );
5553 setPreferenceProperty( ctrlLim, "step", 1000 );
5554 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5555 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5556 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5557 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5558 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5560 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5561 setPreferenceProperty( segGroup, "columns", 2 );
5562 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5563 "SMESH", "segmentation" );
5564 setPreferenceProperty( segLen, "min", 1 );
5565 setPreferenceProperty( segLen, "max", 10000000 );
5566 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5567 "SMESH", "nb_segments_per_edge" );
5568 setPreferenceProperty( nbSeg, "min", 1 );
5569 setPreferenceProperty( nbSeg, "max", 10000000 );
5570 addPreference( tr( "PREF_USE_MESHGEMS_HYPOSET" ), segGroup, LightApp_Preferences::Bool, "SMESH", "use-meshgems-hypo-sets" );
5572 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5573 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5574 "SMESH", "forget_mesh_on_hyp_modif" );
5577 // Quantities with individual precision settings
5578 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5579 setPreferenceProperty( precGroup, "columns", 2 );
5581 const int nbQuantities = 6;
5582 int precs[nbQuantities], ii = 0;
5583 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5584 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5585 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5586 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5587 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5588 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5589 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5590 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5591 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5592 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5593 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5594 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5596 // Set property for precision value for spinboxes
5597 for ( ii = 0; ii < nbQuantities; ii++ ){
5598 setPreferenceProperty( precs[ii], "min", -14 );
5599 setPreferenceProperty( precs[ii], "max", 14 );
5600 setPreferenceProperty( precs[ii], "precision", 2 );
5603 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5604 setPreferenceProperty( previewGroup, "columns", 2 );
5605 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5606 setPreferenceProperty( chunkSize, "min", 1 );
5607 setPreferenceProperty( chunkSize, "max", 1000 );
5608 setPreferenceProperty( chunkSize, "step", 50 );
5610 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5611 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5613 // Mesh tab ------------------------------------------------------------------------
5614 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5615 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5616 setPreferenceProperty( nodeGroup, "columns", 3 );
5618 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5620 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5622 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5623 QList<QVariant> aMarkerTypeIndicesList;
5624 QList<QVariant> aMarkerTypeIconsList;
5625 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5626 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5627 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5628 aMarkerTypeIndicesList << i;
5629 aMarkerTypeIconsList << pixmap;
5631 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5632 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5634 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5636 QList<QVariant> aMarkerScaleIndicesList;
5637 QStringList aMarkerScaleValuesList;
5638 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5639 aMarkerScaleIndicesList << i;
5640 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5641 aMarkerScaleValuesList << QString::number( i );
5643 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5644 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5646 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5647 //setPreferenceProperty( elemGroup, "columns", 2 );
5649 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5650 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5651 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5652 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5653 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5654 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5655 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5656 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5657 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5660 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5661 setPreferenceProperty( grpGroup, "columns", 2 );
5663 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5664 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5666 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5667 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5668 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5669 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5670 int ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5671 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5672 int ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5673 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5674 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5675 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5676 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5677 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5678 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5679 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5681 setPreferenceProperty( size0d, "min", 1 );
5682 setPreferenceProperty( size0d, "max", 10 );
5684 // setPreferenceProperty( ballSize, "min", 1 );
5685 // setPreferenceProperty( ballSize, "max", 10 );
5687 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5688 setPreferenceProperty( ballDiameter, "max", 1e9 );
5689 setPreferenceProperty( ballDiameter, "step", 0.1 );
5691 setPreferenceProperty( ballScale, "min", 1e-2 );
5692 setPreferenceProperty( ballScale, "max", 1e7 );
5693 setPreferenceProperty( ballScale, "step", 0.5 );
5695 setPreferenceProperty( elemW, "min", 1 );
5696 setPreferenceProperty( elemW, "max", 5 );
5698 setPreferenceProperty( outW, "min", 1 );
5699 setPreferenceProperty( outW, "max", 5 );
5701 setPreferenceProperty( shrink, "min", 0 );
5702 setPreferenceProperty( shrink, "max", 100 );
5704 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5705 setPreferenceProperty( numGroup, "columns", 2 );
5707 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5708 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5710 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5711 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5713 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5714 setPreferenceProperty( orientGroup, "columns", 1 );
5716 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5717 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5719 setPreferenceProperty( orientScale, "min", 0.05 );
5720 setPreferenceProperty( orientScale, "max", 0.5 );
5721 setPreferenceProperty( orientScale, "step", 0.05 );
5723 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5725 // Selection tab ------------------------------------------------------------------------
5726 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5728 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5729 setPreferenceProperty( selGroup, "columns", 2 );
5731 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5732 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5734 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5735 setPreferenceProperty( preGroup, "columns", 2 );
5737 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5739 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5740 setPreferenceProperty( precSelGroup, "columns", 2 );
5742 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5743 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5744 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5746 int sinc = addPreference(tr("PREF_SELECTION_INCREMENT"), selTab, LightApp_Preferences::IntSpin, "SMESH", "selection_increment");
5747 setPreferenceProperty( sinc, "min", 0 );
5748 setPreferenceProperty( sinc, "max", 5 );
5750 // Scalar Bar tab ------------------------------------------------------------------------
5751 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5752 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5753 setPreferenceProperty( fontGr, "columns", 2 );
5755 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5756 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5758 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5759 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5761 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5762 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5764 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5765 setPreferenceProperty( numcol, "min", 2 );
5766 setPreferenceProperty( numcol, "max", 256 );
5768 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5769 setPreferenceProperty( numlab, "min", 2 );
5770 setPreferenceProperty( numlab, "max", 65 );
5772 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5773 setPreferenceProperty( orientGr, "columns", 2 );
5774 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5775 QStringList orients;
5776 orients.append( tr( "SMESH_VERTICAL" ) );
5777 orients.append( tr( "SMESH_HORIZONTAL" ) );
5778 indices.clear(); indices.append( 0 ); indices.append( 1 );
5779 setPreferenceProperty( orient, "strings", orients );
5780 setPreferenceProperty( orient, "indexes", indices );
5782 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5783 setPreferenceProperty( posVSizeGr, "columns", 2 );
5784 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5785 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5786 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5787 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5788 setPreferenceProperty( xv, "step", 0.1 );
5789 setPreferenceProperty( xv, "min", 0.0 );
5790 setPreferenceProperty( xv, "max", 1.0 );
5791 setPreferenceProperty( yv, "step", 0.1 );
5792 setPreferenceProperty( yv, "min", 0.0 );
5793 setPreferenceProperty( yv, "max", 1.0 );
5794 setPreferenceProperty( wv, "step", 0.1 );
5795 setPreferenceProperty( wv, "min", 0.0 );
5796 setPreferenceProperty( wv, "max", 1.0 );
5797 setPreferenceProperty( hv, "min", 0.0 );
5798 setPreferenceProperty( hv, "max", 1.0 );
5799 setPreferenceProperty( hv, "step", 0.1 );
5801 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5802 setPreferenceProperty( posHSizeGr, "columns", 2 );
5803 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5804 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5805 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5806 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5807 setPreferenceProperty( xv, "min", 0.0 );
5808 setPreferenceProperty( xv, "max", 1.0 );
5809 setPreferenceProperty( xv, "step", 0.1 );
5810 setPreferenceProperty( xh, "min", 0.0 );
5811 setPreferenceProperty( xh, "max", 1.0 );
5812 setPreferenceProperty( xh, "step", 0.1 );
5813 setPreferenceProperty( yh, "min", 0.0 );
5814 setPreferenceProperty( yh, "max", 1.0 );
5815 setPreferenceProperty( yh, "step", 0.1 );
5816 setPreferenceProperty( wh, "min", 0.0 );
5817 setPreferenceProperty( wh, "max", 1.0 );
5818 setPreferenceProperty( wh, "step", 0.1 );
5819 setPreferenceProperty( hh, "min", 0.0 );
5820 setPreferenceProperty( hh, "max", 1.0 );
5821 setPreferenceProperty( hh, "step", 0.1 );
5823 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5824 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5825 setPreferenceProperty( distributionGr, "columns", 3 );
5827 types.append( tr( "SMESH_MONOCOLOR" ) );
5828 types.append( tr( "SMESH_MULTICOLOR" ) );
5829 indices.clear(); indices.append( 0 ); indices.append( 1 );
5830 setPreferenceProperty( coloringType, "strings", types );
5831 setPreferenceProperty( coloringType, "indexes", indices );
5832 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5834 // Adaptation - begin
5835 #ifndef DISABLE_MG_ADAPT
5836 // Adaptation tab ------------------------------------------------------------------------
5837 int adaptTab = addPreference( tr( "ADAPT_PREF_TAB_GENERAL" ) );
5840 bloc = addPreference( tr( "ADAPT_PREF_MG_ADAPT" ), adaptTab );
5841 setPreferenceProperty( bloc, "columns", 1 );
5842 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_file_mesh_out" );
5843 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_publish_mesh_out" );
5844 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_size_map" );
5845 QStringList aListOfSizeMap;
5846 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL" );
5847 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND" );
5848 aListOfSizeMap << tr( "ADAPT_PREF_NONE" );;
5849 setPreferenceProperty( pref, "strings", aListOfSizeMap );
5850 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_time_step" );
5851 QStringList aListOfTimeStep;
5852 aListOfTimeStep << tr( "ADAPT_PREF_NONE" );
5853 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST" );
5854 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_C" );;
5855 setPreferenceProperty( pref, "strings", aListOfTimeStep );
5860 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5862 if ( sect=="SMESH" ) {
5863 double sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5864 double aTol = 1.00000009999999;
5865 std::string aWarning;
5866 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5868 if ( name == "selection_object_color" ||
5869 name == "selection_element_color" ||
5870 name == "highlight_color" ||
5871 name == "selection_precision_node" ||
5872 name == "selection_precision_element" ||
5873 name == "selection_precision_object" ||
5874 name == "selection_increment")
5876 SMESH::UpdateSelectionProp( this );
5878 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5880 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5881 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5882 if ( sbX1+sbW > aTol ) {
5883 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5886 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5887 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5890 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5892 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5893 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5894 if ( sbY1 + sbH > aTol ) {
5895 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5896 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5897 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5900 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5902 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5903 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5904 if ( sbX1 + sbW > aTol ) {
5905 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5908 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5909 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5912 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5914 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5915 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5916 if ( sbY1 + sbH > aTol ) {
5917 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5920 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5921 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5924 else if ( name == "segmentation" )
5926 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5927 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5929 else if ( name == "nb_segments_per_edge" )
5931 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5932 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5934 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5936 QString val = aResourceMgr->stringValue( "SMESH", name );
5937 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5939 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5941 SMESH::UpdateFontProp( this );
5943 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5945 SMESH::UpdateFontProp( this );
5948 if ( aWarning.size() != 0 ) {
5949 aWarning += "The default values are applied instead.";
5950 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5951 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5952 QObject::tr(aWarning.c_str()));
5957 //================================================================================
5959 * \brief Update something in accordance with update flags
5960 * \param theFlags - update flags
5962 * Update viewer or/and object browser etc. in accordance with update flags ( see
5963 * LightApp_UpdateFlags enumeration ).
5965 //================================================================================
5966 void SMESHGUI::update( const int flags )
5968 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5969 SMESH::UpdateView();
5971 SalomeApp_Module::update( flags );
5974 //================================================================================
5976 * \brief Set default selection mode
5978 * SLOT called when operation committed. Sets default selection mode
5980 //================================================================================
5981 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5983 SVTK_ViewWindow* vtkWnd =
5984 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5986 vtkWnd->SetSelectionMode( ActorSelection );
5989 //================================================================================
5991 * \brief Set default selection mode
5993 * SLOT called when operation aborted. Sets default selection mode
5995 //================================================================================
5996 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5998 SVTK_ViewWindow* vtkWnd =
5999 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
6001 vtkWnd->SetSelectionMode( ActorSelection );
6004 //================================================================================
6006 * \brief Creates operation with given identifier
6007 * \param id - identifier of operation to be started
6008 * \return Pointer on created operation or NULL if operation is not created
6010 * Virtual method redefined from the base class creates operation with given id.
6011 * It is called called automatically from startOperation method of base class.
6013 //================================================================================
6014 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
6016 LightApp_Operation* op = 0;
6017 // to do : create operation here
6020 case SMESHOp::OpSplitBiQuadratic:
6021 op = new SMESHGUI_SplitBiQuadOp();
6023 case SMESHOp::OpConvertMeshToQuadratic:
6024 op = new SMESHGUI_ConvToQuadOp();
6026 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
6027 op = new SMESHGUI_Make2DFrom3DOp();
6029 case SMESHOp::OpReorientFaces:
6030 op = new SMESHGUI_ReorientFacesOp();
6032 case SMESHOp::OpCreateMesh:
6033 op = new SMESHGUI_MeshOp( true, true );
6035 case SMESHOp::OpCreateSubMesh:
6036 op = new SMESHGUI_MeshOp( true, false );
6038 case SMESHOp::OpEditMeshOrSubMesh:
6039 case SMESHOp::OpEditMesh:
6040 case SMESHOp::OpEditSubMesh:
6041 op = new SMESHGUI_MeshOp( false );
6043 case SMESHOp::OpCompute:
6044 case SMESHOp::OpComputeSubMesh:
6045 op = new SMESHGUI_ComputeOp();
6047 case SMESHOp::OpShowErrors:
6048 op = new SMESHGUI_ShowErrorsOp();
6050 case SMESHOp::OpPreCompute:
6051 op = new SMESHGUI_PrecomputeOp();
6053 case SMESHOp::OpEvaluate:
6054 op = new SMESHGUI_EvaluateOp();
6056 case SMESHOp::OpMeshOrder:
6057 op = new SMESHGUI_MeshOrderOp();
6059 case SMESHOp::OpCreateGeometryGroup:
6060 op = new SMESHGUI_GroupOnShapeOp();
6062 case SMESHOp::OpFindElementByPoint:
6063 op = new SMESHGUI_FindElemByPointOp();
6065 case SMESHOp::OpMoveNode: // Make mesh pass through point
6066 op = new SMESHGUI_MakeNodeAtPointOp();
6068 case SMESHOp::OpMoveNodeInteractive: // Make mesh pass through point / by mouse
6069 op = new SMESHGUI_MakeNodeAtPointOp( 2 );
6071 case SMESHOp::OpRemoveNodeWithReconn:
6072 op = new SMESHGUI_RemoveNodeReconnectionOp();
6074 case SMESHOp::OpSplitEdgeInteract:
6075 op = new SMESHGUI_AddNodeOnSegmentOp();
6077 case SMESHOp::OpSplitFaceInteract:
6078 op = new SMESHGUI_AddNodeOnFaceOp();
6080 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
6081 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
6088 op = SalomeApp_Module::createOperation( id );
6092 //================================================================================
6094 * \brief Stops current operations and starts a given one
6095 * \param id - The id of the operation to start
6097 //================================================================================
6099 void SMESHGUI::switchToOperation(int id)
6101 activeStudy()->abortAllOperations();
6102 startOperation( id );
6105 LightApp_Displayer* SMESHGUI::displayer()
6108 myDisplayer = new SMESHGUI_Displayer( getApp() );
6112 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
6115 int aTolerance = 64;
6116 int anIterations = 0;
6122 if( anIterations % aPeriod == 0 )
6125 if( aTolerance < 1 )
6129 aHue = (int)( 360.0 * rand() / RAND_MAX );
6132 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
6133 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
6134 for( ; it != itEnd; ++it )
6136 SALOMEDS::Color anAutoColor = *it;
6137 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
6140 aQColor.getHsv( &h, &s, &v );
6141 if( abs( h - aHue ) < aTolerance )
6153 aColor.setHsv( aHue, 255, 255 );
6155 SALOMEDS::Color aSColor;
6156 aSColor.R = aColor.redF();
6157 aSColor.G = aColor.greenF();
6158 aSColor.B = aColor.blueF();
6163 const char* gSeparator = "_"; // character used to separate parameter names
6164 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
6165 const char* gPathSep = "|"; // character used to separate paths
6168 * \brief Store visual parameters
6170 * This method is called just before the study document is saved.
6171 * Store visual parameters in AttributeParameter attribute(s)
6173 void SMESHGUI::storeVisualParameters (int savePoint)
6176 Kernel_Utils::Localizer loc;
6178 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6179 if (!appStudy || !appStudy->studyDS())
6181 _PTR(Study) studyDS = appStudy->studyDS();
6183 // componentName is used for encoding of entries when storing them in IParameters
6184 std::string componentName = myComponentSMESH->ComponentDataType();
6185 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
6186 //if (!aSComponent) return;
6189 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6190 componentName.c_str(),
6192 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6194 // store custom markers
6195 if( !myMarkerMap.empty() )
6197 VTK::MarkerMap::const_iterator anIter = myMarkerMap.begin();
6198 for( ; anIter != myMarkerMap.end(); anIter++ )
6200 int anId = anIter->first;
6201 VTK::MarkerData aMarkerData = anIter->second;
6202 std::string aMarkerFileName = aMarkerData.first;
6203 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
6204 if( aMarkerTexture.size() < 3 )
6205 continue; // should contain at least width, height and the first value
6207 QString aPropertyName( "texture" );
6208 aPropertyName += gSeparator;
6209 aPropertyName += QString::number( anId );
6211 QString aPropertyValue = aMarkerFileName.c_str();
6212 aPropertyValue += gPathSep;
6214 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
6215 ushort aWidth = *aTextureIter++;
6216 ushort aHeight = *aTextureIter++;
6217 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
6218 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
6219 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
6220 aPropertyValue += QString::number( *aTextureIter );
6222 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6226 // viewers counters are used for storing view_numbers in IParameters
6229 // main cycle to store parameters of displayed objects
6230 QList<SUIT_ViewManager*> lst;
6231 QList<SUIT_ViewManager*>::Iterator it;
6232 getApp()->viewManagers(lst);
6233 for (it = lst.begin(); it != lst.end(); it++)
6235 SUIT_ViewManager* vman = *it;
6236 QString vType = vman->getType();
6238 // saving VTK actors properties
6239 if (vType == SVTK_Viewer::Type())
6241 // store the clipping planes attached to the view manager
6242 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
6243 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
6244 if( anIter != myClippingPlaneInfoMap.end() )
6245 aClippingPlaneInfoList = anIter->second;
6247 if( !aClippingPlaneInfoList.empty() ) {
6248 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
6249 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
6251 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
6252 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
6254 QString aPropertyName( "ClippingPlane" );
6255 aPropertyName += gSeparator;
6256 aPropertyName += QString::number( vtkViewers );
6257 aPropertyName += gSeparator;
6258 aPropertyName += QString::number( anId );
6260 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
6261 aPropertyValue += gDigitsSep;
6262 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
6263 aPropertyValue += gDigitsSep;
6264 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6265 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
6266 aPropertyValue += gDigitsSep;
6267 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
6268 aPropertyValue += gDigitsSep;
6269 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
6270 aPropertyValue += gDigitsSep;
6271 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
6272 aPropertyValue += gDigitsSep;
6273 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
6274 aPropertyValue += gDigitsSep;
6275 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
6276 aPropertyValue += gDigitsSep;
6277 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
6279 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6280 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
6281 aPropertyValue += gDigitsSep;
6282 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
6283 aPropertyValue += gDigitsSep;
6284 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
6285 aPropertyValue += gDigitsSep;
6286 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
6289 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6293 QVector<SUIT_ViewWindow*> views = vman->getViews();
6294 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
6296 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
6298 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
6299 vtkActorCollection* allActors = aCopy.GetActors();
6300 allActors->InitTraversal();
6301 while (vtkActor* actor = allActors->GetNextActor())
6303 if (actor->GetVisibility()) // store only visible actors
6305 SMESH_Actor* aSmeshActor = 0;
6306 if (actor->IsA("SMESH_Actor"))
6307 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
6308 if (aSmeshActor && aSmeshActor->hasIO())
6310 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
6313 // entry is "encoded" = it does NOT contain component address,
6314 // since it is a subject to change on next component loading
6315 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
6317 std::string param, vtkParam = vType.toLatin1().data();
6318 vtkParam += gSeparator;
6319 vtkParam += QString::number(vtkViewers).toLatin1().data();
6320 vtkParam += gSeparator;
6323 param = vtkParam + "Visibility";
6324 ip->setParameter(entry, param, "On");
6327 param = vtkParam + "Representation";
6328 ip->setParameter(entry, param, QString::number
6329 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
6332 param = vtkParam + "IsShrunk";
6333 ip->setParameter(entry, param, QString::number
6334 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
6336 // Displayed entities
6337 unsigned int aMode = aSmeshActor->GetEntityMode();
6338 bool isE = aMode & SMESH_Actor::eEdges;
6339 bool isF = aMode & SMESH_Actor::eFaces;
6340 bool isV = aMode & SMESH_Actor::eVolumes;
6341 bool is0d = aMode & SMESH_Actor::e0DElements;
6342 bool isB = aMode & SMESH_Actor::eBallElem;
6344 QString modeStr ("e");
6345 modeStr += gDigitsSep; modeStr += QString::number(isE);
6346 modeStr += gDigitsSep; modeStr += "f";
6347 modeStr += gDigitsSep; modeStr += QString::number(isF);
6348 modeStr += gDigitsSep; modeStr += "v";
6349 modeStr += gDigitsSep; modeStr += QString::number(isV);
6350 modeStr += gDigitsSep; modeStr += "0d";
6351 modeStr += gDigitsSep; modeStr += QString::number(is0d);
6352 modeStr += gDigitsSep; modeStr += "b";
6353 modeStr += gDigitsSep; modeStr += QString::number(isB);
6355 param = vtkParam + "Entities";
6356 ip->setParameter(entry, param, modeStr.toLatin1().data());
6362 aSmeshActor->GetSufaceColor(r, g, b, delta);
6363 QStringList colorStr;
6364 colorStr << "surface";
6365 colorStr << QString::number(r);
6366 colorStr << QString::number(g);
6367 colorStr << QString::number(b);
6369 colorStr << "backsurface";
6370 colorStr << QString::number(delta);
6372 aSmeshActor->GetVolumeColor(r, g, b, delta);
6373 colorStr << "volume";
6374 colorStr << QString::number(r);
6375 colorStr << QString::number(g);
6376 colorStr << QString::number(b);
6377 colorStr << QString::number(delta);
6379 aSmeshActor->GetEdgeColor(r, g, b);
6381 colorStr << QString::number(r);
6382 colorStr << QString::number(g);
6383 colorStr << QString::number(b);
6385 aSmeshActor->GetNodeColor(r, g, b);
6387 colorStr << QString::number(r);
6388 colorStr << QString::number(g);
6389 colorStr << QString::number(b);
6391 aSmeshActor->GetOutlineColor(r, g, b);
6392 colorStr << "outline";
6393 colorStr << QString::number(r);
6394 colorStr << QString::number(g);
6395 colorStr << QString::number(b);
6397 aSmeshActor->Get0DColor(r, g, b);
6398 colorStr << "elem0d";
6399 colorStr << QString::number(r);
6400 colorStr << QString::number(g);
6401 colorStr << QString::number(b);
6403 aSmeshActor->GetBallColor(r, g, b);
6405 colorStr << QString::number(r);
6406 colorStr << QString::number(g);
6407 colorStr << QString::number(b);
6409 aSmeshActor->GetFacesOrientationColor(r, g, b);
6410 colorStr << "orientation";
6411 colorStr << QString::number(r);
6412 colorStr << QString::number(g);
6413 colorStr << QString::number(b);
6415 param = vtkParam + "Colors";
6416 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
6419 QStringList sizeStr;
6421 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
6422 sizeStr << "outline";
6423 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
6424 sizeStr << "elem0d";
6425 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
6427 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
6428 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
6429 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
6430 sizeStr << "shrink";
6431 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
6432 sizeStr << "orientation";
6433 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
6434 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
6436 param = vtkParam + "Sizes";
6437 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
6442 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
6443 if( aMarkerType == VTK::MT_USER ) {
6444 markerStr += "custom";
6445 markerStr += gDigitsSep;
6446 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
6450 markerStr += gDigitsSep;
6451 markerStr += QString::number( (int)aMarkerType );
6452 markerStr += gDigitsSep;
6453 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
6456 param = vtkParam + "PointMarker";
6457 ip->setParameter(entry, param, markerStr.toLatin1().data());
6460 param = vtkParam + "Opacity";
6461 ip->setParameter(entry, param,
6462 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
6465 param = vtkParam + "ClippingPlane";
6467 if( !aClippingPlaneInfoList.empty() ) {
6468 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
6469 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
6471 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
6472 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
6473 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6474 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6475 if( aSmeshActor == *anIter2 ) {
6476 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6477 QString::number( anId ).toLatin1().constData() );
6484 ip->setParameter( entry, param, "Off" );
6485 } // if (io->hasEntry())
6486 } // SMESH_Actor && hasIO
6488 } // while.. actors traversal
6492 } // if (SVTK view model)
6493 } // for (viewManagers)
6496 // data structures for clipping planes processing
6500 bool isOpenGLClipping;
6501 vtkIdType RelativeOrientation;
6504 int AbsoluteOrientation;
6505 double X, Y, Z, Dx, Dy, Dz;
6507 typedef std::list<TPlaneData> TPlaneDataList;
6508 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6510 typedef std::list<vtkActor*> TActorList;
6513 TActorList ActorList;
6514 SUIT_ViewManager* ViewManager;
6516 typedef std::list<TPlaneInfo> TPlaneInfoList;
6517 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6520 * \brief Restore visual parameters
6522 * This method is called after the study document is opened.
6523 * Restore visual parameters from AttributeParameter attribute(s)
6525 void SMESHGUI::restoreVisualParameters (int savePoint)
6528 Kernel_Utils::Localizer loc;
6530 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6531 if (!appStudy || !appStudy->studyDS())
6533 _PTR(Study) studyDS = appStudy->studyDS();
6535 // componentName is used for encoding of entries when storing them in IParameters
6536 std::string componentName = myComponentSMESH->ComponentDataType();
6539 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6540 componentName.c_str(),
6542 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6544 // restore custom markers and map of clipping planes
6545 TPlaneDataMap aPlaneDataMap;
6547 std::vector<std::string> properties = ip->getProperties();
6548 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6550 std::string property = *propIt;
6551 QString aPropertyName( property.c_str() );
6552 QString aPropertyValue( ip->getProperty( property ).c_str() );
6554 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6555 if( aPropertyNameList.isEmpty() )
6558 QString aPropertyType = aPropertyNameList[0];
6559 if( aPropertyType == "texture" )
6561 if( aPropertyNameList.size() != 2 )
6565 int anId = aPropertyNameList[1].toInt( &ok );
6566 if( !ok || anId < 1 )
6569 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6570 if( aPropertyValueList.size() != 2 )
6573 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6574 QString aMarkerTextureString = aPropertyValueList[1];
6575 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6576 if( aMarkerTextureStringList.size() != 3 )
6580 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6585 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6589 VTK::MarkerTexture aMarkerTexture;
6590 aMarkerTexture.push_back( aWidth );
6591 aMarkerTexture.push_back( aHeight );
6593 QString aMarkerTextureData = aMarkerTextureStringList[2];
6594 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6596 QChar aChar = aMarkerTextureData.at( i );
6597 if( aChar.isDigit() )
6598 aMarkerTexture.push_back( aChar.digitValue() );
6601 myMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6603 else if( aPropertyType == "ClippingPlane" )
6605 if( aPropertyNameList.size() != 3 )
6609 int aViewId = aPropertyNameList[1].toInt( &ok );
6610 if( !ok || aViewId < 0 )
6614 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6615 if( !ok || aClippingPlaneId < 0 )
6618 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6619 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6622 TPlaneData aPlaneData;
6623 aPlaneData.AbsoluteOrientation = false;
6624 aPlaneData.RelativeOrientation = 0;
6625 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6626 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6627 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6629 aPlaneData.Id = aClippingPlaneId;
6632 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6637 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6641 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6644 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6649 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6654 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6659 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6664 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6669 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6674 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6678 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6680 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6685 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6690 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6695 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6700 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6701 aPlaneDataList.push_back( aPlaneData );
6705 TPlaneInfoMap aPlaneInfoMap;
6707 std::vector<std::string> entries = ip->getEntries();
6709 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6711 // entry is a normal entry - it should be "decoded" (setting base address of component)
6712 QString entry (ip->decodeEntry(*entIt).c_str());
6714 // Check that the entry corresponds to a real object in the Study
6715 // as the object may be deleted or modified after the visual state is saved.
6716 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
6717 if (!so) continue; //Skip the not existent entry
6719 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6720 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6722 std::vector<std::string>::iterator namesIt = paramNames.begin();
6723 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6725 // actors are stored in a map after displaying of them for
6726 // quicker access in the future: map < viewID to actor >
6727 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6729 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6731 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6732 // '_' is used as separator and should not be used in viewer type or parameter names.
6733 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6734 if (lst.size() != 3)
6737 QString viewerTypStr = lst[0];
6738 QString viewIndexStr = lst[1];
6739 QString paramNameStr = lst[2];
6742 int viewIndex = viewIndexStr.toUInt(&ok);
6743 if (!ok) // bad conversion of view index to integer
6747 if (viewerTypStr == SVTK_Viewer::Type())
6749 SMESH_Actor* aSmeshActor = 0;
6750 if (vtkActors.IsBound(viewIndex))
6751 aSmeshActor = vtkActors.Find(viewIndex);
6753 QList<SUIT_ViewManager*> lst;
6754 getApp()->viewManagers(viewerTypStr, lst);
6756 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6757 SUIT_ViewManager* vman = NULL;
6758 if (viewIndex >= 0 && viewIndex < lst.count())
6759 vman = lst.at(viewIndex);
6761 if (paramNameStr == "Visibility")
6763 if (!aSmeshActor && displayer() && vman)
6765 SUIT_ViewModel* vmodel = vman->getViewModel();
6766 // SVTK view model can be casted to SALOME_View
6767 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6769 // store displayed actor in a temporary map for quicker
6770 // access later when restoring other parameters
6771 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6772 vtkRenderer* Renderer = vtkView->getRenderer();
6773 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6774 vtkActorCollection* theActors = aCopy.GetActors();
6775 theActors->InitTraversal();
6776 bool isFound = false;
6777 vtkActor *ac = theActors->GetNextActor();
6778 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6779 if (ac->IsA("SMESH_Actor")) {
6780 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6781 if (aGeomAc->hasIO()) {
6782 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6783 if (io->hasEntry() && strcmp(io->getEntry(), entry.toUtf8().data()) == 0) {
6785 vtkActors.Bind(viewIndex, aGeomAc);
6791 } // if (paramNameStr == "Visibility")
6794 // the rest properties "work" with SMESH_Actor
6797 QString val ((*valuesIt).c_str());
6800 if (paramNameStr == "Representation") {
6801 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6804 else if (paramNameStr == "IsShrunk") {
6806 if (!aSmeshActor->IsShrunk())
6807 aSmeshActor->SetShrink();
6810 if (aSmeshActor->IsShrunk())
6811 aSmeshActor->UnShrink();
6814 // Displayed entities
6815 else if (paramNameStr == "Entities") {
6816 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6817 int aEntityMode = SMESH_Actor::eAllEntity;
6818 for ( int i = 0; i < mode.count(); i+=2 ) {
6819 if ( i < mode.count()-1 ) {
6820 QString type = mode[i];
6821 bool val = mode[i+1].toInt();
6822 if ( type == "e" && !val )
6823 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6824 else if ( type == "f" && !val )
6825 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6826 else if ( type == "v" && !val )
6827 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6828 else if ( type == "0d" && !val )
6829 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6830 else if ( type == "b" && !val )
6831 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6834 aSmeshActor->SetEntityMode( aEntityMode );
6837 else if (paramNameStr == "Colors") {
6838 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6845 QColor outlineColor;
6846 QColor orientationColor;
6852 // below lines are required to get default values for delta coefficients
6853 // of backface color for faces and color of reversed volumes
6854 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6855 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6856 for ( int i = 0; i < colors.count(); i++ ) {
6857 QString type = colors[i];
6858 if ( type == "surface" ) {
6859 // face color is set by 3 values r:g:b, where
6860 // - r,g,b - is rgb color components
6861 if ( i+1 >= colors.count() ) break; // format error
6862 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6863 if ( i+2 >= colors.count() ) break; // format error
6864 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6865 if ( i+3 >= colors.count() ) break; // format error
6866 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6867 faceColor.setRgbF( r, g, b );
6870 else if ( type == "backsurface" ) {
6871 // backface color can be defined in several ways
6872 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6873 // - in latest versions, it is set as delta coefficient
6874 bool rgbOk = false, deltaOk;
6875 if ( i+1 >= colors.count() ) break; // format error
6876 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6877 int delta = colors[i+1].toInt( &deltaOk );
6879 if ( i+1 < colors.count() ) // index is shifted to 1
6880 g = colors[i+1].toDouble( &rgbOk );
6881 if ( rgbOk ) i++; // shift index
6882 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6883 b = colors[i+1].toDouble( &rgbOk );
6885 // - as currently there's no way to set directly backsurface color as it was before,
6886 // we ignore old dump where r,g,b triple was set
6887 // - also we check that delta parameter is set properly
6888 if ( !rgbOk && deltaOk )
6891 else if ( type == "volume" ) {
6892 // volume color is set by 4 values r:g:b:delta, where
6893 // - r,g,b - is a normal volume rgb color components
6894 // - delta - is a reversed volume color delta coefficient
6895 if ( i+1 >= colors.count() ) break; // format error
6896 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6897 if ( i+2 >= colors.count() ) break; // format error
6898 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6899 if ( i+3 >= colors.count() ) break; // format error
6900 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6901 if ( i+4 >= colors.count() ) break; // format error
6902 int delta = colors[i+4].toInt( &bOk );
6903 if ( !bOk ) break; // format error
6904 volumeColor.setRgbF( r, g, b );
6908 else if ( type == "edge" ) {
6909 // edge color is set by 3 values r:g:b, where
6910 // - r,g,b - is rgb color components
6911 if ( i+1 >= colors.count() ) break; // format error
6912 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6913 if ( i+2 >= colors.count() ) break; // format error
6914 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6915 if ( i+3 >= colors.count() ) break; // format error
6916 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6917 edgeColor.setRgbF( r, g, b );
6920 else if ( type == "node" ) {
6921 // node color is set by 3 values r:g:b, where
6922 // - r,g,b - is rgb color components
6923 if ( i+1 >= colors.count() ) break; // format error
6924 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6925 if ( i+2 >= colors.count() ) break; // format error
6926 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6927 if ( i+3 >= colors.count() ) break; // format error
6928 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6929 nodeColor.setRgbF( r, g, b );
6932 else if ( type == "elem0d" ) {
6933 // 0d element color is set by 3 values r:g:b, where
6934 // - r,g,b - is rgb color components
6935 if ( i+1 >= colors.count() ) break; // format error
6936 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6937 if ( i+2 >= colors.count() ) break; // format error
6938 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6939 if ( i+3 >= colors.count() ) break; // format error
6940 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6941 elem0dColor.setRgbF( r, g, b );
6944 else if ( type == "ball" ) {
6945 // ball color is set by 3 values r:g:b, where
6946 // - r,g,b - is rgb color components
6947 if ( i+1 >= colors.count() ) break; // format error
6948 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6949 if ( i+2 >= colors.count() ) break; // format error
6950 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6951 if ( i+3 >= colors.count() ) break; // format error
6952 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6953 ballColor.setRgbF( r, g, b );
6956 else if ( type == "outline" ) {
6957 // outline color is set by 3 values r:g:b, where
6958 // - r,g,b - is rgb color components
6959 if ( i+1 >= colors.count() ) break; // format error
6960 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6961 if ( i+2 >= colors.count() ) break; // format error
6962 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6963 if ( i+3 >= colors.count() ) break; // format error
6964 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6965 outlineColor.setRgbF( r, g, b );
6968 else if ( type == "orientation" ) {
6969 // orientation color is set by 3 values r:g:b, where
6970 // - r,g,b - is rgb color components
6971 if ( i+1 >= colors.count() ) break; // format error
6972 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6973 if ( i+2 >= colors.count() ) break; // format error
6974 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6975 if ( i+3 >= colors.count() ) break; // format error
6976 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6977 orientationColor.setRgbF( r, g, b );
6982 if ( nodeColor.isValid() )
6983 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6985 if ( edgeColor.isValid() )
6986 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6988 if ( faceColor.isValid() )
6989 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6991 if ( volumeColor.isValid() )
6992 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6993 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6994 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6996 if ( elem0dColor.isValid() )
6997 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6999 if ( ballColor.isValid() )
7000 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
7002 if ( outlineColor.isValid() )
7003 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
7004 // orientation color
7005 if ( orientationColor.isValid() )
7006 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
7009 else if (paramNameStr == "Sizes") {
7010 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
7013 int outlineWidth = -1;
7014 int elem0dSize = -1;
7015 //int ballSize = -1;
7016 double ballDiameter = -1.0;
7017 double ballScale = -1.0;
7018 double shrinkSize = -1;
7019 double orientationSize = -1;
7020 bool orientation3d = false;
7021 for ( int i = 0; i < sizes.count(); i++ ) {
7022 QString type = sizes[i];
7023 if ( type == "line" ) {
7024 // line (wireframe) width is given as single integer value
7025 if ( i+1 >= sizes.count() ) break; // format error
7026 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7030 if ( type == "outline" ) {
7031 // outline width is given as single integer value
7032 if ( i+1 >= sizes.count() ) break; // format error
7033 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7037 else if ( type == "elem0d" ) {
7038 // 0d element size is given as single integer value
7039 if ( i+1 >= sizes.count() ) break; // format error
7040 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7044 else if ( type == "ball" ) {
7045 // balls are specified by two values: size:scale, where
7046 // - size - is a integer value specifying size
7047 // - scale - is a double value specifying scale factor
7048 if ( i+1 >= sizes.count() ) break; // format error
7049 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7050 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7051 if ( i+2 >= sizes.count() ) break; // format error
7052 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7058 else if ( type == "shrink" ) {
7059 // shrink factor is given as single floating point value
7060 if ( i+1 >= sizes.count() ) break; // format error
7061 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7065 else if ( type == "orientation" ) {
7066 // orientation vectors are specified by two values size:3d, where
7067 // - size - is a floating point value specifying scale factor
7068 // - 3d - is a boolean
7069 if ( i+1 >= sizes.count() ) break; // format error
7070 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7071 if ( i+2 >= sizes.count() ) break; // format error
7072 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
7073 orientationSize = v1;
7074 orientation3d = (bool)v2;
7078 // line (wireframe) width
7079 if ( lineWidth > 0 )
7080 aSmeshActor->SetLineWidth( lineWidth );
7082 if ( outlineWidth > 0 )
7083 aSmeshActor->SetOutlineWidth( outlineWidth );
7084 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
7085 aSmeshActor->SetOutlineWidth( lineWidth );
7087 if ( elem0dSize > 0 )
7088 aSmeshActor->Set0DSize( elem0dSize );
7090 /*if ( ballSize > 0 )
7091 aSmeshActor->SetBallSize( ballSize );*/
7093 if ( ballDiameter > 0 )
7094 aSmeshActor->SetBallSize( ballDiameter );
7096 if ( ballScale > 0.0 )
7097 aSmeshActor->SetBallScale( ballScale );
7099 if ( shrinkSize > 0 )
7100 aSmeshActor->SetShrinkFactor( shrinkSize );
7101 // orientation vectors
7102 if ( orientationSize > 0 ) {
7103 aSmeshActor->SetFacesOrientationScale( orientationSize );
7104 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
7108 else if (paramNameStr == "PointMarker") {
7109 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
7110 if( data.count() >= 2 ) {
7112 int aParam1 = data[1].toInt( &ok );
7114 if( data[0] == "std" && data.count() == 3 ) {
7115 int aParam2 = data[2].toInt( &ok );
7116 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
7118 else if( data[0] == "custom" ) {
7119 VTK::MarkerMap::const_iterator markerIt = myMarkerMap.find( aParam1 );
7120 if( markerIt != myMarkerMap.end() ) {
7121 VTK::MarkerData aMarkerData = markerIt->second;
7122 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
7129 else if (paramNameStr == "Opacity") {
7130 aSmeshActor->SetOpacity(val.toFloat());
7133 else if (paramNameStr.startsWith("ClippingPlane")) {
7134 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
7135 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
7136 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
7137 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
7138 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
7139 // new format - val looks like "Off" or "0" (plane id)
7140 // (note: in new format "Off" value is used only for consistency,
7141 // so it is processed together with values in old format)
7142 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
7143 if( anIsOldFormat ) {
7144 if (paramNameStr == "ClippingPlane1" || val == "Off")
7145 aSmeshActor->RemoveAllClippingPlanes();
7147 QList<SUIT_ViewManager*> lst;
7148 getApp()->viewManagers(viewerTypStr, lst);
7149 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
7150 if (viewIndex >= 0 && viewIndex < lst.count()) {
7151 SUIT_ViewManager* vman = lst.at(viewIndex);
7152 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
7154 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
7156 SMESH::TActorList anActorList;
7157 anActorList.push_back( aSmeshActor );
7158 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
7159 aPlane->myViewWindow = vtkView;
7160 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
7161 aPlane->PlaneMode = aMode;
7162 bool isOpenGLClipping = ( bool )vals[1].toInt();
7163 aPlane->IsOpenGLClipping = isOpenGLClipping;
7164 if ( aMode == SMESH::Absolute ) {
7165 aPlane->myAbsoluteOrientation = vals[2].toInt();
7166 aPlane->X = vals[3].toFloat();
7167 aPlane->Y = vals[4].toFloat();
7168 aPlane->Z = vals[5].toFloat();
7169 aPlane->Dx = vals[6].toFloat();
7170 aPlane->Dy = vals[7].toFloat();
7171 aPlane->Dz = vals[8].toFloat();
7173 else if ( aMode == SMESH::Relative ) {
7174 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
7175 aPlane->myDistance = vals[3].toFloat();
7176 aPlane->myAngle[0] = vals[4].toFloat();
7177 aPlane->myAngle[1] = vals[5].toFloat();
7181 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7182 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7183 aClippingPlaneInfo.Plane = aPlane;
7184 aClippingPlaneInfo.ActorList = anActorList;
7185 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7193 int aPlaneId = val.toInt( &ok );
7194 if( ok && aPlaneId >= 0 ) {
7195 bool anIsDefinedPlane = false;
7196 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
7197 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
7198 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7199 TPlaneInfo& aPlaneInfo = *anIter;
7200 if( aPlaneInfo.PlaneId == aPlaneId ) {
7201 aPlaneInfo.ActorList.push_back( aSmeshActor );
7202 anIsDefinedPlane = true;
7206 if( !anIsDefinedPlane ) {
7207 TPlaneInfo aPlaneInfo;
7208 aPlaneInfo.PlaneId = aPlaneId;
7209 aPlaneInfo.ActorList.push_back( aSmeshActor );
7210 aPlaneInfo.ViewManager = vman;
7212 // to make the list sorted by plane id
7213 anIter = aPlaneInfoList.begin();
7214 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7215 const TPlaneInfo& aPlaneInfoRef = *anIter;
7216 if( aPlaneInfoRef.PlaneId > aPlaneId )
7219 aPlaneInfoList.insert( anIter, aPlaneInfo );
7224 } // if (aSmeshActor)
7225 } // other parameters than Visibility
7227 } // for names/parameters iterator
7228 } // for entries iterator
7230 // take into account planes with empty list of actors referred to them
7231 QList<SUIT_ViewManager*> aVMList;
7232 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
7234 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
7235 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
7236 int aViewId = aPlaneDataIter->first;
7237 if( aViewId >= 0 && aViewId < aVMList.count() ) {
7238 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
7240 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
7242 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
7243 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
7244 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
7245 const TPlaneData& aPlaneData = *anIter2;
7246 int aPlaneId = aPlaneData.Id;
7248 bool anIsFound = false;
7249 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7250 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7251 const TPlaneInfo& aPlaneInfo = *anIter3;
7252 if( aPlaneInfo.PlaneId == aPlaneId ) {
7259 TPlaneInfo aPlaneInfo; // ActorList field is empty
7260 aPlaneInfo.PlaneId = aPlaneId;
7261 aPlaneInfo.ViewManager = aViewManager;
7263 // to make the list sorted by plane id
7264 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
7265 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
7266 const TPlaneInfo& aPlaneInfoRef = *anIter4;
7267 if( aPlaneInfoRef.PlaneId > aPlaneId )
7270 aPlaneInfoList.insert( anIter4, aPlaneInfo );
7276 // add clipping planes to actors according to the restored parameters
7277 // and update the clipping plane map
7278 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
7279 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
7280 int aViewId = anIter1->first;
7281 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
7283 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
7284 if( anIter2 == aPlaneDataMap.end() )
7286 const TPlaneDataList& aPlaneDataList = anIter2->second;
7288 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7289 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7290 const TPlaneInfo& aPlaneInfo = *anIter3;
7291 int aPlaneId = aPlaneInfo.PlaneId;
7292 const TActorList& anActorList = aPlaneInfo.ActorList;
7293 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
7297 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
7301 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
7303 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
7304 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
7305 const TPlaneData& aPlaneData = *anIter4;
7306 if( aPlaneData.Id == aPlaneId ) {
7307 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
7308 aPlane->myViewWindow = aViewWindow;
7309 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
7310 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
7311 if ( aPlane->PlaneMode == SMESH::Absolute ) {
7312 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
7313 aPlane->X = aPlaneData.X;
7314 aPlane->Y = aPlaneData.Y;
7315 aPlane->Z = aPlaneData.Z;
7316 aPlane->Dx = aPlaneData.Dx;
7317 aPlane->Dy = aPlaneData.Dy;
7318 aPlane->Dz = aPlaneData.Dz;
7320 else if ( aPlane->PlaneMode == SMESH::Relative ) {
7321 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
7322 aPlane->myDistance = aPlaneData.Distance;
7323 aPlane->myAngle[0] = aPlaneData.Angle[0];
7324 aPlane->myAngle[1] = aPlaneData.Angle[1];
7327 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7328 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7329 aClippingPlaneInfo.Plane = aPlane;
7330 aClippingPlaneInfo.ActorList = anActorList;
7331 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7342 // update all VTK views
7343 QList<SUIT_ViewManager*> lst;
7344 getApp()->viewManagers(lst);
7345 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
7346 SUIT_ViewModel* vmodel = (*it)->getViewModel();
7347 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
7348 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
7349 // set OpenGL clipping planes
7350 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
7351 vtkActorCollection* anAllActors = aCopy.GetActors();
7352 anAllActors->InitTraversal();
7353 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
7354 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
7355 anActor->SetOpenGLClippingPlane();
7357 vtkView->getRenderer()->ResetCameraClippingRange();
7364 \brief Adds preferences for dfont of VTK viewer
7366 \param pIf group identifier
7367 \param param parameter
7368 \return identifier of preferences
7370 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
7372 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
7374 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
7377 fam.append( tr( "SMESH_FONT_ARIAL" ) );
7378 fam.append( tr( "SMESH_FONT_COURIER" ) );
7379 fam.append( tr( "SMESH_FONT_TIMES" ) );
7381 setPreferenceProperty( tfont, "fonts", fam );
7383 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
7384 if ( needSize ) f = f | QtxFontEdit::Size;
7385 setPreferenceProperty( tfont, "features", f );
7391 \brief Actions after hypothesis edition
7392 Updates object browser after hypothesis edition
7394 void SMESHGUI::onHypothesisEdit( int result )
7397 SMESHGUI::Modified();
7398 updateObjBrowser( true );
7402 \brief Actions after choosing menu of control modes
7403 Updates control mode actions according to current selection
7405 void SMESHGUI::onUpdateControlActions()
7407 SALOME_ListIO selected;
7408 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
7409 aSel->selectedObjects( selected );
7411 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
7412 if ( selected.Extent() ) {
7413 if ( selected.First()->hasEntry() ) {
7414 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
7415 aControl = anActor->GetControlMode();
7416 SALOME_ListIteratorOfListIO it(selected);
7417 for ( it.Next(); it.More(); it.Next() ) {
7418 Handle(SALOME_InteractiveObject) anIO = it.Value();
7419 if ( anIO->hasEntry() ) {
7420 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
7421 if ( aControl != anActor->GetControlMode() ) {
7422 aControl = SMESH_Actor::eNone;
7432 int anAction = ActionToControl( aControl, true );
7434 action( anAction )->setChecked( true );
7436 QMenu* send = (QMenu*)sender();
7437 QList<QAction*> actions = send->actions();
7438 for ( int i = 0; i < actions.size(); i++ )
7439 actions[i]->setChecked( false );
7445 \brief Signal handler closing(SUIT_ViewWindow*) of a view
7446 \param pview view being closed
7448 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
7449 #ifndef DISABLE_PLOT2DVIEWER
7450 //Crear all Plot2d Viewers if need.
7451 SMESH::ClearPlot2Viewers(pview);
7453 EmitSignalCloseView();
7456 void SMESHGUI::message( const QString& msg )
7459 QStringList data = msg.split("/");
7460 if ( data.count() > 0 ) {
7461 if ( data.first() == "mesh_loading" ) {
7463 QString entry = data.count() > 1 ? data[1] : QString();
7464 if ( entry.isEmpty() )
7467 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
7469 _PTR(SObject) obj = study->FindObjectID( entry.toUtf8().constData() );
7472 name = SMESH::fromUtf8(obj->GetName());
7473 if ( name.isEmpty() )
7476 if ( data.last() == "stop" )
7477 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7479 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7480 QApplication::processEvents();
7486 \brief Connects or disconnects signals about activating and cloning view on the module slots
7487 \param pview view which is connected/disconnected
7489 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7493 SUIT_ViewManager* viewMgr = pview->getViewManager();
7495 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7496 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7498 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7499 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7504 \brief Return \c true if object can be renamed
7506 bool SMESHGUI::renameAllowed( const QString& entry) const {
7507 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7511 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7515 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7520 if(appStudy->isComponent(entry) || obj->isReference())
7523 // check type to prevent renaming of inappropriate objects
7524 int aType = SMESHGUI_Selection::type(qPrintable(entry));
7525 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7526 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7527 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7528 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7529 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7536 Rename object by entry.
7537 \param entry entry of the object
7538 \param name new name of the object
7539 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7541 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7543 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7547 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7552 _PTR(Study) aStudy = appStudy->studyDS();
7557 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7559 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7564 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7565 _PTR(GenericAttribute) anAttr;
7566 _PTR(AttributeName) aName;
7568 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7570 // check type to prevent renaming of inappropriate objects
7571 int aType = SMESHGUI_Selection::type( qPrintable(entry));
7572 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7573 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7574 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7575 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7576 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7577 if ( !name.isEmpty() ) {
7578 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qUtf8Printable(name) );
7580 // update name of group object and its actor
7581 Handle(SALOME_InteractiveObject) IObject =
7582 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7584 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7585 if( !aGroupObject->_is_nil() ) {
7586 aGroupObject->SetName( qUtf8Printable(name) );
7587 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7588 anActor->setName( qUtf8Printable(name) );
7598 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7600 static QList<QColor> colors;
7602 if ( colors.isEmpty() ) {
7604 for (int s = 0; s < 2 ; s++)
7606 for (int v = 100; v >= 40; v = v - 20)
7608 for (int h = 0; h < 359 ; h = h + 60)
7610 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7615 static int currentColor = randomize( colors.size() );
7617 SALOMEDS::Color color;
7618 color.R = (double)colors[currentColor].red() / 255.0;
7619 color.G = (double)colors[currentColor].green() / 255.0;
7620 color.B = (double)colors[currentColor].blue() / 255.0;
7622 currentColor = (currentColor+1) % colors.count();