1 // Copyright (C) 2007-2022 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"
113 // SALOME GUI includes
114 #include <LightApp_DataOwner.h>
115 #include <LightApp_NameDlg.h>
116 #include <LightApp_Preferences.h>
117 #include <LightApp_SelectionMgr.h>
118 #include <LightApp_UpdateFlags.h>
119 #include <QtxFontEdit.h>
120 #include <QtxPopupMgr.h>
121 #include <QtxInfoPanel.h>
122 #include <SALOME_ListIO.hxx>
123 #include <SUIT_Desktop.h>
124 #include <SUIT_FileDlg.h>
125 #include <SUIT_MessageBox.h>
126 #include <SUIT_OverrideCursor.h>
127 #include <SUIT_ResourceMgr.h>
128 #include <SUIT_Session.h>
129 #include <SVTK_Renderer.h>
130 #include <SVTK_ViewManager.h>
131 #include <SVTK_ViewModel.h>
132 #include <SVTK_ViewWindow.h>
133 #include <SalomeApp_Application.h>
134 #include <SalomeApp_CheckFileDlg.h>
135 #include <SalomeApp_DataObject.h>
136 #include <SalomeApp_Study.h>
137 #include <SalomeApp_Tools.h>
138 #include <VTKViewer_Algorithm.h>
140 #ifndef DISABLE_PLOT2DVIEWER
141 #include <SPlot2d_ViewModel.h>
142 #include <SPlot2d_Histogram.h>
146 #include <SALOMEconfig.h>
147 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
148 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
149 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
150 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
151 #include CORBA_CLIENT_HEADER(SMESH_Homard)
154 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
155 #include <QApplication>
157 #include <QDialogButtonBox>
161 #include <QTextStream>
165 #include <boost/shared_ptr.hpp>
168 #include <vtkCallbackCommand.h>
169 #include <vtkCamera.h>
170 #include <vtkLookupTable.h>
171 #include <vtkPlane.h>
172 #include <vtkRenderer.h>
174 // SALOME KERNEL includes
175 #include <Basics_Utils.hxx>
176 #include <SALOMEDSClient_ClientFactory.hxx>
177 #include <SALOMEDSClient_IParameters.hxx>
178 #include <SALOMEDSClient_SComponent.hxx>
179 #include <SALOMEDSClient_StudyBuilder.hxx>
180 #include <SALOMEDS_SObject.hxx>
181 #include <SALOMEDS_Study.hxx>
182 #include <SALOME_GenericObj_wrap.hxx>
183 #include <SALOME_LifeCycleCORBA.hxx>
184 #include <utilities.h>
187 #include <Standard_ErrorHandler.hxx>
188 #include <NCollection_DataMap.hxx>
189 #include <NCollection_DoubleMap.hxx>
191 // Below macro, when uncommented, switches on simplified (more performant) algorithm
192 // of auto-color picking up
193 #define SIMPLE_AUTOCOLOR
198 //=============================================================
199 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
202 void ExportMeshToFile(int theCommandID);
204 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap);
206 void SetDisplayEntity(int theCommandID);
208 int ActionToControl( int theID, bool theReversed = false );
210 void Control( int theCommandID );
213 //================================================================================
215 * \brief Reads meshes from file
217 //================================================================================
219 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
223 std::string myExtension;
225 if ( theCommandID == SMESHOp::OpImportMED ||
226 theCommandID == SMESHOp::OpPopupImportMED ) {
227 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
228 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
230 else if ( theCommandID == SMESHOp::OpImportUNV ||
231 theCommandID == SMESHOp::OpPopupImportUNV ) {
232 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
234 else if ( theCommandID == SMESHOp::OpImportDAT ||
235 theCommandID == SMESHOp::OpPopupImportDAT ) {
236 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
238 else if ( theCommandID == SMESHOp::OpImportSTL ||
239 theCommandID == SMESHOp::OpPopupImportSTL ) {
240 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
242 else if ( theCommandID == SMESHOp::OpImportCGNS ||
243 theCommandID == SMESHOp::OpPopupImportCGNS ) {
244 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
246 else if ( theCommandID == SMESHOp::OpImportGMF ||
247 theCommandID == SMESHOp::OpPopupImportGMF ) {
248 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
249 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
252 QString anInitialPath = "";
253 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
254 anInitialPath = QDir::currentPath();
256 QStringList filenames;
257 bool toCreateGroups = true;
259 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
260 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
261 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
262 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
263 // fd->setNameFilters( filter );
264 // fd->SetChecked( true );
266 // filenames << fd->selectedFile();
267 // toCreateGroups = fd->IsChecked();
273 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
276 QObject::tr( "SMESH_IMPORT_MESH" ) );
278 if ( filenames.count() > 0 )
280 SUIT_OverrideCursor wc;
281 _PTR(Study) aStudy = SMESH::getStudy();
284 QStringList anEntryList;
285 bool isEmpty = false;
286 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it )
288 QString filename = *it;
289 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
291 switch ( theCommandID ) {
292 case SMESHOp::OpImportDAT:
293 case SMESHOp::OpPopupImportDAT:
295 // DAT format (currently unsupported)
296 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
297 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
300 case SMESHOp::OpImportUNV:
301 case SMESHOp::OpPopupImportUNV:
304 aMeshes->length( 1 );
305 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
306 if ( aMeshes[0]->_is_nil() )
307 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
308 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
311 case SMESHOp::OpImportMED:
312 case SMESHOp::OpPopupImportMED:
315 SMESH::DriverMED_ReadStatus res;
316 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
317 if ( res != SMESH::DRS_OK ) {
318 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
319 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
323 case SMESHOp::OpImportSTL:
324 case SMESHOp::OpPopupImportSTL:
327 aMeshes->length( 1 );
328 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
329 if ( aMeshes[0]->_is_nil() ) {
330 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
331 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
335 case SMESHOp::OpImportCGNS:
336 case SMESHOp::OpPopupImportCGNS:
339 SMESH::DriverMED_ReadStatus res;
340 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
341 if ( res != SMESH::DRS_OK ) {
342 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
343 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
347 case SMESHOp::OpImportGMF:
348 case SMESHOp::OpPopupImportGMF:
351 SMESH::ComputeError_var res;
352 aMeshes->length( 1 );
353 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
356 if ( res->code != SMESH::DRS_OK ) {
357 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
358 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
359 if ( strlen( res->comment.in() ) > 0 ) {
360 errors.back() += ": ";
361 errors.back() += res->comment.in();
368 catch ( const SALOME::SALOME_Exception& S_ex ) {
369 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
370 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
373 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ )
375 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
377 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
378 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
379 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
380 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
381 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
383 anEntryList.append( aMeshSO->GetID().c_str() );
391 // update Object browser
392 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
394 // browse to the published meshes
395 if( LightApp_Application* anApp =
396 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
397 anApp->browseObjects( anEntryList );
399 // show Error message box if there were errors
400 if ( errors.count() > 0 ) {
401 SUIT_MessageBox::critical( SMESHGUI::desktop(),
402 QObject::tr( "SMESH_ERROR" ),
403 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
406 // show warning message box, if some imported mesh is empty
408 SUIT_MessageBox::warning( SMESHGUI::desktop(),
409 QObject::tr( "SMESH_WRN_WARNING" ),
410 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
415 //================================================================================
417 * \brief Export selected meshes or groups into a file
419 //================================================================================
421 void ExportMeshToFile( int theCommandID )
423 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
424 SALOME_ListIO selected;
426 aSel->selectedObjects( selected );
428 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT ||
429 theCommandID == SMESHOp::OpPopupExportDAT );
430 const bool isMED = ( theCommandID == SMESHOp::OpExportMED ||
431 theCommandID == SMESHOp::OpPopupExportMED );
432 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV ||
433 theCommandID == SMESHOp::OpPopupExportUNV );
434 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL ||
435 theCommandID == SMESHOp::OpPopupExportSTL );
436 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS ||
437 theCommandID == SMESHOp::OpPopupExportCGNS );
438 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF ||
439 theCommandID == SMESHOp::OpPopupExportGMF );
441 const bool multiMeshSupported = ( isMED || isCGNS ); // file can hold several meshes
442 if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
444 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
445 bool aCheckWarn = true;
447 aCheckWarn = resMgr->booleanValue( "SMESH", "show_warning", false );
449 // get mesh object from selection and check duplication of their names
450 bool hasDuplicatedMeshNames = false;
451 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
452 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
453 SALOME_ListIteratorOfListIO It( selected );
454 for( ; It.More(); It.Next() )
456 Handle(SALOME_InteractiveObject) anIObject = It.Value();
457 SMESH::SMESH_IDSource_var aMeshItem =
458 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
459 if ( aMeshItem->_is_nil() ) {
460 SUIT_MessageBox::warning( SMESHGUI::desktop(),
461 QObject::tr( "SMESH_WRN_WARNING" ),
462 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
465 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aMeshItem );
466 if ( aCheckWarn && !aGroup->_is_nil() )
468 QMessageBox msgBox(SUIT_MessageBox::Warning,
469 QObject::tr("SMESH_WRN_WARNING"),
470 QObject::tr("SMESH_EXPORT_ONLY_GPOUP"),
471 QMessageBox::StandardButton::NoButton,
472 SMESHGUI::desktop());
473 QCheckBox dontShowCheckBox(QObject::tr("SMESH_WRN_SHOW_DLG_CHECKBOX"));
474 msgBox.addButton(QMessageBox::Ok);
475 msgBox.addButton(QMessageBox::Cancel);
476 msgBox.setDefaultButton(QMessageBox::Cancel);
477 QGridLayout* lt = qobject_cast<QGridLayout*>(msgBox.layout());
478 QDialogButtonBox* btnbox = msgBox.findChild<QDialogButtonBox*>();
479 lt->addWidget(&dontShowCheckBox, lt->rowCount(), lt->columnCount()-1, lt->rowCount(), lt->columnCount());
480 lt->addWidget(btnbox, lt->rowCount(), 0, lt->rowCount(), lt->columnCount());
481 if ( msgBox.exec() != QMessageBox::Ok )
484 if ( dontShowCheckBox.checkState() == Qt::Checked && resMgr )
485 resMgr->setValue( "SMESH", "show_warning", false);
488 QString aMeshName = anIObject->getName();
490 // check for name duplications
491 if ( !hasDuplicatedMeshNames )
492 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
493 if( aMeshName == (*aMeshIter).second ) {
494 hasDuplicatedMeshNames = true;
499 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
502 if( hasDuplicatedMeshNames && isMED ) {
503 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
504 QObject::tr("SMESH_WRN_WARNING"),
505 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
506 QObject::tr("SMESH_BUT_YES"),
507 QObject::tr("SMESH_BUT_NO"), 0, 1);
512 aMeshIter = aMeshList.begin();
513 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
514 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
515 QString aMeshName = (*aMeshIter).second;
517 if ( isMED || isCGNS ) // formats where group names must be unique
519 // check for equal group names within each mesh
520 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
521 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
522 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
523 int aRet = SUIT_MessageBox::warning
524 (SMESHGUI::desktop(),
525 QObject::tr("SMESH_WRN_WARNING"),
526 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
527 QObject::tr("SMESH_BUT_YES"),
528 QObject::tr("SMESH_BUT_NO"), 0, 1);
535 // Warn the user about presence of not supported elements
537 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
541 notSupportedElemTypes.push_back( SMESH::Entity_0D );
542 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
547 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
548 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
549 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
550 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
551 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
552 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
553 notSupportedElemTypes.push_back( SMESH::Entity_0D );
554 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
559 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
560 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
561 notSupportedElemTypes.push_back( SMESH::Entity_0D );
562 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
567 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
572 notSupportedElemTypes.push_back( SMESH::Entity_0D );
573 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
574 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
575 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
576 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
577 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Penta );
578 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
579 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
580 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
581 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
583 if ( ! notSupportedElemTypes.empty() )
585 SMESH::smIdType_array_var nbElems = aMeshOrGroup->GetMeshInfo();
586 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
587 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
588 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
590 if ( !presentNotSupported.empty() )
593 const char* typeMsg[] = {
594 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
595 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
596 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
597 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
598 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
599 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
600 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
601 "SMESH_BIQUADRATIC_PENTAHEDRONS",
602 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
604 // is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
605 static_assert( sizeof(typeMsg) / sizeof(const char*) == SMESH::Entity_Last,
606 "Update names of EntityType's!!!" );
608 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
609 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
610 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
611 if ( iType != presentNotSupported.size() - 1 )
612 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
614 int aRet = SUIT_MessageBox::warning
615 (SMESHGUI::desktop(),
616 QObject::tr("SMESH_WRN_WARNING"),
617 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
618 QObject::tr("SMESH_BUT_YES"),
619 QObject::tr("SMESH_BUT_NO"), 0, 1);
624 // Get parameters of export operation
627 int aFormat =-1; // for MED version used for write
628 bool isOkToWrite = true; // to check MED file version compatibility before adding a mesh in an existing file
630 // Init the parameters with the default values
631 bool aIsASCII_STL = true;
632 bool toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
633 bool toOverwrite = true;
634 bool toFindOutDim = true;
635 bool saveNumbers = resMgr->booleanValue( "SMESH", "med_save_numbers", true );
636 bool toRenumber = true;
637 double zTol = resMgr->doubleValue( "SMESH", "med_ztolerance", 0. );
639 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
640 QString anInitialPath = "";
641 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
642 anInitialPath = QDir::currentPath();
644 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
646 // Get a file name to write in and additional options
647 if ( isGMF ) // Export w/o options
649 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
650 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
651 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
653 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
654 anInitialPath + QString("/") + aMeshName,
655 aFilter, aTitle, false);
657 else if ( isCGNS || isUNV || isDAT ) // Export to [ CGNS | UNV | DAT ] - one option
659 const char* theOptionResource = isCGNS ? "cgns_group_elems_by_type" : "export_renumber";
660 bool option = resMgr->booleanValue( "SMESH", theOptionResource, false );
662 QStringList checkBoxes;
663 checkBoxes << QObject::tr( isCGNS ? "CGNS_EXPORT_ELEMS_BY_TYPE" : "SMESH_RENUMBER" );
665 SalomeApp_CheckFileDlg* fd =
666 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
667 fd->setWindowTitle( aTitle );
669 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
671 fd->setNameFilter( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
673 fd->setNameFilter( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
674 if ( !anInitialPath.isEmpty() )
675 fd->setDirectory( anInitialPath );
676 fd->selectFile( aMeshName );
677 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
678 fd->setValidator( fv );
679 fd->SetChecked( option, 0 );
682 aFilename = fd->selectedFile();
683 toOverwrite = fv->isOverwrite( aFilename );
684 option = fd->IsChecked( 0 );
685 SMESHGUI::resourceMgr()->setValue("SMESH", theOptionResource, option );
686 ( isCGNS ? toCreateGroups : toRenumber ) = option;
690 else if ( isSTL ) // Export to STL
692 QMap<QString, int> aFilterMap;
693 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
694 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
697 QMap<QString, int>::const_iterator it = aFilterMap.begin();
698 for ( ; it != aFilterMap.end(); ++it )
699 filters.push_back( it.key() );
701 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
702 fd->setWindowTitle( aTitle );
703 fd->setNameFilters( filters );
704 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
705 if ( !anInitialPath.isEmpty() )
706 fd->setDirectory( anInitialPath );
707 fd->selectFile(aMeshName);
711 aFilename = fd->selectedFile();
712 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
717 else if ( isMED ) // Export to MED
719 int defaultVersion = 0;
720 QMap<QString, int> aFilterMap;
721 //filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
722 //QString vmed (aMesh->GetVersionString(-1, 2));
723 SMESH::long_array_var mvok = aMesh->GetMEDVersionsCompatibleForAppend();
724 if ( mvok->length() > 0)
725 defaultVersion = mvok[0]; // the current version to set the default filter on it
726 for ( CORBA::ULong i = 0; i < mvok->length(); ++i )
728 QString vs = (char*)( SMESH_Comment( mvok[i]/10 ) << "." << mvok[i]%10 );
729 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vs ) + " (*.med)", mvok[i]);
732 QMap<QString, int>::const_iterator it = aFilterMap.begin();
733 QString aDefaultFilter = it.key();
734 for ( ; it != aFilterMap.end(); ++it ) {
735 filters.push_back( it.key() );
736 if (it.value() == defaultVersion) // explicit default for MED = current MED version
737 aDefaultFilter = it.key();
739 QStringList checkBoxes;
740 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS")
741 << QObject::tr("SMESH_AUTO_DIM")
742 << QObject::tr("SMESH_MED_SAVE_NUMS");
744 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
745 QList< QWidget* > wdgList;
746 if ( fieldSelWdg->GetAllFields( aMeshList, aFieldList ))
747 wdgList.append( fieldSelWdg );
749 QWidget* zTolWdg = new QWidget();
750 QCheckBox* zTolCheck = new QCheckBox( QObject::tr( "SMESH_ZTOLERANCE" ), zTolWdg );
751 SMESHGUI_SpinBox* zTolSpin = new SMESHGUI_SpinBox( zTolWdg );
752 QHBoxLayout* zTolLayout = new QHBoxLayout( zTolWdg );
753 zTolLayout->addWidget( zTolCheck );
754 zTolLayout->addWidget( zTolSpin );
755 zTolLayout->setMargin( 0 );
756 zTolSpin->RangeStepAndValidator( 0, 1e+100, 1., "length_precision" );
757 zTolSpin->setValue( zTol );
758 QObject::connect( zTolCheck, SIGNAL( toggled(bool)), zTolSpin, SLOT( setEnabled(bool)));
759 zTolCheck->setChecked( resMgr->booleanValue( "SMESH", "enable_ztolerance", false ));
760 zTolSpin ->setEnabled( zTolCheck->isChecked() );
761 wdgList.append( zTolWdg );
763 SalomeApp_CheckFileDlg* fd =
764 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
765 fd->setWindowTitle( aTitle );
766 fd->setNameFilters( filters );
767 fd->selectNameFilter( aDefaultFilter );
768 fd->SetChecked( toCreateGroups, 0 );
769 fd->SetChecked( toFindOutDim, 1 );
770 fd->SetChecked( saveNumbers, 2 );
771 if ( !anInitialPath.isEmpty() )
772 fd->setDirectory( anInitialPath );
773 fd->selectFile(aMeshName);
776 QListView *lview = fd->findChild<QListView*>("listView");
778 lview->setMinimumHeight(200);
780 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
782 tview->setMinimumHeight(200);
785 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
786 fd->setValidator( fv );
791 //MESSAGE("******* Loop on file dialog ***********");
794 aFilename = fd->selectedFile();
796 aFilename = QString::null;
799 aFormat = aFilterMap[fd->selectedNameFilter()];
800 //MESSAGE("selected version: " << aFormat << " file: " << aFilename.toUtf8().constData());
801 toOverwrite = fv->isOverwrite(aFilename);
802 //MESSAGE("toOverwrite:" << toOverwrite);
804 if ( !aFilename.isEmpty() ) {
806 // append is only possible if the existing file format is compatible
807 bool isVersionOk = SMESHGUI::GetSMESHGen()->CheckWriteCompatibility( aFilename.toUtf8().constData() );
808 MESSAGE("Append check, isVersionOk:" << isVersionOk);
809 if ( !isVersionOk ) {
810 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
811 QObject::tr("SMESH_WRN_WARNING"),
812 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
813 QObject::tr("SMESH_BUT_YES"),
814 QObject::tr("SMESH_BUT_NO"), 0, 1);
818 //MESSAGE("incompatible MED file version for add, overwrite accepted");
824 //MESSAGE("incompatible MED file version for add, overwrite refused");
827 QStringList aMeshNamesCollisionList;
828 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
829 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
830 QString anExistingMeshName( aMeshNames[ i ] );
831 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
832 QString anExportMeshName = (*aMeshIter).second;
833 if( anExportMeshName == anExistingMeshName ) {
834 aMeshNamesCollisionList.append( anExportMeshName );
839 if( !aMeshNamesCollisionList.isEmpty() ) {
841 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
842 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
843 QObject::tr("SMESH_WRN_WARNING"),
844 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
845 QObject::tr("SMESH_BUT_YES"),
846 QObject::tr("SMESH_BUT_NO"),
847 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
848 MESSAGE("answer collision name " << aRet);
859 toCreateGroups = fd->IsChecked(0);
860 toFindOutDim = fd->IsChecked(1);
861 saveNumbers = fd->IsChecked(2);
862 zTol = zTolCheck->isChecked() ? zTolSpin->value() : -1;
863 fieldSelWdg->GetSelectedFields();
864 if ( resMgr ) resMgr->setValue( "SMESH", "enable_ztolerance", zTolCheck->isChecked() );
866 if ( !fieldSelWdg->parent() )
868 if ( !zTolWdg->parent() )
879 if ( !aFilename.isEmpty() ) {
880 // Check whether the file already exists and delete it if yes
881 QFile aFile( aFilename );
882 if ( aFile.exists() && toOverwrite )
884 SUIT_OverrideCursor wc;
887 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
888 // bool Renumber = false;
889 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
891 // Renumber= resMgr->booleanValue("renumbering");
893 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
894 // aMeshEditor->RenumberNodes();
895 // aMeshEditor->RenumberElements();
896 // if ( SMESHGUI::automaticUpdate() )
897 // SMESH::UpdateView();
899 if ( isMED && isOkToWrite )
901 aMeshIter = aMeshList.begin();
902 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
904 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
905 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
906 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
907 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
909 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(),
910 toCreateGroups, aFormat,
911 toOverwrite && aMeshIndex == 0, toFindOutDim,
912 fields, geoAssFields.toLatin1().data(), zTol, saveNumbers );
917 if ( aMeshOrGroup->_is_equivalent( aMesh ))
918 aMesh->ExportDAT( aFilename.toUtf8().data(), toRenumber );
920 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
924 if ( aMeshOrGroup->_is_equivalent( aMesh ))
925 aMesh->ExportUNV( aFilename.toUtf8().data(), toRenumber );
927 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
931 if ( aMeshOrGroup->_is_equivalent( aMesh ))
932 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
934 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
938 aMeshIter = aMeshList.begin();
939 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
941 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
942 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
943 aMeshItem->ExportCGNS( aMeshOrGroup,
944 aFilename.toUtf8().data(),
945 toOverwrite && aMeshIndex == 0,
951 toCreateGroups = true;
952 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
955 catch (const SALOME::SALOME_Exception& S_ex)
958 if ( S_ex.details.type == SALOME::COMM && // communicate about too large mesh
959 strncmp( "format=", S_ex.details.sourceFile.in(), 7 ) == 0 )
961 SUIT_MessageBox::critical(SMESHGUI::desktop(),
962 QObject::tr("SMESH_WRN_WARNING"),
963 QObject::tr(S_ex.details.text.in() ));
965 SUIT_MessageBox::warning(SMESHGUI::desktop(),
966 QObject::tr("SMESH_WRN_WARNING"),
967 QObject::tr("SMESH_EXPORT_FAILED") + SalomeApp_Tools::ExceptionToString(S_ex));
973 inline void InverseEntityMode(unsigned int& theOutputMode,
974 unsigned int theMode)
976 bool anIsNotPresent = ~theOutputMode & theMode;
978 theOutputMode |= theMode;
980 theOutputMode &= ~theMode;
983 void SetDisplayEntity(int theCommandID)
985 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
986 SALOME_ListIO selected;
988 aSel->selectedObjects( selected );
990 if ( selected.Extent() >= 1 ) {
991 SUIT_OverrideCursor wc;
992 SALOME_ListIteratorOfListIO It( selected );
993 for( ; It.More(); It.Next()){
994 Handle(SALOME_InteractiveObject) IObject = It.Value();
995 if(IObject->hasEntry()){
996 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
997 unsigned int aMode = anActor->GetEntityMode();
998 switch(theCommandID){
999 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
1000 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
1001 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
1002 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
1003 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
1004 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
1007 anActor->SetEntityMode(aMode);
1016 SalomeApp_Application* app =
1017 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1021 LightApp_SelectionMgr* aSel = app->selectionMgr();
1022 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1023 if ( !aSel || !appStudy )
1026 SALOME_ListIO selected;
1027 aSel->selectedObjects( selected );
1028 if ( selected.IsEmpty() )
1031 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1033 _PTR(Study) aStudy = appStudy->studyDS();
1034 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
1035 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1036 if ( aMainObject->_is_nil() )
1039 SUIT_OverrideCursor wc;
1041 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
1043 QList<SALOMEDS::Color> aReservedColors;
1045 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1046 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1048 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1050 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1051 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1052 #else // old algorithm for auto-colors
1053 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1054 aReservedColors.append( aColor );
1055 #endif // SIMPLE_AUTOCOLOR
1056 aGroupObject->SetColor( aColor );
1058 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1059 if ( aGroupSObject ) {
1062 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1063 switch ( aGroupObject->GetType ()) {
1065 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1067 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1069 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1071 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1073 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1074 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1077 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1078 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1084 SMESH::RepaintCurrentView();
1087 void OverallMeshQuality()
1089 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1090 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1091 SALOME_ListIO selected;
1093 aSel->selectedObjects( selected );
1095 if ( selected.IsEmpty() ) return;
1096 SALOME_ListIteratorOfListIO It( selected );
1097 for ( ; It.More(); It.Next() ) {
1098 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1099 ctrlDlg->showInfo( It.Value() );
1104 QString functorToString( SMESH::Controls::FunctorPtr f )
1106 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1107 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1108 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1109 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1110 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1111 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1112 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1113 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1114 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1115 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1116 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1117 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1118 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1119 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1120 type = QObject::tr( "WARP_ELEMENTS" );
1121 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1122 type = QObject::tr( "TAPER_ELEMENTS" );
1123 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1124 type = QObject::tr( "SKEW_ELEMENTS" );
1125 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1126 type = QObject::tr( "AREA_ELEMENTS" );
1127 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1128 type = QObject::tr( "LENGTH_EDGES" );
1129 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1130 type = QObject::tr( "LENGTH2D_EDGES" );
1131 else if ( dynamic_cast< SMESH::Controls::Deflection2D* >( f.get() ) )
1132 type = QObject::tr( "DEFLECTION2D_FACES" );
1133 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1134 type = QObject::tr( "MULTI_BORDERS" );
1135 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1136 type = QObject::tr( "MULTI2D_BORDERS" );
1137 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1138 type = QObject::tr( "FREE_NODES" );
1139 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1140 type = QObject::tr( "FREE_EDGES" );
1141 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1142 type = QObject::tr( "FREE_BORDERS" );
1143 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1144 type = QObject::tr( "FREE_FACES" );
1145 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1146 type = QObject::tr( "BARE_BORDER_VOLUME" );
1147 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1148 type = QObject::tr( "BARE_BORDER_FACE" );
1149 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1150 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1151 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1152 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1153 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1154 type = QObject::tr( "EQUAL_NODE" );
1155 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1156 type = QObject::tr( "EQUAL_EDGE" );
1157 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1158 type = QObject::tr( "EQUAL_FACE" );
1159 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1160 type = QObject::tr( "EQUAL_VOLUME" );
1161 else if ( dynamic_cast< SMESH::Controls::NodeConnectivityNumber* >( f.get() ) )
1162 type = QObject::tr( "NODE_CONNECTIVITY_NB" );
1166 void SaveDistribution()
1168 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1169 SALOME_ListIO selected;
1171 aSel->selectedObjects( selected );
1173 if ( selected.Extent() == 1 ) {
1174 Handle(SALOME_InteractiveObject) anIO = selected.First();
1175 if ( anIO->hasEntry() ) {
1176 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1178 anActor->GetScalarBarActor() &&
1179 anActor->GetControlMode() != SMESH_Actor::eNone )
1181 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1182 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1183 if ( aScalarBarActor && aFunctor ) {
1184 SMESH::Controls::NumericalFunctor* aNumFun =
1185 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1187 std::vector<smIdType> elements;
1188 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1189 if ( mesh->_is_nil() ) {
1190 SMESH::SMESH_IDSource_var idSource =
1191 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1192 if ( !idSource->_is_nil() )
1194 SMESH::smIdType_array_var ids = idSource->GetIDs();
1195 elements.resize( ids->length() );
1196 for ( unsigned i = 0; i < elements.size(); ++i )
1197 elements[i] = ids[i];
1200 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1201 vtkLookupTable* lookupTable =
1202 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1203 double * minmax = lookupTable->GetRange();
1204 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1205 std::vector<int> nbEvents;
1206 std::vector<double> funValues;
1207 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1208 elements, minmax, isLogarithmic );
1209 QString anInitialPath = "";
1210 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1211 anInitialPath = QDir::currentPath();
1212 QString aMeshName = anIO->getName();
1214 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1215 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1216 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1217 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1218 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1221 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1223 if ( !aFilename.isEmpty() ) {
1224 QFile f( aFilename );
1225 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1226 QTextStream out( &f );
1227 out << "# Mesh: " << aMeshName << endl;
1228 out << "# Control: " << functorToString( aFunctor ) << endl;
1230 out.setFieldWidth( 10 );
1231 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1232 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1243 void ShowElement( int theCommandID )
1245 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1246 SALOME_ListIO selected;
1248 aSel->selectedObjects( selected );
1250 if ( selected.Extent() == 1 ) {
1251 Handle(SALOME_InteractiveObject) anIO = selected.First();
1252 if ( anIO->hasEntry() ) {
1253 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1255 anActor->GetScalarBarActor() &&
1256 anActor->GetControlMode() != SMESH_Actor::eNone )
1258 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1259 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1260 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1262 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1263 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1270 #ifndef DISABLE_PLOT2DVIEWER
1271 void PlotDistribution()
1273 SalomeApp_Application* app =
1274 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1278 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1279 SALOME_ListIO selected;
1281 aSel->selectedObjects( selected );
1283 if ( selected.Extent() == 1 ) {
1284 Handle(SALOME_InteractiveObject) anIO = selected.First();
1285 if ( anIO->hasEntry() ) {
1286 //Find Actor by entry before getting Plot2d viewer,
1287 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1288 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1290 SUIT_ViewManager* aViewManager =
1291 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1295 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1299 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1303 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1305 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1306 QString functorName = functorToString( anActor->GetFunctor());
1307 QString aHistogramName("%1 : %2");
1308 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1309 aHistogram->setName(aHistogramName);
1310 aHistogram->setHorTitle(functorName);
1311 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1312 aPlot->displayObject(aHistogram, true);
1317 #endif //DISABLE_PLOT2DVIEWER
1319 void DisableAutoColor()
1321 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1322 SALOME_ListIO selected;
1324 aSel->selectedObjects( selected );
1326 if ( selected.Extent() ) {
1327 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1328 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1329 if ( !aMesh->_is_nil() ) {
1330 aMesh->SetAutoColor( false );
1337 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1338 SALOME_ListIO selected;
1340 aSel->selectedObjects( selected );
1341 if ( selected.Extent() )
1343 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1344 _PTR(Study) aStudy = SMESH::getStudy();
1345 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1347 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1348 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1355 // Break link with Shaper model
1356 void breakShaperLink()
1358 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1359 SALOME_ListIO selected;
1361 aSel->selectedObjects(selected);
1362 if (selected.Extent()) {
1363 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1364 _PTR(Study) aStudy = SMESH::getStudy();
1365 std::string aEntry = anIObject->getEntry();
1366 _PTR(SObject) aSObj = aStudy->FindObjectID(aEntry);
1368 std::string aName = aSObj->GetName();
1369 QMessageBox::StandardButton aRes = SUIT_MessageBox::warning(SMESHGUI::desktop(),
1370 QObject::tr("SMESH_WRN_WARNING"),
1371 QObject::tr("MSG_BREAK_SHAPER_LINK").arg(aName.c_str()),
1372 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No);
1373 if (aRes == SUIT_MessageBox::Yes) {
1374 SUIT_DataOwnerPtrList aList;
1375 aSel->selected(aList, "ObjectBrowser", true);
1376 SUIT_DataOwner* aOwn = aList.first();
1377 LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>(aOwn);
1378 QString aREntry = sowner->entry();
1380 static GEOM::GEOM_Gen_var geomGen;
1381 if (CORBA::is_nil(geomGen)) {
1382 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
1383 (SUIT_Session::session()->activeApplication());
1385 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
1386 Engines::EngineComponent_var comp =
1387 ls->FindOrLoad_Component("FactoryServer", "SHAPERSTUDY");
1388 geomGen = GEOM::GEOM_Gen::_narrow(comp);
1391 if (!CORBA::is_nil(geomGen))
1393 geomGen->BreakLink(aREntry.toStdString().c_str());
1394 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1396 // remove actors whose objects are removed by BreakLink()
1397 QList<SUIT_ViewWindow*> wndList = SMESHGUI::desktop()->windows();
1398 SUIT_ViewWindow* wnd;
1399 foreach(wnd, wndList)
1400 SMESH::UpdateActorsAfterUpdateStudy(wnd);
1408 //================================================================================
1410 * \brief Return true if a mesh icon == ICON_SMESH_TREE_GEOM_MODIF
1411 * which means that the mesh can't be modified. It should be either re-computed
1412 * or breakShaperLink()'ed. Warn the user about it.
1414 //================================================================================
1416 bool warnOnGeomModif()
1418 SALOME_ListIO selected;
1419 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1420 aSel->selectedObjects(selected,"",/*convertReferences=*/false);
1422 SALOME_ListIteratorOfListIO It( selected );
1423 for ( ; It.More(); It.Next() )
1425 Handle(SALOME_InteractiveObject) io = It.Value();
1426 if ( !io->hasEntry() ) continue;
1427 _PTR(SObject) so = SMESH::getStudy()->FindObjectID( io->getEntry() );
1428 SMESH::SMESH_Mesh_var mesh;
1429 while ( mesh->_is_nil() && so && so->GetID() != "0:" )
1431 CORBA::Object_var obj = SMESH::SObjectToObject( so );
1432 SMESH::SMESH_IDSource_var isrc = SMESH::SMESH_IDSource::_narrow( obj );
1433 if ( isrc->_is_nil() )
1434 so = so->GetFather();
1436 mesh = isrc->GetMesh();
1438 if ( mesh->_is_nil() ) continue;
1439 so = SMESH::FindSObject( mesh );
1440 if ( !so ) continue;
1441 _PTR(GenericAttribute) attr;
1442 so->FindAttribute( attr, "AttributePixMap" );
1443 _PTR(AttributePixMap) pixmap = attr;
1444 if ( !pixmap ) continue;
1446 if ( pixmap->GetPixMap() == "ICON_SMESH_TREE_GEOM_MODIF" )
1448 SUIT_MessageBox::warning(SMESHGUI::desktop(),
1449 QObject::tr("SMESH_WRN_WARNING"),
1450 QObject::tr("MSG_WARN_ON_GEOM_MODIF"));
1457 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap)
1459 SALOME_ListIO selected;
1460 SalomeApp_Application* app =
1461 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1465 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1466 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1467 if ( !aSel || !appStudy )
1470 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1471 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1472 aModule->EmitSignalDeactivateDialog();
1473 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1474 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1479 aSel->selectedObjects( selected );
1481 if ( selected.Extent() >= 1 )
1483 switch ( theCommandID ) {
1484 case SMESHOp::OpTransparency:
1486 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1487 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1490 case SMESHOp::OpProperties:
1493 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1494 QColor orientationColor, outlineColor, volumeColor;
1495 int deltaF = 0, deltaV = 0;
1498 double ballScale = 1.0;
1500 int outlineWidth = 1;
1501 double shrinkCoef = 0.0;
1502 double orientationScale = 0.0;
1503 bool orientation3d = false;
1504 VTK::MarkerType markerType = VTK::MT_NONE;
1505 VTK::MarkerScale markerScale = VTK::MS_NONE;
1507 bool hasNodes = false;
1508 int presentEntities = 0;
1509 bool firstTime = true;
1511 SALOME_ListIteratorOfListIO It( selected );
1512 for ( ; It.More(); It.Next() ) {
1513 Handle(SALOME_InteractiveObject) IObject = It.Value();
1514 if ( !IObject->hasEntry() ) continue;
1515 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1516 if ( !anActor || !anActor->GetObject() ) continue;
1519 // nodes: color, marker
1520 anActor->GetNodeColor( color[0], color[1], color[2] );
1521 nodeColor.setRgbF( color[0], color[1], color[2] );
1522 markerType = anActor->GetMarkerType();
1523 markerScale = anActor->GetMarkerScale();
1524 markerId = anActor->GetMarkerTexture();
1525 // edges: color, width
1526 anActor->GetEdgeColor( color[0], color[1], color[2] );
1527 edgeColor.setRgbF( color[0], color[1], color[2] );
1528 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1529 // faces: front color, back color (delta)
1530 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1531 faceColor.setRgbF( color[0], color[1], color[2] );
1532 // faces: front color, back color (delta)
1533 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1534 volumeColor.setRgbF( color[0], color[1], color[2] );
1535 // 0d elements: color, size
1536 anActor->Get0DColor( color[0], color[1], color[2] );
1537 elem0dColor.setRgbF( color[0], color[1], color[2] );
1538 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1539 // balls: color, size
1540 anActor->GetBallColor( color[0], color[1], color[2] );
1541 ballColor.setRgbF( color[0], color[1], color[2] );
1542 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1543 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1545 anActor->GetOutlineColor( color[0], color[1], color[2] );
1546 outlineColor.setRgbF( color[0], color[1], color[2] );
1547 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1548 // orientation vectors: color, scale, 3d flag
1549 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1550 orientationColor.setRgbF( color[0], color[1], color[2] );
1551 orientationScale = anActor->GetFacesOrientationScale();
1552 orientation3d = anActor->GetFacesOrientation3DVectors();
1554 shrinkCoef = anActor->GetShrinkFactor();
1557 firstTime = false; // we only take properties from first object (for performance reasons)
1560 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1561 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1562 presentEntities = presentEntities | SMESH_Actor::eEdges;
1563 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1564 presentEntities = presentEntities | SMESH_Actor::eFaces;
1565 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1566 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1567 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1568 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1569 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1570 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1572 // as we know that all types of elements are present, we can exit the loop
1573 if ( presentEntities == SMESH_Actor::eAllEntity )
1577 SMESHGUI_PropertiesDlg dlg( theMarkerMap, SMESHGUI::desktop() );
1578 // nodes: color, marker
1579 dlg.setNodeColor( nodeColor );
1580 if( markerType != VTK::MT_USER )
1581 dlg.setNodeMarker( markerType, markerScale );
1583 dlg.setNodeCustomMarker( markerId );
1584 // edges: color, line width
1585 dlg.setEdgeColor( edgeColor );
1586 dlg.setEdgeWidth( edgeWidth );
1587 // faces: front color, back color
1588 dlg.setFaceColor( faceColor, deltaF );
1589 // volumes: normal color, reversed color
1590 dlg.setVolumeColor( volumeColor, deltaV );
1591 // outlines: color, line width
1592 dlg.setOutlineColor( outlineColor );
1593 dlg.setOutlineWidth( outlineWidth );
1594 // 0d elements: color, size
1595 dlg.setElem0dColor( elem0dColor );
1596 dlg.setElem0dSize( elem0dSize );
1597 // balls: color, size
1598 dlg.setBallColor( ballColor );
1599 //dlg.setBallSize( ballSize );
1600 dlg.setBallScale( ballScale );
1601 // orientation: color, scale, 3d flag
1602 dlg.setOrientationColor( orientationColor );
1603 dlg.setOrientationSize( int( orientationScale * 100. ) );
1604 dlg.setOrientation3d( orientation3d );
1605 // shrink: scale factor
1606 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1607 // hide unused controls
1608 dlg.showControls( presentEntities, hasNodes );
1611 nodeColor = dlg.nodeColor();
1612 markerType = dlg.nodeMarkerType();
1613 markerScale = dlg.nodeMarkerScale();
1614 markerId = dlg.nodeMarkerId();
1615 edgeColor = dlg.edgeColor();
1616 edgeWidth = dlg.edgeWidth();
1617 faceColor = dlg.faceColor();
1618 deltaF = dlg.faceColorDelta();
1619 volumeColor = dlg.volumeColor();
1620 deltaV = dlg.volumeColorDelta();
1621 outlineColor = dlg.outlineColor();
1622 outlineWidth = dlg.outlineWidth();
1623 elem0dColor = dlg.elem0dColor();
1624 elem0dSize = dlg.elem0dSize();
1625 ballColor = dlg.ballColor();
1626 // ballSize = dlg.ballSize();
1627 ballScale = dlg.ballScale();
1628 orientationColor = dlg.orientationColor();
1629 orientationScale = dlg.orientationSize() / 100.;
1630 orientation3d = dlg.orientation3d();
1631 shrinkCoef = dlg.shrinkCoef() / 100.;
1633 // store point markers that might be changed by the user
1634 theMarkerMap = dlg.customMarkers();
1636 // set properties from dialog box to the presentations
1637 SALOME_ListIteratorOfListIO It( selected );
1638 for ( ; It.More(); It.Next() ) {
1639 Handle(SALOME_InteractiveObject) IObject = It.Value();
1640 if ( !IObject->hasEntry() ) continue;
1641 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1642 if ( !anActor ) continue;
1644 // nodes: color, marker
1645 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1646 if ( markerType != VTK::MT_USER ) {
1647 anActor->SetMarkerStd( markerType, markerScale );
1650 VTK::MarkerMap::const_iterator iter = theMarkerMap.find( markerId );
1651 if ( iter != theMarkerMap.end() )
1652 anActor->SetMarkerTexture( markerId, iter->second.second );
1654 // volumes: normal color, reversed color (delta)
1655 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1656 // faces: front color, back color (delta)
1657 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1658 // edges: color, width
1659 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1660 anActor->SetLineWidth( edgeWidth );
1662 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1663 anActor->SetOutlineWidth( outlineWidth );
1664 // 0D elements: color, size
1665 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1666 anActor->Set0DSize( elem0dSize );
1667 // balls: color, size
1668 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1669 // anActor->SetBallSize( ballSize );
1670 anActor->SetBallScale( ballScale );
1671 // orientation: color, scale, 3d flag
1672 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1673 anActor->SetFacesOrientationScale( orientationScale );
1674 anActor->SetFacesOrientation3DVectors( orientation3d );
1676 anActor->SetShrinkFactor( shrinkCoef );
1678 // for groups, set also proper color
1679 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1680 if ( !aGroupObject->_is_nil() ) {
1681 SMESH::ElementType anElementType = aGroupObject->GetType();
1683 switch( anElementType ) {
1685 aColor = nodeColor; break;
1687 aColor = edgeColor; break;
1689 aColor = faceColor; break;
1691 aColor = volumeColor; break;
1693 aColor = elem0dColor; break;
1695 aColor = ballColor; break;
1699 if ( aColor.isValid() ) {
1700 SALOMEDS::Color aGroupColor;
1701 aGroupColor.R = aColor.redF();
1702 aGroupColor.G = aColor.greenF();
1703 aGroupColor.B = aColor.blueF();
1704 aGroupObject->SetColor( aGroupColor );
1706 } // if ( !aGroupObject->_is_nil() )
1707 } // for ( ; It.More(); It.Next() )
1708 SMESH::RepaintCurrentView();
1709 } // if ( dlg.exec() )
1711 } // case SMESHOp::OpProperties:
1712 } // switch(theCommandID)
1713 SUIT_OverrideCursor wc;
1714 SALOME_ListIteratorOfListIO It( selected );
1715 for( ; It.More(); It.Next()){
1716 Handle(SALOME_InteractiveObject) IObject = It.Value();
1717 if(IObject->hasEntry()){
1718 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1719 switch(theCommandID){
1720 case SMESHOp::OpDMWireframe:
1721 anActor->SetRepresentation(SMESH_Actor::eEdge);
1723 case SMESHOp::OpDMShading:
1724 anActor->SetRepresentation(SMESH_Actor::eSurface);
1726 case SMESHOp::OpDMShrink:
1727 if(anActor->IsShrunk())
1728 anActor->UnShrink();
1730 anActor->SetShrink();
1732 case SMESHOp::OpDMNodes:
1733 anActor->SetRepresentation(SMESH_Actor::ePoint);
1735 case SMESHOp::OpRepresentationLines:
1736 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1737 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1739 case SMESHOp::OpRepresentationArcs:
1740 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1741 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1747 SMESH::RepaintCurrentView();
1751 int ActionToControl( int theID, bool theReversed )
1753 NCollection_DoubleMap<int,int> ActionControl;
1754 ActionControl.Bind( 0, SMESH_Actor::eNone );
1755 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1756 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1757 ActionControl.Bind( SMESHOp::OpNodeConnectivityNb, SMESH_Actor::eNodeConnectivityNb );
1758 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1759 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1760 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1761 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1762 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1763 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1764 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1765 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1766 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1767 ActionControl.Bind( SMESHOp::OpDeflection2D, SMESH_Actor::eDeflection2D );
1768 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1769 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1770 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1771 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1772 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1773 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1774 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1775 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1776 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1777 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1778 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1779 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1780 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1781 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1782 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1785 return ActionControl.IsBound2( theID ) ? ActionControl.Find2( theID ) : 0;
1786 return ActionControl.IsBound1( theID ) ? ActionControl.Find1( theID ) : 0;
1789 void Control( int theCommandID )
1791 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1792 _PTR(Study) aStudy = SMESH::getStudy();
1794 SALOME_ListIO selected;
1795 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1796 aSel->selectedObjects( selected );
1798 if ( !selected.IsEmpty() ) {
1799 SALOME_ListIteratorOfListIO It(selected);
1800 for ( ; It.More(); It.Next())
1802 Handle(SALOME_InteractiveObject) anIO = It.Value();
1803 if ( !anIO.IsNull() ) {
1804 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1806 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1807 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1808 if ( !anIDSrc->_is_nil() ) {
1809 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1810 if (( !anActor && selected.Extent() == 1 ) &&
1811 ( anActor = SMESH::CreateActor( anIO->getEntry() )))
1813 anActor->SetControlMode( aControl );
1814 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1815 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1819 if ( anActor->GetControlMode() != aControl )
1820 anActor->SetControlMode( aControl );
1821 QString functorName = functorToString( anActor->GetFunctor() );
1822 smIdType anEntitiesCount = anActor->GetNumberControlEntities();
1823 if (anEntitiesCount >= 0)
1824 functorName = functorName + ": " + QString::number(anEntitiesCount);
1825 anActor->GetScalarBarActor()->SetTitle( functorName.toUtf8().constData() );
1826 SMESH::RepaintCurrentView();
1827 #ifndef DISABLE_PLOT2DVIEWER
1828 if ( anActor->GetPlot2Histogram() ) {
1829 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1830 QString aHistogramName("%1 : %2");
1831 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1832 aHistogram->setName( aHistogramName );
1833 aHistogram->setHorTitle( functorName );
1834 SMESH::ProcessIn2DViewers( anActor );
1846 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1847 SMESH::MeshObjectType theType,
1848 const QString theInTypeName,
1849 QString & theOutTypeName)
1851 SMESH_TypeFilter aTypeFilter( theType );
1853 if ( !theIO.IsNull() )
1855 entry = theIO->getEntry();
1856 LightApp_DataOwner owner( entry );
1857 if ( aTypeFilter.isOk( &owner )) {
1858 theOutTypeName = theInTypeName;
1866 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1868 _PTR(Study) aStudy = SMESH::getStudy();
1869 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1871 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1872 CORBA::String_var anID = aSComp->GetID().c_str();
1873 if ( !strcmp(anID.in(),theIO->getEntry()) )
1879 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1880 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1881 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1882 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1883 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1891 // QString CheckHomogeneousSelection()
1893 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1894 // SALOME_ListIO selected;
1896 // aSel->selectedObjects( selected );
1898 // QString RefType = CheckTypeObject(selected.First());
1899 // SALOME_ListIteratorOfListIO It(selected);
1900 // for ( ; It.More(); It.Next())
1902 // Handle(SALOME_InteractiveObject) IObject = It.Value();
1903 // QString Type = CheckTypeObject(IObject);
1904 // if ( Type.compare(RefType) != 0 )
1905 // return "Heterogeneous Selection";
1911 uint randomize( uint size )
1913 static bool initialized = false;
1914 if ( !initialized ) {
1915 qsrand( QDateTime::currentDateTime().toTime_t() );
1919 v = uint( (double)( v ) / RAND_MAX * size );
1920 v = qMax( uint(0), qMin ( v, size-1 ) );
1926 void SMESHGUI::OnEditDelete()
1928 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1929 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1930 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1932 _PTR(Study) aStudy = SMESH::getStudy();
1933 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1934 _PTR(GenericAttribute) anAttr;
1935 _PTR(AttributeIOR) anIOR;
1937 const int objectCountLimit = 30; // PAL23599
1938 int objectCount = 0;
1940 QString aParentComponent = QString::null;
1942 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1944 Handle(SALOME_InteractiveObject) anIO = anIt.Value();
1945 if ( anIO.IsNull() ) continue;
1947 QString father = "unknown", name;
1949 _PTR(SObject) aSO = aStudy->FindObjectID( anIO->getEntry() );
1951 father = QString::fromStdString( aSO->GetFatherComponent()->ComponentDataType() );
1952 // check if object is reference
1953 _PTR(SObject) aRefSObj;
1954 if ( aSO->ReferencedObject( aRefSObj ) ) {
1955 name = QString::fromStdString ( aRefSObj->GetName() );
1956 father = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1959 name = anIO->getName();
1962 if ( objectCount < objectCountLimit ) { // avoid occupying the whole screen
1963 aNameList.append("\n - ");
1964 aNameList.append( name );
1967 if( aParentComponent.isNull() )
1968 aParentComponent = father;
1969 else if( !aParentComponent.isEmpty() && aParentComponent!=father )
1970 aParentComponent = "";
1972 if ( objectCount >= objectCountLimit )
1973 aNameList.append("\n - ...");
1975 if ( objectCount == 0 )
1976 return; // No Valid Objects Selected
1978 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1979 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1980 QObject::tr("ERR_ERROR"),
1981 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1984 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1985 if (SUIT_MessageBox::warning
1986 (SMESHGUI::desktop(),
1987 QObject::tr("SMESH_WRN_WARNING"),
1988 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1989 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1990 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1993 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1995 // Put one level of sub-objects of the selected SO's into a list
1996 // in order to get objects inside folders like "Assigned Algorithms"
1997 std::list< _PTR(SObject) > listSO;
1998 SALOME_ListIteratorOfListIO It(selected);
1999 for( ; It.More(); It.Next()) // loop on selected IO's
2001 Handle(SALOME_InteractiveObject) IObject = It.Value();
2002 if(IObject->hasEntry()) {
2003 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
2005 // disable removal of "SMESH" component object
2006 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
2008 if ( engineIOR() == anIOR->Value().c_str() )
2011 //Check the referenced object
2012 _PTR(SObject) aRefSObject;
2013 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
2014 aSO = aRefSObject; // Delete main Object instead of reference
2016 listSO.push_back( aSO );
2018 _PTR(ChildIterator) it = aStudy->NewChildIterator( aSO );
2019 for (it->InitEx(false); it->More(); it->Next())
2020 listSO.push_back( it->Value() );
2023 // Check if none of objects to delete is referred from outside
2024 std::list< _PTR(SObject) >::reverse_iterator ritSO;
2025 std::vector< _PTR(SObject) > subSO;
2026 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2028 _PTR(SObject) SO = *ritSO;
2029 if ( !SO ) continue;
2031 int nbChildren = SO->GetLastChildTag();
2033 subSO.reserve( 1 + nbChildren );
2034 subSO.push_back( SO );
2035 if ( nbChildren > 0 )
2037 _PTR(ChildIterator) it = aStudy->NewChildIterator( SO );
2038 for ( it->InitEx( true ); it->More(); it->Next() )
2039 subSO.push_back( it->Value() );
2041 for ( size_t i = 0; i < subSO.size(); ++i )
2043 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( subSO[i] );
2044 for ( size_t j = 0; j < aReferences.size(); j++ ) {
2045 _PTR(SComponent) aComponent = aReferences[j]->GetFatherComponent();
2046 std::string type = aComponent->ComponentDataType();
2047 if ( type != "SMESH" )
2049 SUIT_MessageBox::warning( anApp->desktop(),
2050 QObject::tr("WRN_WARNING"),
2051 QObject::tr("DEP_OBJECT") );
2052 return; // outside SMESH, there is an object depending on a SMESH object
2058 // Treat SO's in the list starting from the back
2059 aStudyBuilder->NewCommand(); // There is a transaction
2060 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2062 _PTR(SObject) SO = *ritSO;
2063 if ( !SO ) continue;
2064 std::string anEntry = SO->GetID();
2066 /** Erase graphical object and remove all its data **/
2067 if ( SO->FindAttribute( anAttr, "AttributeIOR" )) {
2068 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
2070 /** Remove an object from data structures **/
2071 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
2072 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
2073 if ( !aGroup->_is_nil() ) { // DELETE GROUP
2074 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
2075 aMesh->RemoveGroup( aGroup );
2077 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
2078 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2079 aMesh->RemoveSubMesh( aSubMesh );
2082 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
2083 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
2084 QString objType = CheckTypeObject(IObject);
2085 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
2086 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2087 aStudyBuilder->RemoveObjectWithChildren( SO );
2089 else {// default action: remove SObject from the study
2090 // Find Sub-Meshes and Group and delete corresopning visual objects and actors
2091 _PTR(ChildIterator) it1 = aStudy->NewChildIterator(SO);
2092 for (it1->InitEx(false); it1->More(); it1->Next()) {
2093 _PTR(SObject) SObj = it1->Value();
2094 if (!SObj) continue;
2095 if (SObj->FindAttribute(anAttr, "AttributeIOR")) {
2096 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(SMESH::SObjectToObject(SObj));
2097 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(SMESH::SObjectToObject(SObj));
2098 if (!aGroup->_is_nil() || !aSubMesh->_is_nil()) {
2099 SMESH::RemoveVisualObjectWithActors(SObj->GetID().c_str(), true);
2103 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
2104 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
2106 aStudyBuilder->RemoveObjectWithChildren( SO );
2110 } /* listSO back loop */
2112 aStudyBuilder->CommitCommand();
2114 /* Clear any previous selection */
2116 aSel->setSelectedObjects( l1 );
2118 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
2122 SMESHGUI_EXPORT CAM_Module* createModule()
2124 return new SMESHGUI();
2127 SMESHGUI_EXPORT char* getModuleVersion() {
2128 return (char*)SMESH_VERSION_STR;
2132 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
2134 //=============================================================================
2138 //=============================================================================
2139 SMESHGUI::SMESHGUI() : SalomeApp_Module( "SMESH" )
2141 if ( CORBA::is_nil( myComponentSMESH ) )
2143 CORBA::Boolean anIsEmbeddedMode;
2144 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
2146 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2148 // 0019923: EDF 765 SMESH : default values of hypothesis
2149 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2150 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2151 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2152 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2153 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2155 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2156 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2157 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2159 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2160 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2164 myActiveDialogBox = 0;
2165 myFilterLibraryDlg = 0;
2169 myEventCallbackCommand = vtkCallbackCommand::New();
2170 myEventCallbackCommand->Delete();
2171 myEventCallbackCommand->SetClientData( this );
2172 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2175 /* load resources for all available meshers */
2176 SMESH::InitAvailableHypotheses();
2179 //=============================================================================
2183 //=============================================================================
2184 SMESHGUI::~SMESHGUI()
2188 //=============================================================================
2192 //=============================================================================
2193 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2195 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2197 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2202 //=============================================================================
2206 //=============================================================================
2207 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2209 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2213 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2214 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2215 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2216 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2217 return autoUpdate && !exceeded;
2220 //=============================================================================
2224 //=============================================================================
2225 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2226 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2228 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2232 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2233 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2234 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2236 SMESH::smIdType_array_var info = theMesh->GetMeshInfo();
2237 long nbOdElems = info[SMDSEntity_0D];
2238 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2239 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2240 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2241 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2242 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2243 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2244 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2245 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
2246 info[SMDSEntity_Polyhedra] +
2247 info[SMDSEntity_Hexagonal_Prism];
2248 long nbBalls = info[SMDSEntity_Ball];
2250 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2251 *nbElements = requestedSize;
2253 *entities = SMESH_Actor::eAllEntity;
2256 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2258 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2260 if ( incrementalLimit ) {
2263 if ( nbOdElems > 0 ) {
2264 if ( total + nbOdElems > updateLimit ) {
2265 *entities = *entities & ~SMESH_Actor::e0DElements;
2266 *hidden = *hidden | SMESH_Actor::e0DElements;
2273 if ( nbEdges > 0 ) {
2274 if ( total + nbEdges > updateLimit ) {
2275 *entities = *entities & ~SMESH_Actor::eEdges;
2276 *hidden = *hidden | SMESH_Actor::eEdges;
2283 if ( nbFaces > 0 ) {
2284 if ( total + nbFaces > updateLimit ) {
2285 *entities = *entities & ~SMESH_Actor::eFaces;
2286 *hidden = *hidden | SMESH_Actor::eFaces;
2293 if ( nbVolumes > 0 ) {
2294 if ( total + nbVolumes > updateLimit ) {
2295 *entities = *entities & ~SMESH_Actor::eVolumes;
2296 *hidden = *hidden | SMESH_Actor::eVolumes;
2303 if ( nbBalls > 0 ) {
2304 if ( total + nbBalls > updateLimit ) {
2305 *entities = *entities & ~SMESH_Actor::eBallElem;
2306 *hidden = *hidden | SMESH_Actor::eBallElem;
2314 return autoUpdate && !exceeded;
2317 //=============================================================================
2321 //=============================================================================
2322 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2324 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2327 //=============================================================================
2331 //=============================================================================
2332 SMESHGUI* SMESHGUI::GetSMESHGUI()
2334 SMESHGUI* smeshMod = 0;
2335 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2338 CAM_Module* module = app->module( "Mesh" );
2339 smeshMod = dynamic_cast<SMESHGUI*>( module );
2347 Standard_EXPORT SMESHGUI* GetComponentGUI()
2349 return SMESHGUI::GetSMESHGUI();
2353 //=============================================================================
2357 //=============================================================================
2358 void SMESHGUI::SetState(int aState)
2363 //=============================================================================
2367 //=============================================================================
2368 void SMESHGUI::ResetState()
2373 //=============================================================================
2377 //=============================================================================
2378 void SMESHGUI::EmitSignalDeactivateDialog()
2380 emit SignalDeactivateActiveDialog();
2383 //=============================================================================
2387 //=============================================================================
2388 void SMESHGUI::EmitSignalStudyFrameChanged()
2390 emit SignalStudyFrameChanged();
2393 //=============================================================================
2397 //=============================================================================
2398 void SMESHGUI::EmitSignalCloseAllDialogs()
2400 emit SignalCloseAllDialogs();
2403 //=============================================================================
2407 //=============================================================================
2408 void SMESHGUI::EmitSignalVisibilityChanged()
2410 emit SignalVisibilityChanged();
2413 //=============================================================================
2417 //=============================================================================
2418 void SMESHGUI::EmitSignalCloseView()
2420 emit SignalCloseView();
2423 //=============================================================================
2427 //=============================================================================
2428 void SMESHGUI::EmitSignalActivatedViewManager()
2430 emit SignalActivatedViewManager();
2433 //=============================================================================
2437 //=============================================================================
2438 QDialog *SMESHGUI::GetActiveDialogBox()
2440 return myActiveDialogBox;
2443 //=============================================================================
2447 //=============================================================================
2448 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2450 myActiveDialogBox = (QDialog *) aDlg;
2454 //=============================================================================
2458 //=============================================================================
2459 SUIT_Desktop* SMESHGUI::desktop()
2461 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2463 return app->desktop();
2468 //=============================================================================
2472 //=============================================================================
2473 SalomeApp_Study* SMESHGUI::activeStudy()
2475 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2477 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2482 //=============================================================================
2486 //=============================================================================
2487 void SMESHGUI::Modified( bool theIsUpdateActions )
2489 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2490 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2491 appStudy->Modified();
2492 if( theIsUpdateActions )
2493 app->updateActions();
2498 //=============================================================================
2502 //=============================================================================
2503 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2505 /* Here the position is on the bottom right corner - 10 */
2506 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2508 SUIT_Desktop *PP = desktop();
2509 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2510 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2515 * \brief Verifies whether study of operation is locked
2516 * \param theMess - specifies whether message box must be shown if study is locked
2517 * \return State of study.
2519 * Verifies whether study of operation is locked. If second parameter is TRUE and study
2520 * is locked when corresponding message box appears
2522 bool SMESHGUI::isStudyLocked( bool theMessage )
2524 if ( SMESH::getStudy()->GetProperties()->IsLocked() )
2527 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2528 QObject::tr( "WRN_WARNING" ),
2529 QObject::tr( "WRN_STUDY_LOCKED" ) );
2535 //=============================================================================
2539 //=============================================================================
2540 bool SMESHGUI::OnGUIEvent( int theCommandID )
2542 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2546 SUIT_ResourceMgr* mgr = resourceMgr();
2550 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2551 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2553 //QAction* act = action( theCommandID );
2555 switch (theCommandID) {
2556 case SMESHOp::OpDelete:
2557 if(isStudyLocked()) break;
2560 case SMESHOp::OpImportDAT:
2561 case SMESHOp::OpImportUNV:
2562 case SMESHOp::OpImportMED:
2563 case SMESHOp::OpImportSTL:
2564 case SMESHOp::OpImportCGNS:
2565 case SMESHOp::OpImportGMF:
2566 case SMESHOp::OpPopupImportDAT:
2567 case SMESHOp::OpPopupImportUNV:
2568 case SMESHOp::OpPopupImportMED:
2569 case SMESHOp::OpPopupImportSTL:
2570 case SMESHOp::OpPopupImportCGNS:
2571 case SMESHOp::OpPopupImportGMF:
2573 if(isStudyLocked()) break;
2574 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2578 case SMESHOp::OpFileInformation:
2580 SALOME_ListIO selected;
2581 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2583 aSel->selectedObjects( selected );
2584 if( selected.Extent() )
2586 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2587 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2588 if ( !aMesh->_is_nil() )
2590 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2596 case SMESHOp::OpExportDAT:
2597 case SMESHOp::OpExportMED:
2598 case SMESHOp::OpExportUNV:
2599 case SMESHOp::OpExportSTL:
2600 case SMESHOp::OpExportCGNS:
2601 case SMESHOp::OpExportGMF:
2602 case SMESHOp::OpPopupExportDAT:
2603 case SMESHOp::OpPopupExportMED:
2604 case SMESHOp::OpPopupExportUNV:
2605 case SMESHOp::OpPopupExportSTL:
2606 case SMESHOp::OpPopupExportCGNS:
2607 case SMESHOp::OpPopupExportGMF:
2609 ::ExportMeshToFile(theCommandID);
2613 case SMESHOp::OpReset: // SCALAR BAR
2615 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2616 SALOME_ListIO selected;
2618 aSel->selectedObjects( selected );
2620 SALOME_ListIteratorOfListIO it(selected);
2621 for( ; it.More(); it.Next()) {
2622 Handle(SALOME_InteractiveObject) anIO = it.Value();
2623 if( anIO->hasEntry() ) {
2624 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2625 anActor->SetControlMode( SMESH_Actor::eNone );
2626 #ifndef DISABLE_PLOT2DVIEWER
2627 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2629 anActor->UpdateFilter();
2633 SMESH::UpdateView();
2636 case SMESHOp::OpScalarBarProperties:
2638 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2641 case SMESHOp::OpShowScalarBar:
2643 // show/hide scalar bar
2644 ::ShowElement(theCommandID);
2647 case SMESHOp::OpSaveDistribution:
2649 // dump control distribution data to the text file
2650 ::SaveDistribution();
2654 case SMESHOp::OpShowDistribution:
2656 // show/hide distribution
2657 ::ShowElement(theCommandID);
2661 #ifndef DISABLE_PLOT2DVIEWER
2662 case SMESHOp::OpPlotDistribution:
2664 // plot distribution
2665 ::PlotDistribution();
2671 case SMESHOp::OpAutoColor:
2675 case SMESHOp::OpDisableAutoColor:
2676 ::DisableAutoColor();
2679 case SMESHOp::OpClipping:
2680 case SMESHOp::OpTransparency:
2681 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2684 case SMESHOp::OpDMWireframe:
2685 case SMESHOp::OpDMShading:
2686 case SMESHOp::OpDMNodes:
2687 case SMESHOp::OpDMShrink:
2688 ::SetDisplayMode(theCommandID, myMarkerMap);
2691 //2D quadratic representation
2692 case SMESHOp::OpRepresentationLines:
2693 case SMESHOp::OpRepresentationArcs:
2694 ::SetDisplayMode(theCommandID, myMarkerMap);
2698 case SMESHOp::OpDE0DElements:
2699 case SMESHOp::OpDEEdges:
2700 case SMESHOp::OpDEFaces:
2701 case SMESHOp::OpDEVolumes:
2702 case SMESHOp::OpDEBalls:
2703 case SMESHOp::OpDEAllEntity:
2704 ::SetDisplayEntity(theCommandID);
2707 // Choose entities to be displayed
2708 case SMESHOp::OpDEChoose:
2710 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2714 case SMESHOp::OpOrientationOnFaces:
2716 SUIT_OverrideCursor wc;
2717 LightApp_SelectionMgr* mgr = selectionMgr();
2718 SALOME_ListIO selected; mgr->selectedObjects( selected );
2720 SALOME_ListIteratorOfListIO it(selected);
2721 for( ; it.More(); it.Next()) {
2722 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2723 if(anIObject->hasEntry()) {
2724 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2725 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2732 case SMESHOp::OpUpdate:
2734 if(isStudyLocked()) break;
2735 SUIT_OverrideCursor wc;
2738 SMESH::UpdateView();
2740 catch (std::bad_alloc&) { // PAL16774 (Crash after display of many groups)
2741 SMESH::OnVisuException();
2743 catch (...) { // PAL16774 (Crash after display of many groups)
2744 SMESH::OnVisuException();
2748 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2749 aSel->selectedObjects( l );
2750 aSel->setSelectedObjects( l );
2754 case SMESHOp::OpHide:
2755 case SMESHOp::OpShow:
2756 case SMESHOp::OpShowOnly:
2758 SUIT_OverrideCursor wc;
2759 SMESH::EDisplaing anAction;
2760 switch (theCommandID) {
2761 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2762 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2763 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2766 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2767 SALOME_ListIO sel_objects, to_process;
2769 aSel->selectedObjects( sel_objects );
2771 if ( theCommandID==SMESHOp::OpShowOnly )
2773 //MESSAGE("anAction = SMESH::eDisplayOnly");
2774 startOperation( myEraseAll );
2777 extractContainers( sel_objects, to_process );
2782 SALOME_ListIteratorOfListIO It( to_process );
2783 for ( ; It.More(); It.Next())
2785 Handle(SALOME_InteractiveObject) IOS = It.Value();
2786 if ( IOS->hasEntry() )
2788 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2789 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2790 break; // PAL16774 (Crash after display of many groups)
2792 if (anAction == SMESH::eDisplayOnly)
2793 anAction = SMESH::eDisplay;
2798 // PAL13338 + PAL15161 -->
2799 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !isStudyLocked()) {
2800 SMESH::UpdateView();
2801 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2803 // PAL13338 + PAL15161 <--
2805 catch (...) { // PAL16774 (Crash after display of many groups)
2806 SMESH::OnVisuException();
2809 if (anAction == SMESH::eErase) {
2811 aSel->setSelectedObjects( l1 );
2814 aSel->setSelectedObjects( to_process );
2816 if ( vtkwnd && vtkwnd->GetRenderer() && !isStudyLocked() &&
2817 ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) )
2818 vtkwnd->GetRenderer()->AdjustActors();
2823 case SMESHOp::OpNode:
2825 if(isStudyLocked()) break;
2828 EmitSignalDeactivateDialog();
2830 ( new SMESHGUI_NodesDlg( this ) )->show();
2833 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2838 case SMESHOp::OpEditMeshOrSubMesh:
2839 case SMESHOp::OpEditMesh:
2840 case SMESHOp::OpEditSubMesh:
2841 case SMESHOp::OpMeshOrder:
2842 case SMESHOp::OpCreateSubMesh:
2843 if ( warnOnGeomModif() )
2844 break; // action forbidden as geometry modified
2846 case SMESHOp::OpCreateMesh:
2847 case SMESHOp::OpCompute:
2848 case SMESHOp::OpComputeSubMesh:
2849 case SMESHOp::OpPreCompute:
2850 case SMESHOp::OpEvaluate:
2851 case SMESHOp::OpShowErrors:
2852 startOperation( theCommandID );
2854 case SMESHOp::OpRecompute:
2856 if ( isStudyLocked() )
2858 SALOME_ListIO selected;
2859 if ( LightApp_SelectionMgr *sel = selectionMgr() )
2860 sel->selectedObjects( selected );
2861 if ( selected.Extent() == 1 ) {
2862 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( selected.First() );
2863 if ( !aMesh->_is_nil() )
2865 startOperation( SMESHOp::OpCompute );
2869 case SMESHOp::OpCopyMesh:
2871 if (isStudyLocked()) break;
2872 EmitSignalDeactivateDialog();
2873 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2876 case SMESHOp::OpBuildCompoundMesh:
2878 if (isStudyLocked()) break;
2879 EmitSignalDeactivateDialog();
2880 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2884 case SMESHOp::OpDiagonalInversion:
2885 case SMESHOp::OpUnionOfTwoTriangle:
2889 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2893 if ( isStudyLocked() )
2895 if ( warnOnGeomModif() )
2896 break; // action forbidden as geometry modified
2898 /*Standard_Boolean aRes;
2899 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2900 if ( aMesh->_is_nil() )
2902 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2903 tr( "SMESH_BAD_SELECTION" ) );
2907 EmitSignalDeactivateDialog();
2908 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2909 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2911 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2914 case SMESHOp::OpOrientation:
2915 case SMESHOp::OpUnionOfTriangles:
2916 case SMESHOp::OpCuttingOfQuadrangles:
2917 case SMESHOp::OpSplitVolumes:
2921 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2925 if ( isStudyLocked() )
2927 if ( warnOnGeomModif() )
2928 break; // action forbidden as geometry modified
2930 EmitSignalDeactivateDialog();
2931 SMESHGUI_MultiEditDlg* aDlg = NULL;
2932 if ( theCommandID == SMESHOp::OpOrientation )
2933 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2934 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2935 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2936 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2937 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2939 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2944 case SMESHOp::OpSmoothing:
2946 if(isStudyLocked()) break;
2947 if ( warnOnGeomModif() )
2948 break; // action forbidden as geometry modified
2950 EmitSignalDeactivateDialog();
2951 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2954 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2958 case SMESHOp::OpExtrusion:
2960 if (isStudyLocked()) break;
2961 if ( warnOnGeomModif() )
2962 break; // action forbidden as geometry modified
2964 EmitSignalDeactivateDialog();
2965 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2967 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2971 case SMESHOp::OpExtrusionAlongAPath:
2973 if (isStudyLocked()) break;
2974 if ( warnOnGeomModif() )
2975 break; // action forbidden as geometry modified
2977 EmitSignalDeactivateDialog();
2978 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2980 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2984 case SMESHOp::OpRevolution:
2986 if(isStudyLocked()) break;
2987 if ( warnOnGeomModif() )
2988 break; // action forbidden as geometry modified
2990 EmitSignalDeactivateDialog();
2991 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2994 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2998 case SMESHOp::OpPatternMapping:
3000 if ( isStudyLocked() )
3002 if ( warnOnGeomModif() )
3003 break; // action forbidden as geometry modified
3006 EmitSignalDeactivateDialog();
3007 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
3010 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3014 // Adaptation - begin
3015 #ifndef DISABLE_MG_ADAPT
3016 case SMESHOp::OpMGAdapt:
3018 if ( isStudyLocked() )
3020 EmitSignalDeactivateDialog();
3022 SALOME::GenericObj_wrap< SMESH::MG_ADAPT > model = GetSMESHGen()->CreateMG_ADAPT();
3023 bool isCreation = false;
3024 ( new SMESHGUI_MG_ADAPTDRIVER( this, model, isCreation ))->show();
3028 #ifndef DISABLE_HOMARD_ADAPT
3029 case SMESHOp::OpHomardAdapt:
3031 if ( isStudyLocked() )
3033 EmitSignalDeactivateDialog();
3035 SALOME::GenericObj_wrap< SMESHHOMARD::HOMARD_Gen > homardGen;
3037 homardGen = GetSMESHGen()->CreateHOMARD_ADAPT();
3039 catch ( const SALOME::SALOME_Exception& S_ex ) {
3040 SUIT_MessageBox::critical(SMESHGUI::desktop(),
3041 QObject::tr("SMESH_ERROR"),
3042 QObject::tr(S_ex.details.text.in()));
3044 if (!homardGen->_is_nil()) {
3045 SMESHGUI_HomardAdaptDlg *aDlg = new SMESHGUI_HomardAdaptDlg(homardGen);
3052 case SMESHOp::OpSplitBiQuadratic:
3053 case SMESHOp::OpConvertMeshToQuadratic:
3054 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
3055 case SMESHOp::OpReorientFaces:
3056 case SMESHOp::OpCreateGeometryGroup:
3058 if ( warnOnGeomModif() )
3059 break; // action forbidden as geometry modified
3060 startOperation( theCommandID );
3063 case SMESHOp::OpCreateGroup:
3067 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3071 if(isStudyLocked()) break;
3072 if ( warnOnGeomModif() )
3073 break; // action forbidden as geometry modified
3074 EmitSignalDeactivateDialog();
3075 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
3077 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3078 SALOME_ListIO selected;
3080 aSel->selectedObjects( selected );
3082 int nbSel = selected.Extent();
3084 // check if mesh is selected
3085 aMesh = SMESH::GetMeshByIO( selected.First() );
3087 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
3092 case SMESHOp::OpConstructGroup:
3096 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3100 if(isStudyLocked()) break;
3101 if ( warnOnGeomModif() )
3102 break; // action forbidden as geometry modified
3103 EmitSignalDeactivateDialog();
3105 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3106 SALOME_ListIO selected;
3108 aSel->selectedObjects( selected );
3110 int nbSel = selected.Extent();
3112 // check if submesh is selected
3113 Handle(SALOME_InteractiveObject) IObject = selected.First();
3114 if (IObject->hasEntry()) {
3115 _PTR(SObject) aSObj = SMESH::getStudy()->FindObjectID(IObject->getEntry());
3117 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
3118 if (!aSubMesh->_is_nil()) {
3120 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
3121 // get submesh elements list by types
3122 SMESH::smIdType_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
3123 SMESH::smIdType_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
3124 SMESH::smIdType_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
3125 SMESH::smIdType_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
3126 // create group for each type o elements
3127 QString aName = IObject->getName();
3128 QStringList anEntryList;
3129 if (aNodes->length() > 0) {
3130 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
3131 aGroup->Add(aNodes.inout());
3132 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3133 anEntryList.append( aSObject->GetID().c_str() );
3135 if (aEdges->length() > 0) {
3136 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
3137 aGroup->Add(aEdges.inout());
3138 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3139 anEntryList.append( aSObject->GetID().c_str() );
3141 if (aFaces->length() > 0) {
3142 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
3143 aGroup->Add(aFaces.inout());
3144 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3145 anEntryList.append( aSObject->GetID().c_str() );
3147 if (aVolumes->length() > 0) {
3148 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
3149 aGroup->Add(aVolumes.inout());
3150 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3151 anEntryList.append( aSObject->GetID().c_str() );
3154 anApp->browseObjects( anEntryList );
3156 catch(const SALOME::SALOME_Exception & S_ex){
3157 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3164 SUIT_MessageBox::warning(desktop(),
3165 tr("SMESH_WRN_WARNING"),
3166 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
3171 case SMESHOp::OpEditGroup:
3175 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3179 if(isStudyLocked()) break;
3180 if ( warnOnGeomModif() )
3181 break; // action forbidden as geometry modified
3182 EmitSignalDeactivateDialog();
3184 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3185 SALOME_ListIO selected;
3187 aSel->selectedObjects( selected );
3189 SALOME_ListIteratorOfListIO It (selected);
3190 int nbSelectedGroups = 0;
3191 for ( ; It.More(); It.Next() )
3193 SMESH::SMESH_GroupBase_var aGroup =
3194 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3195 if (!aGroup->_is_nil()) {
3197 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3201 if (nbSelectedGroups == 0)
3203 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3209 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3211 if(isStudyLocked()) break;
3212 if (myState == 800) {
3213 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3214 if (aDlg) aDlg->onAdd();
3219 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3221 if(isStudyLocked()) break;
3222 if (myState == 800) {
3223 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3224 if (aDlg) aDlg->onRemove();
3229 case SMESHOp::OpEditGeomGroupAsGroup:
3233 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3237 if(isStudyLocked()) break;
3238 EmitSignalDeactivateDialog();
3240 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3241 SALOME_ListIO selected;
3243 aSel->selectedObjects( selected );
3245 SALOME_ListIteratorOfListIO It (selected);
3246 for ( ; It.More(); It.Next() )
3248 SMESH::SMESH_GroupOnGeom_var aGroup =
3249 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3250 if (!aGroup->_is_nil()) {
3251 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3256 SMESH::SMESH_GroupOnFilter_var aGroup =
3257 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3258 if (!aGroup->_is_nil()) {
3259 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3267 case SMESHOp::OpUnionGroups:
3268 case SMESHOp::OpIntersectGroups:
3269 case SMESHOp::OpCutGroups:
3273 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3277 if ( isStudyLocked() )
3279 if ( warnOnGeomModif() )
3280 break; // action forbidden as geometry modified
3282 EmitSignalDeactivateDialog();
3284 SMESHGUI_GroupOpDlg* aDlg = 0;
3285 if ( theCommandID == SMESHOp::OpUnionGroups )
3286 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3287 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3288 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3290 aDlg = new SMESHGUI_CutGroupsDlg( this );
3297 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3299 if ( isStudyLocked() )
3301 if ( warnOnGeomModif() )
3302 break; // action forbidden as geometry modified
3304 EmitSignalDeactivateDialog();
3305 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3311 case SMESHOp::OpFaceGroupsByEdges: // Create face groups separated by sharp edges
3313 if ( isStudyLocked() )
3315 if ( warnOnGeomModif() )
3316 break; // action forbidden as geometry modified
3318 EmitSignalDeactivateDialog();
3319 SMESHGUI_FaceGroupsSeparatedByEdgesDlg* aDlg = new SMESHGUI_FaceGroupsSeparatedByEdgesDlg( this );
3325 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3329 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3333 if ( isStudyLocked() )
3336 EmitSignalDeactivateDialog();
3338 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3342 case SMESHOp::OpMeshInformation:
3343 case SMESHOp::OpWhatIs:
3345 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3346 EmitSignalDeactivateDialog();
3347 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3348 SALOME_ListIO selected;
3350 aSel->selectedObjects( selected );
3352 if ( selected.Extent() > 1 ) { // a dlg for each IO
3353 SALOME_ListIteratorOfListIO It( selected );
3354 for ( ; It.More(); It.Next() ) {
3355 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3356 dlg->showInfo( It.Value() );
3361 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3367 case SMESHOp::OpFindElementByPoint:
3369 startOperation( theCommandID );
3373 case SMESHOp::OpEditHypothesis:
3375 if(isStudyLocked()) break;
3376 if ( warnOnGeomModif() )
3377 break; // action forbidden as geometry modified
3379 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3380 SALOME_ListIO selected;
3382 aSel->selectedObjects( selected );
3384 int nbSel = selected.Extent();
3387 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3388 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3390 if ( !aHypothesis->_is_nil() )
3392 SMESHGUI_GenericHypothesisCreator* aCreator =
3393 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3396 // set geometry of mesh and sub-mesh to aCreator
3397 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3398 if ( selected.Extent() == 1 )
3400 QString subGeomID, meshGeomID;
3401 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3402 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3404 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3405 aCreator->setShapeEntry( subGeomID );
3406 aCreator->setMainShapeEntry( meshGeomID );
3410 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3420 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3422 if(isStudyLocked()) break;
3423 if ( warnOnGeomModif() )
3424 break; // action forbidden as geometry modified
3425 SUIT_OverrideCursor wc;
3427 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3428 SALOME_ListIO selected;
3430 aSel->selectedObjects( selected, QString::null, false );
3432 SALOME_ListIteratorOfListIO It(selected);
3433 for (int i = 0; It.More(); It.Next(), i++) {
3434 Handle(SALOME_InteractiveObject) IObject = It.Value();
3435 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3438 aSel->setSelectedObjects( l1 );
3443 case SMESHOp::OpElem0D:
3444 case SMESHOp::OpBall:
3445 case SMESHOp::OpEdge:
3446 case SMESHOp::OpTriangle:
3447 case SMESHOp::OpQuadrangle:
3448 case SMESHOp::OpPolygon:
3449 case SMESHOp::OpTetrahedron:
3450 case SMESHOp::OpHexahedron:
3451 case SMESHOp::OpPentahedron:
3452 case SMESHOp::OpPyramid:
3453 case SMESHOp::OpHexagonalPrism:
3455 if(isStudyLocked()) break;
3456 if ( warnOnGeomModif() )
3457 break; // action forbidden as geometry modified
3459 EmitSignalDeactivateDialog();
3460 SMDSAbs_EntityType type = SMDSEntity_Edge;
3461 switch (theCommandID) {
3462 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3463 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3464 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3465 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3466 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3467 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3468 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3469 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3470 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3471 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3474 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3477 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3481 case SMESHOp::OpPolyhedron:
3483 if(isStudyLocked()) break;
3484 if ( warnOnGeomModif() )
3485 break; // action forbidden as geometry modified
3487 EmitSignalDeactivateDialog();
3488 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3491 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3495 case SMESHOp::OpQuadraticEdge:
3496 case SMESHOp::OpQuadraticTriangle:
3497 case SMESHOp::OpBiQuadraticTriangle:
3498 case SMESHOp::OpQuadraticQuadrangle:
3499 case SMESHOp::OpBiQuadraticQuadrangle:
3500 case SMESHOp::OpQuadraticPolygon:
3501 case SMESHOp::OpQuadraticTetrahedron:
3502 case SMESHOp::OpQuadraticPyramid:
3503 case SMESHOp::OpQuadraticPentahedron:
3504 case SMESHOp::OpBiQuadraticPentahedron:
3505 case SMESHOp::OpQuadraticHexahedron:
3506 case SMESHOp::OpTriQuadraticHexahedron:
3508 if(isStudyLocked()) break;
3509 if ( warnOnGeomModif() )
3510 break; // action forbidden as geometry modified
3512 EmitSignalDeactivateDialog();
3513 SMDSAbs_EntityType type = SMDSEntity_Last;
3515 switch (theCommandID) {
3516 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3517 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3518 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3519 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3520 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3521 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3522 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3523 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3524 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3525 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3526 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3527 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3530 if ( type != SMDSEntity_Last )
3531 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3534 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3535 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3539 case SMESHOp::OpRemoveNodes:
3541 if(isStudyLocked()) break;
3542 if ( warnOnGeomModif() )
3543 break; // action forbidden as geometry modified
3545 EmitSignalDeactivateDialog();
3546 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3549 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3550 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3554 case SMESHOp::OpRemoveNodeWithReconn:
3556 if(isStudyLocked()) break;
3557 if ( warnOnGeomModif() )
3558 break; // action forbidden as geometry modified
3559 startOperation( SMESHOp::OpRemoveNodeWithReconn );
3562 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3564 if(isStudyLocked()) break;
3565 if ( warnOnGeomModif() )
3566 break; // action forbidden as geometry modified
3568 EmitSignalDeactivateDialog();
3569 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3573 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3574 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3578 case SMESHOp::OpClearMesh: {
3580 if(isStudyLocked()) break;
3581 if ( warnOnGeomModif() )
3582 break; // action forbidden as geometry modified
3584 SALOME_ListIO selected;
3585 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3586 aSel->selectedObjects( selected );
3588 SUIT_OverrideCursor wc;
3589 SALOME_ListIteratorOfListIO It (selected);
3590 for ( ; It.More(); It.Next() )
3592 Handle(SALOME_InteractiveObject) IOS = It.Value();
3593 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3594 if ( aMesh->_is_nil()) continue;
3597 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3598 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3599 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3600 // hide groups and submeshes
3601 _PTR(ChildIterator) anIter =
3602 SMESH::getStudy()->NewChildIterator( aMeshSObj );
3603 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3605 _PTR(SObject) so = anIter->Value();
3606 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3609 catch (const SALOME::SALOME_Exception& S_ex){
3611 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3615 SMESH::UpdateView();
3619 case SMESHOp::OpRemoveOrphanNodes:
3621 if(isStudyLocked()) break;
3622 if ( warnOnGeomModif() )
3623 break; // action forbidden as geometry modified
3624 SALOME_ListIO selected;
3625 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3626 aSel->selectedObjects( selected );
3627 if ( selected.Extent() == 1 ) {
3628 Handle(SALOME_InteractiveObject) anIO = selected.First();
3629 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3630 if ( !aMesh->_is_nil() ) {
3631 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3632 tr( "SMESH_WARNING" ),
3633 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3634 SUIT_MessageBox::Yes |
3635 SUIT_MessageBox::No,
3636 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3639 SUIT_OverrideCursor wc;
3640 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3641 smIdType removed = aMeshEditor->RemoveOrphanNodes();
3642 SUIT_MessageBox::information(SMESHGUI::desktop(),
3643 tr("SMESH_INFORMATION"),
3644 tr("NB_NODES_REMOVED").arg(removed));
3645 if ( removed > 0 ) {
3646 SMESH::UpdateView();
3647 SMESHGUI::Modified();
3650 catch (const SALOME::SALOME_Exception& S_ex) {
3651 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3660 case SMESHOp::OpRenumberingNodes:
3662 if(isStudyLocked()) break;
3663 if ( warnOnGeomModif() )
3664 break; // action forbidden as geometry modified
3666 EmitSignalDeactivateDialog();
3667 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3671 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3672 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3676 case SMESHOp::OpRenumberingElements:
3678 if(isStudyLocked()) break;
3679 if ( warnOnGeomModif() )
3680 break; // action forbidden as geometry modified
3682 EmitSignalDeactivateDialog();
3683 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3687 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3688 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3692 case SMESHOp::OpTranslation:
3694 if(isStudyLocked()) break;
3695 if ( warnOnGeomModif() )
3696 break; // action forbidden as geometry modified
3698 EmitSignalDeactivateDialog();
3699 ( new SMESHGUI_TranslationDlg( this ) )->show();
3702 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3703 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3707 case SMESHOp::OpRotation:
3709 if(isStudyLocked()) break;
3710 if ( warnOnGeomModif() )
3711 break; // action forbidden as geometry modified
3713 EmitSignalDeactivateDialog();
3714 ( new SMESHGUI_RotationDlg( this ) )->show();
3717 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3718 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3722 case SMESHOp::OpSymmetry:
3724 if(isStudyLocked()) break;
3725 if ( warnOnGeomModif() )
3726 break; // action forbidden as geometry modified
3728 EmitSignalDeactivateDialog();
3729 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3732 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3733 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3737 case SMESHOp::OpScale:
3739 if(isStudyLocked()) break;
3740 if ( warnOnGeomModif() )
3741 break; // action forbidden as geometry modified
3743 EmitSignalDeactivateDialog();
3744 ( new SMESHGUI_ScaleDlg( this ) )->show();
3747 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3748 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3753 case SMESHOp::OpOffset:
3755 if(isStudyLocked()) break;
3756 if ( warnOnGeomModif() )
3757 break; // action forbidden as geometry modified
3759 EmitSignalDeactivateDialog();
3760 ( new SMESHGUI_OffsetDlg( this ) )->show();
3763 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3764 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3769 case SMESHOp::OpSewing:
3771 if(isStudyLocked()) break;
3772 if ( warnOnGeomModif() )
3773 break; // action forbidden as geometry modified
3775 EmitSignalDeactivateDialog();
3776 ( new SMESHGUI_SewingDlg( this ) )->show();
3779 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3780 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3784 case SMESHOp::OpMergeNodes:
3786 if(isStudyLocked()) break;
3787 if ( warnOnGeomModif() )
3788 break; // action forbidden as geometry modified
3790 EmitSignalDeactivateDialog();
3791 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3794 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3795 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3799 case SMESHOp::OpMergeElements:
3801 if (isStudyLocked()) break;
3802 if ( warnOnGeomModif() )
3803 break; // action forbidden as geometry modified
3805 EmitSignalDeactivateDialog();
3806 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3808 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3809 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3814 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3815 if ( warnOnGeomModif() )
3816 break; // action forbidden as geometry modified
3817 startOperation( SMESHOp::OpMoveNode );
3820 case SMESHOp::OpMoveNodeInteractive:
3821 if ( warnOnGeomModif() )
3822 break; // action forbidden as geometry modified
3823 startOperation( SMESHOp::OpMoveNodeInteractive );
3826 case SMESHOp::OpSplitEdgeInteract:
3827 if ( warnOnGeomModif() )
3828 break; // action forbidden as geometry modified
3829 startOperation( SMESHOp::OpSplitEdgeInteract );
3832 case SMESHOp::OpSplitFaceInteract:
3833 if ( warnOnGeomModif() )
3834 break; // action forbidden as geometry modified
3835 startOperation( SMESHOp::OpSplitFaceInteract );
3838 case SMESHOp::OpDuplicateNodes:
3840 if(isStudyLocked()) break;
3841 if ( warnOnGeomModif() )
3842 break; // action forbidden as geometry modified
3844 EmitSignalDeactivateDialog();
3845 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3848 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3849 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3854 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3855 if ( warnOnGeomModif() )
3856 break; // action forbidden as geometry modified
3857 startOperation( SMESHOp::OpElem0DOnElemNodes );
3860 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3862 static QList<int> aTypes;
3863 if ( aTypes.isEmpty() )
3865 aTypes.append( SMESH::NODE );
3866 aTypes.append( SMESH::EDGE );
3867 aTypes.append( SMESH::FACE );
3868 aTypes.append( SMESH::VOLUME );
3870 if (!myFilterLibraryDlg)
3871 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3872 else if (myFilterLibraryDlg->isHidden())
3873 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3874 myFilterLibraryDlg->raise();
3878 case SMESHOp::OpFreeNode:
3879 case SMESHOp::OpEqualNode:
3880 case SMESHOp::OpNodeConnectivityNb:
3881 case SMESHOp::OpFreeEdge:
3882 case SMESHOp::OpFreeBorder:
3883 case SMESHOp::OpLength:
3884 case SMESHOp::OpConnection:
3885 case SMESHOp::OpEqualEdge:
3886 case SMESHOp::OpFreeFace:
3887 case SMESHOp::OpBareBorderFace:
3888 case SMESHOp::OpOverConstrainedFace:
3889 case SMESHOp::OpLength2D:
3890 case SMESHOp::OpDeflection2D:
3891 case SMESHOp::OpConnection2D:
3892 case SMESHOp::OpArea:
3893 case SMESHOp::OpTaper:
3894 case SMESHOp::OpAspectRatio:
3895 case SMESHOp::OpMinimumAngle:
3896 case SMESHOp::OpWarpingAngle:
3897 case SMESHOp::OpSkew:
3898 case SMESHOp::OpMaxElementLength2D:
3899 case SMESHOp::OpEqualFace:
3900 case SMESHOp::OpAspectRatio3D:
3901 case SMESHOp::OpVolume:
3902 case SMESHOp::OpMaxElementLength3D:
3903 case SMESHOp::OpBareBorderVolume:
3904 case SMESHOp::OpOverConstrainedVolume:
3905 case SMESHOp::OpEqualVolume:
3908 LightApp_SelectionMgr* mgr = selectionMgr();
3909 SALOME_ListIO selected; mgr->selectedObjects( selected );
3911 if( !selected.IsEmpty() ) {
3912 SUIT_OverrideCursor wc;
3913 ::Control( theCommandID );
3916 SUIT_MessageBox::warning(desktop(),
3917 tr( "SMESH_WRN_WARNING" ),
3918 tr( "SMESH_BAD_SELECTION" ) );
3922 SUIT_MessageBox::warning(desktop(),
3923 tr( "SMESH_WRN_WARNING" ),
3924 tr( "NOT_A_VTK_VIEWER" ) );
3927 case SMESHOp::OpOverallMeshQuality:
3928 OverallMeshQuality();
3930 case SMESHOp::OpNumberingNodes:
3932 SUIT_OverrideCursor wc;
3933 LightApp_SelectionMgr* mgr = selectionMgr();
3934 SALOME_ListIO selected; mgr->selectedObjects( selected );
3936 SALOME_ListIteratorOfListIO it(selected);
3937 for( ; it.More(); it.Next()) {
3938 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3939 if(anIObject->hasEntry()) {
3940 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3941 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3947 case SMESHOp::OpNumberingElements:
3949 SUIT_OverrideCursor wc;
3950 LightApp_SelectionMgr* mgr = selectionMgr();
3951 SALOME_ListIO selected; mgr->selectedObjects( selected );
3953 SALOME_ListIteratorOfListIO it(selected);
3954 for( ; it.More(); it.Next()) {
3955 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3956 if(anIObject->hasEntry())
3957 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3958 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3963 case SMESHOp::OpPropertiesLength:
3964 case SMESHOp::OpPropertiesArea:
3965 case SMESHOp::OpPropertiesVolume:
3966 case SMESHOp::OpMinimumDistance:
3967 case SMESHOp::OpBoundingBox:
3968 case SMESHOp::OpAngle:
3970 int page = SMESHGUI_MeasureDlg::MinDistance;
3971 if ( theCommandID == SMESHOp::OpBoundingBox )
3972 page = SMESHGUI_MeasureDlg::BoundingBox;
3973 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3974 page = SMESHGUI_MeasureDlg::Length;
3975 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3976 page = SMESHGUI_MeasureDlg::Area;
3977 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3978 page = SMESHGUI_MeasureDlg::Volume;
3979 else if ( theCommandID == SMESHOp::OpAngle )
3980 page = SMESHGUI_MeasureDlg::Angle;
3982 EmitSignalDeactivateDialog();
3983 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3987 case SMESHOp::OpSortChild:
3990 case SMESHOp::OpBreakLink:
3991 ::breakShaperLink();
3996 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3997 //updateObjBrowser();
4001 //=============================================================================
4005 //=============================================================================
4006 bool SMESHGUI::OnMousePress( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4011 //=============================================================================
4015 //=============================================================================
4016 bool SMESHGUI::OnMouseMove( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4021 //=============================================================================
4025 //=============================================================================
4026 bool SMESHGUI::OnKeyPress( QKeyEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4031 //=============================================================================
4032 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
4033 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
4035 //=============================================================================
4036 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
4037 SUIT_ViewWindow* wnd )
4039 if(theIO->hasEntry()){
4040 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
4041 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
4045 //=======================================================================
4046 // function : createSMESHAction
4048 //=======================================================================
4049 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
4050 const int key, const bool toggle, const QString& shortcutAction )
4053 QWidget* parent = application()->desktop();
4054 SUIT_ResourceMgr* resMgr = resourceMgr();
4056 if ( !icon_id.isEmpty() )
4057 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
4059 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICON_%1" ).arg( po_id ).toLatin1().data() ), false );
4060 if ( !pix.isNull() )
4061 icon = QIcon( pix );
4063 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
4064 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
4065 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
4067 createAction( id, tooltip, icon, menu, status_bar, key, parent,
4068 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
4071 //=======================================================================
4072 // function : createPopupItem
4074 //=======================================================================
4075 void SMESHGUI::createPopupItem( const int id,
4076 const QString& clients,
4077 const QString& types,
4078 const QString& theRule,
4081 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
4082 popupMgr()->insert( action( id ), pId, 0 );
4084 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4085 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4086 QString rule = "(%1) and (%2) and (%3)";
4087 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
4088 if( clients.isEmpty() )
4089 rule = rule.arg( QString( "true" ) );
4091 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
4092 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
4095 bool cont = myRules.contains( id );
4097 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
4099 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
4100 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
4103 //=======================================================================
4104 // function : initialize
4106 //=======================================================================
4107 void SMESHGUI::initialize( CAM_Application* app )
4109 SalomeApp_Module::initialize( app );
4111 // SUIT_ResourceMgr* mgr = app->resourceMgr();
4113 /* Automatic Update flag */
4114 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
4116 // ----- create actions --------------
4118 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
4119 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
4120 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
4121 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
4123 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
4125 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
4126 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
4127 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
4128 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
4130 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
4132 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
4134 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
4135 createSMESHAction( SMESHOp::OpExportMED, "MED" );
4136 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
4137 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
4139 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
4141 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
4142 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
4143 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
4144 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
4145 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
4147 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
4149 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
4150 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
4151 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
4152 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
4153 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
4154 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
4155 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
4156 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
4157 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
4158 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
4159 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
4160 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
4161 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
4162 createSMESHAction( SMESHOp::OpRecompute, "RE_COMPUTE", "ICON_COMPUTE" );
4163 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
4164 createSMESHAction( SMESHOp::OpShowErrors, "SHOW_ERRORS", "ICON_SHOW_ERRORS" );
4165 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
4166 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
4167 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
4168 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
4169 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
4170 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
4171 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
4172 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
4173 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
4174 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
4175 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
4176 createSMESHAction( SMESHOp::OpFaceGroupsByEdges, "FACE_GROUPS_BY_EDGES", "ICON_FACE_GROUPS_BY_EDGES" );
4177 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
4178 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
4179 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
4180 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
4181 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
4182 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4183 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
4185 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
4186 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
4187 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
4188 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
4189 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
4190 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
4191 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
4192 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
4193 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
4194 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
4195 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
4196 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
4197 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
4198 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
4199 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
4200 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
4201 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
4202 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
4203 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
4204 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
4205 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
4206 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
4207 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
4208 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
4209 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
4210 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
4211 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
4212 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
4213 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
4215 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
4216 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
4217 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
4218 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
4219 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
4220 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
4221 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
4222 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
4223 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
4224 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
4225 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
4226 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
4227 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
4228 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
4229 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
4230 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
4231 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
4232 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
4233 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
4234 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
4235 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
4236 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
4237 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
4238 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
4239 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
4240 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
4242 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
4243 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
4244 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
4245 createSMESHAction( SMESHOp::OpRemoveNodeWithReconn, "REMOVE_NODE_RECON", "ICON_REM_NODE_RECON" );
4246 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
4248 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
4249 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
4251 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
4252 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
4253 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
4254 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
4255 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
4256 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
4257 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
4258 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
4259 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
4260 createSMESHAction( SMESHOp::OpMoveNodeInteractive, "MOVE_NODE_INTRCT","ICON_DLG_MOVE_NODE_INTERACTIVE" );
4261 createSMESHAction( SMESHOp::OpSplitEdgeInteract, "SPLIT_DIAG_INTRC","ICON_SPLIT_DIAG_INTERACTIVE" );
4262 createSMESHAction( SMESHOp::OpSplitFaceInteract, "SPLIT_FACE_INTRC","ICON_SPLIT_FACE_INTERACTIVE" );
4263 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
4264 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
4265 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
4266 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
4267 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
4268 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
4269 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
4270 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
4271 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
4272 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
4273 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
4274 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
4275 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
4276 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
4277 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
4278 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
4280 createSMESHAction( SMESHOp::OpReset, "RESET" );
4281 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
4282 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
4283 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
4284 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
4285 #ifndef DISABLE_PLOT2DVIEWER
4286 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
4288 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
4289 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
4290 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
4291 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
4292 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
4293 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4294 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4295 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4296 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4297 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4298 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4299 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4300 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4302 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4303 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4305 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4306 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4307 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4308 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4309 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4310 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4311 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4312 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4313 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4315 // Adaptation - begin
4316 #ifndef DISABLE_MG_ADAPT
4317 createSMESHAction( SMESHOp::OpMGAdapt, "MG_ADAPT", "ICON_MG_ADAPT" );
4319 #ifndef DISABLE_HOMARD_ADAPT
4320 createSMESHAction( SMESHOp::OpHomardAdapt, "HOMARD_ADAPT", "ICON_HOMARD_ADAPT" );
4324 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4325 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4326 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4327 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4328 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4329 createSMESHAction( SMESHOp::OpAngle, "MEASURE_ANGLE", "ICON_MEASURE_ANGLE" );
4331 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
4332 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
4333 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4335 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4337 createSMESHAction( SMESHOp::OpBreakLink, "BREAK_SHAPER_LINK" );
4339 QList<int> aCtrlActions;
4340 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4341 << SMESHOp::OpNodeConnectivityNb // node controls
4342 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4343 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4344 << SMESHOp::OpDeflection2D
4345 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4346 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4347 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4348 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4349 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4350 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
4351 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4352 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls
4353 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4354 aCtrlGroup->setExclusive( true );
4355 for( int i = 0; i < aCtrlActions.size(); i++ )
4356 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4358 // ----- create menu --------------
4359 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4360 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4361 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4362 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4363 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4364 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4365 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4366 adaptId = createMenu( tr( "MEN_ADAPT" ), -1, 80, 10 ),
4368 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4369 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4371 createMenu( separator(), fileId );
4373 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4374 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4375 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4376 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4377 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4378 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4379 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4380 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4381 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4382 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4383 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4384 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4385 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4387 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4388 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4389 createMenu( SMESHOp::OpImportMED, importId, -1 );
4390 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4392 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4394 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4395 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4396 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4397 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4398 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4400 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4402 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4403 createMenu( separator(), fileId, 10 );
4405 createMenu( SMESHOp::OpDelete, editId, -1 );
4407 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4409 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4410 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4411 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4412 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4413 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4414 createMenu( separator(), meshId, -1 );
4415 createMenu( SMESHOp::OpCompute, meshId, -1 );
4416 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4417 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4418 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4419 createMenu( separator(), meshId, -1 );
4420 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4421 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4422 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4423 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4424 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4425 createMenu( separator(), meshId, -1 );
4426 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4427 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4428 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4429 createMenu( separator(), meshId, -1 );
4430 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4431 createMenu( SMESHOp::OpFaceGroupsByEdges, meshId, -1 );
4432 createMenu( separator(), meshId, -1 );
4433 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4434 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4435 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4436 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4437 createMenu( separator(), meshId, -1 );
4439 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4440 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4441 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4442 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4443 createMenu( SMESHOp::OpLength, edgeId, -1 );
4444 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4445 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4446 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4447 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4448 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4449 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4450 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4451 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4452 createMenu( SMESHOp::OpArea, faceId, -1 );
4453 createMenu( SMESHOp::OpTaper, faceId, -1 );
4454 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4455 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4456 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4457 createMenu( SMESHOp::OpSkew, faceId, -1 );
4458 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4459 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4460 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4461 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4462 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4463 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4464 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4465 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4466 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4467 createMenu( separator(), ctrlId, -1 );
4468 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4469 createMenu( separator(), ctrlId, -1 );
4470 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4472 createMenu( SMESHOp::OpNode, addId, -1 );
4473 createMenu( SMESHOp::OpElem0D, addId, -1 );
4474 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4475 createMenu( SMESHOp::OpBall, addId, -1 );
4476 createMenu( SMESHOp::OpEdge, addId, -1 );
4477 createMenu( SMESHOp::OpTriangle, addId, -1 );
4478 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4479 createMenu( SMESHOp::OpPolygon, addId, -1 );
4480 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4481 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4482 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4483 createMenu( SMESHOp::OpPyramid, addId, -1 );
4484 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4485 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4486 createMenu( separator(), addId, -1 );
4487 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4488 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4489 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4490 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4491 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4492 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4493 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4494 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4495 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4496 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4497 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4498 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4499 createMenu( separator(), addId, -1 );
4500 createMenu( SMESHOp::OpSplitEdgeInteract, addId, -1 );
4501 createMenu( SMESHOp::OpSplitFaceInteract, addId, -1 );
4503 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4504 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4505 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4506 createMenu( SMESHOp::OpRemoveNodeWithReconn, removeId, -1 );
4507 createMenu( separator(), removeId, -1 );
4508 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4509 createMenu( separator(), removeId, -1 );
4510 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4512 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4513 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4515 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4516 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4517 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4518 createMenu( SMESHOp::OpRotation, transfId, -1 );
4519 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4520 createMenu( SMESHOp::OpScale, transfId, -1 );
4521 createMenu( SMESHOp::OpOffset, transfId, -1 );
4522 createMenu( SMESHOp::OpSewing, transfId, -1 );
4523 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4525 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4526 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4527 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4528 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4529 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4530 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4531 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4532 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4533 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4534 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4535 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4536 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4537 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4538 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4539 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4540 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4542 // Adaptation - begin
4543 #ifndef DISABLE_MG_ADAPT
4544 createMenu( SMESHOp::OpMGAdapt, adaptId, -1 );
4546 #ifndef DISABLE_HOMARD_ADAPT
4547 createMenu( SMESHOp::OpHomardAdapt, adaptId, -1 );
4551 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4552 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4553 createMenu( SMESHOp::OpAngle, measureId, -1 );
4554 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4555 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4556 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4557 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4559 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4560 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4561 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4562 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4564 // ----- create toolbars --------------
4565 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ) ;
4566 createTool( SMESHOp::OpCreateMesh, meshTb );
4567 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4568 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4569 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4570 createTool( SMESHOp::OpCopyMesh, meshTb );
4571 createTool( separator(), meshTb );
4572 createTool( SMESHOp::OpCompute, meshTb );
4573 createTool( SMESHOp::OpPreCompute, meshTb );
4574 createTool( SMESHOp::OpEvaluate, meshTb );
4575 createTool( SMESHOp::OpMeshOrder, meshTb );
4577 int infoTb = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ) ;
4578 createTool( SMESHOp::OpMeshInformation, infoTb );
4579 //createTool( SMESHOp::OpStdInfo, meshTb );
4580 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4581 createTool( SMESHOp::OpFindElementByPoint, infoTb );
4583 int groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ) ;
4584 createTool( SMESHOp::OpCreateGroup, groupTb );
4585 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4586 createTool( SMESHOp::OpConstructGroup, groupTb );
4587 createTool( SMESHOp::OpEditGroup, groupTb );
4589 int ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ) ;
4590 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4591 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4592 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4594 int ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ) ;
4595 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4596 createTool( SMESHOp::OpLength, ctrl1dTb );
4597 createTool( SMESHOp::OpConnection, ctrl1dTb );
4598 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4600 int ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ) ;
4601 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4602 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4603 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4604 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4605 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4606 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4607 createTool( SMESHOp::OpArea, ctrl2dTb );
4608 createTool( SMESHOp::OpTaper, ctrl2dTb );
4609 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4610 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4611 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4612 createTool( SMESHOp::OpSkew, ctrl2dTb );
4613 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4614 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4615 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4617 int ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ) ;
4618 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4619 createTool( SMESHOp::OpVolume, ctrl3dTb );
4620 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4621 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4622 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4623 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4625 int addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ) ;
4626 createTool( SMESHOp::OpNode, addElemTb );
4627 createTool( SMESHOp::OpElem0D, addElemTb );
4628 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4629 createTool( SMESHOp::OpBall, addElemTb );
4630 createTool( SMESHOp::OpEdge, addElemTb );
4631 createTool( SMESHOp::OpTriangle, addElemTb );
4632 createTool( SMESHOp::OpQuadrangle, addElemTb );
4633 createTool( SMESHOp::OpPolygon, addElemTb );
4634 createTool( SMESHOp::OpTetrahedron, addElemTb );
4635 createTool( SMESHOp::OpHexahedron, addElemTb );
4636 createTool( SMESHOp::OpPentahedron, addElemTb );
4637 createTool( SMESHOp::OpPyramid, addElemTb );
4638 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4639 createTool( SMESHOp::OpPolyhedron, addElemTb );
4641 int addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ) ;
4642 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4643 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4644 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4645 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4646 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4647 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4648 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4649 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4650 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4651 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4652 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4653 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4655 int remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ) ;
4656 createTool( SMESHOp::OpRemoveNodes, remTb );
4657 createTool( SMESHOp::OpRemoveElements, remTb );
4658 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4659 createTool( SMESHOp::OpClearMesh, remTb );
4661 // int renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ) ;
4662 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4663 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4665 int transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ) ;
4666 createTool( SMESHOp::OpMergeNodes, transformTb );
4667 createTool( SMESHOp::OpMergeElements, transformTb );
4668 createTool( SMESHOp::OpTranslation, transformTb );
4669 createTool( SMESHOp::OpRotation, transformTb );
4670 createTool( SMESHOp::OpSymmetry, transformTb );
4671 createTool( SMESHOp::OpScale, transformTb );
4672 createTool( SMESHOp::OpOffset, transformTb );
4673 createTool( SMESHOp::OpSewing, transformTb );
4674 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4676 int modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ) ;
4677 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4678 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4679 createTool( SMESHOp::OpExtrusion, modifyTb );
4680 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4681 createTool( SMESHOp::OpRevolution, modifyTb );
4682 createTool( SMESHOp::OpOrientation, modifyTb );
4683 createTool( SMESHOp::OpReorientFaces, modifyTb );
4684 createTool( SMESHOp::OpMoveNode, modifyTb );
4685 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4686 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4687 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4688 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4689 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4690 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4691 createTool( SMESHOp::OpSmoothing, modifyTb );
4692 createTool( SMESHOp::OpPatternMapping, modifyTb );
4694 int interactTb = createTool( tr( "TB_INTERACT" ), QString( "SMESHInteractiveToolbar" ) ) ;
4695 createTool( SMESHOp::OpMoveNodeInteractive, interactTb );
4696 createTool( SMESHOp::OpRemoveNodeWithReconn, interactTb );
4697 createTool( SMESHOp::OpSplitEdgeInteract, interactTb );
4698 createTool( SMESHOp::OpSplitFaceInteract, interactTb );
4700 // Adaptation - begin
4701 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4702 int adaptTb = createTool( tr( "TB_ADAPTATION" ), QString( "SMESHAdaptationToolbar" ) ) ;
4704 #ifndef DISABLE_MG_ADAPT
4705 createTool( SMESHOp::OpMGAdapt, adaptTb );
4707 #ifndef DISABLE_HOMARD_ADAPT
4708 createTool( SMESHOp::OpHomardAdapt, adaptTb );
4712 int measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ) ;
4713 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4715 int dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4716 createTool( SMESHOp::OpUpdate, dispModeTb );
4718 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4719 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4723 OB = "'ObjectBrowser'",
4724 View = "'" + SVTK_Viewer::Type() + "'",
4726 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4727 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4728 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4729 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4730 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4731 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4732 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4733 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4734 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4735 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4736 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4737 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4739 mesh_part = mesh + " " + subMesh + " " + group,
4740 mesh_group = mesh + " " + group,
4741 mesh_submesh = mesh + " " + subMesh,
4742 hyp_alg = hypo + " " + algo;
4744 // popup for object browser
4746 isInvisible("not( isVisible )"),
4747 isEmpty("numberOfNodes = 0"),
4748 isNotEmpty("numberOfNodes <> 0"),
4750 // has nodes, edges, etc in VISIBLE! actor
4751 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4752 hasElems("(count( elemTypes ) > 0)"),
4753 hasDifferentElems("(count( elemTypes ) > 1)"),
4754 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4755 hasBalls("({'BallElem'} in elemTypes)"),
4756 hasElems0d("({'Elem0d'} in elemTypes)"),
4757 hasEdges("({'Edge'} in elemTypes)"),
4758 hasFaces("({'Face'} in elemTypes)"),
4759 hasVolumes("({'Volume'} in elemTypes)"),
4760 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4762 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4763 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4764 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && hasAlgo && hasGeomReference" );
4765 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4766 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4767 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4769 popupMgr()->insert( separator(), -1, 0 );
4770 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4771 createPopupItem( SMESHOp::OpRecompute, OB, mesh, "&& selcount=1 && hasAlgo && (" + isNotEmpty + " || hasErrors )");
4772 createPopupItem( SMESHOp::OpShowErrors, OB, mesh, "&& selcount=1 && hasErrors" );
4773 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && hasAlgo && isComputable" );
4774 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && hasAlgo && isPreComputable" );
4775 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4776 popupMgr()->insert( separator(), -1, 0 );
4777 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4778 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4779 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1 && " + hasElems );
4780 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4781 popupMgr()->insert( separator(), -1, 0 );
4782 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4783 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4784 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4785 popupMgr()->insert( separator(), -1, 0 );
4786 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4787 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4788 popupMgr()->insert( separator(), -1, 0 );
4789 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems );
4790 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4792 // Adaptation - begin
4793 popupMgr()->insert( separator(), -1, 0 );
4794 #ifndef DISABLE_MG_ADAPT
4795 createPopupItem( SMESHOp::OpMGAdapt, OB, mesh );
4797 #ifndef DISABLE_HOMARD_ADAPT
4798 createPopupItem( SMESHOp::OpHomardAdapt, OB, mesh );
4800 popupMgr()->insert( separator(), -1, 0 );
4803 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4804 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4805 QString only_one_2D = only_one_non_empty + " && dim>1";
4807 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4808 popupMgr()->findMenu( anId )->menuAction()->setIcon( resourceMgr()->loadPixmap( "SMESH", tr( "ICON_EXPORT" )));
4809 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4810 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4811 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4813 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4815 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4816 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4818 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4819 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4820 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4821 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4823 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4825 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4826 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4827 popupMgr()->insert( separator(), -1, 0 );
4829 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4830 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4831 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4834 createPopupItem( SMESHOp::OpEditGroup, View, group );
4835 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4836 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4838 popupMgr()->insert( separator(), -1, 0 );
4839 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4840 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4841 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh, "&& " + hasElems);
4842 popupMgr()->insert( separator(), -1, 0 );
4844 createPopupItem( SMESHOp::OpUpdate, OB + " " + View, mesh_part );
4845 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4846 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4847 popupMgr()->insert( separator(), -1, 0 );
4849 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4850 QString aType = QString( "%1type in {%2}" ).arg( lc );
4851 aType = aType.arg( mesh_part );
4852 QString aMeshInVTK = aClient + "&&" + aType;
4854 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4855 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4856 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4858 //-------------------------------------------------
4860 //-------------------------------------------------
4861 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4863 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4864 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4865 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4867 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4868 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4869 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4871 popupMgr()->insert( separator(), -1, -1 );
4873 //-------------------------------------------------
4875 //-------------------------------------------------
4876 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4878 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4879 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4880 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4882 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4883 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4884 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4886 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4887 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4888 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4890 popupMgr()->insert( separator(), anId, -1 );
4892 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4893 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4894 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4896 //-------------------------------------------------
4898 //-------------------------------------------------
4899 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4901 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4903 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4904 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4905 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4907 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4908 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4909 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4911 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4912 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4913 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4915 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4916 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4917 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4919 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4920 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4921 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4923 popupMgr()->insert( separator(), anId, -1 );
4925 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4926 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
4928 popupMgr()->insert( separator(), anId, -1 );
4930 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4931 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4934 //-------------------------------------------------
4935 // Representation of the 2D Quadratic elements
4936 //-------------------------------------------------
4937 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4938 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4939 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4940 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4942 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4943 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4944 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4946 //-------------------------------------------------
4947 // Orientation of faces
4948 //-------------------------------------------------
4949 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4950 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4951 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4953 //-------------------------------------------------
4955 //-------------------------------------------------
4956 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4957 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4959 //-------------------------------------------------
4961 //-------------------------------------------------
4962 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4963 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4965 //-------------------------------------------------
4967 //-------------------------------------------------
4969 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4970 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4971 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4972 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4974 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4976 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
4977 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4979 popupMgr()->insert( separator(), anId, -1 );
4981 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4983 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
4984 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4985 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4987 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
4988 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4989 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4991 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
4992 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4993 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
4995 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4997 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
4998 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
4999 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
5001 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
5002 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5003 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
5005 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
5006 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5007 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
5008 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
5009 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5010 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
5012 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
5014 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
5015 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5016 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
5018 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
5019 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
5020 QtxPopupMgr::VisibleRule );
5021 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
5023 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
5024 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5025 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
5027 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
5028 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5029 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
5031 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
5032 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5033 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
5035 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
5036 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5037 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
5039 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
5040 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5041 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
5043 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
5044 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5045 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
5047 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
5048 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5049 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
5051 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
5052 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5053 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
5055 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
5056 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5057 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
5059 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
5060 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5061 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
5063 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
5064 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5065 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
5067 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
5068 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5069 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
5071 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
5072 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
5073 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
5075 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
5077 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
5078 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5079 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
5081 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
5082 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5083 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
5085 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
5086 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5087 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
5089 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
5090 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5091 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
5093 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
5094 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5095 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
5097 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
5098 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5099 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
5101 popupMgr()->insert( separator(), anId, -1 );
5103 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
5104 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5105 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
5106 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
5107 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5109 popupMgr()->insert( separator(), anId, -1 );
5111 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
5113 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
5114 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5116 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
5117 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5118 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
5120 #ifndef DISABLE_PLOT2DVIEWER
5121 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
5122 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5125 //-------------------------------------------------
5127 //-------------------------------------------------
5128 popupMgr()->insert( separator(), -1, -1 );
5129 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
5130 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
5131 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
5132 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
5134 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
5135 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
5137 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
5138 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
5140 popupMgr()->insert( separator(), -1, -1 );
5142 //-------------------------------------------------
5144 //-------------------------------------------------
5145 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
5146 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
5148 popupMgr()->insert( separator(), -1, -1 );
5150 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
5151 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
5152 popupMgr()->insert( separator(), -1, -1 );
5154 popupMgr()->insert( action( SMESHOp::OpBreakLink), -1, -1 );
5155 popupMgr()->setRule( action( SMESHOp::OpBreakLink), "$component={'SHAPERSTUDY'} and client='ObjectBrowser' and canBreakLink", QtxPopupMgr::VisibleRule );
5157 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
5158 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
5160 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
5161 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
5164 //================================================================================
5166 * \brief Return true if SMESH or GEOM objects are selected.
5167 * Is called form LightApp_Module::activateModule() which clear selection if
5168 * not isSelectionCompatible()
5170 //================================================================================
5172 bool SMESHGUI::isSelectionCompatible()
5174 bool isCompatible = true;
5175 SALOME_ListIO selected;
5176 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
5177 Sel->selectedObjects( selected );
5179 SALOME_ListIteratorOfListIO It( selected );
5180 for ( ; isCompatible && It.More(); It.Next())
5182 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
5183 ( strcmp("SHAPERSTUDY", It.Value()->getComponentDataType()) == 0 ) ||
5184 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
5186 return isCompatible;
5190 bool SMESHGUI::reusableOperation( const int id )
5192 // compute, evaluate and precompute are not reusable operations
5193 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate || id == SMESHOp::OpRecompute ) ? false : SalomeApp_Module::reusableOperation( id );
5198 QString wrap(const QString& text, const QString& tag)
5199 { return QString("<%1>%2</%3>").arg(tag).arg(text).arg(tag);}
5202 bool SMESHGUI::activateModule( SUIT_Study* study )
5204 bool res = SalomeApp_Module::activateModule( study );
5206 setMenuShown( true );
5207 setToolShown( true );
5209 // Fill in Help Panel
5210 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
5211 app->infoPanel()->setTitle(tr("INFO_WELCOME_TO_SMESH"));
5213 int gb = app->infoPanel()->addGroup(tr("INFO_GRP_CREATE_MESH"));
5216 lab = tr("INFO_DEFINE_ALGOS") + "<br/>";
5217 lab = lab + tr("INFO_DEFINE_HYPOS") + "<br/>";
5218 lab = lab + tr("INFO_COMPUTE") + "<br/>";
5219 lab = lab + tr("INFO_REFINE") + ":";
5220 items << wrap(tr("INFO_REFINE_LOCAL_SIZE"), "li")
5221 << wrap(tr("INFO_REFINE_SUBMESH"), "li");
5222 lab = lab + wrap(items.join(""), "ul");
5225 app->infoPanel()->addLabel(lab, gb);
5227 gb = app->infoPanel()->addGroup(tr("INFO_GRP_IMPORT_MESH"));
5228 items << wrap("UNV", "li")
5229 << wrap("MED", "li")
5230 << wrap("STL", "li")
5231 << wrap("CGNS", "li")
5232 << wrap("GMF", "li");
5233 lab = tr("INFO_AVAILABLE_FORMATS") + ":" + wrap(items.join(""), "ul");
5236 app->infoPanel()->addLabel(lab, gb);
5238 gb = app->infoPanel()->addGroup(tr("INFO_GRP_CHECK_MESH"));
5239 lab = tr("INFO_DISPLAY") + "<br/>";
5240 items << wrap(tr("INFO_QUALITY_AREA"), "li")
5241 << wrap(tr("INFO_QUALITY_VOLUME"), "li")
5242 << wrap(tr("INFO_QUALITY_ASPECT_RATION"), "li")
5243 << wrap("...", "li");
5244 lab = lab + tr("INFO_QUALITY_INFO") + ":" + wrap(items.join(""), "ul");
5246 lab = lab + tr("INFO_CLIPPING");
5248 app->infoPanel()->addLabel(lab, gb);
5251 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
5252 PyGILState_STATE gstate = PyGILState_Ensure();
5253 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
5254 if ( !pluginsmanager ) {
5258 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
5263 PyGILState_Release(gstate);
5264 // end of SMESH plugins loading
5266 // Reset actions accelerator keys
5267 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
5269 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
5270 GetSMESHGen()->UpdateStudy();
5272 // get all view currently opened in the study and connect their signals to
5273 // the corresponding slots of the class.
5274 SUIT_Desktop* aDesk = study->application()->desktop();
5276 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
5277 SUIT_ViewWindow* wnd;
5278 foreach ( wnd, wndList )
5282 // remove actors whose objects are removed in GetSMESHGen()->UpdateStudy()
5283 SMESH::UpdateActorsAfterUpdateStudy(wnd);
5289 Py_XDECREF(pluginsmanager);
5293 bool SMESHGUI::deactivateModule( SUIT_Study* study )
5295 setMenuShown( false );
5296 setToolShown( false );
5298 EmitSignalCloseAllDialogs();
5300 // Unset actions accelerator keys
5301 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
5303 return SalomeApp_Module::deactivateModule( study );
5306 void SMESHGUI::studyClosed( SUIT_Study* s )
5310 SMESH::RemoveVisuData();
5311 SalomeApp_Module::studyClosed( s );
5314 void SMESHGUI::OnGUIEvent()
5316 const QObject* obj = sender();
5317 if ( !obj || !obj->inherits( "QAction" ) )
5319 int id = actionId((QAction*)obj);
5324 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
5326 if ( CORBA::is_nil( myComponentSMESH ) )
5328 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
5329 return aGUI.myComponentSMESH;
5331 return myComponentSMESH;
5334 QString SMESHGUI::engineIOR() const
5336 CORBA::ORB_var anORB = getApp()->orb();
5337 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
5338 return QString( anIOR.in() );
5341 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
5343 SalomeApp_Module::contextMenuPopup( client, menu, title );
5345 selectionMgr()->selectedObjects( lst );
5346 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
5347 Handle(SALOME_InteractiveObject) io = lst.First();
5348 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
5349 _PTR(Study) study = appStudy->studyDS();
5350 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
5352 QString aName = SMESH::fromUtf8( obj->GetName());
5353 while ( !aName.isEmpty() && aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
5354 aName.remove(( aName.length() - 1 ), 1 );
5360 LightApp_Selection* SMESHGUI::createSelection() const
5362 return new SMESHGUI_Selection();
5365 void SMESHGUI::windows( QMap<int, int>& aMap ) const
5367 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
5368 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
5369 aMap.insert( SalomeApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea);
5370 #ifndef DISABLE_PYCONSOLE
5371 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
5375 void SMESHGUI::viewManagers( QStringList& list ) const
5377 list.append( SVTK_Viewer::Type() );
5380 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
5382 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
5383 SMESH::UpdateSelectionProp( this );
5385 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
5386 for(int i = 0; i < aViews.count() ; i++){
5387 SUIT_ViewWindow *sf = aViews[i];
5390 EmitSignalActivatedViewManager();
5394 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
5396 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
5397 myClippingPlaneInfoMap.erase( theViewManager );
5400 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
5402 theActor->AddObserver( SMESH::DeleteActorEvent,
5403 myEventCallbackCommand.GetPointer(),
5407 void SMESHGUI::ProcessEvents( vtkObject* theObject,
5408 unsigned long theEvent,
5409 void* theClientData,
5410 void* /*theCallData*/ )
5412 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
5413 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
5414 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
5415 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5416 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5417 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5418 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5419 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5420 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5421 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5422 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5423 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5424 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5425 if( anActor == *anIter3 ) {
5426 anActorList.erase( anIter3 );
5437 void SMESHGUI::createPreferences()
5439 // General tab ------------------------------------------------------------------------
5440 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5442 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5443 setPreferenceProperty( autoUpdate, "columns", 2 );
5444 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5445 setPreferenceProperty( lim, "min", 0 );
5446 setPreferenceProperty( lim, "max", 100000000 );
5447 setPreferenceProperty( lim, "step", 1000 );
5448 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5449 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5451 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5452 setPreferenceProperty( dispgroup, "columns", 2 );
5454 addPreference( tr( "PREF_FITALL_ON_DISPLAYONLY" ), dispgroup, LightApp_Preferences::Bool, "SMESH", "fitall_on_displayonly" );
5456 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5458 modes.append( tr("MEN_WIRE") );
5459 modes.append( tr("MEN_SHADE") );
5460 modes.append( tr("MEN_NODES") );
5461 modes.append( tr("MEN_SHRINK") );
5462 QList<QVariant> indices;
5463 indices.append( 0 );
5464 indices.append( 1 );
5465 indices.append( 2 );
5466 indices.append( 3 );
5467 setPreferenceProperty( dispmode, "strings", modes );
5468 setPreferenceProperty( dispmode, "indexes", indices );
5470 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5471 setPreferenceProperty( arcgroup, "columns", 2 );
5472 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5473 QStringList quadraticModes;
5474 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5475 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5477 indices.append( 0 );
5478 indices.append( 1 );
5479 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5480 setPreferenceProperty( quadraticmode, "indexes", indices );
5482 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5483 "SMESH", "max_angle" );
5484 setPreferenceProperty( maxAngle, "min", 1 );
5485 setPreferenceProperty( maxAngle, "max", 90 );
5487 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5488 setPreferenceProperty( qaGroup, "columns", 2 );
5489 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5490 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5491 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5492 setPreferenceProperty( prec, "min", 0 );
5493 setPreferenceProperty( prec, "max", 100 );
5494 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5495 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5496 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5497 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5498 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5501 int cinc = addPreference(tr("PREF_CONTROLS_INCREMENT"), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_increment");
5502 setPreferenceProperty( cinc, "min", 0 );
5503 setPreferenceProperty( cinc, "max", 5 );
5506 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5507 setPreferenceProperty( exportgroup, "columns", 2 );
5508 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5509 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5510 addPreference( tr( "PREF_MED_SAVE_NUMS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "med_save_numbers" );
5511 int zTol = addPreference( tr( "PREF_ZTOLERANCE" ), exportgroup, LightApp_Preferences::DblSpin, "SMESH", "med_ztolerance" );
5512 setPreferenceProperty( zTol, "precision", 10 );
5513 setPreferenceProperty( zTol, "min", 0.0000000001 );
5514 setPreferenceProperty( zTol, "max", 1000000.0 );
5515 setPreferenceProperty( zTol, "step", 1. );
5516 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5518 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5519 setPreferenceProperty( computeGroup, "columns", 2 );
5520 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5522 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5523 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5524 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5526 indices.append( 0 );
5527 indices.append( 1 );
5528 indices.append( 2 );
5529 setPreferenceProperty( notifyMode, "strings", modes );
5530 setPreferenceProperty( notifyMode, "indexes", indices );
5532 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5533 setPreferenceProperty( infoGroup, "columns", 2 );
5534 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5536 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5537 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5539 indices.append( 0 );
5540 indices.append( 1 );
5541 setPreferenceProperty( elemInfo, "strings", modes );
5542 setPreferenceProperty( elemInfo, "indexes", indices );
5543 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5544 setPreferenceProperty( nodesLim, "min", 0 );
5545 setPreferenceProperty( nodesLim, "max", 10000000 );
5546 setPreferenceProperty( nodesLim, "step", 10000 );
5547 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5548 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5549 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5550 setPreferenceProperty( ctrlLim, "min", 0 );
5551 setPreferenceProperty( ctrlLim, "max", 10000000 );
5552 setPreferenceProperty( ctrlLim, "step", 1000 );
5553 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5554 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5555 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5556 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5557 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5559 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5560 setPreferenceProperty( segGroup, "columns", 2 );
5561 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5562 "SMESH", "segmentation" );
5563 setPreferenceProperty( segLen, "min", 1 );
5564 setPreferenceProperty( segLen, "max", 10000000 );
5565 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5566 "SMESH", "nb_segments_per_edge" );
5567 setPreferenceProperty( nbSeg, "min", 1 );
5568 setPreferenceProperty( nbSeg, "max", 10000000 );
5569 addPreference( tr( "PREF_USE_MESHGEMS_HYPOSET" ), segGroup, LightApp_Preferences::Bool, "SMESH", "use-meshgems-hypo-sets" );
5571 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5572 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5573 "SMESH", "forget_mesh_on_hyp_modif" );
5576 // Quantities with individual precision settings
5577 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5578 setPreferenceProperty( precGroup, "columns", 2 );
5580 const int nbQuantities = 6;
5581 int precs[nbQuantities], ii = 0;
5582 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5583 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5584 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5585 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5586 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5587 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5588 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5589 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5590 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5591 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5592 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5593 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5595 // Set property for precision value for spinboxes
5596 for ( ii = 0; ii < nbQuantities; ii++ ){
5597 setPreferenceProperty( precs[ii], "min", -14 );
5598 setPreferenceProperty( precs[ii], "max", 14 );
5599 setPreferenceProperty( precs[ii], "precision", 2 );
5602 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5603 setPreferenceProperty( previewGroup, "columns", 2 );
5604 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5605 setPreferenceProperty( chunkSize, "min", 1 );
5606 setPreferenceProperty( chunkSize, "max", 1000 );
5607 setPreferenceProperty( chunkSize, "step", 50 );
5609 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5610 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5612 // Mesh tab ------------------------------------------------------------------------
5613 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5614 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5615 setPreferenceProperty( nodeGroup, "columns", 3 );
5617 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5619 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5621 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5622 QList<QVariant> aMarkerTypeIndicesList;
5623 QList<QVariant> aMarkerTypeIconsList;
5624 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5625 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5626 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5627 aMarkerTypeIndicesList << i;
5628 aMarkerTypeIconsList << pixmap;
5630 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5631 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5633 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5635 QList<QVariant> aMarkerScaleIndicesList;
5636 QStringList aMarkerScaleValuesList;
5637 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5638 aMarkerScaleIndicesList << i;
5639 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5640 aMarkerScaleValuesList << QString::number( i );
5642 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5643 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5645 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5646 //setPreferenceProperty( elemGroup, "columns", 2 );
5648 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5649 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5650 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5651 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5652 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5653 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5654 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5655 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5656 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5659 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5660 setPreferenceProperty( grpGroup, "columns", 2 );
5662 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5663 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5665 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5666 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5667 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5668 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5669 int ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5670 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5671 int ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5672 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5673 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5674 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5675 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5676 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5677 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5678 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5680 setPreferenceProperty( size0d, "min", 1 );
5681 setPreferenceProperty( size0d, "max", 10 );
5683 // setPreferenceProperty( ballSize, "min", 1 );
5684 // setPreferenceProperty( ballSize, "max", 10 );
5686 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5687 setPreferenceProperty( ballDiameter, "max", 1e9 );
5688 setPreferenceProperty( ballDiameter, "step", 0.1 );
5690 setPreferenceProperty( ballScale, "min", 1e-2 );
5691 setPreferenceProperty( ballScale, "max", 1e7 );
5692 setPreferenceProperty( ballScale, "step", 0.5 );
5694 setPreferenceProperty( elemW, "min", 1 );
5695 setPreferenceProperty( elemW, "max", 5 );
5697 setPreferenceProperty( outW, "min", 1 );
5698 setPreferenceProperty( outW, "max", 5 );
5700 setPreferenceProperty( shrink, "min", 0 );
5701 setPreferenceProperty( shrink, "max", 100 );
5703 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5704 setPreferenceProperty( numGroup, "columns", 2 );
5706 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5707 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5709 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5710 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5712 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5713 setPreferenceProperty( orientGroup, "columns", 1 );
5715 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5716 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5718 setPreferenceProperty( orientScale, "min", 0.05 );
5719 setPreferenceProperty( orientScale, "max", 0.5 );
5720 setPreferenceProperty( orientScale, "step", 0.05 );
5722 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5724 // Selection tab ------------------------------------------------------------------------
5725 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5727 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5728 setPreferenceProperty( selGroup, "columns", 2 );
5730 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5731 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5733 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5734 setPreferenceProperty( preGroup, "columns", 2 );
5736 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5738 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5739 setPreferenceProperty( precSelGroup, "columns", 2 );
5741 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5742 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5743 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5745 int sinc = addPreference(tr("PREF_SELECTION_INCREMENT"), selTab, LightApp_Preferences::IntSpin, "SMESH", "selection_increment");
5746 setPreferenceProperty( sinc, "min", 0 );
5747 setPreferenceProperty( sinc, "max", 5 );
5749 // Scalar Bar tab ------------------------------------------------------------------------
5750 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5751 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5752 setPreferenceProperty( fontGr, "columns", 2 );
5754 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5755 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5757 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5758 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5760 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5761 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5763 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5764 setPreferenceProperty( numcol, "min", 2 );
5765 setPreferenceProperty( numcol, "max", 256 );
5767 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5768 setPreferenceProperty( numlab, "min", 2 );
5769 setPreferenceProperty( numlab, "max", 65 );
5771 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5772 setPreferenceProperty( orientGr, "columns", 2 );
5773 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5774 QStringList orients;
5775 orients.append( tr( "SMESH_VERTICAL" ) );
5776 orients.append( tr( "SMESH_HORIZONTAL" ) );
5777 indices.clear(); indices.append( 0 ); indices.append( 1 );
5778 setPreferenceProperty( orient, "strings", orients );
5779 setPreferenceProperty( orient, "indexes", indices );
5781 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5782 setPreferenceProperty( posVSizeGr, "columns", 2 );
5783 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5784 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5785 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5786 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5787 setPreferenceProperty( xv, "step", 0.1 );
5788 setPreferenceProperty( xv, "min", 0.0 );
5789 setPreferenceProperty( xv, "max", 1.0 );
5790 setPreferenceProperty( yv, "step", 0.1 );
5791 setPreferenceProperty( yv, "min", 0.0 );
5792 setPreferenceProperty( yv, "max", 1.0 );
5793 setPreferenceProperty( wv, "step", 0.1 );
5794 setPreferenceProperty( wv, "min", 0.0 );
5795 setPreferenceProperty( wv, "max", 1.0 );
5796 setPreferenceProperty( hv, "min", 0.0 );
5797 setPreferenceProperty( hv, "max", 1.0 );
5798 setPreferenceProperty( hv, "step", 0.1 );
5800 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5801 setPreferenceProperty( posHSizeGr, "columns", 2 );
5802 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5803 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5804 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5805 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5806 setPreferenceProperty( xv, "min", 0.0 );
5807 setPreferenceProperty( xv, "max", 1.0 );
5808 setPreferenceProperty( xv, "step", 0.1 );
5809 setPreferenceProperty( xh, "min", 0.0 );
5810 setPreferenceProperty( xh, "max", 1.0 );
5811 setPreferenceProperty( xh, "step", 0.1 );
5812 setPreferenceProperty( yh, "min", 0.0 );
5813 setPreferenceProperty( yh, "max", 1.0 );
5814 setPreferenceProperty( yh, "step", 0.1 );
5815 setPreferenceProperty( wh, "min", 0.0 );
5816 setPreferenceProperty( wh, "max", 1.0 );
5817 setPreferenceProperty( wh, "step", 0.1 );
5818 setPreferenceProperty( hh, "min", 0.0 );
5819 setPreferenceProperty( hh, "max", 1.0 );
5820 setPreferenceProperty( hh, "step", 0.1 );
5822 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5823 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5824 setPreferenceProperty( distributionGr, "columns", 3 );
5826 types.append( tr( "SMESH_MONOCOLOR" ) );
5827 types.append( tr( "SMESH_MULTICOLOR" ) );
5828 indices.clear(); indices.append( 0 ); indices.append( 1 );
5829 setPreferenceProperty( coloringType, "strings", types );
5830 setPreferenceProperty( coloringType, "indexes", indices );
5831 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5833 // Adaptation - begin
5834 #ifndef DISABLE_MG_ADAPT
5835 // Adaptation tab ------------------------------------------------------------------------
5836 int adaptTab = addPreference( tr( "ADAPT_PREF_TAB_GENERAL" ) );
5839 bloc = addPreference( tr( "ADAPT_PREF_MG_ADAPT" ), adaptTab );
5840 setPreferenceProperty( bloc, "columns", 1 );
5841 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_file_mesh_out" );
5842 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_publish_mesh_out" );
5843 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_size_map" );
5844 QStringList aListOfSizeMap;
5845 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL" );
5846 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND" );
5847 aListOfSizeMap << tr( "ADAPT_PREF_NONE" );;
5848 setPreferenceProperty( pref, "strings", aListOfSizeMap );
5849 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_time_step" );
5850 QStringList aListOfTimeStep;
5851 aListOfTimeStep << tr( "ADAPT_PREF_NONE" );
5852 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST" );
5853 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_C" );;
5854 setPreferenceProperty( pref, "strings", aListOfTimeStep );
5859 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5861 if ( sect=="SMESH" ) {
5862 double sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5863 double aTol = 1.00000009999999;
5864 std::string aWarning;
5865 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5867 if ( name == "selection_object_color" ||
5868 name == "selection_element_color" ||
5869 name == "highlight_color" ||
5870 name == "selection_precision_node" ||
5871 name == "selection_precision_element" ||
5872 name == "selection_precision_object" ||
5873 name == "selection_increment")
5875 SMESH::UpdateSelectionProp( this );
5877 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5879 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5880 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5881 if ( sbX1+sbW > aTol ) {
5882 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5885 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5886 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5889 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5891 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5892 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5893 if ( sbY1 + sbH > aTol ) {
5894 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5895 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5896 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5899 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5901 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5902 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5903 if ( sbX1 + sbW > aTol ) {
5904 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5907 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5908 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5911 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5913 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5914 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5915 if ( sbY1 + sbH > aTol ) {
5916 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5919 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5920 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5923 else if ( name == "segmentation" )
5925 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5926 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5928 else if ( name == "nb_segments_per_edge" )
5930 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5931 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5933 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5935 QString val = aResourceMgr->stringValue( "SMESH", name );
5936 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5938 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5940 SMESH::UpdateFontProp( this );
5942 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5944 SMESH::UpdateFontProp( this );
5947 if ( aWarning.size() != 0 ) {
5948 aWarning += "The default values are applied instead.";
5949 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5950 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5951 QObject::tr(aWarning.c_str()));
5956 //================================================================================
5958 * \brief Update something in accordance with update flags
5959 * \param theFlags - update flags
5961 * Update viewer or/and object browser etc. in accordance with update flags ( see
5962 * LightApp_UpdateFlags enumeration ).
5964 //================================================================================
5965 void SMESHGUI::update( const int flags )
5967 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5968 SMESH::UpdateView();
5970 SalomeApp_Module::update( flags );
5973 //================================================================================
5975 * \brief Set default selection mode
5977 * SLOT called when operation committed. Sets default selection mode
5979 //================================================================================
5980 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5982 SVTK_ViewWindow* vtkWnd =
5983 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5985 vtkWnd->SetSelectionMode( ActorSelection );
5988 //================================================================================
5990 * \brief Set default selection mode
5992 * SLOT called when operation aborted. Sets default selection mode
5994 //================================================================================
5995 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5997 SVTK_ViewWindow* vtkWnd =
5998 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
6000 vtkWnd->SetSelectionMode( ActorSelection );
6003 //================================================================================
6005 * \brief Creates operation with given identifier
6006 * \param id - identifier of operation to be started
6007 * \return Pointer on created operation or NULL if operation is not created
6009 * Virtual method redefined from the base class creates operation with given id.
6010 * It is called called automatically from startOperation method of base class.
6012 //================================================================================
6013 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
6015 LightApp_Operation* op = 0;
6016 // to do : create operation here
6019 case SMESHOp::OpSplitBiQuadratic:
6020 op = new SMESHGUI_SplitBiQuadOp();
6022 case SMESHOp::OpConvertMeshToQuadratic:
6023 op = new SMESHGUI_ConvToQuadOp();
6025 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
6026 op = new SMESHGUI_Make2DFrom3DOp();
6028 case SMESHOp::OpReorientFaces:
6029 op = new SMESHGUI_ReorientFacesOp();
6031 case SMESHOp::OpCreateMesh:
6032 op = new SMESHGUI_MeshOp( true, true );
6034 case SMESHOp::OpCreateSubMesh:
6035 op = new SMESHGUI_MeshOp( true, false );
6037 case SMESHOp::OpEditMeshOrSubMesh:
6038 case SMESHOp::OpEditMesh:
6039 case SMESHOp::OpEditSubMesh:
6040 op = new SMESHGUI_MeshOp( false );
6042 case SMESHOp::OpCompute:
6043 case SMESHOp::OpComputeSubMesh:
6044 op = new SMESHGUI_ComputeOp();
6046 case SMESHOp::OpShowErrors:
6047 op = new SMESHGUI_ShowErrorsOp();
6049 case SMESHOp::OpPreCompute:
6050 op = new SMESHGUI_PrecomputeOp();
6052 case SMESHOp::OpEvaluate:
6053 op = new SMESHGUI_EvaluateOp();
6055 case SMESHOp::OpMeshOrder:
6056 op = new SMESHGUI_MeshOrderOp();
6058 case SMESHOp::OpCreateGeometryGroup:
6059 op = new SMESHGUI_GroupOnShapeOp();
6061 case SMESHOp::OpFindElementByPoint:
6062 op = new SMESHGUI_FindElemByPointOp();
6064 case SMESHOp::OpMoveNode: // Make mesh pass through point
6065 op = new SMESHGUI_MakeNodeAtPointOp();
6067 case SMESHOp::OpMoveNodeInteractive: // Make mesh pass through point / by mouse
6068 op = new SMESHGUI_MakeNodeAtPointOp( 2 );
6070 case SMESHOp::OpRemoveNodeWithReconn:
6071 op = new SMESHGUI_RemoveNodeReconnectionOp();
6073 case SMESHOp::OpSplitEdgeInteract:
6074 op = new SMESHGUI_AddNodeOnSegmentOp();
6076 case SMESHOp::OpSplitFaceInteract:
6077 op = new SMESHGUI_AddNodeOnFaceOp();
6079 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
6080 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
6087 op = SalomeApp_Module::createOperation( id );
6091 //================================================================================
6093 * \brief Stops current operations and starts a given one
6094 * \param id - The id of the operation to start
6096 //================================================================================
6098 void SMESHGUI::switchToOperation(int id)
6100 activeStudy()->abortAllOperations();
6101 startOperation( id );
6104 LightApp_Displayer* SMESHGUI::displayer()
6107 myDisplayer = new SMESHGUI_Displayer( getApp() );
6111 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
6114 int aTolerance = 64;
6115 int anIterations = 0;
6121 if( anIterations % aPeriod == 0 )
6124 if( aTolerance < 1 )
6128 aHue = (int)( 360.0 * rand() / RAND_MAX );
6131 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
6132 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
6133 for( ; it != itEnd; ++it )
6135 SALOMEDS::Color anAutoColor = *it;
6136 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
6139 aQColor.getHsv( &h, &s, &v );
6140 if( abs( h - aHue ) < aTolerance )
6152 aColor.setHsv( aHue, 255, 255 );
6154 SALOMEDS::Color aSColor;
6155 aSColor.R = aColor.redF();
6156 aSColor.G = aColor.greenF();
6157 aSColor.B = aColor.blueF();
6162 const char* gSeparator = "_"; // character used to separate parameter names
6163 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
6164 const char* gPathSep = "|"; // character used to separate paths
6167 * \brief Store visual parameters
6169 * This method is called just before the study document is saved.
6170 * Store visual parameters in AttributeParameter attribute(s)
6172 void SMESHGUI::storeVisualParameters (int savePoint)
6175 Kernel_Utils::Localizer loc;
6177 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6178 if (!appStudy || !appStudy->studyDS())
6180 _PTR(Study) studyDS = appStudy->studyDS();
6182 // componentName is used for encoding of entries when storing them in IParameters
6183 std::string componentName = myComponentSMESH->ComponentDataType();
6184 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
6185 //if (!aSComponent) return;
6188 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6189 componentName.c_str(),
6191 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6193 // store custom markers
6194 if( !myMarkerMap.empty() )
6196 VTK::MarkerMap::const_iterator anIter = myMarkerMap.begin();
6197 for( ; anIter != myMarkerMap.end(); anIter++ )
6199 int anId = anIter->first;
6200 VTK::MarkerData aMarkerData = anIter->second;
6201 std::string aMarkerFileName = aMarkerData.first;
6202 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
6203 if( aMarkerTexture.size() < 3 )
6204 continue; // should contain at least width, height and the first value
6206 QString aPropertyName( "texture" );
6207 aPropertyName += gSeparator;
6208 aPropertyName += QString::number( anId );
6210 QString aPropertyValue = aMarkerFileName.c_str();
6211 aPropertyValue += gPathSep;
6213 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
6214 ushort aWidth = *aTextureIter++;
6215 ushort aHeight = *aTextureIter++;
6216 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
6217 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
6218 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
6219 aPropertyValue += QString::number( *aTextureIter );
6221 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6225 // viewers counters are used for storing view_numbers in IParameters
6228 // main cycle to store parameters of displayed objects
6229 QList<SUIT_ViewManager*> lst;
6230 QList<SUIT_ViewManager*>::Iterator it;
6231 getApp()->viewManagers(lst);
6232 for (it = lst.begin(); it != lst.end(); it++)
6234 SUIT_ViewManager* vman = *it;
6235 QString vType = vman->getType();
6237 // saving VTK actors properties
6238 if (vType == SVTK_Viewer::Type())
6240 // store the clipping planes attached to the view manager
6241 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
6242 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
6243 if( anIter != myClippingPlaneInfoMap.end() )
6244 aClippingPlaneInfoList = anIter->second;
6246 if( !aClippingPlaneInfoList.empty() ) {
6247 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
6248 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
6250 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
6251 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
6253 QString aPropertyName( "ClippingPlane" );
6254 aPropertyName += gSeparator;
6255 aPropertyName += QString::number( vtkViewers );
6256 aPropertyName += gSeparator;
6257 aPropertyName += QString::number( anId );
6259 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
6260 aPropertyValue += gDigitsSep;
6261 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
6262 aPropertyValue += gDigitsSep;
6263 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6264 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
6265 aPropertyValue += gDigitsSep;
6266 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
6267 aPropertyValue += gDigitsSep;
6268 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
6269 aPropertyValue += gDigitsSep;
6270 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
6271 aPropertyValue += gDigitsSep;
6272 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
6273 aPropertyValue += gDigitsSep;
6274 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
6275 aPropertyValue += gDigitsSep;
6276 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
6278 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6279 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
6280 aPropertyValue += gDigitsSep;
6281 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
6282 aPropertyValue += gDigitsSep;
6283 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
6284 aPropertyValue += gDigitsSep;
6285 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
6288 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6292 QVector<SUIT_ViewWindow*> views = vman->getViews();
6293 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
6295 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
6297 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
6298 vtkActorCollection* allActors = aCopy.GetActors();
6299 allActors->InitTraversal();
6300 while (vtkActor* actor = allActors->GetNextActor())
6302 if (actor->GetVisibility()) // store only visible actors
6304 SMESH_Actor* aSmeshActor = 0;
6305 if (actor->IsA("SMESH_Actor"))
6306 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
6307 if (aSmeshActor && aSmeshActor->hasIO())
6309 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
6312 // entry is "encoded" = it does NOT contain component address,
6313 // since it is a subject to change on next component loading
6314 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
6316 std::string param, vtkParam = vType.toLatin1().data();
6317 vtkParam += gSeparator;
6318 vtkParam += QString::number(vtkViewers).toLatin1().data();
6319 vtkParam += gSeparator;
6322 param = vtkParam + "Visibility";
6323 ip->setParameter(entry, param, "On");
6326 param = vtkParam + "Representation";
6327 ip->setParameter(entry, param, QString::number
6328 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
6331 param = vtkParam + "IsShrunk";
6332 ip->setParameter(entry, param, QString::number
6333 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
6335 // Displayed entities
6336 unsigned int aMode = aSmeshActor->GetEntityMode();
6337 bool isE = aMode & SMESH_Actor::eEdges;
6338 bool isF = aMode & SMESH_Actor::eFaces;
6339 bool isV = aMode & SMESH_Actor::eVolumes;
6340 bool is0d = aMode & SMESH_Actor::e0DElements;
6341 bool isB = aMode & SMESH_Actor::eBallElem;
6343 QString modeStr ("e");
6344 modeStr += gDigitsSep; modeStr += QString::number(isE);
6345 modeStr += gDigitsSep; modeStr += "f";
6346 modeStr += gDigitsSep; modeStr += QString::number(isF);
6347 modeStr += gDigitsSep; modeStr += "v";
6348 modeStr += gDigitsSep; modeStr += QString::number(isV);
6349 modeStr += gDigitsSep; modeStr += "0d";
6350 modeStr += gDigitsSep; modeStr += QString::number(is0d);
6351 modeStr += gDigitsSep; modeStr += "b";
6352 modeStr += gDigitsSep; modeStr += QString::number(isB);
6354 param = vtkParam + "Entities";
6355 ip->setParameter(entry, param, modeStr.toLatin1().data());
6361 aSmeshActor->GetSufaceColor(r, g, b, delta);
6362 QStringList colorStr;
6363 colorStr << "surface";
6364 colorStr << QString::number(r);
6365 colorStr << QString::number(g);
6366 colorStr << QString::number(b);
6368 colorStr << "backsurface";
6369 colorStr << QString::number(delta);
6371 aSmeshActor->GetVolumeColor(r, g, b, delta);
6372 colorStr << "volume";
6373 colorStr << QString::number(r);
6374 colorStr << QString::number(g);
6375 colorStr << QString::number(b);
6376 colorStr << QString::number(delta);
6378 aSmeshActor->GetEdgeColor(r, g, b);
6380 colorStr << QString::number(r);
6381 colorStr << QString::number(g);
6382 colorStr << QString::number(b);
6384 aSmeshActor->GetNodeColor(r, g, b);
6386 colorStr << QString::number(r);
6387 colorStr << QString::number(g);
6388 colorStr << QString::number(b);
6390 aSmeshActor->GetOutlineColor(r, g, b);
6391 colorStr << "outline";
6392 colorStr << QString::number(r);
6393 colorStr << QString::number(g);
6394 colorStr << QString::number(b);
6396 aSmeshActor->Get0DColor(r, g, b);
6397 colorStr << "elem0d";
6398 colorStr << QString::number(r);
6399 colorStr << QString::number(g);
6400 colorStr << QString::number(b);
6402 aSmeshActor->GetBallColor(r, g, b);
6404 colorStr << QString::number(r);
6405 colorStr << QString::number(g);
6406 colorStr << QString::number(b);
6408 aSmeshActor->GetFacesOrientationColor(r, g, b);
6409 colorStr << "orientation";
6410 colorStr << QString::number(r);
6411 colorStr << QString::number(g);
6412 colorStr << QString::number(b);
6414 param = vtkParam + "Colors";
6415 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
6418 QStringList sizeStr;
6420 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
6421 sizeStr << "outline";
6422 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
6423 sizeStr << "elem0d";
6424 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
6426 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
6427 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
6428 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
6429 sizeStr << "shrink";
6430 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
6431 sizeStr << "orientation";
6432 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
6433 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
6435 param = vtkParam + "Sizes";
6436 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
6441 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
6442 if( aMarkerType == VTK::MT_USER ) {
6443 markerStr += "custom";
6444 markerStr += gDigitsSep;
6445 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
6449 markerStr += gDigitsSep;
6450 markerStr += QString::number( (int)aMarkerType );
6451 markerStr += gDigitsSep;
6452 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
6455 param = vtkParam + "PointMarker";
6456 ip->setParameter(entry, param, markerStr.toLatin1().data());
6459 param = vtkParam + "Opacity";
6460 ip->setParameter(entry, param,
6461 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
6464 param = vtkParam + "ClippingPlane";
6466 if( !aClippingPlaneInfoList.empty() ) {
6467 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
6468 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
6470 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
6471 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
6472 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6473 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6474 if( aSmeshActor == *anIter2 ) {
6475 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6476 QString::number( anId ).toLatin1().constData() );
6483 ip->setParameter( entry, param, "Off" );
6484 } // if (io->hasEntry())
6485 } // SMESH_Actor && hasIO
6487 } // while.. actors traversal
6491 } // if (SVTK view model)
6492 } // for (viewManagers)
6495 // data structures for clipping planes processing
6499 bool isOpenGLClipping;
6500 vtkIdType RelativeOrientation;
6503 int AbsoluteOrientation;
6504 double X, Y, Z, Dx, Dy, Dz;
6506 typedef std::list<TPlaneData> TPlaneDataList;
6507 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6509 typedef std::list<vtkActor*> TActorList;
6512 TActorList ActorList;
6513 SUIT_ViewManager* ViewManager;
6515 typedef std::list<TPlaneInfo> TPlaneInfoList;
6516 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6519 * \brief Restore visual parameters
6521 * This method is called after the study document is opened.
6522 * Restore visual parameters from AttributeParameter attribute(s)
6524 void SMESHGUI::restoreVisualParameters (int savePoint)
6527 Kernel_Utils::Localizer loc;
6529 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6530 if (!appStudy || !appStudy->studyDS())
6532 _PTR(Study) studyDS = appStudy->studyDS();
6534 // componentName is used for encoding of entries when storing them in IParameters
6535 std::string componentName = myComponentSMESH->ComponentDataType();
6538 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6539 componentName.c_str(),
6541 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6543 // restore custom markers and map of clipping planes
6544 TPlaneDataMap aPlaneDataMap;
6546 std::vector<std::string> properties = ip->getProperties();
6547 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6549 std::string property = *propIt;
6550 QString aPropertyName( property.c_str() );
6551 QString aPropertyValue( ip->getProperty( property ).c_str() );
6553 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6554 if( aPropertyNameList.isEmpty() )
6557 QString aPropertyType = aPropertyNameList[0];
6558 if( aPropertyType == "texture" )
6560 if( aPropertyNameList.size() != 2 )
6564 int anId = aPropertyNameList[1].toInt( &ok );
6565 if( !ok || anId < 1 )
6568 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6569 if( aPropertyValueList.size() != 2 )
6572 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6573 QString aMarkerTextureString = aPropertyValueList[1];
6574 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6575 if( aMarkerTextureStringList.size() != 3 )
6579 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6584 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6588 VTK::MarkerTexture aMarkerTexture;
6589 aMarkerTexture.push_back( aWidth );
6590 aMarkerTexture.push_back( aHeight );
6592 QString aMarkerTextureData = aMarkerTextureStringList[2];
6593 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6595 QChar aChar = aMarkerTextureData.at( i );
6596 if( aChar.isDigit() )
6597 aMarkerTexture.push_back( aChar.digitValue() );
6600 myMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6602 else if( aPropertyType == "ClippingPlane" )
6604 if( aPropertyNameList.size() != 3 )
6608 int aViewId = aPropertyNameList[1].toInt( &ok );
6609 if( !ok || aViewId < 0 )
6613 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6614 if( !ok || aClippingPlaneId < 0 )
6617 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6618 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6621 TPlaneData aPlaneData;
6622 aPlaneData.AbsoluteOrientation = false;
6623 aPlaneData.RelativeOrientation = 0;
6624 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6625 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6626 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6628 aPlaneData.Id = aClippingPlaneId;
6631 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6636 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6640 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6643 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6648 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6653 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6658 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6663 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6668 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6673 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6677 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6679 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6684 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6689 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6694 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6699 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6700 aPlaneDataList.push_back( aPlaneData );
6704 TPlaneInfoMap aPlaneInfoMap;
6706 std::vector<std::string> entries = ip->getEntries();
6708 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6710 // entry is a normal entry - it should be "decoded" (setting base address of component)
6711 QString entry (ip->decodeEntry(*entIt).c_str());
6713 // Check that the entry corresponds to a real object in the Study
6714 // as the object may be deleted or modified after the visual state is saved.
6715 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
6716 if (!so) continue; //Skip the not existent entry
6718 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6719 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6721 std::vector<std::string>::iterator namesIt = paramNames.begin();
6722 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6724 // actors are stored in a map after displaying of them for
6725 // quicker access in the future: map < viewID to actor >
6726 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6728 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6730 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6731 // '_' is used as separator and should not be used in viewer type or parameter names.
6732 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6733 if (lst.size() != 3)
6736 QString viewerTypStr = lst[0];
6737 QString viewIndexStr = lst[1];
6738 QString paramNameStr = lst[2];
6741 int viewIndex = viewIndexStr.toUInt(&ok);
6742 if (!ok) // bad conversion of view index to integer
6746 if (viewerTypStr == SVTK_Viewer::Type())
6748 SMESH_Actor* aSmeshActor = 0;
6749 if (vtkActors.IsBound(viewIndex))
6750 aSmeshActor = vtkActors.Find(viewIndex);
6752 QList<SUIT_ViewManager*> lst;
6753 getApp()->viewManagers(viewerTypStr, lst);
6755 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6756 SUIT_ViewManager* vman = NULL;
6757 if (viewIndex >= 0 && viewIndex < lst.count())
6758 vman = lst.at(viewIndex);
6760 if (paramNameStr == "Visibility")
6762 if (!aSmeshActor && displayer() && vman)
6764 SUIT_ViewModel* vmodel = vman->getViewModel();
6765 // SVTK view model can be casted to SALOME_View
6766 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6768 // store displayed actor in a temporary map for quicker
6769 // access later when restoring other parameters
6770 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6771 vtkRenderer* Renderer = vtkView->getRenderer();
6772 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6773 vtkActorCollection* theActors = aCopy.GetActors();
6774 theActors->InitTraversal();
6775 bool isFound = false;
6776 vtkActor *ac = theActors->GetNextActor();
6777 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6778 if (ac->IsA("SMESH_Actor")) {
6779 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6780 if (aGeomAc->hasIO()) {
6781 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6782 if (io->hasEntry() && strcmp(io->getEntry(), entry.toUtf8().data()) == 0) {
6784 vtkActors.Bind(viewIndex, aGeomAc);
6790 } // if (paramNameStr == "Visibility")
6793 // the rest properties "work" with SMESH_Actor
6796 QString val ((*valuesIt).c_str());
6799 if (paramNameStr == "Representation") {
6800 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6803 else if (paramNameStr == "IsShrunk") {
6805 if (!aSmeshActor->IsShrunk())
6806 aSmeshActor->SetShrink();
6809 if (aSmeshActor->IsShrunk())
6810 aSmeshActor->UnShrink();
6813 // Displayed entities
6814 else if (paramNameStr == "Entities") {
6815 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6816 int aEntityMode = SMESH_Actor::eAllEntity;
6817 for ( int i = 0; i < mode.count(); i+=2 ) {
6818 if ( i < mode.count()-1 ) {
6819 QString type = mode[i];
6820 bool val = mode[i+1].toInt();
6821 if ( type == "e" && !val )
6822 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6823 else if ( type == "f" && !val )
6824 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6825 else if ( type == "v" && !val )
6826 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6827 else if ( type == "0d" && !val )
6828 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6829 else if ( type == "b" && !val )
6830 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6833 aSmeshActor->SetEntityMode( aEntityMode );
6836 else if (paramNameStr == "Colors") {
6837 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6844 QColor outlineColor;
6845 QColor orientationColor;
6851 // below lines are required to get default values for delta coefficients
6852 // of backface color for faces and color of reversed volumes
6853 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6854 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6855 for ( int i = 0; i < colors.count(); i++ ) {
6856 QString type = colors[i];
6857 if ( type == "surface" ) {
6858 // face color is set by 3 values r:g:b, where
6859 // - r,g,b - is rgb color components
6860 if ( i+1 >= colors.count() ) break; // format error
6861 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6862 if ( i+2 >= colors.count() ) break; // format error
6863 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6864 if ( i+3 >= colors.count() ) break; // format error
6865 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6866 faceColor.setRgbF( r, g, b );
6869 else if ( type == "backsurface" ) {
6870 // backface color can be defined in several ways
6871 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6872 // - in latest versions, it is set as delta coefficient
6873 bool rgbOk = false, deltaOk;
6874 if ( i+1 >= colors.count() ) break; // format error
6875 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6876 int delta = colors[i+1].toInt( &deltaOk );
6878 if ( i+1 < colors.count() ) // index is shifted to 1
6879 g = colors[i+1].toDouble( &rgbOk );
6880 if ( rgbOk ) i++; // shift index
6881 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6882 b = colors[i+1].toDouble( &rgbOk );
6884 // - as currently there's no way to set directly backsurface color as it was before,
6885 // we ignore old dump where r,g,b triple was set
6886 // - also we check that delta parameter is set properly
6887 if ( !rgbOk && deltaOk )
6890 else if ( type == "volume" ) {
6891 // volume color is set by 4 values r:g:b:delta, where
6892 // - r,g,b - is a normal volume rgb color components
6893 // - delta - is a reversed volume color delta coefficient
6894 if ( i+1 >= colors.count() ) break; // format error
6895 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6896 if ( i+2 >= colors.count() ) break; // format error
6897 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6898 if ( i+3 >= colors.count() ) break; // format error
6899 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6900 if ( i+4 >= colors.count() ) break; // format error
6901 int delta = colors[i+4].toInt( &bOk );
6902 if ( !bOk ) break; // format error
6903 volumeColor.setRgbF( r, g, b );
6907 else if ( type == "edge" ) {
6908 // edge color is set by 3 values r:g:b, where
6909 // - r,g,b - is rgb color components
6910 if ( i+1 >= colors.count() ) break; // format error
6911 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6912 if ( i+2 >= colors.count() ) break; // format error
6913 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6914 if ( i+3 >= colors.count() ) break; // format error
6915 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6916 edgeColor.setRgbF( r, g, b );
6919 else if ( type == "node" ) {
6920 // node color is set by 3 values r:g:b, where
6921 // - r,g,b - is rgb color components
6922 if ( i+1 >= colors.count() ) break; // format error
6923 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6924 if ( i+2 >= colors.count() ) break; // format error
6925 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6926 if ( i+3 >= colors.count() ) break; // format error
6927 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6928 nodeColor.setRgbF( r, g, b );
6931 else if ( type == "elem0d" ) {
6932 // 0d element color is set by 3 values r:g:b, where
6933 // - r,g,b - is rgb color components
6934 if ( i+1 >= colors.count() ) break; // format error
6935 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6936 if ( i+2 >= colors.count() ) break; // format error
6937 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6938 if ( i+3 >= colors.count() ) break; // format error
6939 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6940 elem0dColor.setRgbF( r, g, b );
6943 else if ( type == "ball" ) {
6944 // ball color is set by 3 values r:g:b, where
6945 // - r,g,b - is rgb color components
6946 if ( i+1 >= colors.count() ) break; // format error
6947 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6948 if ( i+2 >= colors.count() ) break; // format error
6949 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6950 if ( i+3 >= colors.count() ) break; // format error
6951 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6952 ballColor.setRgbF( r, g, b );
6955 else if ( type == "outline" ) {
6956 // outline color is set by 3 values r:g:b, where
6957 // - r,g,b - is rgb color components
6958 if ( i+1 >= colors.count() ) break; // format error
6959 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6960 if ( i+2 >= colors.count() ) break; // format error
6961 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6962 if ( i+3 >= colors.count() ) break; // format error
6963 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6964 outlineColor.setRgbF( r, g, b );
6967 else if ( type == "orientation" ) {
6968 // orientation color is set by 3 values r:g:b, where
6969 // - r,g,b - is rgb color components
6970 if ( i+1 >= colors.count() ) break; // format error
6971 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6972 if ( i+2 >= colors.count() ) break; // format error
6973 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6974 if ( i+3 >= colors.count() ) break; // format error
6975 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6976 orientationColor.setRgbF( r, g, b );
6981 if ( nodeColor.isValid() )
6982 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6984 if ( edgeColor.isValid() )
6985 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6987 if ( faceColor.isValid() )
6988 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6990 if ( volumeColor.isValid() )
6991 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6992 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6993 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6995 if ( elem0dColor.isValid() )
6996 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6998 if ( ballColor.isValid() )
6999 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
7001 if ( outlineColor.isValid() )
7002 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
7003 // orientation color
7004 if ( orientationColor.isValid() )
7005 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
7008 else if (paramNameStr == "Sizes") {
7009 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
7012 int outlineWidth = -1;
7013 int elem0dSize = -1;
7014 //int ballSize = -1;
7015 double ballDiameter = -1.0;
7016 double ballScale = -1.0;
7017 double shrinkSize = -1;
7018 double orientationSize = -1;
7019 bool orientation3d = false;
7020 for ( int i = 0; i < sizes.count(); i++ ) {
7021 QString type = sizes[i];
7022 if ( type == "line" ) {
7023 // line (wireframe) width is given as single integer value
7024 if ( i+1 >= sizes.count() ) break; // format error
7025 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7029 if ( type == "outline" ) {
7030 // outline width is given as single integer value
7031 if ( i+1 >= sizes.count() ) break; // format error
7032 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7036 else if ( type == "elem0d" ) {
7037 // 0d element size is given as single integer value
7038 if ( i+1 >= sizes.count() ) break; // format error
7039 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7043 else if ( type == "ball" ) {
7044 // balls are specified by two values: size:scale, where
7045 // - size - is a integer value specifying size
7046 // - scale - is a double value specifying scale factor
7047 if ( i+1 >= sizes.count() ) break; // format error
7048 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7049 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7050 if ( i+2 >= sizes.count() ) break; // format error
7051 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7057 else if ( type == "shrink" ) {
7058 // shrink factor is given as single floating point value
7059 if ( i+1 >= sizes.count() ) break; // format error
7060 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7064 else if ( type == "orientation" ) {
7065 // orientation vectors are specified by two values size:3d, where
7066 // - size - is a floating point value specifying scale factor
7067 // - 3d - is a boolean
7068 if ( i+1 >= sizes.count() ) break; // format error
7069 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7070 if ( i+2 >= sizes.count() ) break; // format error
7071 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
7072 orientationSize = v1;
7073 orientation3d = (bool)v2;
7077 // line (wireframe) width
7078 if ( lineWidth > 0 )
7079 aSmeshActor->SetLineWidth( lineWidth );
7081 if ( outlineWidth > 0 )
7082 aSmeshActor->SetOutlineWidth( outlineWidth );
7083 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
7084 aSmeshActor->SetOutlineWidth( lineWidth );
7086 if ( elem0dSize > 0 )
7087 aSmeshActor->Set0DSize( elem0dSize );
7089 /*if ( ballSize > 0 )
7090 aSmeshActor->SetBallSize( ballSize );*/
7092 if ( ballDiameter > 0 )
7093 aSmeshActor->SetBallSize( ballDiameter );
7095 if ( ballScale > 0.0 )
7096 aSmeshActor->SetBallScale( ballScale );
7098 if ( shrinkSize > 0 )
7099 aSmeshActor->SetShrinkFactor( shrinkSize );
7100 // orientation vectors
7101 if ( orientationSize > 0 ) {
7102 aSmeshActor->SetFacesOrientationScale( orientationSize );
7103 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
7107 else if (paramNameStr == "PointMarker") {
7108 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
7109 if( data.count() >= 2 ) {
7111 int aParam1 = data[1].toInt( &ok );
7113 if( data[0] == "std" && data.count() == 3 ) {
7114 int aParam2 = data[2].toInt( &ok );
7115 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
7117 else if( data[0] == "custom" ) {
7118 VTK::MarkerMap::const_iterator markerIt = myMarkerMap.find( aParam1 );
7119 if( markerIt != myMarkerMap.end() ) {
7120 VTK::MarkerData aMarkerData = markerIt->second;
7121 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
7128 else if (paramNameStr == "Opacity") {
7129 aSmeshActor->SetOpacity(val.toFloat());
7132 else if (paramNameStr.startsWith("ClippingPlane")) {
7133 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
7134 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
7135 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
7136 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
7137 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
7138 // new format - val looks like "Off" or "0" (plane id)
7139 // (note: in new format "Off" value is used only for consistency,
7140 // so it is processed together with values in old format)
7141 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
7142 if( anIsOldFormat ) {
7143 if (paramNameStr == "ClippingPlane1" || val == "Off")
7144 aSmeshActor->RemoveAllClippingPlanes();
7146 QList<SUIT_ViewManager*> lst;
7147 getApp()->viewManagers(viewerTypStr, lst);
7148 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
7149 if (viewIndex >= 0 && viewIndex < lst.count()) {
7150 SUIT_ViewManager* vman = lst.at(viewIndex);
7151 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
7153 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
7155 SMESH::TActorList anActorList;
7156 anActorList.push_back( aSmeshActor );
7157 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
7158 aPlane->myViewWindow = vtkView;
7159 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
7160 aPlane->PlaneMode = aMode;
7161 bool isOpenGLClipping = ( bool )vals[1].toInt();
7162 aPlane->IsOpenGLClipping = isOpenGLClipping;
7163 if ( aMode == SMESH::Absolute ) {
7164 aPlane->myAbsoluteOrientation = vals[2].toInt();
7165 aPlane->X = vals[3].toFloat();
7166 aPlane->Y = vals[4].toFloat();
7167 aPlane->Z = vals[5].toFloat();
7168 aPlane->Dx = vals[6].toFloat();
7169 aPlane->Dy = vals[7].toFloat();
7170 aPlane->Dz = vals[8].toFloat();
7172 else if ( aMode == SMESH::Relative ) {
7173 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
7174 aPlane->myDistance = vals[3].toFloat();
7175 aPlane->myAngle[0] = vals[4].toFloat();
7176 aPlane->myAngle[1] = vals[5].toFloat();
7180 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7181 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7182 aClippingPlaneInfo.Plane = aPlane;
7183 aClippingPlaneInfo.ActorList = anActorList;
7184 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7192 int aPlaneId = val.toInt( &ok );
7193 if( ok && aPlaneId >= 0 ) {
7194 bool anIsDefinedPlane = false;
7195 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
7196 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
7197 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7198 TPlaneInfo& aPlaneInfo = *anIter;
7199 if( aPlaneInfo.PlaneId == aPlaneId ) {
7200 aPlaneInfo.ActorList.push_back( aSmeshActor );
7201 anIsDefinedPlane = true;
7205 if( !anIsDefinedPlane ) {
7206 TPlaneInfo aPlaneInfo;
7207 aPlaneInfo.PlaneId = aPlaneId;
7208 aPlaneInfo.ActorList.push_back( aSmeshActor );
7209 aPlaneInfo.ViewManager = vman;
7211 // to make the list sorted by plane id
7212 anIter = aPlaneInfoList.begin();
7213 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7214 const TPlaneInfo& aPlaneInfoRef = *anIter;
7215 if( aPlaneInfoRef.PlaneId > aPlaneId )
7218 aPlaneInfoList.insert( anIter, aPlaneInfo );
7223 } // if (aSmeshActor)
7224 } // other parameters than Visibility
7226 } // for names/parameters iterator
7227 } // for entries iterator
7229 // take into account planes with empty list of actors referred to them
7230 QList<SUIT_ViewManager*> aVMList;
7231 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
7233 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
7234 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
7235 int aViewId = aPlaneDataIter->first;
7236 if( aViewId >= 0 && aViewId < aVMList.count() ) {
7237 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
7239 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
7241 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
7242 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
7243 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
7244 const TPlaneData& aPlaneData = *anIter2;
7245 int aPlaneId = aPlaneData.Id;
7247 bool anIsFound = false;
7248 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7249 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7250 const TPlaneInfo& aPlaneInfo = *anIter3;
7251 if( aPlaneInfo.PlaneId == aPlaneId ) {
7258 TPlaneInfo aPlaneInfo; // ActorList field is empty
7259 aPlaneInfo.PlaneId = aPlaneId;
7260 aPlaneInfo.ViewManager = aViewManager;
7262 // to make the list sorted by plane id
7263 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
7264 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
7265 const TPlaneInfo& aPlaneInfoRef = *anIter4;
7266 if( aPlaneInfoRef.PlaneId > aPlaneId )
7269 aPlaneInfoList.insert( anIter4, aPlaneInfo );
7275 // add clipping planes to actors according to the restored parameters
7276 // and update the clipping plane map
7277 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
7278 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
7279 int aViewId = anIter1->first;
7280 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
7282 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
7283 if( anIter2 == aPlaneDataMap.end() )
7285 const TPlaneDataList& aPlaneDataList = anIter2->second;
7287 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7288 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7289 const TPlaneInfo& aPlaneInfo = *anIter3;
7290 int aPlaneId = aPlaneInfo.PlaneId;
7291 const TActorList& anActorList = aPlaneInfo.ActorList;
7292 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
7296 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
7300 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
7302 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
7303 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
7304 const TPlaneData& aPlaneData = *anIter4;
7305 if( aPlaneData.Id == aPlaneId ) {
7306 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
7307 aPlane->myViewWindow = aViewWindow;
7308 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
7309 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
7310 if ( aPlane->PlaneMode == SMESH::Absolute ) {
7311 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
7312 aPlane->X = aPlaneData.X;
7313 aPlane->Y = aPlaneData.Y;
7314 aPlane->Z = aPlaneData.Z;
7315 aPlane->Dx = aPlaneData.Dx;
7316 aPlane->Dy = aPlaneData.Dy;
7317 aPlane->Dz = aPlaneData.Dz;
7319 else if ( aPlane->PlaneMode == SMESH::Relative ) {
7320 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
7321 aPlane->myDistance = aPlaneData.Distance;
7322 aPlane->myAngle[0] = aPlaneData.Angle[0];
7323 aPlane->myAngle[1] = aPlaneData.Angle[1];
7326 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7327 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7328 aClippingPlaneInfo.Plane = aPlane;
7329 aClippingPlaneInfo.ActorList = anActorList;
7330 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7341 // update all VTK views
7342 QList<SUIT_ViewManager*> lst;
7343 getApp()->viewManagers(lst);
7344 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
7345 SUIT_ViewModel* vmodel = (*it)->getViewModel();
7346 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
7347 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
7348 // set OpenGL clipping planes
7349 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
7350 vtkActorCollection* anAllActors = aCopy.GetActors();
7351 anAllActors->InitTraversal();
7352 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
7353 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
7354 anActor->SetOpenGLClippingPlane();
7356 vtkView->getRenderer()->ResetCameraClippingRange();
7363 \brief Adds preferences for dfont of VTK viewer
7365 \param pIf group identifier
7366 \param param parameter
7367 \return identifier of preferences
7369 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
7371 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
7373 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
7376 fam.append( tr( "SMESH_FONT_ARIAL" ) );
7377 fam.append( tr( "SMESH_FONT_COURIER" ) );
7378 fam.append( tr( "SMESH_FONT_TIMES" ) );
7380 setPreferenceProperty( tfont, "fonts", fam );
7382 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
7383 if ( needSize ) f = f | QtxFontEdit::Size;
7384 setPreferenceProperty( tfont, "features", f );
7390 \brief Actions after hypothesis edition
7391 Updates object browser after hypothesis edition
7393 void SMESHGUI::onHypothesisEdit( int result )
7396 SMESHGUI::Modified();
7397 updateObjBrowser( true );
7401 \brief Actions after choosing menu of control modes
7402 Updates control mode actions according to current selection
7404 void SMESHGUI::onUpdateControlActions()
7406 SALOME_ListIO selected;
7407 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
7408 aSel->selectedObjects( selected );
7410 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
7411 if ( selected.Extent() ) {
7412 if ( selected.First()->hasEntry() ) {
7413 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
7414 aControl = anActor->GetControlMode();
7415 SALOME_ListIteratorOfListIO it(selected);
7416 for ( it.Next(); it.More(); it.Next() ) {
7417 Handle(SALOME_InteractiveObject) anIO = it.Value();
7418 if ( anIO->hasEntry() ) {
7419 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
7420 if ( aControl != anActor->GetControlMode() ) {
7421 aControl = SMESH_Actor::eNone;
7431 int anAction = ActionToControl( aControl, true );
7433 action( anAction )->setChecked( true );
7435 QMenu* send = (QMenu*)sender();
7436 QList<QAction*> actions = send->actions();
7437 for ( int i = 0; i < actions.size(); i++ )
7438 actions[i]->setChecked( false );
7444 \brief Signal handler closing(SUIT_ViewWindow*) of a view
7445 \param pview view being closed
7447 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
7448 #ifndef DISABLE_PLOT2DVIEWER
7449 //Crear all Plot2d Viewers if need.
7450 SMESH::ClearPlot2Viewers(pview);
7452 EmitSignalCloseView();
7455 void SMESHGUI::message( const QString& msg )
7458 QStringList data = msg.split("/");
7459 if ( data.count() > 0 ) {
7460 if ( data.first() == "mesh_loading" ) {
7462 QString entry = data.count() > 1 ? data[1] : QString();
7463 if ( entry.isEmpty() )
7466 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
7468 _PTR(SObject) obj = study->FindObjectID( entry.toUtf8().constData() );
7471 name = SMESH::fromUtf8(obj->GetName());
7472 if ( name.isEmpty() )
7475 if ( data.last() == "stop" )
7476 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7478 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7479 QApplication::processEvents();
7485 \brief Connects or disconnects signals about activating and cloning view on the module slots
7486 \param pview view which is connected/disconnected
7488 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7492 SUIT_ViewManager* viewMgr = pview->getViewManager();
7494 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7495 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7497 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7498 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7503 \brief Return \c true if object can be renamed
7505 bool SMESHGUI::renameAllowed( const QString& entry) const {
7506 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7510 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7514 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7519 if(appStudy->isComponent(entry) || obj->isReference())
7522 // check type to prevent renaming of inappropriate objects
7523 int aType = SMESHGUI_Selection::type(qPrintable(entry));
7524 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7525 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7526 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7527 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7528 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7535 Rename object by entry.
7536 \param entry entry of the object
7537 \param name new name of the object
7538 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7540 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7542 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7546 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7551 _PTR(Study) aStudy = appStudy->studyDS();
7556 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7558 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7563 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7564 _PTR(GenericAttribute) anAttr;
7565 _PTR(AttributeName) aName;
7567 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7569 // check type to prevent renaming of inappropriate objects
7570 int aType = SMESHGUI_Selection::type( qPrintable(entry));
7571 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7572 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7573 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7574 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7575 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7576 if ( !name.isEmpty() ) {
7577 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qUtf8Printable(name) );
7579 // update name of group object and its actor
7580 Handle(SALOME_InteractiveObject) IObject =
7581 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7583 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7584 if( !aGroupObject->_is_nil() ) {
7585 aGroupObject->SetName( qUtf8Printable(name) );
7586 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7587 anActor->setName( qUtf8Printable(name) );
7597 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7599 static QList<QColor> colors;
7601 if ( colors.isEmpty() ) {
7603 for (int s = 0; s < 2 ; s++)
7605 for (int v = 100; v >= 40; v = v - 20)
7607 for (int h = 0; h < 359 ; h = h + 60)
7609 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7614 static int currentColor = randomize( colors.size() );
7616 SALOMEDS::Color color;
7617 color.R = (double)colors[currentColor].red() / 255.0;
7618 color.G = (double)colors[currentColor].green() / 255.0;
7619 color.B = (double)colors[currentColor].blue() / 255.0;
7621 currentColor = (currentColor+1) % colors.count();