1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
33 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
34 #include "SMESHGUI_AddMeshElementDlg.h"
35 #include "SMESHGUI_AddQuadraticElementDlg.h"
36 #include "SMESHGUI_BuildCompoundDlg.h"
37 #include "SMESHGUI_ClippingDlg.h"
38 #include "SMESHGUI_ComputeDlg.h"
39 #include "SMESHGUI_ConvToQuadOp.h"
40 #include "SMESHGUI_CopyMeshDlg.h"
41 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
42 #include "SMESHGUI_DeleteGroupDlg.h"
43 #include "SMESHGUI_DisplayEntitiesDlg.h"
44 #include "SMESHGUI_Displayer.h"
45 #include "SMESHGUI_DuplicateNodesDlg.h"
46 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
47 #include "SMESHGUI_ExtrusionDlg.h"
48 #include "SMESHGUI_FaceGroupsSeparatedByEdgesDlg.h"
49 #include "SMESHGUI_FieldSelectorWdg.h"
50 #include "SMESHGUI_FileInfoDlg.h"
51 #include "SMESHGUI_FileValidator.h"
52 #include "SMESHGUI_FilterDlg.h"
53 #include "SMESHGUI_FilterLibraryDlg.h"
54 #include "SMESHGUI_FilterUtils.h"
55 #include "SMESHGUI_FindElemByPointDlg.h"
56 #include "SMESHGUI_GEOMGenUtils.h"
57 #include "SMESHGUI_GroupDlg.h"
58 #include "SMESHGUI_GroupOnShapeDlg.h"
59 #include "SMESHGUI_GroupOpDlg.h"
60 #include "SMESHGUI_GroupUtils.h"
61 #include "SMESHGUI_Hypotheses.h"
62 #include "SMESHGUI_HypothesesUtils.h"
63 #include "SMESHGUI_MG_ADAPTDRIVER.h"
64 #include "SMESHGUI_Make2DFrom3DOp.h"
65 #include "SMESHGUI_MakeNodeAtPointDlg.h"
66 #include "SMESHGUI_Measurements.h"
67 #include "SMESHGUI_MergeDlg.h"
68 #include "SMESHGUI_MeshInfo.h"
69 #include "SMESHGUI_MeshOp.h"
70 #include "SMESHGUI_MeshOrderOp.h"
71 #include "SMESHGUI_MeshPatternDlg.h"
72 #include "SMESHGUI_MeshUtils.h"
73 #include "SMESHGUI_MultiEditDlg.h"
74 #include "SMESHGUI_NodesDlg.h"
75 #include "SMESHGUI_OffsetDlg.h"
76 #include "SMESHGUI_Operations.h"
77 #include "SMESHGUI_PatternUtils.h"
78 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
79 #include "SMESHGUI_PropertiesDlg.h"
80 #include "SMESHGUI_RemoveElementsDlg.h"
81 #include "SMESHGUI_RemoveNodesDlg.h"
82 #include "SMESHGUI_RenumberingDlg.h"
83 #include "SMESHGUI_ReorientFacesDlg.h"
84 #include "SMESHGUI_RevolutionDlg.h"
85 #include "SMESHGUI_RotationDlg.h"
86 #include "SMESHGUI_ScaleDlg.h"
87 #include "SMESHGUI_Selection.h"
88 #include "SMESHGUI_SewingDlg.h"
89 #include "SMESHGUI_SingleEditDlg.h"
90 #include "SMESHGUI_SmoothingDlg.h"
91 #include "SMESHGUI_SpinBox.h"
92 #include "SMESHGUI_SplitBiQuad.h"
93 #include "SMESHGUI_SymmetryDlg.h"
94 #include "SMESHGUI_TranslationDlg.h"
95 #include "SMESHGUI_TransparencyDlg.h"
96 #include "SMESHGUI_Utils.h"
97 #include "SMESHGUI_VTKUtils.h"
99 #include "SMESH_version.h"
101 #include "SMESH_Actor.h"
102 #include "SMESH_ActorUtils.h"
103 #include "SMESH_Client.hxx"
104 #include "SMESH_Comment.hxx"
105 #include "SMESH_ControlsDef.hxx"
106 #include "SMESH_ScalarBarActor.h"
107 #include "SMESH_TypeFilter.hxx"
108 #include "SMESH_Component_Generator.hxx"
110 // SALOME GUI includes
111 #include <LightApp_DataOwner.h>
112 #include <LightApp_NameDlg.h>
113 #include <LightApp_Preferences.h>
114 #include <LightApp_SelectionMgr.h>
115 #include <LightApp_UpdateFlags.h>
116 #include <QtxFontEdit.h>
117 #include <QtxPopupMgr.h>
118 #include <QtxInfoPanel.h>
119 #include <SALOME_ListIO.hxx>
120 #include <SUIT_Desktop.h>
121 #include <SUIT_FileDlg.h>
122 #include <SUIT_MessageBox.h>
123 #include <SUIT_OverrideCursor.h>
124 #include <SUIT_ResourceMgr.h>
125 #include <SUIT_Session.h>
126 #include <SVTK_Renderer.h>
127 #include <SVTK_ViewManager.h>
128 #include <SVTK_ViewModel.h>
129 #include <SVTK_ViewWindow.h>
130 #include <SalomeApp_Application.h>
131 #include <SalomeApp_CheckFileDlg.h>
132 #include <SalomeApp_DataObject.h>
133 #include <SalomeApp_Study.h>
134 #include <SalomeApp_Tools.h>
135 #include <VTKViewer_Algorithm.h>
137 #ifndef DISABLE_PLOT2DVIEWER
138 #include <SPlot2d_ViewModel.h>
139 #include <SPlot2d_Histogram.h>
143 #include <SALOMEconfig.h>
144 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
145 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
146 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
147 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
150 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
151 #include <QApplication>
153 #include <QDialogButtonBox>
157 #include <QTextStream>
161 #include <boost/shared_ptr.hpp>
164 #include <vtkCallbackCommand.h>
165 #include <vtkCamera.h>
166 #include <vtkLookupTable.h>
167 #include <vtkPlane.h>
168 #include <vtkRenderer.h>
170 // SALOME KERNEL includes
171 #include <Basics_Utils.hxx>
172 #include <SALOMEDSClient_ClientFactory.hxx>
173 #include <SALOMEDSClient_IParameters.hxx>
174 #include <SALOMEDSClient_SComponent.hxx>
175 #include <SALOMEDSClient_StudyBuilder.hxx>
176 #include <SALOMEDS_SObject.hxx>
177 #include <SALOMEDS_Study.hxx>
178 #include <SALOME_GenericObj_wrap.hxx>
179 #include <SALOME_LifeCycleCORBA.hxx>
180 #include <utilities.h>
183 #include <Standard_ErrorHandler.hxx>
184 #include <NCollection_DataMap.hxx>
185 #include <NCollection_DoubleMap.hxx>
187 // Below macro, when uncommented, switches on simplified (more performant) algorithm
188 // of auto-color picking up
189 #define SIMPLE_AUTOCOLOR
194 //=============================================================
195 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
198 void ExportMeshToFile(int theCommandID);
200 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap);
202 void SetDisplayEntity(int theCommandID);
204 int ActionToControl( int theID, bool theReversed = false );
206 void Control( int theCommandID );
209 //================================================================================
211 * \brief Reads meshes from file
213 //================================================================================
215 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
219 std::string myExtension;
221 if ( theCommandID == SMESHOp::OpImportMED ||
222 theCommandID == SMESHOp::OpPopupImportMED ) {
223 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
224 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
226 else if ( theCommandID == SMESHOp::OpImportUNV ||
227 theCommandID == SMESHOp::OpPopupImportUNV ) {
228 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
230 else if ( theCommandID == SMESHOp::OpImportDAT ||
231 theCommandID == SMESHOp::OpPopupImportDAT ) {
232 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
234 else if ( theCommandID == SMESHOp::OpImportSTL ||
235 theCommandID == SMESHOp::OpPopupImportSTL ) {
236 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
238 else if ( theCommandID == SMESHOp::OpImportCGNS ||
239 theCommandID == SMESHOp::OpPopupImportCGNS ) {
240 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
242 else if ( theCommandID == SMESHOp::OpImportGMF ||
243 theCommandID == SMESHOp::OpPopupImportGMF ) {
244 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
245 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
248 QString anInitialPath = "";
249 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
250 anInitialPath = QDir::currentPath();
252 QStringList filenames;
253 bool toCreateGroups = true;
255 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
256 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
257 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
258 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
259 // fd->setNameFilters( filter );
260 // fd->SetChecked( true );
262 // filenames << fd->selectedFile();
263 // toCreateGroups = fd->IsChecked();
269 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
272 QObject::tr( "SMESH_IMPORT_MESH" ) );
274 if ( filenames.count() > 0 )
276 SUIT_OverrideCursor wc;
277 _PTR(Study) aStudy = SMESH::getStudy();
280 QStringList anEntryList;
281 bool isEmpty = false;
282 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it )
284 QString filename = *it;
285 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
287 switch ( theCommandID ) {
288 case SMESHOp::OpImportDAT:
289 case SMESHOp::OpPopupImportDAT:
291 // DAT format (currently unsupported)
292 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
293 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
296 case SMESHOp::OpImportUNV:
297 case SMESHOp::OpPopupImportUNV:
300 aMeshes->length( 1 );
301 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
302 if ( aMeshes[0]->_is_nil() )
303 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
304 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
307 case SMESHOp::OpImportMED:
308 case SMESHOp::OpPopupImportMED:
311 SMESH::DriverMED_ReadStatus res;
312 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
313 if ( res != SMESH::DRS_OK ) {
314 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
315 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
319 case SMESHOp::OpImportSTL:
320 case SMESHOp::OpPopupImportSTL:
323 aMeshes->length( 1 );
324 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
325 if ( aMeshes[0]->_is_nil() ) {
326 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
327 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
331 case SMESHOp::OpImportCGNS:
332 case SMESHOp::OpPopupImportCGNS:
335 SMESH::DriverMED_ReadStatus res;
336 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
337 if ( res != SMESH::DRS_OK ) {
338 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
339 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
343 case SMESHOp::OpImportGMF:
344 case SMESHOp::OpPopupImportGMF:
347 SMESH::ComputeError_var res;
348 aMeshes->length( 1 );
349 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
352 if ( res->code != SMESH::DRS_OK ) {
353 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
354 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
355 if ( strlen( res->comment.in() ) > 0 ) {
356 errors.back() += ": ";
357 errors.back() += res->comment.in();
364 catch ( const SALOME::SALOME_Exception& S_ex ) {
365 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
366 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
369 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ )
371 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
373 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
374 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
375 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
376 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
377 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
379 anEntryList.append( aMeshSO->GetID().c_str() );
387 // update Object browser
388 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
390 // browse to the published meshes
391 if( LightApp_Application* anApp =
392 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
393 anApp->browseObjects( anEntryList );
395 // show Error message box if there were errors
396 if ( errors.count() > 0 ) {
397 SUIT_MessageBox::critical( SMESHGUI::desktop(),
398 QObject::tr( "SMESH_ERROR" ),
399 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
402 // show warning message box, if some imported mesh is empty
404 SUIT_MessageBox::warning( SMESHGUI::desktop(),
405 QObject::tr( "SMESH_WRN_WARNING" ),
406 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
411 //================================================================================
413 * \brief Export selected meshes or groups into a file
415 //================================================================================
417 void ExportMeshToFile( int theCommandID )
419 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
420 SALOME_ListIO selected;
422 aSel->selectedObjects( selected );
424 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT ||
425 theCommandID == SMESHOp::OpPopupExportDAT );
426 const bool isMED = ( theCommandID == SMESHOp::OpExportMED ||
427 theCommandID == SMESHOp::OpPopupExportMED );
428 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV ||
429 theCommandID == SMESHOp::OpPopupExportUNV );
430 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL ||
431 theCommandID == SMESHOp::OpPopupExportSTL );
432 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS ||
433 theCommandID == SMESHOp::OpPopupExportCGNS );
434 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF ||
435 theCommandID == SMESHOp::OpPopupExportGMF );
437 const bool multiMeshSupported = ( isMED || isCGNS ); // file can hold several meshes
438 if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
440 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
441 bool aCheckWarn = true;
443 aCheckWarn = resMgr->booleanValue( "SMESH", "show_warning", false );
445 // get mesh object from selection and check duplication of their names
446 bool hasDuplicatedMeshNames = false;
447 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
448 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
449 SALOME_ListIteratorOfListIO It( selected );
450 for( ; It.More(); It.Next() )
452 Handle(SALOME_InteractiveObject) anIObject = It.Value();
453 SMESH::SMESH_IDSource_var aMeshItem =
454 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
455 if ( aMeshItem->_is_nil() ) {
456 SUIT_MessageBox::warning( SMESHGUI::desktop(),
457 QObject::tr( "SMESH_WRN_WARNING" ),
458 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
461 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aMeshItem );
462 if ( aCheckWarn && !aGroup->_is_nil() )
464 QMessageBox msgBox(SUIT_MessageBox::Warning,
465 QObject::tr("SMESH_WRN_WARNING"),
466 QObject::tr("SMESH_EXPORT_ONLY_GPOUP"),
467 QMessageBox::StandardButton::NoButton,
468 SMESHGUI::desktop());
469 QCheckBox dontShowCheckBox(QObject::tr("SMESH_WRN_SHOW_DLG_CHECKBOX"));
470 msgBox.addButton(QMessageBox::Ok);
471 msgBox.addButton(QMessageBox::Cancel);
472 msgBox.setDefaultButton(QMessageBox::Cancel);
473 QGridLayout* lt = qobject_cast<QGridLayout*>(msgBox.layout());
474 QDialogButtonBox* btnbox = msgBox.findChild<QDialogButtonBox*>();
475 lt->addWidget(&dontShowCheckBox, lt->rowCount(), lt->columnCount()-1, lt->rowCount(), lt->columnCount());
476 lt->addWidget(btnbox, lt->rowCount(), 0, lt->rowCount(), lt->columnCount());
477 if ( msgBox.exec() != QMessageBox::Ok )
480 if ( dontShowCheckBox.checkState() == Qt::Checked && resMgr )
481 resMgr->setValue( "SMESH", "show_warning", false);
484 QString aMeshName = anIObject->getName();
486 // check for name duplications
487 if ( !hasDuplicatedMeshNames )
488 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
489 if( aMeshName == (*aMeshIter).second ) {
490 hasDuplicatedMeshNames = true;
495 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
498 if( hasDuplicatedMeshNames && isMED ) {
499 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
500 QObject::tr("SMESH_WRN_WARNING"),
501 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
502 QObject::tr("SMESH_BUT_YES"),
503 QObject::tr("SMESH_BUT_NO"), 0, 1);
508 aMeshIter = aMeshList.begin();
509 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
510 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
511 QString aMeshName = (*aMeshIter).second;
513 if ( isMED || isCGNS ) // formats where group names must be unique
515 // check for equal group names within each mesh
516 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
517 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
518 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
519 int aRet = SUIT_MessageBox::warning
520 (SMESHGUI::desktop(),
521 QObject::tr("SMESH_WRN_WARNING"),
522 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
523 QObject::tr("SMESH_BUT_YES"),
524 QObject::tr("SMESH_BUT_NO"), 0, 1);
531 // Warn the user about presence of not supported elements
533 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
537 notSupportedElemTypes.push_back( SMESH::Entity_0D );
538 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
543 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
544 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
545 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
546 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
547 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
548 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
549 notSupportedElemTypes.push_back( SMESH::Entity_0D );
550 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
555 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
556 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
557 notSupportedElemTypes.push_back( SMESH::Entity_0D );
558 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
563 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
568 notSupportedElemTypes.push_back( SMESH::Entity_0D );
569 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
570 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
571 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
572 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
573 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Penta );
574 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
575 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
576 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
577 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
579 if ( ! notSupportedElemTypes.empty() )
581 SMESH::smIdType_array_var nbElems = aMeshOrGroup->GetMeshInfo();
582 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
583 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
584 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
586 if ( !presentNotSupported.empty() )
589 const char* typeMsg[] = {
590 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
591 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
592 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
593 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
594 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
595 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
596 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
597 "SMESH_BIQUADRATIC_PENTAHEDRONS",
598 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
600 // is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
601 static_assert( sizeof(typeMsg) / sizeof(const char*) == SMESH::Entity_Last,
602 "Update names of EntityType's!!!" );
604 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
605 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
606 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
607 if ( iType != presentNotSupported.size() - 1 )
608 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
610 int aRet = SUIT_MessageBox::warning
611 (SMESHGUI::desktop(),
612 QObject::tr("SMESH_WRN_WARNING"),
613 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
614 QObject::tr("SMESH_BUT_YES"),
615 QObject::tr("SMESH_BUT_NO"), 0, 1);
620 // Get parameters of export operation
623 int aFormat =-1; // for MED version used for write
624 bool isOkToWrite = true; // to check MED file version compatibility before adding a mesh in an existing file
626 // Init the parameters with the default values
627 bool aIsASCII_STL = true;
628 bool toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
629 bool toOverwrite = true;
630 bool toFindOutDim = true;
631 bool saveNumbers = resMgr->booleanValue( "SMESH", "med_save_numbers", true );
632 bool toRenumber = true;
633 double zTol = resMgr->doubleValue( "SMESH", "med_ztolerance", 0. );
635 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
636 QString anInitialPath = "";
637 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
638 anInitialPath = QDir::currentPath();
640 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
642 // Get a file name to write in and additional options
643 if ( isGMF ) // Export w/o options
645 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
646 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
647 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
649 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
650 anInitialPath + QString("/") + aMeshName,
651 aFilter, aTitle, false);
653 else if ( isCGNS || isUNV || isDAT ) // Export to [ CGNS | UNV | DAT ] - one option
655 const char* theOptionResource = isCGNS ? "cgns_group_elems_by_type" : "export_renumber";
656 bool option = resMgr->booleanValue( "SMESH", theOptionResource, false );
658 QStringList checkBoxes;
659 checkBoxes << QObject::tr( isCGNS ? "CGNS_EXPORT_ELEMS_BY_TYPE" : "SMESH_RENUMBER" );
661 SalomeApp_CheckFileDlg* fd =
662 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
663 fd->setWindowTitle( aTitle );
665 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
667 fd->setNameFilter( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
669 fd->setNameFilter( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
670 if ( !anInitialPath.isEmpty() )
671 fd->setDirectory( anInitialPath );
672 fd->selectFile( aMeshName );
673 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
674 fd->setValidator( fv );
675 fd->SetChecked( option, 0 );
678 aFilename = fd->selectedFile();
679 toOverwrite = fv->isOverwrite( aFilename );
680 option = fd->IsChecked( 0 );
681 SMESHGUI::resourceMgr()->setValue("SMESH", theOptionResource, option );
682 ( isCGNS ? toCreateGroups : toRenumber ) = option;
686 else if ( isSTL ) // Export to STL
688 QMap<QString, int> aFilterMap;
689 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
690 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
693 QMap<QString, int>::const_iterator it = aFilterMap.begin();
694 for ( ; it != aFilterMap.end(); ++it )
695 filters.push_back( it.key() );
697 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
698 fd->setWindowTitle( aTitle );
699 fd->setNameFilters( filters );
700 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
701 if ( !anInitialPath.isEmpty() )
702 fd->setDirectory( anInitialPath );
703 fd->selectFile(aMeshName);
707 aFilename = fd->selectedFile();
708 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
713 else if ( isMED ) // Export to MED
715 int defaultVersion = 0;
716 QMap<QString, int> aFilterMap;
717 //filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
718 //QString vmed (aMesh->GetVersionString(-1, 2));
719 SMESH::long_array_var mvok = aMesh->GetMEDVersionsCompatibleForAppend();
720 if ( mvok->length() > 0)
721 defaultVersion = mvok[0]; // the current version to set the default filter on it
722 for ( CORBA::ULong i = 0; i < mvok->length(); ++i )
724 QString vs = (char*)( SMESH_Comment( mvok[i]/10 ) << "." << mvok[i]%10 );
725 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vs ) + " (*.med)", mvok[i]);
728 QMap<QString, int>::const_iterator it = aFilterMap.begin();
729 QString aDefaultFilter = it.key();
730 for ( ; it != aFilterMap.end(); ++it ) {
731 filters.push_back( it.key() );
732 if (it.value() == defaultVersion) // explicit default for MED = current MED version
733 aDefaultFilter = it.key();
735 QStringList checkBoxes;
736 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS")
737 << QObject::tr("SMESH_AUTO_DIM")
738 << QObject::tr("SMESH_MED_SAVE_NUMS");
740 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
741 QList< QWidget* > wdgList;
742 if ( fieldSelWdg->GetAllFields( aMeshList, aFieldList ))
743 wdgList.append( fieldSelWdg );
745 QWidget* zTolWdg = new QWidget();
746 QCheckBox* zTolCheck = new QCheckBox( QObject::tr( "SMESH_ZTOLERANCE" ), zTolWdg );
747 SMESHGUI_SpinBox* zTolSpin = new SMESHGUI_SpinBox( zTolWdg );
748 QHBoxLayout* zTolLayout = new QHBoxLayout( zTolWdg );
749 zTolLayout->addWidget( zTolCheck );
750 zTolLayout->addWidget( zTolSpin );
751 zTolLayout->setMargin( 0 );
752 zTolSpin->RangeStepAndValidator( 0, 1e+100, 1., "length_precision" );
753 zTolSpin->setValue( zTol );
754 QObject::connect( zTolCheck, SIGNAL( toggled(bool)), zTolSpin, SLOT( setEnabled(bool)));
755 zTolCheck->setChecked( resMgr->booleanValue( "SMESH", "enable_ztolerance", false ));
756 zTolSpin ->setEnabled( zTolCheck->isChecked() );
757 wdgList.append( zTolWdg );
759 SalomeApp_CheckFileDlg* fd =
760 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
761 fd->setWindowTitle( aTitle );
762 fd->setNameFilters( filters );
763 fd->selectNameFilter( aDefaultFilter );
764 fd->SetChecked( toCreateGroups, 0 );
765 fd->SetChecked( toFindOutDim, 1 );
766 fd->SetChecked( saveNumbers, 2 );
767 if ( !anInitialPath.isEmpty() )
768 fd->setDirectory( anInitialPath );
769 fd->selectFile(aMeshName);
772 QListView *lview = fd->findChild<QListView*>("listView");
774 lview->setMinimumHeight(200);
776 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
778 tview->setMinimumHeight(200);
781 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
782 fd->setValidator( fv );
787 //MESSAGE("******* Loop on file dialog ***********");
790 aFilename = fd->selectedFile();
792 aFilename = QString::null;
795 aFormat = aFilterMap[fd->selectedNameFilter()];
796 //MESSAGE("selected version: " << aFormat << " file: " << aFilename.toUtf8().constData());
797 toOverwrite = fv->isOverwrite(aFilename);
798 //MESSAGE("toOverwrite:" << toOverwrite);
800 if ( !aFilename.isEmpty() ) {
802 // append is only possible if the existing file format is compatible
803 bool isVersionOk = SMESHGUI::GetSMESHGen()->CheckWriteCompatibility( aFilename.toUtf8().constData() );
804 MESSAGE("Append check, isVersionOk:" << isVersionOk);
805 if ( !isVersionOk ) {
806 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
807 QObject::tr("SMESH_WRN_WARNING"),
808 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
809 QObject::tr("SMESH_BUT_YES"),
810 QObject::tr("SMESH_BUT_NO"), 0, 1);
814 //MESSAGE("incompatible MED file version for add, overwrite accepted");
820 //MESSAGE("incompatible MED file version for add, overwrite refused");
823 QStringList aMeshNamesCollisionList;
824 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
825 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
826 QString anExistingMeshName( aMeshNames[ i ] );
827 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
828 QString anExportMeshName = (*aMeshIter).second;
829 if( anExportMeshName == anExistingMeshName ) {
830 aMeshNamesCollisionList.append( anExportMeshName );
835 if( !aMeshNamesCollisionList.isEmpty() ) {
837 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
838 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
839 QObject::tr("SMESH_WRN_WARNING"),
840 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
841 QObject::tr("SMESH_BUT_YES"),
842 QObject::tr("SMESH_BUT_NO"),
843 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
844 MESSAGE("answer collision name " << aRet);
855 toCreateGroups = fd->IsChecked(0);
856 toFindOutDim = fd->IsChecked(1);
857 saveNumbers = fd->IsChecked(2);
858 zTol = zTolCheck->isChecked() ? zTolSpin->value() : -1;
859 fieldSelWdg->GetSelectedFields();
860 if ( resMgr ) resMgr->setValue( "SMESH", "enable_ztolerance", zTolCheck->isChecked() );
862 if ( !fieldSelWdg->parent() )
864 if ( !zTolWdg->parent() )
875 if ( !aFilename.isEmpty() ) {
876 // Check whether the file already exists and delete it if yes
877 QFile aFile( aFilename );
878 if ( aFile.exists() && toOverwrite )
880 SUIT_OverrideCursor wc;
883 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
884 // bool Renumber = false;
885 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
887 // Renumber= resMgr->booleanValue("renumbering");
889 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
890 // aMeshEditor->RenumberNodes();
891 // aMeshEditor->RenumberElements();
892 // if ( SMESHGUI::automaticUpdate() )
893 // SMESH::UpdateView();
895 if ( isMED && isOkToWrite )
897 aMeshIter = aMeshList.begin();
898 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
900 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
901 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
902 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
903 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
905 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(),
906 toCreateGroups, aFormat,
907 toOverwrite && aMeshIndex == 0, toFindOutDim,
908 fields, geoAssFields.toLatin1().data(), zTol, saveNumbers );
913 if ( aMeshOrGroup->_is_equivalent( aMesh ))
914 aMesh->ExportDAT( aFilename.toUtf8().data(), toRenumber );
916 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
920 if ( aMeshOrGroup->_is_equivalent( aMesh ))
921 aMesh->ExportUNV( aFilename.toUtf8().data(), toRenumber );
923 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
927 if ( aMeshOrGroup->_is_equivalent( aMesh ))
928 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
930 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
934 aMeshIter = aMeshList.begin();
935 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
937 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
938 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
939 aMeshItem->ExportCGNS( aMeshOrGroup,
940 aFilename.toUtf8().data(),
941 toOverwrite && aMeshIndex == 0,
947 toCreateGroups = true;
948 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
951 catch (const SALOME::SALOME_Exception& S_ex)
954 if ( S_ex.details.type == SALOME::COMM && // communicate about too large mesh
955 strncmp( "format=", S_ex.details.sourceFile.in(), 7 ) == 0 )
957 SUIT_MessageBox::critical(SMESHGUI::desktop(),
958 QObject::tr("SMESH_WRN_WARNING"),
959 QObject::tr(S_ex.details.text.in() ));
961 SUIT_MessageBox::warning(SMESHGUI::desktop(),
962 QObject::tr("SMESH_WRN_WARNING"),
963 QObject::tr("SMESH_EXPORT_FAILED") + SalomeApp_Tools::ExceptionToString(S_ex));
969 inline void InverseEntityMode(unsigned int& theOutputMode,
970 unsigned int theMode)
972 bool anIsNotPresent = ~theOutputMode & theMode;
974 theOutputMode |= theMode;
976 theOutputMode &= ~theMode;
979 void SetDisplayEntity(int theCommandID)
981 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
982 SALOME_ListIO selected;
984 aSel->selectedObjects( selected );
986 if ( selected.Extent() >= 1 ) {
987 SUIT_OverrideCursor wc;
988 SALOME_ListIteratorOfListIO It( selected );
989 for( ; It.More(); It.Next()){
990 Handle(SALOME_InteractiveObject) IObject = It.Value();
991 if(IObject->hasEntry()){
992 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
993 unsigned int aMode = anActor->GetEntityMode();
994 switch(theCommandID){
995 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
996 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
997 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
998 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
999 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
1000 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
1003 anActor->SetEntityMode(aMode);
1012 SalomeApp_Application* app =
1013 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1017 LightApp_SelectionMgr* aSel = app->selectionMgr();
1018 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1019 if ( !aSel || !appStudy )
1022 SALOME_ListIO selected;
1023 aSel->selectedObjects( selected );
1024 if ( selected.IsEmpty() )
1027 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1029 _PTR(Study) aStudy = appStudy->studyDS();
1030 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
1031 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1032 if ( aMainObject->_is_nil() )
1035 SUIT_OverrideCursor wc;
1037 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
1039 QList<SALOMEDS::Color> aReservedColors;
1041 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1042 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1044 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1046 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1047 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1048 #else // old algorithm for auto-colors
1049 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1050 aReservedColors.append( aColor );
1051 #endif // SIMPLE_AUTOCOLOR
1052 aGroupObject->SetColor( aColor );
1054 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1055 if ( aGroupSObject ) {
1058 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1059 switch ( aGroupObject->GetType ()) {
1061 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1063 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1065 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1067 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1069 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1070 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1073 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1074 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1080 SMESH::RepaintCurrentView();
1083 void OverallMeshQuality()
1085 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1086 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1087 SALOME_ListIO selected;
1089 aSel->selectedObjects( selected );
1091 if ( selected.IsEmpty() ) return;
1092 SALOME_ListIteratorOfListIO It( selected );
1093 for ( ; It.More(); It.Next() ) {
1094 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1095 ctrlDlg->showInfo( It.Value() );
1100 QString functorToString( SMESH::Controls::FunctorPtr f )
1102 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1103 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1104 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1105 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1106 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1107 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1108 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1109 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1110 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1111 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1112 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1113 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1114 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1115 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1116 type = QObject::tr( "WARP_ELEMENTS" );
1117 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1118 type = QObject::tr( "TAPER_ELEMENTS" );
1119 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1120 type = QObject::tr( "SKEW_ELEMENTS" );
1121 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1122 type = QObject::tr( "AREA_ELEMENTS" );
1123 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1124 type = QObject::tr( "LENGTH_EDGES" );
1125 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1126 type = QObject::tr( "LENGTH2D_EDGES" );
1127 else if ( dynamic_cast< SMESH::Controls::Deflection2D* >( f.get() ) )
1128 type = QObject::tr( "DEFLECTION2D_FACES" );
1129 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1130 type = QObject::tr( "MULTI_BORDERS" );
1131 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1132 type = QObject::tr( "MULTI2D_BORDERS" );
1133 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1134 type = QObject::tr( "FREE_NODES" );
1135 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1136 type = QObject::tr( "FREE_EDGES" );
1137 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1138 type = QObject::tr( "FREE_BORDERS" );
1139 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1140 type = QObject::tr( "FREE_FACES" );
1141 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1142 type = QObject::tr( "BARE_BORDER_VOLUME" );
1143 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1144 type = QObject::tr( "BARE_BORDER_FACE" );
1145 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1146 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1147 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1148 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1149 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1150 type = QObject::tr( "EQUAL_NODE" );
1151 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1152 type = QObject::tr( "EQUAL_EDGE" );
1153 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1154 type = QObject::tr( "EQUAL_FACE" );
1155 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1156 type = QObject::tr( "EQUAL_VOLUME" );
1157 else if ( dynamic_cast< SMESH::Controls::NodeConnectivityNumber* >( f.get() ) )
1158 type = QObject::tr( "NODE_CONNECTIVITY_NB" );
1162 void SaveDistribution()
1164 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1165 SALOME_ListIO selected;
1167 aSel->selectedObjects( selected );
1169 if ( selected.Extent() == 1 ) {
1170 Handle(SALOME_InteractiveObject) anIO = selected.First();
1171 if ( anIO->hasEntry() ) {
1172 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1174 anActor->GetScalarBarActor() &&
1175 anActor->GetControlMode() != SMESH_Actor::eNone )
1177 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1178 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1179 if ( aScalarBarActor && aFunctor ) {
1180 SMESH::Controls::NumericalFunctor* aNumFun =
1181 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1183 std::vector<smIdType> elements;
1184 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1185 if ( mesh->_is_nil() ) {
1186 SMESH::SMESH_IDSource_var idSource =
1187 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1188 if ( !idSource->_is_nil() )
1190 SMESH::smIdType_array_var ids = idSource->GetIDs();
1191 elements.resize( ids->length() );
1192 for ( unsigned i = 0; i < elements.size(); ++i )
1193 elements[i] = ids[i];
1196 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1197 vtkLookupTable* lookupTable =
1198 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1199 double * minmax = lookupTable->GetRange();
1200 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1201 std::vector<int> nbEvents;
1202 std::vector<double> funValues;
1203 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1204 elements, minmax, isLogarithmic );
1205 QString anInitialPath = "";
1206 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1207 anInitialPath = QDir::currentPath();
1208 QString aMeshName = anIO->getName();
1210 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1211 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1212 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1213 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1214 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1217 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1219 if ( !aFilename.isEmpty() ) {
1220 QFile f( aFilename );
1221 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1222 QTextStream out( &f );
1223 out << "# Mesh: " << aMeshName << endl;
1224 out << "# Control: " << functorToString( aFunctor ) << endl;
1226 out.setFieldWidth( 10 );
1227 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1228 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1239 void ShowElement( int theCommandID )
1241 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1242 SALOME_ListIO selected;
1244 aSel->selectedObjects( selected );
1246 if ( selected.Extent() == 1 ) {
1247 Handle(SALOME_InteractiveObject) anIO = selected.First();
1248 if ( anIO->hasEntry() ) {
1249 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1251 anActor->GetScalarBarActor() &&
1252 anActor->GetControlMode() != SMESH_Actor::eNone )
1254 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1255 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1256 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1258 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1259 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1266 #ifndef DISABLE_PLOT2DVIEWER
1267 void PlotDistribution()
1269 SalomeApp_Application* app =
1270 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1274 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1275 SALOME_ListIO selected;
1277 aSel->selectedObjects( selected );
1279 if ( selected.Extent() == 1 ) {
1280 Handle(SALOME_InteractiveObject) anIO = selected.First();
1281 if ( anIO->hasEntry() ) {
1282 //Find Actor by entry before getting Plot2d viewer,
1283 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1284 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1286 SUIT_ViewManager* aViewManager =
1287 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1291 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1295 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1299 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1301 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1302 QString functorName = functorToString( anActor->GetFunctor());
1303 QString aHistogramName("%1 : %2");
1304 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1305 aHistogram->setName(aHistogramName);
1306 aHistogram->setHorTitle(functorName);
1307 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1308 aPlot->displayObject(aHistogram, true);
1313 #endif //DISABLE_PLOT2DVIEWER
1315 void DisableAutoColor()
1317 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1318 SALOME_ListIO selected;
1320 aSel->selectedObjects( selected );
1322 if ( selected.Extent() ) {
1323 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1324 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1325 if ( !aMesh->_is_nil() ) {
1326 aMesh->SetAutoColor( false );
1333 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1334 SALOME_ListIO selected;
1336 aSel->selectedObjects( selected );
1337 if ( selected.Extent() )
1339 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1340 _PTR(Study) aStudy = SMESH::getStudy();
1341 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1343 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1344 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1351 // Break link with Shaper model
1352 void breakShaperLink()
1354 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1355 SALOME_ListIO selected;
1357 aSel->selectedObjects(selected);
1358 if (selected.Extent()) {
1359 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1360 _PTR(Study) aStudy = SMESH::getStudy();
1361 std::string aEntry = anIObject->getEntry();
1362 _PTR(SObject) aSObj = aStudy->FindObjectID(aEntry);
1364 std::string aName = aSObj->GetName();
1365 QMessageBox::StandardButton aRes = SUIT_MessageBox::warning(SMESHGUI::desktop(),
1366 QObject::tr("SMESH_WRN_WARNING"),
1367 QObject::tr("MSG_BREAK_SHAPER_LINK").arg(aName.c_str()),
1368 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No);
1369 if (aRes == SUIT_MessageBox::Yes) {
1370 SUIT_DataOwnerPtrList aList;
1371 aSel->selected(aList, "ObjectBrowser", true);
1372 SUIT_DataOwner* aOwn = aList.first();
1373 LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>(aOwn);
1374 QString aREntry = sowner->entry();
1376 static GEOM::GEOM_Gen_var geomGen;
1377 if (CORBA::is_nil(geomGen)) {
1378 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
1379 (SUIT_Session::session()->activeApplication());
1381 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
1382 Engines::EngineComponent_var comp =
1383 ls->FindOrLoad_Component("FactoryServer", "SHAPERSTUDY");
1384 geomGen = GEOM::GEOM_Gen::_narrow(comp);
1387 if (!CORBA::is_nil(geomGen))
1389 geomGen->BreakLink(aREntry.toStdString().c_str());
1390 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1392 // remove actors whose objects are removed by BreakLink()
1393 QList<SUIT_ViewWindow*> wndList = SMESHGUI::desktop()->windows();
1394 SUIT_ViewWindow* wnd;
1395 foreach(wnd, wndList)
1396 SMESH::UpdateActorsAfterUpdateStudy(wnd);
1404 //================================================================================
1406 * \brief Return true if a mesh icon == ICON_SMESH_TREE_GEOM_MODIF
1407 * which means that the mesh can't be modified. It should be either re-computed
1408 * or breakShaperLink()'ed. Warn the user about it.
1410 //================================================================================
1412 bool warnOnGeomModif()
1414 SALOME_ListIO selected;
1415 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1416 aSel->selectedObjects(selected,"",/*convertReferences=*/false);
1418 SALOME_ListIteratorOfListIO It( selected );
1419 for ( ; It.More(); It.Next() )
1421 Handle(SALOME_InteractiveObject) io = It.Value();
1422 if ( !io->hasEntry() ) continue;
1423 _PTR(SObject) so = SMESH::getStudy()->FindObjectID( io->getEntry() );
1424 SMESH::SMESH_Mesh_var mesh;
1425 while ( mesh->_is_nil() && so && so->GetID() != "0:" )
1427 CORBA::Object_var obj = SMESH::SObjectToObject( so );
1428 SMESH::SMESH_IDSource_var isrc = SMESH::SMESH_IDSource::_narrow( obj );
1429 if ( isrc->_is_nil() )
1430 so = so->GetFather();
1432 mesh = isrc->GetMesh();
1434 if ( mesh->_is_nil() ) continue;
1435 so = SMESH::FindSObject( mesh );
1436 if ( !so ) continue;
1437 _PTR(GenericAttribute) attr;
1438 so->FindAttribute( attr, "AttributePixMap" );
1439 _PTR(AttributePixMap) pixmap = attr;
1440 if ( !pixmap ) continue;
1442 if ( pixmap->GetPixMap() == "ICON_SMESH_TREE_GEOM_MODIF" )
1444 SUIT_MessageBox::warning(SMESHGUI::desktop(),
1445 QObject::tr("SMESH_WRN_WARNING"),
1446 QObject::tr("MSG_WARN_ON_GEOM_MODIF"));
1453 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap)
1455 SALOME_ListIO selected;
1456 SalomeApp_Application* app =
1457 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1461 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1462 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1463 if ( !aSel || !appStudy )
1466 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1467 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1468 aModule->EmitSignalDeactivateDialog();
1469 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1470 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1475 aSel->selectedObjects( selected );
1477 if ( selected.Extent() >= 1 )
1479 switch ( theCommandID ) {
1480 case SMESHOp::OpTransparency:
1482 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1483 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1486 case SMESHOp::OpProperties:
1489 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1490 QColor orientationColor, outlineColor, volumeColor;
1491 int deltaF = 0, deltaV = 0;
1494 double ballScale = 1.0;
1496 int outlineWidth = 1;
1497 double shrinkCoef = 0.0;
1498 double orientationScale = 0.0;
1499 bool orientation3d = false;
1500 VTK::MarkerType markerType = VTK::MT_NONE;
1501 VTK::MarkerScale markerScale = VTK::MS_NONE;
1503 bool hasNodes = false;
1504 int presentEntities = 0;
1505 bool firstTime = true;
1507 SALOME_ListIteratorOfListIO It( selected );
1508 for ( ; It.More(); It.Next() ) {
1509 Handle(SALOME_InteractiveObject) IObject = It.Value();
1510 if ( !IObject->hasEntry() ) continue;
1511 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1512 if ( !anActor || !anActor->GetObject() ) continue;
1515 // nodes: color, marker
1516 anActor->GetNodeColor( color[0], color[1], color[2] );
1517 nodeColor.setRgbF( color[0], color[1], color[2] );
1518 markerType = anActor->GetMarkerType();
1519 markerScale = anActor->GetMarkerScale();
1520 markerId = anActor->GetMarkerTexture();
1521 // edges: color, width
1522 anActor->GetEdgeColor( color[0], color[1], color[2] );
1523 edgeColor.setRgbF( color[0], color[1], color[2] );
1524 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1525 // faces: front color, back color (delta)
1526 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1527 faceColor.setRgbF( color[0], color[1], color[2] );
1528 // faces: front color, back color (delta)
1529 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1530 volumeColor.setRgbF( color[0], color[1], color[2] );
1531 // 0d elements: color, size
1532 anActor->Get0DColor( color[0], color[1], color[2] );
1533 elem0dColor.setRgbF( color[0], color[1], color[2] );
1534 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1535 // balls: color, size
1536 anActor->GetBallColor( color[0], color[1], color[2] );
1537 ballColor.setRgbF( color[0], color[1], color[2] );
1538 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1539 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1541 anActor->GetOutlineColor( color[0], color[1], color[2] );
1542 outlineColor.setRgbF( color[0], color[1], color[2] );
1543 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1544 // orientation vectors: color, scale, 3d flag
1545 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1546 orientationColor.setRgbF( color[0], color[1], color[2] );
1547 orientationScale = anActor->GetFacesOrientationScale();
1548 orientation3d = anActor->GetFacesOrientation3DVectors();
1550 shrinkCoef = anActor->GetShrinkFactor();
1553 firstTime = false; // we only take properties from first object (for performance reasons)
1556 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1557 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1558 presentEntities = presentEntities | SMESH_Actor::eEdges;
1559 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1560 presentEntities = presentEntities | SMESH_Actor::eFaces;
1561 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1562 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1563 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1564 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1565 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1566 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1568 // as we know that all types of elements are present, we can exit the loop
1569 if ( presentEntities == SMESH_Actor::eAllEntity )
1573 SMESHGUI_PropertiesDlg dlg( theMarkerMap, SMESHGUI::desktop() );
1574 // nodes: color, marker
1575 dlg.setNodeColor( nodeColor );
1576 if( markerType != VTK::MT_USER )
1577 dlg.setNodeMarker( markerType, markerScale );
1579 dlg.setNodeCustomMarker( markerId );
1580 // edges: color, line width
1581 dlg.setEdgeColor( edgeColor );
1582 dlg.setEdgeWidth( edgeWidth );
1583 // faces: front color, back color
1584 dlg.setFaceColor( faceColor, deltaF );
1585 // volumes: normal color, reversed color
1586 dlg.setVolumeColor( volumeColor, deltaV );
1587 // outlines: color, line width
1588 dlg.setOutlineColor( outlineColor );
1589 dlg.setOutlineWidth( outlineWidth );
1590 // 0d elements: color, size
1591 dlg.setElem0dColor( elem0dColor );
1592 dlg.setElem0dSize( elem0dSize );
1593 // balls: color, size
1594 dlg.setBallColor( ballColor );
1595 //dlg.setBallSize( ballSize );
1596 dlg.setBallScale( ballScale );
1597 // orientation: color, scale, 3d flag
1598 dlg.setOrientationColor( orientationColor );
1599 dlg.setOrientationSize( int( orientationScale * 100. ) );
1600 dlg.setOrientation3d( orientation3d );
1601 // shrink: scale factor
1602 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1603 // hide unused controls
1604 dlg.showControls( presentEntities, hasNodes );
1607 nodeColor = dlg.nodeColor();
1608 markerType = dlg.nodeMarkerType();
1609 markerScale = dlg.nodeMarkerScale();
1610 markerId = dlg.nodeMarkerId();
1611 edgeColor = dlg.edgeColor();
1612 edgeWidth = dlg.edgeWidth();
1613 faceColor = dlg.faceColor();
1614 deltaF = dlg.faceColorDelta();
1615 volumeColor = dlg.volumeColor();
1616 deltaV = dlg.volumeColorDelta();
1617 outlineColor = dlg.outlineColor();
1618 outlineWidth = dlg.outlineWidth();
1619 elem0dColor = dlg.elem0dColor();
1620 elem0dSize = dlg.elem0dSize();
1621 ballColor = dlg.ballColor();
1622 // ballSize = dlg.ballSize();
1623 ballScale = dlg.ballScale();
1624 orientationColor = dlg.orientationColor();
1625 orientationScale = dlg.orientationSize() / 100.;
1626 orientation3d = dlg.orientation3d();
1627 shrinkCoef = dlg.shrinkCoef() / 100.;
1629 // store point markers that might be changed by the user
1630 theMarkerMap = dlg.customMarkers();
1632 // set properties from dialog box to the presentations
1633 SALOME_ListIteratorOfListIO It( selected );
1634 for ( ; It.More(); It.Next() ) {
1635 Handle(SALOME_InteractiveObject) IObject = It.Value();
1636 if ( !IObject->hasEntry() ) continue;
1637 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1638 if ( !anActor ) continue;
1640 // nodes: color, marker
1641 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1642 if ( markerType != VTK::MT_USER ) {
1643 anActor->SetMarkerStd( markerType, markerScale );
1646 VTK::MarkerMap::const_iterator iter = theMarkerMap.find( markerId );
1647 if ( iter != theMarkerMap.end() )
1648 anActor->SetMarkerTexture( markerId, iter->second.second );
1650 // volumes: normal color, reversed color (delta)
1651 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1652 // faces: front color, back color (delta)
1653 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1654 // edges: color, width
1655 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1656 anActor->SetLineWidth( edgeWidth );
1658 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1659 anActor->SetOutlineWidth( outlineWidth );
1660 // 0D elements: color, size
1661 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1662 anActor->Set0DSize( elem0dSize );
1663 // balls: color, size
1664 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1665 // anActor->SetBallSize( ballSize );
1666 anActor->SetBallScale( ballScale );
1667 // orientation: color, scale, 3d flag
1668 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1669 anActor->SetFacesOrientationScale( orientationScale );
1670 anActor->SetFacesOrientation3DVectors( orientation3d );
1672 anActor->SetShrinkFactor( shrinkCoef );
1674 // for groups, set also proper color
1675 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1676 if ( !aGroupObject->_is_nil() ) {
1677 SMESH::ElementType anElementType = aGroupObject->GetType();
1679 switch( anElementType ) {
1681 aColor = nodeColor; break;
1683 aColor = edgeColor; break;
1685 aColor = faceColor; break;
1687 aColor = volumeColor; break;
1689 aColor = elem0dColor; break;
1691 aColor = ballColor; break;
1695 if ( aColor.isValid() ) {
1696 SALOMEDS::Color aGroupColor;
1697 aGroupColor.R = aColor.redF();
1698 aGroupColor.G = aColor.greenF();
1699 aGroupColor.B = aColor.blueF();
1700 aGroupObject->SetColor( aGroupColor );
1702 } // if ( !aGroupObject->_is_nil() )
1703 } // for ( ; It.More(); It.Next() )
1704 SMESH::RepaintCurrentView();
1705 } // if ( dlg.exec() )
1707 } // case SMESHOp::OpProperties:
1708 } // switch(theCommandID)
1709 SUIT_OverrideCursor wc;
1710 SALOME_ListIteratorOfListIO It( selected );
1711 for( ; It.More(); It.Next()){
1712 Handle(SALOME_InteractiveObject) IObject = It.Value();
1713 if(IObject->hasEntry()){
1714 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1715 switch(theCommandID){
1716 case SMESHOp::OpDMWireframe:
1717 anActor->SetRepresentation(SMESH_Actor::eEdge);
1719 case SMESHOp::OpDMShading:
1720 anActor->SetRepresentation(SMESH_Actor::eSurface);
1722 case SMESHOp::OpDMShrink:
1723 if(anActor->IsShrunk())
1724 anActor->UnShrink();
1726 anActor->SetShrink();
1728 case SMESHOp::OpDMNodes:
1729 anActor->SetRepresentation(SMESH_Actor::ePoint);
1731 case SMESHOp::OpRepresentationLines:
1732 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1733 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1735 case SMESHOp::OpRepresentationArcs:
1736 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1737 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1743 SMESH::RepaintCurrentView();
1747 int ActionToControl( int theID, bool theReversed )
1749 NCollection_DoubleMap<int,int> ActionControl;
1750 ActionControl.Bind( 0, SMESH_Actor::eNone );
1751 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1752 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1753 ActionControl.Bind( SMESHOp::OpNodeConnectivityNb, SMESH_Actor::eNodeConnectivityNb );
1754 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1755 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1756 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1757 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1758 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1759 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1760 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1761 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1762 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1763 ActionControl.Bind( SMESHOp::OpDeflection2D, SMESH_Actor::eDeflection2D );
1764 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1765 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1766 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1767 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1768 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1769 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1770 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1771 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1772 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1773 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1774 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1775 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1776 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1777 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1778 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1781 return ActionControl.IsBound2( theID ) ? ActionControl.Find2( theID ) : 0;
1782 return ActionControl.IsBound1( theID ) ? ActionControl.Find1( theID ) : 0;
1785 void Control( int theCommandID )
1787 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1788 _PTR(Study) aStudy = SMESH::getStudy();
1790 SALOME_ListIO selected;
1791 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1792 aSel->selectedObjects( selected );
1794 if ( !selected.IsEmpty() ) {
1795 SALOME_ListIteratorOfListIO It(selected);
1796 for ( ; It.More(); It.Next())
1798 Handle(SALOME_InteractiveObject) anIO = It.Value();
1799 if ( !anIO.IsNull() ) {
1800 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1802 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1803 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1804 if ( !anIDSrc->_is_nil() ) {
1805 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1806 if (( !anActor && selected.Extent() == 1 ) &&
1807 ( anActor = SMESH::CreateActor( anIO->getEntry() )))
1809 anActor->SetControlMode( aControl );
1810 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1811 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1815 if ( anActor->GetControlMode() != aControl )
1816 anActor->SetControlMode( aControl );
1817 QString functorName = functorToString( anActor->GetFunctor() );
1818 smIdType anEntitiesCount = anActor->GetNumberControlEntities();
1819 if (anEntitiesCount >= 0)
1820 functorName = functorName + ": " + QString::number(anEntitiesCount);
1821 anActor->GetScalarBarActor()->SetTitle( functorName.toUtf8().constData() );
1822 SMESH::RepaintCurrentView();
1823 #ifndef DISABLE_PLOT2DVIEWER
1824 if ( anActor->GetPlot2Histogram() ) {
1825 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1826 QString aHistogramName("%1 : %2");
1827 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1828 aHistogram->setName( aHistogramName );
1829 aHistogram->setHorTitle( functorName );
1830 SMESH::ProcessIn2DViewers( anActor );
1842 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1843 SMESH::MeshObjectType theType,
1844 const QString theInTypeName,
1845 QString & theOutTypeName)
1847 SMESH_TypeFilter aTypeFilter( theType );
1849 if ( !theIO.IsNull() )
1851 entry = theIO->getEntry();
1852 LightApp_DataOwner owner( entry );
1853 if ( aTypeFilter.isOk( &owner )) {
1854 theOutTypeName = theInTypeName;
1862 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1864 _PTR(Study) aStudy = SMESH::getStudy();
1865 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1867 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1868 CORBA::String_var anID = aSComp->GetID().c_str();
1869 if ( !strcmp(anID.in(),theIO->getEntry()) )
1875 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1876 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1877 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1878 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1879 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1887 // QString CheckHomogeneousSelection()
1889 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1890 // SALOME_ListIO selected;
1892 // aSel->selectedObjects( selected );
1894 // QString RefType = CheckTypeObject(selected.First());
1895 // SALOME_ListIteratorOfListIO It(selected);
1896 // for ( ; It.More(); It.Next())
1898 // Handle(SALOME_InteractiveObject) IObject = It.Value();
1899 // QString Type = CheckTypeObject(IObject);
1900 // if ( Type.compare(RefType) != 0 )
1901 // return "Heterogeneous Selection";
1907 uint randomize( uint size )
1909 static bool initialized = false;
1910 if ( !initialized ) {
1911 qsrand( QDateTime::currentDateTime().toTime_t() );
1915 v = uint( (double)( v ) / RAND_MAX * size );
1916 v = qMax( uint(0), qMin ( v, size-1 ) );
1922 void SMESHGUI::OnEditDelete()
1924 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1925 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1926 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1928 _PTR(Study) aStudy = SMESH::getStudy();
1929 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1930 _PTR(GenericAttribute) anAttr;
1931 _PTR(AttributeIOR) anIOR;
1933 const int objectCountLimit = 30; // PAL23599
1934 int objectCount = 0;
1936 QString aParentComponent = QString::null;
1938 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1940 Handle(SALOME_InteractiveObject) anIO = anIt.Value();
1941 if ( anIO.IsNull() ) continue;
1943 QString father = "unknown", name;
1945 _PTR(SObject) aSO = aStudy->FindObjectID( anIO->getEntry() );
1947 father = QString::fromStdString( aSO->GetFatherComponent()->ComponentDataType() );
1948 // check if object is reference
1949 _PTR(SObject) aRefSObj;
1950 if ( aSO->ReferencedObject( aRefSObj ) ) {
1951 name = QString::fromStdString ( aRefSObj->GetName() );
1952 father = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1955 name = anIO->getName();
1958 if ( objectCount < objectCountLimit ) { // avoid occupying the whole screen
1959 aNameList.append("\n - ");
1960 aNameList.append( name );
1963 if( aParentComponent.isNull() )
1964 aParentComponent = father;
1965 else if( !aParentComponent.isEmpty() && aParentComponent!=father )
1966 aParentComponent = "";
1968 if ( objectCount >= objectCountLimit )
1969 aNameList.append("\n - ...");
1971 if ( objectCount == 0 )
1972 return; // No Valid Objects Selected
1974 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1975 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1976 QObject::tr("ERR_ERROR"),
1977 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1980 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1981 if (SUIT_MessageBox::warning
1982 (SMESHGUI::desktop(),
1983 QObject::tr("SMESH_WRN_WARNING"),
1984 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1985 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1986 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1989 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1991 // Put one level of sub-objects of the selected SO's into a list
1992 // in order to get objects inside folders like "Assigned Algorithms"
1993 std::list< _PTR(SObject) > listSO;
1994 SALOME_ListIteratorOfListIO It(selected);
1995 for( ; It.More(); It.Next()) // loop on selected IO's
1997 Handle(SALOME_InteractiveObject) IObject = It.Value();
1998 if(IObject->hasEntry()) {
1999 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
2001 // disable removal of "SMESH" component object
2002 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
2004 if ( engineIOR() == anIOR->Value().c_str() )
2007 //Check the referenced object
2008 _PTR(SObject) aRefSObject;
2009 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
2010 aSO = aRefSObject; // Delete main Object instead of reference
2012 listSO.push_back( aSO );
2014 _PTR(ChildIterator) it = aStudy->NewChildIterator( aSO );
2015 for (it->InitEx(false); it->More(); it->Next())
2016 listSO.push_back( it->Value() );
2019 // Check if none of objects to delete is referred from outside
2020 std::list< _PTR(SObject) >::reverse_iterator ritSO;
2021 std::vector< _PTR(SObject) > subSO;
2022 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2024 _PTR(SObject) SO = *ritSO;
2025 if ( !SO ) continue;
2027 int nbChildren = SO->GetLastChildTag();
2029 subSO.reserve( 1 + nbChildren );
2030 subSO.push_back( SO );
2031 if ( nbChildren > 0 )
2033 _PTR(ChildIterator) it = aStudy->NewChildIterator( SO );
2034 for ( it->InitEx( true ); it->More(); it->Next() )
2035 subSO.push_back( it->Value() );
2037 for ( size_t i = 0; i < subSO.size(); ++i )
2039 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( subSO[i] );
2040 for ( size_t j = 0; j < aReferences.size(); j++ ) {
2041 _PTR(SComponent) aComponent = aReferences[j]->GetFatherComponent();
2042 std::string type = aComponent->ComponentDataType();
2043 if ( type != "SMESH" )
2045 SUIT_MessageBox::warning( anApp->desktop(),
2046 QObject::tr("WRN_WARNING"),
2047 QObject::tr("DEP_OBJECT") );
2048 return; // outside SMESH, there is an object depending on a SMESH object
2054 // Treat SO's in the list starting from the back
2055 aStudyBuilder->NewCommand(); // There is a transaction
2056 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2058 _PTR(SObject) SO = *ritSO;
2059 if ( !SO ) continue;
2060 std::string anEntry = SO->GetID();
2062 /** Erase graphical object and remove all its data **/
2063 if ( SO->FindAttribute( anAttr, "AttributeIOR" )) {
2064 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
2066 /** Remove an object from data structures **/
2067 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
2068 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
2069 if ( !aGroup->_is_nil() ) { // DELETE GROUP
2070 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
2071 aMesh->RemoveGroup( aGroup );
2073 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
2074 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2075 aMesh->RemoveSubMesh( aSubMesh );
2078 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
2079 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
2080 QString objType = CheckTypeObject(IObject);
2081 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
2082 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2083 aStudyBuilder->RemoveObjectWithChildren( SO );
2085 else {// default action: remove SObject from the study
2086 // Find Sub-Meshes and Group and delete corresopning visual objects and actors
2087 _PTR(ChildIterator) it1 = aStudy->NewChildIterator(SO);
2088 for (it1->InitEx(false); it1->More(); it1->Next()) {
2089 _PTR(SObject) SObj = it1->Value();
2090 if (!SObj) continue;
2091 if (SObj->FindAttribute(anAttr, "AttributeIOR")) {
2092 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(SMESH::SObjectToObject(SObj));
2093 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(SMESH::SObjectToObject(SObj));
2094 if (!aGroup->_is_nil() || !aSubMesh->_is_nil()) {
2095 SMESH::RemoveVisualObjectWithActors(SObj->GetID().c_str(), true);
2099 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
2100 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
2102 aStudyBuilder->RemoveObjectWithChildren( SO );
2106 } /* listSO back loop */
2108 aStudyBuilder->CommitCommand();
2110 /* Clear any previous selection */
2112 aSel->setSelectedObjects( l1 );
2114 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
2118 SMESHGUI_EXPORT CAM_Module* createModule()
2120 return new SMESHGUI();
2123 SMESHGUI_EXPORT char* getModuleVersion() {
2124 return (char*)SMESH_VERSION_STR;
2128 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
2130 //=============================================================================
2134 //=============================================================================
2135 SMESHGUI::SMESHGUI() : SalomeApp_Module( "SMESH" )
2137 if ( CORBA::is_nil( myComponentSMESH ) )
2139 CORBA::Boolean anIsEmbeddedMode;
2140 SALOME_NamingService_Abstract *ns = SalomeApp_Application::namingService();
2141 if( dynamic_cast<SALOME_NamingService *>(ns) )
2142 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
2145 Engines::EngineComponent_var comp = RetrieveSMESHInstance();
2146 myComponentSMESH = SMESH::SMESH_Gen::_narrow(comp);
2149 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2151 // 0019923: EDF 765 SMESH : default values of hypothesis
2152 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2153 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2154 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2155 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2156 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2158 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2159 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2160 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2162 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2163 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2167 myActiveDialogBox = 0;
2168 myFilterLibraryDlg = 0;
2172 myEventCallbackCommand = vtkCallbackCommand::New();
2173 myEventCallbackCommand->Delete();
2174 myEventCallbackCommand->SetClientData( this );
2175 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2178 /* load resources for all available meshers */
2179 SMESH::InitAvailableHypotheses();
2182 //=============================================================================
2186 //=============================================================================
2187 SMESHGUI::~SMESHGUI()
2191 //=============================================================================
2195 //=============================================================================
2196 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2198 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2200 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2205 //=============================================================================
2209 //=============================================================================
2210 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2212 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2216 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2217 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2218 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2219 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2220 return autoUpdate && !exceeded;
2223 //=============================================================================
2227 //=============================================================================
2228 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2229 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2231 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2235 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2236 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2237 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2239 SMESH::smIdType_array_var info = theMesh->GetMeshInfo();
2240 long nbOdElems = info[SMDSEntity_0D];
2241 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2242 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2243 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2244 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2245 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2246 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2247 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2248 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
2249 info[SMDSEntity_Polyhedra] +
2250 info[SMDSEntity_Hexagonal_Prism];
2251 long nbBalls = info[SMDSEntity_Ball];
2253 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2254 *nbElements = requestedSize;
2256 *entities = SMESH_Actor::eAllEntity;
2259 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2261 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2263 if ( incrementalLimit ) {
2266 if ( nbOdElems > 0 ) {
2267 if ( total + nbOdElems > updateLimit ) {
2268 *entities = *entities & ~SMESH_Actor::e0DElements;
2269 *hidden = *hidden | SMESH_Actor::e0DElements;
2276 if ( nbEdges > 0 ) {
2277 if ( total + nbEdges > updateLimit ) {
2278 *entities = *entities & ~SMESH_Actor::eEdges;
2279 *hidden = *hidden | SMESH_Actor::eEdges;
2286 if ( nbFaces > 0 ) {
2287 if ( total + nbFaces > updateLimit ) {
2288 *entities = *entities & ~SMESH_Actor::eFaces;
2289 *hidden = *hidden | SMESH_Actor::eFaces;
2296 if ( nbVolumes > 0 ) {
2297 if ( total + nbVolumes > updateLimit ) {
2298 *entities = *entities & ~SMESH_Actor::eVolumes;
2299 *hidden = *hidden | SMESH_Actor::eVolumes;
2306 if ( nbBalls > 0 ) {
2307 if ( total + nbBalls > updateLimit ) {
2308 *entities = *entities & ~SMESH_Actor::eBallElem;
2309 *hidden = *hidden | SMESH_Actor::eBallElem;
2317 return autoUpdate && !exceeded;
2320 //=============================================================================
2324 //=============================================================================
2325 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2327 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2330 //=============================================================================
2334 //=============================================================================
2335 SMESHGUI* SMESHGUI::GetSMESHGUI()
2337 SMESHGUI* smeshMod = 0;
2338 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2341 CAM_Module* module = app->module( "Mesh" );
2342 smeshMod = dynamic_cast<SMESHGUI*>( module );
2350 Standard_EXPORT SMESHGUI* GetComponentGUI()
2352 return SMESHGUI::GetSMESHGUI();
2356 //=============================================================================
2360 //=============================================================================
2361 void SMESHGUI::SetState(int aState)
2366 //=============================================================================
2370 //=============================================================================
2371 void SMESHGUI::ResetState()
2376 //=============================================================================
2380 //=============================================================================
2381 void SMESHGUI::EmitSignalDeactivateDialog()
2383 emit SignalDeactivateActiveDialog();
2386 //=============================================================================
2390 //=============================================================================
2391 void SMESHGUI::EmitSignalStudyFrameChanged()
2393 emit SignalStudyFrameChanged();
2396 //=============================================================================
2400 //=============================================================================
2401 void SMESHGUI::EmitSignalCloseAllDialogs()
2403 emit SignalCloseAllDialogs();
2406 //=============================================================================
2410 //=============================================================================
2411 void SMESHGUI::EmitSignalVisibilityChanged()
2413 emit SignalVisibilityChanged();
2416 //=============================================================================
2420 //=============================================================================
2421 void SMESHGUI::EmitSignalCloseView()
2423 emit SignalCloseView();
2426 //=============================================================================
2430 //=============================================================================
2431 void SMESHGUI::EmitSignalActivatedViewManager()
2433 emit SignalActivatedViewManager();
2436 //=============================================================================
2440 //=============================================================================
2441 QDialog *SMESHGUI::GetActiveDialogBox()
2443 return myActiveDialogBox;
2446 //=============================================================================
2450 //=============================================================================
2451 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2453 myActiveDialogBox = (QDialog *) aDlg;
2457 //=============================================================================
2461 //=============================================================================
2462 SUIT_Desktop* SMESHGUI::desktop()
2464 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2466 return app->desktop();
2471 //=============================================================================
2475 //=============================================================================
2476 SalomeApp_Study* SMESHGUI::activeStudy()
2478 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2480 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2485 //=============================================================================
2489 //=============================================================================
2490 void SMESHGUI::Modified( bool theIsUpdateActions )
2492 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2493 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2494 appStudy->Modified();
2495 if( theIsUpdateActions )
2496 app->updateActions();
2501 //=============================================================================
2505 //=============================================================================
2506 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2508 /* Here the position is on the bottom right corner - 10 */
2509 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2511 SUIT_Desktop *PP = desktop();
2512 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2513 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2518 * \brief Verifies whether study of operation is locked
2519 * \param theMess - specifies whether message box must be shown if study is locked
2520 * \return State of study.
2522 * Verifies whether study of operation is locked. If second parameter is TRUE and study
2523 * is locked when corresponding message box appears
2525 bool SMESHGUI::isStudyLocked( bool theMessage )
2527 if ( SMESH::getStudy()->GetProperties()->IsLocked() )
2530 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2531 QObject::tr( "WRN_WARNING" ),
2532 QObject::tr( "WRN_STUDY_LOCKED" ) );
2538 //=============================================================================
2542 //=============================================================================
2543 bool SMESHGUI::OnGUIEvent( int theCommandID )
2545 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2549 SUIT_ResourceMgr* mgr = resourceMgr();
2553 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2554 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2556 //QAction* act = action( theCommandID );
2558 switch (theCommandID) {
2559 case SMESHOp::OpDelete:
2560 if(isStudyLocked()) break;
2563 case SMESHOp::OpImportDAT:
2564 case SMESHOp::OpImportUNV:
2565 case SMESHOp::OpImportMED:
2566 case SMESHOp::OpImportSTL:
2567 case SMESHOp::OpImportCGNS:
2568 case SMESHOp::OpImportGMF:
2569 case SMESHOp::OpPopupImportDAT:
2570 case SMESHOp::OpPopupImportUNV:
2571 case SMESHOp::OpPopupImportMED:
2572 case SMESHOp::OpPopupImportSTL:
2573 case SMESHOp::OpPopupImportCGNS:
2574 case SMESHOp::OpPopupImportGMF:
2576 if(isStudyLocked()) break;
2577 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2581 case SMESHOp::OpFileInformation:
2583 SALOME_ListIO selected;
2584 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2586 aSel->selectedObjects( selected );
2587 if( selected.Extent() )
2589 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2590 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2591 if ( !aMesh->_is_nil() )
2593 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2599 case SMESHOp::OpExportDAT:
2600 case SMESHOp::OpExportMED:
2601 case SMESHOp::OpExportUNV:
2602 case SMESHOp::OpExportSTL:
2603 case SMESHOp::OpExportCGNS:
2604 case SMESHOp::OpExportGMF:
2605 case SMESHOp::OpPopupExportDAT:
2606 case SMESHOp::OpPopupExportMED:
2607 case SMESHOp::OpPopupExportUNV:
2608 case SMESHOp::OpPopupExportSTL:
2609 case SMESHOp::OpPopupExportCGNS:
2610 case SMESHOp::OpPopupExportGMF:
2612 ::ExportMeshToFile(theCommandID);
2616 case SMESHOp::OpReset: // SCALAR BAR
2618 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2619 SALOME_ListIO selected;
2621 aSel->selectedObjects( selected );
2623 SALOME_ListIteratorOfListIO it(selected);
2624 for( ; it.More(); it.Next()) {
2625 Handle(SALOME_InteractiveObject) anIO = it.Value();
2626 if( anIO->hasEntry() ) {
2627 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2628 anActor->SetControlMode( SMESH_Actor::eNone );
2629 #ifndef DISABLE_PLOT2DVIEWER
2630 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2632 anActor->UpdateFilter();
2636 SMESH::UpdateView();
2639 case SMESHOp::OpScalarBarProperties:
2641 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2644 case SMESHOp::OpShowScalarBar:
2646 // show/hide scalar bar
2647 ::ShowElement(theCommandID);
2650 case SMESHOp::OpSaveDistribution:
2652 // dump control distribution data to the text file
2653 ::SaveDistribution();
2657 case SMESHOp::OpShowDistribution:
2659 // show/hide distribution
2660 ::ShowElement(theCommandID);
2664 #ifndef DISABLE_PLOT2DVIEWER
2665 case SMESHOp::OpPlotDistribution:
2667 // plot distribution
2668 ::PlotDistribution();
2674 case SMESHOp::OpAutoColor:
2678 case SMESHOp::OpDisableAutoColor:
2679 ::DisableAutoColor();
2682 case SMESHOp::OpClipping:
2683 case SMESHOp::OpTransparency:
2684 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2687 case SMESHOp::OpDMWireframe:
2688 case SMESHOp::OpDMShading:
2689 case SMESHOp::OpDMNodes:
2690 case SMESHOp::OpDMShrink:
2691 ::SetDisplayMode(theCommandID, myMarkerMap);
2694 //2D quadratic representation
2695 case SMESHOp::OpRepresentationLines:
2696 case SMESHOp::OpRepresentationArcs:
2697 ::SetDisplayMode(theCommandID, myMarkerMap);
2701 case SMESHOp::OpDE0DElements:
2702 case SMESHOp::OpDEEdges:
2703 case SMESHOp::OpDEFaces:
2704 case SMESHOp::OpDEVolumes:
2705 case SMESHOp::OpDEBalls:
2706 case SMESHOp::OpDEAllEntity:
2707 ::SetDisplayEntity(theCommandID);
2710 // Choose entities to be displayed
2711 case SMESHOp::OpDEChoose:
2713 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2717 case SMESHOp::OpOrientationOnFaces:
2719 SUIT_OverrideCursor wc;
2720 LightApp_SelectionMgr* mgr = selectionMgr();
2721 SALOME_ListIO selected; mgr->selectedObjects( selected );
2723 SALOME_ListIteratorOfListIO it(selected);
2724 for( ; it.More(); it.Next()) {
2725 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2726 if(anIObject->hasEntry()) {
2727 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2728 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2735 case SMESHOp::OpUpdate:
2737 if(isStudyLocked()) break;
2738 SUIT_OverrideCursor wc;
2741 SMESH::UpdateView();
2743 catch (std::bad_alloc&) { // PAL16774 (Crash after display of many groups)
2744 SMESH::OnVisuException();
2746 catch (...) { // PAL16774 (Crash after display of many groups)
2747 SMESH::OnVisuException();
2751 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2752 aSel->selectedObjects( l );
2753 aSel->setSelectedObjects( l );
2757 case SMESHOp::OpHide:
2758 case SMESHOp::OpShow:
2759 case SMESHOp::OpShowOnly:
2761 SUIT_OverrideCursor wc;
2762 SMESH::EDisplaing anAction;
2763 switch (theCommandID) {
2764 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2765 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2766 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2769 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2770 SALOME_ListIO sel_objects, to_process;
2772 aSel->selectedObjects( sel_objects );
2774 if ( theCommandID==SMESHOp::OpShowOnly )
2776 //MESSAGE("anAction = SMESH::eDisplayOnly");
2777 startOperation( myEraseAll );
2780 extractContainers( sel_objects, to_process );
2785 SALOME_ListIteratorOfListIO It( to_process );
2786 for ( ; It.More(); It.Next())
2788 Handle(SALOME_InteractiveObject) IOS = It.Value();
2789 if ( IOS->hasEntry() )
2791 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2792 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2793 break; // PAL16774 (Crash after display of many groups)
2795 if (anAction == SMESH::eDisplayOnly)
2796 anAction = SMESH::eDisplay;
2801 // PAL13338 + PAL15161 -->
2802 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !isStudyLocked()) {
2803 SMESH::UpdateView();
2804 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2806 // PAL13338 + PAL15161 <--
2808 catch (...) { // PAL16774 (Crash after display of many groups)
2809 SMESH::OnVisuException();
2812 if (anAction == SMESH::eErase) {
2814 aSel->setSelectedObjects( l1 );
2817 aSel->setSelectedObjects( to_process );
2819 if ( vtkwnd && vtkwnd->GetRenderer() && !isStudyLocked() &&
2820 ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) )
2821 vtkwnd->GetRenderer()->AdjustActors();
2826 case SMESHOp::OpNode:
2828 if(isStudyLocked()) break;
2831 EmitSignalDeactivateDialog();
2833 ( new SMESHGUI_NodesDlg( this ) )->show();
2836 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2841 case SMESHOp::OpEditMeshOrSubMesh:
2842 case SMESHOp::OpEditMesh:
2843 case SMESHOp::OpEditSubMesh:
2844 case SMESHOp::OpMeshOrder:
2845 case SMESHOp::OpCreateSubMesh:
2846 if ( warnOnGeomModif() )
2847 break; // action forbidden as geometry modified
2849 case SMESHOp::OpCreateMesh:
2850 case SMESHOp::OpCompute:
2851 case SMESHOp::OpComputeSubMesh:
2852 case SMESHOp::OpPreCompute:
2853 case SMESHOp::OpEvaluate:
2854 case SMESHOp::OpShowErrors:
2855 startOperation( theCommandID );
2857 case SMESHOp::OpRecompute:
2859 if ( isStudyLocked() )
2861 SALOME_ListIO selected;
2862 if ( LightApp_SelectionMgr *sel = selectionMgr() )
2863 sel->selectedObjects( selected );
2864 if ( selected.Extent() == 1 ) {
2865 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( selected.First() );
2866 if ( !aMesh->_is_nil() )
2868 startOperation( SMESHOp::OpCompute );
2872 case SMESHOp::OpCopyMesh:
2874 if (isStudyLocked()) break;
2875 EmitSignalDeactivateDialog();
2876 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2879 case SMESHOp::OpBuildCompoundMesh:
2881 if (isStudyLocked()) break;
2882 EmitSignalDeactivateDialog();
2883 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2887 case SMESHOp::OpDiagonalInversion:
2888 case SMESHOp::OpUnionOfTwoTriangle:
2892 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2896 if ( isStudyLocked() )
2898 if ( warnOnGeomModif() )
2899 break; // action forbidden as geometry modified
2901 /*Standard_Boolean aRes;
2902 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2903 if ( aMesh->_is_nil() )
2905 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2906 tr( "SMESH_BAD_SELECTION" ) );
2910 EmitSignalDeactivateDialog();
2911 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2912 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2914 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2917 case SMESHOp::OpOrientation:
2918 case SMESHOp::OpUnionOfTriangles:
2919 case SMESHOp::OpCuttingOfQuadrangles:
2920 case SMESHOp::OpSplitVolumes:
2924 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2928 if ( isStudyLocked() )
2930 if ( warnOnGeomModif() )
2931 break; // action forbidden as geometry modified
2933 EmitSignalDeactivateDialog();
2934 SMESHGUI_MultiEditDlg* aDlg = NULL;
2935 if ( theCommandID == SMESHOp::OpOrientation )
2936 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2937 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2938 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2939 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2940 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2942 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2947 case SMESHOp::OpSmoothing:
2949 if(isStudyLocked()) break;
2950 if ( warnOnGeomModif() )
2951 break; // action forbidden as geometry modified
2953 EmitSignalDeactivateDialog();
2954 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2957 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2961 case SMESHOp::OpExtrusion:
2963 if (isStudyLocked()) break;
2964 if ( warnOnGeomModif() )
2965 break; // action forbidden as geometry modified
2967 EmitSignalDeactivateDialog();
2968 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2970 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2974 case SMESHOp::OpExtrusionAlongAPath:
2976 if (isStudyLocked()) break;
2977 if ( warnOnGeomModif() )
2978 break; // action forbidden as geometry modified
2980 EmitSignalDeactivateDialog();
2981 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2983 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2987 case SMESHOp::OpRevolution:
2989 if(isStudyLocked()) break;
2990 if ( warnOnGeomModif() )
2991 break; // action forbidden as geometry modified
2993 EmitSignalDeactivateDialog();
2994 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2997 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3001 case SMESHOp::OpPatternMapping:
3003 if ( isStudyLocked() )
3005 if ( warnOnGeomModif() )
3006 break; // action forbidden as geometry modified
3009 EmitSignalDeactivateDialog();
3010 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
3013 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3017 // Adaptation - begin
3018 #ifndef DISABLE_MG_ADAPT
3019 case SMESHOp::OpMGAdapt:
3021 if ( isStudyLocked() )
3023 EmitSignalDeactivateDialog();
3025 SALOME::GenericObj_wrap< SMESH::MG_ADAPT > model = GetSMESHGen()->CreateMG_ADAPT();
3026 bool isCreation = false;
3027 ( new SMESHGUI_MG_ADAPTDRIVER( this, model, isCreation ))->show();
3032 case SMESHOp::OpSplitBiQuadratic:
3033 case SMESHOp::OpConvertMeshToQuadratic:
3034 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
3035 case SMESHOp::OpReorientFaces:
3036 case SMESHOp::OpCreateGeometryGroup:
3038 if ( warnOnGeomModif() )
3039 break; // action forbidden as geometry modified
3040 startOperation( theCommandID );
3043 case SMESHOp::OpCreateGroup:
3047 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3051 if(isStudyLocked()) break;
3052 if ( warnOnGeomModif() )
3053 break; // action forbidden as geometry modified
3054 EmitSignalDeactivateDialog();
3055 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
3057 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3058 SALOME_ListIO selected;
3060 aSel->selectedObjects( selected );
3062 int nbSel = selected.Extent();
3064 // check if mesh is selected
3065 aMesh = SMESH::GetMeshByIO( selected.First() );
3067 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
3072 case SMESHOp::OpConstructGroup:
3076 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3080 if(isStudyLocked()) break;
3081 if ( warnOnGeomModif() )
3082 break; // action forbidden as geometry modified
3083 EmitSignalDeactivateDialog();
3085 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3086 SALOME_ListIO selected;
3088 aSel->selectedObjects( selected );
3090 int nbSel = selected.Extent();
3092 // check if submesh is selected
3093 Handle(SALOME_InteractiveObject) IObject = selected.First();
3094 if (IObject->hasEntry()) {
3095 _PTR(SObject) aSObj = SMESH::getStudy()->FindObjectID(IObject->getEntry());
3097 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
3098 if (!aSubMesh->_is_nil()) {
3100 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
3101 // get submesh elements list by types
3102 SMESH::smIdType_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
3103 SMESH::smIdType_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
3104 SMESH::smIdType_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
3105 SMESH::smIdType_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
3106 // create group for each type o elements
3107 QString aName = IObject->getName();
3108 QStringList anEntryList;
3109 if (aNodes->length() > 0) {
3110 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
3111 aGroup->Add(aNodes.inout());
3112 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3113 anEntryList.append( aSObject->GetID().c_str() );
3115 if (aEdges->length() > 0) {
3116 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
3117 aGroup->Add(aEdges.inout());
3118 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3119 anEntryList.append( aSObject->GetID().c_str() );
3121 if (aFaces->length() > 0) {
3122 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
3123 aGroup->Add(aFaces.inout());
3124 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3125 anEntryList.append( aSObject->GetID().c_str() );
3127 if (aVolumes->length() > 0) {
3128 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
3129 aGroup->Add(aVolumes.inout());
3130 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3131 anEntryList.append( aSObject->GetID().c_str() );
3134 anApp->browseObjects( anEntryList );
3136 catch(const SALOME::SALOME_Exception & S_ex){
3137 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3144 SUIT_MessageBox::warning(desktop(),
3145 tr("SMESH_WRN_WARNING"),
3146 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
3151 case SMESHOp::OpEditGroup:
3155 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3159 if(isStudyLocked()) break;
3160 if ( warnOnGeomModif() )
3161 break; // action forbidden as geometry modified
3162 EmitSignalDeactivateDialog();
3164 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3165 SALOME_ListIO selected;
3167 aSel->selectedObjects( selected );
3169 SALOME_ListIteratorOfListIO It (selected);
3170 int nbSelectedGroups = 0;
3171 for ( ; It.More(); It.Next() )
3173 SMESH::SMESH_GroupBase_var aGroup =
3174 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3175 if (!aGroup->_is_nil()) {
3177 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3181 if (nbSelectedGroups == 0)
3183 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3189 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3191 if(isStudyLocked()) break;
3192 if (myState == 800) {
3193 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3194 if (aDlg) aDlg->onAdd();
3199 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3201 if(isStudyLocked()) break;
3202 if (myState == 800) {
3203 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3204 if (aDlg) aDlg->onRemove();
3209 case SMESHOp::OpEditGeomGroupAsGroup:
3213 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3217 if(isStudyLocked()) break;
3218 EmitSignalDeactivateDialog();
3220 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3221 SALOME_ListIO selected;
3223 aSel->selectedObjects( selected );
3225 SALOME_ListIteratorOfListIO It (selected);
3226 for ( ; It.More(); It.Next() )
3228 SMESH::SMESH_GroupOnGeom_var aGroup =
3229 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3230 if (!aGroup->_is_nil()) {
3231 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3236 SMESH::SMESH_GroupOnFilter_var aGroup =
3237 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3238 if (!aGroup->_is_nil()) {
3239 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3247 case SMESHOp::OpUnionGroups:
3248 case SMESHOp::OpIntersectGroups:
3249 case SMESHOp::OpCutGroups:
3253 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3257 if ( isStudyLocked() )
3259 if ( warnOnGeomModif() )
3260 break; // action forbidden as geometry modified
3262 EmitSignalDeactivateDialog();
3264 SMESHGUI_GroupOpDlg* aDlg = 0;
3265 if ( theCommandID == SMESHOp::OpUnionGroups )
3266 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3267 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3268 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3270 aDlg = new SMESHGUI_CutGroupsDlg( this );
3277 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3279 if ( isStudyLocked() )
3281 if ( warnOnGeomModif() )
3282 break; // action forbidden as geometry modified
3284 EmitSignalDeactivateDialog();
3285 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3291 case SMESHOp::OpFaceGroupsByEdges: // Create face groups separated by sharp edges
3293 if ( isStudyLocked() )
3295 if ( warnOnGeomModif() )
3296 break; // action forbidden as geometry modified
3298 EmitSignalDeactivateDialog();
3299 SMESHGUI_FaceGroupsSeparatedByEdgesDlg* aDlg = new SMESHGUI_FaceGroupsSeparatedByEdgesDlg( this );
3305 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3309 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3313 if ( isStudyLocked() )
3316 EmitSignalDeactivateDialog();
3318 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3322 case SMESHOp::OpMeshInformation:
3323 case SMESHOp::OpWhatIs:
3325 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3326 EmitSignalDeactivateDialog();
3327 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3328 SALOME_ListIO selected;
3330 aSel->selectedObjects( selected );
3332 if ( selected.Extent() > 1 ) { // a dlg for each IO
3333 SALOME_ListIteratorOfListIO It( selected );
3334 for ( ; It.More(); It.Next() ) {
3335 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3336 dlg->showInfo( It.Value() );
3341 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3347 case SMESHOp::OpFindElementByPoint:
3349 startOperation( theCommandID );
3353 case SMESHOp::OpEditHypothesis:
3355 if(isStudyLocked()) break;
3356 if ( warnOnGeomModif() )
3357 break; // action forbidden as geometry modified
3359 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3360 SALOME_ListIO selected;
3362 aSel->selectedObjects( selected );
3364 int nbSel = selected.Extent();
3367 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3368 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3370 if ( !aHypothesis->_is_nil() )
3372 SMESHGUI_GenericHypothesisCreator* aCreator =
3373 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3376 // set geometry of mesh and sub-mesh to aCreator
3377 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3378 if ( selected.Extent() == 1 )
3380 QString subGeomID, meshGeomID;
3381 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3382 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3384 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3385 aCreator->setShapeEntry( subGeomID );
3386 aCreator->setMainShapeEntry( meshGeomID );
3390 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3400 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3402 if(isStudyLocked()) break;
3403 if ( warnOnGeomModif() )
3404 break; // action forbidden as geometry modified
3405 SUIT_OverrideCursor wc;
3407 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3408 SALOME_ListIO selected;
3410 aSel->selectedObjects( selected, QString::null, false );
3412 SALOME_ListIteratorOfListIO It(selected);
3413 for (int i = 0; It.More(); It.Next(), i++) {
3414 Handle(SALOME_InteractiveObject) IObject = It.Value();
3415 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3418 aSel->setSelectedObjects( l1 );
3423 case SMESHOp::OpElem0D:
3424 case SMESHOp::OpBall:
3425 case SMESHOp::OpEdge:
3426 case SMESHOp::OpTriangle:
3427 case SMESHOp::OpQuadrangle:
3428 case SMESHOp::OpPolygon:
3429 case SMESHOp::OpTetrahedron:
3430 case SMESHOp::OpHexahedron:
3431 case SMESHOp::OpPentahedron:
3432 case SMESHOp::OpPyramid:
3433 case SMESHOp::OpHexagonalPrism:
3435 if(isStudyLocked()) break;
3436 if ( warnOnGeomModif() )
3437 break; // action forbidden as geometry modified
3439 EmitSignalDeactivateDialog();
3440 SMDSAbs_EntityType type = SMDSEntity_Edge;
3441 switch (theCommandID) {
3442 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3443 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3444 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3445 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3446 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3447 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3448 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3449 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3450 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3451 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3454 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3457 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3461 case SMESHOp::OpPolyhedron:
3463 if(isStudyLocked()) break;
3464 if ( warnOnGeomModif() )
3465 break; // action forbidden as geometry modified
3467 EmitSignalDeactivateDialog();
3468 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3471 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3475 case SMESHOp::OpQuadraticEdge:
3476 case SMESHOp::OpQuadraticTriangle:
3477 case SMESHOp::OpBiQuadraticTriangle:
3478 case SMESHOp::OpQuadraticQuadrangle:
3479 case SMESHOp::OpBiQuadraticQuadrangle:
3480 case SMESHOp::OpQuadraticPolygon:
3481 case SMESHOp::OpQuadraticTetrahedron:
3482 case SMESHOp::OpQuadraticPyramid:
3483 case SMESHOp::OpQuadraticPentahedron:
3484 case SMESHOp::OpBiQuadraticPentahedron:
3485 case SMESHOp::OpQuadraticHexahedron:
3486 case SMESHOp::OpTriQuadraticHexahedron:
3488 if(isStudyLocked()) break;
3489 if ( warnOnGeomModif() )
3490 break; // action forbidden as geometry modified
3492 EmitSignalDeactivateDialog();
3493 SMDSAbs_EntityType type = SMDSEntity_Last;
3495 switch (theCommandID) {
3496 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3497 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3498 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3499 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3500 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3501 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3502 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3503 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3504 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3505 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3506 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3507 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3510 if ( type != SMDSEntity_Last )
3511 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3514 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3515 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3519 case SMESHOp::OpRemoveNodes:
3521 if(isStudyLocked()) break;
3522 if ( warnOnGeomModif() )
3523 break; // action forbidden as geometry modified
3525 EmitSignalDeactivateDialog();
3526 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3529 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3530 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3534 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3536 if(isStudyLocked()) break;
3537 if ( warnOnGeomModif() )
3538 break; // action forbidden as geometry modified
3540 EmitSignalDeactivateDialog();
3541 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3545 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3546 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3550 case SMESHOp::OpClearMesh: {
3552 if(isStudyLocked()) break;
3553 if ( warnOnGeomModif() )
3554 break; // action forbidden as geometry modified
3556 SALOME_ListIO selected;
3557 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3558 aSel->selectedObjects( selected );
3560 SUIT_OverrideCursor wc;
3561 SALOME_ListIteratorOfListIO It (selected);
3562 for ( ; It.More(); It.Next() )
3564 Handle(SALOME_InteractiveObject) IOS = It.Value();
3565 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3566 if ( aMesh->_is_nil()) continue;
3569 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3570 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3571 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3572 // hide groups and submeshes
3573 _PTR(ChildIterator) anIter =
3574 SMESH::getStudy()->NewChildIterator( aMeshSObj );
3575 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3577 _PTR(SObject) so = anIter->Value();
3578 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3581 catch (const SALOME::SALOME_Exception& S_ex){
3583 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3587 SMESH::UpdateView();
3591 case SMESHOp::OpRemoveOrphanNodes:
3593 if(isStudyLocked()) break;
3594 if ( warnOnGeomModif() )
3595 break; // action forbidden as geometry modified
3596 SALOME_ListIO selected;
3597 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3598 aSel->selectedObjects( selected );
3599 if ( selected.Extent() == 1 ) {
3600 Handle(SALOME_InteractiveObject) anIO = selected.First();
3601 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3602 if ( !aMesh->_is_nil() ) {
3603 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3604 tr( "SMESH_WARNING" ),
3605 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3606 SUIT_MessageBox::Yes |
3607 SUIT_MessageBox::No,
3608 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3611 SUIT_OverrideCursor wc;
3612 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3613 smIdType removed = aMeshEditor->RemoveOrphanNodes();
3614 SUIT_MessageBox::information(SMESHGUI::desktop(),
3615 tr("SMESH_INFORMATION"),
3616 tr("NB_NODES_REMOVED").arg(removed));
3617 if ( removed > 0 ) {
3618 SMESH::UpdateView();
3619 SMESHGUI::Modified();
3622 catch (const SALOME::SALOME_Exception& S_ex) {
3623 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3632 case SMESHOp::OpRenumberingNodes:
3634 if(isStudyLocked()) break;
3635 if ( warnOnGeomModif() )
3636 break; // action forbidden as geometry modified
3638 EmitSignalDeactivateDialog();
3639 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3643 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3644 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3648 case SMESHOp::OpRenumberingElements:
3650 if(isStudyLocked()) break;
3651 if ( warnOnGeomModif() )
3652 break; // action forbidden as geometry modified
3654 EmitSignalDeactivateDialog();
3655 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3659 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3660 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3664 case SMESHOp::OpTranslation:
3666 if(isStudyLocked()) break;
3667 if ( warnOnGeomModif() )
3668 break; // action forbidden as geometry modified
3670 EmitSignalDeactivateDialog();
3671 ( new SMESHGUI_TranslationDlg( this ) )->show();
3674 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3675 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3679 case SMESHOp::OpRotation:
3681 if(isStudyLocked()) break;
3682 if ( warnOnGeomModif() )
3683 break; // action forbidden as geometry modified
3685 EmitSignalDeactivateDialog();
3686 ( new SMESHGUI_RotationDlg( this ) )->show();
3689 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3690 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3694 case SMESHOp::OpSymmetry:
3696 if(isStudyLocked()) break;
3697 if ( warnOnGeomModif() )
3698 break; // action forbidden as geometry modified
3700 EmitSignalDeactivateDialog();
3701 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3704 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3705 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3709 case SMESHOp::OpScale:
3711 if(isStudyLocked()) break;
3712 if ( warnOnGeomModif() )
3713 break; // action forbidden as geometry modified
3715 EmitSignalDeactivateDialog();
3716 ( new SMESHGUI_ScaleDlg( this ) )->show();
3719 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3720 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3725 case SMESHOp::OpOffset:
3727 if(isStudyLocked()) break;
3728 if ( warnOnGeomModif() )
3729 break; // action forbidden as geometry modified
3731 EmitSignalDeactivateDialog();
3732 ( new SMESHGUI_OffsetDlg( this ) )->show();
3735 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3736 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3741 case SMESHOp::OpSewing:
3743 if(isStudyLocked()) break;
3744 if ( warnOnGeomModif() )
3745 break; // action forbidden as geometry modified
3747 EmitSignalDeactivateDialog();
3748 ( new SMESHGUI_SewingDlg( this ) )->show();
3751 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3752 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3756 case SMESHOp::OpMergeNodes:
3758 if(isStudyLocked()) break;
3759 if ( warnOnGeomModif() )
3760 break; // action forbidden as geometry modified
3762 EmitSignalDeactivateDialog();
3763 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3766 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3767 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3771 case SMESHOp::OpMergeElements:
3773 if (isStudyLocked()) break;
3774 if ( warnOnGeomModif() )
3775 break; // action forbidden as geometry modified
3777 EmitSignalDeactivateDialog();
3778 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3780 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3781 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3786 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3787 if ( warnOnGeomModif() )
3788 break; // action forbidden as geometry modified
3789 startOperation( SMESHOp::OpMoveNode );
3792 case SMESHOp::OpDuplicateNodes:
3794 if(isStudyLocked()) break;
3795 if ( warnOnGeomModif() )
3796 break; // action forbidden as geometry modified
3798 EmitSignalDeactivateDialog();
3799 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3802 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3803 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3808 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3809 if ( warnOnGeomModif() )
3810 break; // action forbidden as geometry modified
3811 startOperation( SMESHOp::OpElem0DOnElemNodes );
3814 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3816 static QList<int> aTypes;
3817 if ( aTypes.isEmpty() )
3819 aTypes.append( SMESH::NODE );
3820 aTypes.append( SMESH::EDGE );
3821 aTypes.append( SMESH::FACE );
3822 aTypes.append( SMESH::VOLUME );
3824 if (!myFilterLibraryDlg)
3825 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3826 else if (myFilterLibraryDlg->isHidden())
3827 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3828 myFilterLibraryDlg->raise();
3832 case SMESHOp::OpFreeNode:
3833 case SMESHOp::OpEqualNode:
3834 case SMESHOp::OpNodeConnectivityNb:
3835 case SMESHOp::OpFreeEdge:
3836 case SMESHOp::OpFreeBorder:
3837 case SMESHOp::OpLength:
3838 case SMESHOp::OpConnection:
3839 case SMESHOp::OpEqualEdge:
3840 case SMESHOp::OpFreeFace:
3841 case SMESHOp::OpBareBorderFace:
3842 case SMESHOp::OpOverConstrainedFace:
3843 case SMESHOp::OpLength2D:
3844 case SMESHOp::OpDeflection2D:
3845 case SMESHOp::OpConnection2D:
3846 case SMESHOp::OpArea:
3847 case SMESHOp::OpTaper:
3848 case SMESHOp::OpAspectRatio:
3849 case SMESHOp::OpMinimumAngle:
3850 case SMESHOp::OpWarpingAngle:
3851 case SMESHOp::OpSkew:
3852 case SMESHOp::OpMaxElementLength2D:
3853 case SMESHOp::OpEqualFace:
3854 case SMESHOp::OpAspectRatio3D:
3855 case SMESHOp::OpVolume:
3856 case SMESHOp::OpMaxElementLength3D:
3857 case SMESHOp::OpBareBorderVolume:
3858 case SMESHOp::OpOverConstrainedVolume:
3859 case SMESHOp::OpEqualVolume:
3862 LightApp_SelectionMgr* mgr = selectionMgr();
3863 SALOME_ListIO selected; mgr->selectedObjects( selected );
3865 if( !selected.IsEmpty() ) {
3866 SUIT_OverrideCursor wc;
3867 ::Control( theCommandID );
3870 SUIT_MessageBox::warning(desktop(),
3871 tr( "SMESH_WRN_WARNING" ),
3872 tr( "SMESH_BAD_SELECTION" ) );
3876 SUIT_MessageBox::warning(desktop(),
3877 tr( "SMESH_WRN_WARNING" ),
3878 tr( "NOT_A_VTK_VIEWER" ) );
3881 case SMESHOp::OpOverallMeshQuality:
3882 OverallMeshQuality();
3884 case SMESHOp::OpNumberingNodes:
3886 SUIT_OverrideCursor wc;
3887 LightApp_SelectionMgr* mgr = selectionMgr();
3888 SALOME_ListIO selected; mgr->selectedObjects( selected );
3890 SALOME_ListIteratorOfListIO it(selected);
3891 for( ; it.More(); it.Next()) {
3892 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3893 if(anIObject->hasEntry()) {
3894 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3895 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3901 case SMESHOp::OpNumberingElements:
3903 SUIT_OverrideCursor wc;
3904 LightApp_SelectionMgr* mgr = selectionMgr();
3905 SALOME_ListIO selected; mgr->selectedObjects( selected );
3907 SALOME_ListIteratorOfListIO it(selected);
3908 for( ; it.More(); it.Next()) {
3909 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3910 if(anIObject->hasEntry())
3911 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3912 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3917 case SMESHOp::OpPropertiesLength:
3918 case SMESHOp::OpPropertiesArea:
3919 case SMESHOp::OpPropertiesVolume:
3920 case SMESHOp::OpMinimumDistance:
3921 case SMESHOp::OpBoundingBox:
3922 case SMESHOp::OpAngle:
3924 int page = SMESHGUI_MeasureDlg::MinDistance;
3925 if ( theCommandID == SMESHOp::OpBoundingBox )
3926 page = SMESHGUI_MeasureDlg::BoundingBox;
3927 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3928 page = SMESHGUI_MeasureDlg::Length;
3929 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3930 page = SMESHGUI_MeasureDlg::Area;
3931 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3932 page = SMESHGUI_MeasureDlg::Volume;
3933 else if ( theCommandID == SMESHOp::OpAngle )
3934 page = SMESHGUI_MeasureDlg::Angle;
3936 EmitSignalDeactivateDialog();
3937 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3941 case SMESHOp::OpSortChild:
3944 case SMESHOp::OpBreakLink:
3945 ::breakShaperLink();
3950 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3951 //updateObjBrowser();
3955 //=============================================================================
3959 //=============================================================================
3960 bool SMESHGUI::OnMousePress( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
3965 //=============================================================================
3969 //=============================================================================
3970 bool SMESHGUI::OnMouseMove( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
3975 //=============================================================================
3979 //=============================================================================
3980 bool SMESHGUI::OnKeyPress( QKeyEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
3985 //=============================================================================
3986 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3987 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3989 //=============================================================================
3990 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3991 SUIT_ViewWindow* wnd )
3993 if(theIO->hasEntry()){
3994 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3995 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3999 //=======================================================================
4000 // function : createSMESHAction
4002 //=======================================================================
4003 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
4004 const int key, const bool toggle, const QString& shortcutAction )
4007 QWidget* parent = application()->desktop();
4008 SUIT_ResourceMgr* resMgr = resourceMgr();
4010 if ( !icon_id.isEmpty() )
4011 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
4013 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICON_%1" ).arg( po_id ).toLatin1().data() ), false );
4014 if ( !pix.isNull() )
4015 icon = QIcon( pix );
4017 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
4018 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
4019 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
4021 createAction( id, tooltip, icon, menu, status_bar, key, parent,
4022 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
4025 //=======================================================================
4026 // function : createPopupItem
4028 //=======================================================================
4029 void SMESHGUI::createPopupItem( const int id,
4030 const QString& clients,
4031 const QString& types,
4032 const QString& theRule,
4035 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
4036 popupMgr()->insert( action( id ), pId, 0 );
4038 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4039 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4040 QString rule = "(%1) and (%2) and (%3)";
4041 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
4042 if( clients.isEmpty() )
4043 rule = rule.arg( QString( "true" ) );
4045 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
4046 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
4049 bool cont = myRules.contains( id );
4051 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
4053 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
4054 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
4057 //=======================================================================
4058 // function : initialize
4060 //=======================================================================
4061 void SMESHGUI::initialize( CAM_Application* app )
4063 SalomeApp_Module::initialize( app );
4065 // SUIT_ResourceMgr* mgr = app->resourceMgr();
4067 /* Automatic Update flag */
4068 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
4070 // ----- create actions --------------
4072 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
4073 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
4074 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
4075 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
4077 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
4079 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
4080 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
4081 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
4082 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
4084 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
4086 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
4088 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
4089 createSMESHAction( SMESHOp::OpExportMED, "MED" );
4090 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
4091 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
4093 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
4095 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
4096 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
4097 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
4098 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
4099 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
4101 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
4103 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
4104 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
4105 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
4106 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
4107 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
4108 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
4109 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
4110 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
4111 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
4112 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
4113 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
4114 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
4115 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
4116 createSMESHAction( SMESHOp::OpRecompute, "RE_COMPUTE", "ICON_COMPUTE" );
4117 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
4118 createSMESHAction( SMESHOp::OpShowErrors, "SHOW_ERRORS", "ICON_SHOW_ERRORS" );
4119 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
4120 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
4121 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
4122 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
4123 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
4124 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
4125 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
4126 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
4127 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
4128 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
4129 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
4130 createSMESHAction( SMESHOp::OpFaceGroupsByEdges, "FACE_GROUPS_BY_EDGES", "ICON_FACE_GROUPS_BY_EDGES" );
4131 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
4132 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
4133 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
4134 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
4135 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
4136 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4137 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
4139 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
4140 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
4141 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
4142 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
4143 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
4144 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
4145 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
4146 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
4147 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
4148 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
4149 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
4150 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
4151 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
4152 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
4153 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
4154 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
4155 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
4156 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
4157 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
4158 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
4159 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
4160 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
4161 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
4162 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
4163 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
4164 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
4165 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
4166 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
4167 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
4169 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
4170 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
4171 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
4172 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
4173 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
4174 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
4175 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
4176 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
4177 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
4178 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
4179 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
4180 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
4181 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
4182 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
4183 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
4184 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
4185 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
4186 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
4187 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
4188 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
4189 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
4190 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
4191 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
4192 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
4193 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
4194 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
4196 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
4197 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
4198 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
4199 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
4201 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
4202 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
4204 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
4205 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
4206 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
4207 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
4208 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
4209 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
4210 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
4211 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
4212 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
4213 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
4214 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
4215 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
4216 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
4217 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
4218 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
4219 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
4220 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
4221 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
4222 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
4223 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
4224 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
4225 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
4226 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
4227 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
4228 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
4230 createSMESHAction( SMESHOp::OpReset, "RESET" );
4231 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
4232 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
4233 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
4234 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
4235 #ifndef DISABLE_PLOT2DVIEWER
4236 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
4238 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
4239 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
4240 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
4241 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
4242 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
4243 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4244 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4245 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4246 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4247 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4248 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4249 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4250 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4252 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4253 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4255 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4256 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4257 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4258 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4259 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4260 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4261 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4262 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4263 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4265 // Adaptation - begin
4266 #ifndef DISABLE_MG_ADAPT
4267 createSMESHAction( SMESHOp::OpMGAdapt, "MG_ADAPT", "ICON_MG_ADAPT" );
4271 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4272 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4273 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4274 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4275 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4276 createSMESHAction( SMESHOp::OpAngle, "MEASURE_ANGLE", "ICON_MEASURE_ANGLE" );
4278 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
4279 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
4280 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4282 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4284 createSMESHAction( SMESHOp::OpBreakLink, "BREAK_SHAPER_LINK" );
4286 QList<int> aCtrlActions;
4287 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4288 << SMESHOp::OpNodeConnectivityNb // node controls
4289 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4290 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4291 << SMESHOp::OpDeflection2D
4292 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4293 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4294 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4295 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4296 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4297 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
4298 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4299 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls
4300 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4301 aCtrlGroup->setExclusive( true );
4302 for( int i = 0; i < aCtrlActions.size(); i++ )
4303 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4305 // ----- create menu --------------
4306 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4307 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4308 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4309 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4310 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4311 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4312 #ifndef DISABLE_MG_ADAPT
4313 adaptId = createMenu( tr( "MEN_ADAPT" ), -1, 80, 10 ),
4315 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4316 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4318 createMenu( separator(), fileId );
4320 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4321 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4322 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4323 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4324 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4325 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4326 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4327 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4328 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4329 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4330 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4331 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4332 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4334 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4335 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4336 createMenu( SMESHOp::OpImportMED, importId, -1 );
4337 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4339 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4341 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4342 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4343 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4344 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4345 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4347 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4349 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4350 createMenu( separator(), fileId, 10 );
4352 createMenu( SMESHOp::OpDelete, editId, -1 );
4354 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4356 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4357 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4358 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4359 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4360 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4361 createMenu( separator(), meshId, -1 );
4362 createMenu( SMESHOp::OpCompute, meshId, -1 );
4363 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4364 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4365 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4366 createMenu( separator(), meshId, -1 );
4367 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4368 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4369 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4370 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4371 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4372 createMenu( separator(), meshId, -1 );
4373 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4374 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4375 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4376 createMenu( separator(), meshId, -1 );
4377 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4378 createMenu( SMESHOp::OpFaceGroupsByEdges, meshId, -1 );
4379 createMenu( separator(), meshId, -1 );
4380 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4381 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4382 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4383 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4384 createMenu( separator(), meshId, -1 );
4386 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4387 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4388 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4389 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4390 createMenu( SMESHOp::OpLength, edgeId, -1 );
4391 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4392 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4393 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4394 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4395 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4396 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4397 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4398 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4399 createMenu( SMESHOp::OpArea, faceId, -1 );
4400 createMenu( SMESHOp::OpTaper, faceId, -1 );
4401 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4402 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4403 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4404 createMenu( SMESHOp::OpSkew, faceId, -1 );
4405 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4406 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4407 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4408 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4409 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4410 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4411 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4412 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4413 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4414 createMenu( separator(), ctrlId, -1 );
4415 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4416 createMenu( separator(), ctrlId, -1 );
4417 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4419 createMenu( SMESHOp::OpNode, addId, -1 );
4420 createMenu( SMESHOp::OpElem0D, addId, -1 );
4421 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4422 createMenu( SMESHOp::OpBall, addId, -1 );
4423 createMenu( SMESHOp::OpEdge, addId, -1 );
4424 createMenu( SMESHOp::OpTriangle, addId, -1 );
4425 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4426 createMenu( SMESHOp::OpPolygon, addId, -1 );
4427 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4428 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4429 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4430 createMenu( SMESHOp::OpPyramid, addId, -1 );
4431 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4432 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4433 createMenu( separator(), addId, -1 );
4434 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4435 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4436 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4437 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4438 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4439 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4440 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4441 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4442 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4443 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4444 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4445 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4447 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4448 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4449 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4450 createMenu( separator(), removeId, -1 );
4451 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4452 createMenu( separator(), removeId, -1 );
4453 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4455 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4456 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4458 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4459 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4460 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4461 createMenu( SMESHOp::OpRotation, transfId, -1 );
4462 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4463 createMenu( SMESHOp::OpScale, transfId, -1 );
4464 createMenu( SMESHOp::OpOffset, transfId, -1 );
4465 createMenu( SMESHOp::OpSewing, transfId, -1 );
4466 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4468 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4469 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4470 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4471 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4472 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4473 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4474 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4475 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4476 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4477 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4478 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4479 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4480 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4481 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4482 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4483 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4485 // Adaptation - begin
4486 #ifndef DISABLE_MG_ADAPT
4487 createMenu( SMESHOp::OpMGAdapt, adaptId, -1 );
4491 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4492 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4493 createMenu( SMESHOp::OpAngle, measureId, -1 );
4494 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4495 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4496 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4497 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4499 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4500 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4501 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4502 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4504 // ----- create toolbars --------------
4505 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ) ;
4506 createTool( SMESHOp::OpCreateMesh, meshTb );
4507 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4508 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4509 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4510 createTool( SMESHOp::OpCopyMesh, meshTb );
4511 createTool( separator(), meshTb );
4512 createTool( SMESHOp::OpCompute, meshTb );
4513 createTool( SMESHOp::OpPreCompute, meshTb );
4514 createTool( SMESHOp::OpEvaluate, meshTb );
4515 createTool( SMESHOp::OpMeshOrder, meshTb );
4517 int infoTb = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ) ;
4518 createTool( SMESHOp::OpMeshInformation, infoTb );
4519 //createTool( SMESHOp::OpStdInfo, meshTb );
4520 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4521 createTool( SMESHOp::OpFindElementByPoint, infoTb );
4523 int groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ) ;
4524 createTool( SMESHOp::OpCreateGroup, groupTb );
4525 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4526 createTool( SMESHOp::OpConstructGroup, groupTb );
4527 createTool( SMESHOp::OpEditGroup, groupTb );
4529 int ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ) ;
4530 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4531 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4532 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4534 int ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ) ;
4535 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4536 createTool( SMESHOp::OpLength, ctrl1dTb );
4537 createTool( SMESHOp::OpConnection, ctrl1dTb );
4538 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4540 int ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ) ;
4541 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4542 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4543 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4544 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4545 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4546 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4547 createTool( SMESHOp::OpArea, ctrl2dTb );
4548 createTool( SMESHOp::OpTaper, ctrl2dTb );
4549 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4550 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4551 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4552 createTool( SMESHOp::OpSkew, ctrl2dTb );
4553 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4554 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4555 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4557 int ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ) ;
4558 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4559 createTool( SMESHOp::OpVolume, ctrl3dTb );
4560 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4561 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4562 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4563 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4565 int addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ) ;
4566 createTool( SMESHOp::OpNode, addElemTb );
4567 createTool( SMESHOp::OpElem0D, addElemTb );
4568 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4569 createTool( SMESHOp::OpBall, addElemTb );
4570 createTool( SMESHOp::OpEdge, addElemTb );
4571 createTool( SMESHOp::OpTriangle, addElemTb );
4572 createTool( SMESHOp::OpQuadrangle, addElemTb );
4573 createTool( SMESHOp::OpPolygon, addElemTb );
4574 createTool( SMESHOp::OpTetrahedron, addElemTb );
4575 createTool( SMESHOp::OpHexahedron, addElemTb );
4576 createTool( SMESHOp::OpPentahedron, addElemTb );
4577 createTool( SMESHOp::OpPyramid, addElemTb );
4578 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4579 createTool( SMESHOp::OpPolyhedron, addElemTb );
4581 int addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ) ;
4582 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4583 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4584 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4585 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4586 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4587 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4588 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4589 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4590 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4591 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4592 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4593 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4595 int remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ) ;
4596 createTool( SMESHOp::OpRemoveNodes, remTb );
4597 createTool( SMESHOp::OpRemoveElements, remTb );
4598 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4599 createTool( SMESHOp::OpClearMesh, remTb );
4601 // int renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ) ;
4602 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4603 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4605 int transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ) ;
4606 createTool( SMESHOp::OpMergeNodes, transformTb );
4607 createTool( SMESHOp::OpMergeElements, transformTb );
4608 createTool( SMESHOp::OpTranslation, transformTb );
4609 createTool( SMESHOp::OpRotation, transformTb );
4610 createTool( SMESHOp::OpSymmetry, transformTb );
4611 createTool( SMESHOp::OpScale, transformTb );
4612 createTool( SMESHOp::OpOffset, transformTb );
4613 createTool( SMESHOp::OpSewing, transformTb );
4614 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4616 int modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ) ;
4617 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4618 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4619 createTool( SMESHOp::OpExtrusion, modifyTb );
4620 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4621 createTool( SMESHOp::OpRevolution, modifyTb );
4622 createTool( SMESHOp::OpOrientation, modifyTb );
4623 createTool( SMESHOp::OpReorientFaces, modifyTb );
4624 createTool( SMESHOp::OpMoveNode, modifyTb );
4625 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4626 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4627 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4628 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4629 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4630 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4631 createTool( SMESHOp::OpSmoothing, modifyTb );
4632 createTool( SMESHOp::OpPatternMapping, modifyTb );
4634 // Adaptation - begin
4635 #ifndef DISABLE_MG_ADAPT
4636 int adaptTb = createTool( tr( "TB_ADAPTATION" ), QString( "SMESHAdaptationToolbar" ) ) ;
4637 createTool( SMESHOp::OpMGAdapt, adaptTb );
4641 int measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ) ;
4642 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4644 int dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4645 createTool( SMESHOp::OpUpdate, dispModeTb );
4647 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4648 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4652 OB = "'ObjectBrowser'",
4653 View = "'" + SVTK_Viewer::Type() + "'",
4655 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4656 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4657 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4658 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4659 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4660 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4661 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4662 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4663 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4664 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4665 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4666 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4668 mesh_part = mesh + " " + subMesh + " " + group,
4669 mesh_group = mesh + " " + group,
4670 mesh_submesh = mesh + " " + subMesh,
4671 hyp_alg = hypo + " " + algo;
4673 // popup for object browser
4675 isInvisible("not( isVisible )"),
4676 isEmpty("numberOfNodes = 0"),
4677 isNotEmpty("numberOfNodes <> 0"),
4679 // has nodes, edges, etc in VISIBLE! actor
4680 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4681 hasElems("(count( elemTypes ) > 0)"),
4682 hasDifferentElems("(count( elemTypes ) > 1)"),
4683 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4684 hasBalls("({'BallElem'} in elemTypes)"),
4685 hasElems0d("({'Elem0d'} in elemTypes)"),
4686 hasEdges("({'Edge'} in elemTypes)"),
4687 hasFaces("({'Face'} in elemTypes)"),
4688 hasVolumes("({'Volume'} in elemTypes)"),
4689 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4691 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4692 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4693 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && hasAlgo && hasGeomReference" );
4694 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4695 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4696 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4698 popupMgr()->insert( separator(), -1, 0 );
4699 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4700 createPopupItem( SMESHOp::OpRecompute, OB, mesh, "&& selcount=1 && hasAlgo && (" + isNotEmpty + " || hasErrors )");
4701 createPopupItem( SMESHOp::OpShowErrors, OB, mesh, "&& selcount=1 && hasErrors" );
4702 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && hasAlgo && isComputable" );
4703 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && hasAlgo && isPreComputable" );
4704 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4705 popupMgr()->insert( separator(), -1, 0 );
4706 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4707 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4708 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1 && " + hasElems );
4709 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4710 popupMgr()->insert( separator(), -1, 0 );
4711 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4712 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4713 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4714 popupMgr()->insert( separator(), -1, 0 );
4715 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4716 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4717 popupMgr()->insert( separator(), -1, 0 );
4718 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems );
4719 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4721 // Adaptation - begin
4722 #ifndef DISABLE_MG_ADAPT
4723 popupMgr()->insert( separator(), -1, 0 );
4724 createPopupItem( SMESHOp::OpMGAdapt, OB, mesh );
4725 popupMgr()->insert( separator(), -1, 0 );
4729 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4730 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4731 QString only_one_2D = only_one_non_empty + " && dim>1";
4733 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4734 popupMgr()->findMenu( anId )->menuAction()->setIcon( resourceMgr()->loadPixmap( "SMESH", tr( "ICON_EXPORT" )));
4735 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4736 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4737 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4739 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4741 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4742 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4744 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4745 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4746 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4747 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4749 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4751 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4752 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4753 popupMgr()->insert( separator(), -1, 0 );
4755 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4756 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4757 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4760 createPopupItem( SMESHOp::OpEditGroup, View, group );
4761 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4762 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4764 popupMgr()->insert( separator(), -1, 0 );
4765 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4766 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4767 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh, "&& " + hasElems);
4768 popupMgr()->insert( separator(), -1, 0 );
4770 createPopupItem( SMESHOp::OpUpdate, OB + " " + View, mesh_part );
4771 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4772 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4773 popupMgr()->insert( separator(), -1, 0 );
4775 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4776 QString aType = QString( "%1type in {%2}" ).arg( lc );
4777 aType = aType.arg( mesh_part );
4778 QString aMeshInVTK = aClient + "&&" + aType;
4780 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4781 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4782 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4784 //-------------------------------------------------
4786 //-------------------------------------------------
4787 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4789 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4790 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4791 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4793 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4794 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4795 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4797 popupMgr()->insert( separator(), -1, -1 );
4799 //-------------------------------------------------
4801 //-------------------------------------------------
4802 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4804 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4805 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4806 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4808 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4809 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4810 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4812 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4813 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4814 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4816 popupMgr()->insert( separator(), anId, -1 );
4818 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4819 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4820 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4822 //-------------------------------------------------
4824 //-------------------------------------------------
4825 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4827 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4829 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4830 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4831 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4833 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4834 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4835 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4837 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4838 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4839 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4841 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4842 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4843 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4845 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4846 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4847 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4849 popupMgr()->insert( separator(), anId, -1 );
4851 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4852 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
4854 popupMgr()->insert( separator(), anId, -1 );
4856 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4857 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4860 //-------------------------------------------------
4861 // Representation of the 2D Quadratic elements
4862 //-------------------------------------------------
4863 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4864 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4865 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4866 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4868 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4869 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4870 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4872 //-------------------------------------------------
4873 // Orientation of faces
4874 //-------------------------------------------------
4875 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4876 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4877 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4879 //-------------------------------------------------
4881 //-------------------------------------------------
4882 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4883 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4885 //-------------------------------------------------
4887 //-------------------------------------------------
4888 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4889 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4891 //-------------------------------------------------
4893 //-------------------------------------------------
4895 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4896 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4897 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4898 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4900 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4902 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
4903 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4905 popupMgr()->insert( separator(), anId, -1 );
4907 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4909 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
4910 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4911 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4913 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
4914 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4915 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4917 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
4918 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4919 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
4921 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4923 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
4924 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
4925 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4927 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
4928 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4929 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4931 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
4932 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4933 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4934 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
4935 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4936 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4938 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4940 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
4941 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4942 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4944 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
4945 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4946 QtxPopupMgr::VisibleRule );
4947 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4949 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
4950 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4951 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4953 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
4954 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4955 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4957 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
4958 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4959 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4961 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
4962 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4963 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4965 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
4966 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4967 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4969 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
4970 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4971 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4973 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
4974 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4975 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4977 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
4978 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4979 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4981 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
4982 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4983 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4985 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
4986 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4987 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4989 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
4990 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4991 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4993 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
4994 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4995 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4997 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
4998 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
4999 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
5001 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
5003 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
5004 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5005 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
5007 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
5008 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5009 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
5011 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
5012 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5013 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
5015 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
5016 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5017 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
5019 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
5020 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5021 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
5023 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
5024 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5025 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
5027 popupMgr()->insert( separator(), anId, -1 );
5029 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
5030 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5031 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
5032 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
5033 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5035 popupMgr()->insert( separator(), anId, -1 );
5037 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
5039 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
5040 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5042 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
5043 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5044 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
5046 #ifndef DISABLE_PLOT2DVIEWER
5047 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
5048 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5051 //-------------------------------------------------
5053 //-------------------------------------------------
5054 popupMgr()->insert( separator(), -1, -1 );
5055 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
5056 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
5057 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
5058 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
5060 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
5061 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
5063 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
5064 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
5066 popupMgr()->insert( separator(), -1, -1 );
5068 //-------------------------------------------------
5070 //-------------------------------------------------
5071 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
5072 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
5074 popupMgr()->insert( separator(), -1, -1 );
5076 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
5077 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
5078 popupMgr()->insert( separator(), -1, -1 );
5080 popupMgr()->insert( action( SMESHOp::OpBreakLink), -1, -1 );
5081 popupMgr()->setRule( action( SMESHOp::OpBreakLink), "$component={'SHAPERSTUDY'} and client='ObjectBrowser' and canBreakLink", QtxPopupMgr::VisibleRule );
5083 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
5084 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
5086 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
5087 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
5090 //================================================================================
5092 * \brief Return true if SMESH or GEOM objects are selected.
5093 * Is called form LightApp_Module::activateModule() which clear selection if
5094 * not isSelectionCompatible()
5096 //================================================================================
5098 bool SMESHGUI::isSelectionCompatible()
5100 bool isCompatible = true;
5101 SALOME_ListIO selected;
5102 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
5103 Sel->selectedObjects( selected );
5105 SALOME_ListIteratorOfListIO It( selected );
5106 for ( ; isCompatible && It.More(); It.Next())
5108 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
5109 ( strcmp("SHAPERSTUDY", It.Value()->getComponentDataType()) == 0 ) ||
5110 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
5112 return isCompatible;
5116 bool SMESHGUI::reusableOperation( const int id )
5118 // compute, evaluate and precompute are not reusable operations
5119 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate || id == SMESHOp::OpRecompute ) ? false : SalomeApp_Module::reusableOperation( id );
5124 QString wrap(const QString& text, const QString& tag)
5125 { return QString("<%1>%2</%3>").arg(tag).arg(text).arg(tag);}
5128 bool SMESHGUI::activateModule( SUIT_Study* study )
5130 bool res = SalomeApp_Module::activateModule( study );
5132 setMenuShown( true );
5133 setToolShown( true );
5135 // Fill in Help Panel
5136 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
5137 app->infoPanel()->setTitle(tr("INFO_WELCOME_TO_SMESH"));
5139 int gb = app->infoPanel()->addGroup(tr("INFO_GRP_CREATE_MESH"));
5142 lab = tr("INFO_DEFINE_ALGOS") + "<br/>";
5143 lab = lab + tr("INFO_DEFINE_HYPOS") + "<br/>";
5144 lab = lab + tr("INFO_COMPUTE") + "<br/>";
5145 lab = lab + tr("INFO_REFINE") + ":";
5146 items << wrap(tr("INFO_REFINE_LOCAL_SIZE"), "li")
5147 << wrap(tr("INFO_REFINE_SUBMESH"), "li");
5148 lab = lab + wrap(items.join(""), "ul");
5151 app->infoPanel()->addLabel(lab, gb);
5153 gb = app->infoPanel()->addGroup(tr("INFO_GRP_IMPORT_MESH"));
5154 items << wrap("UNV", "li")
5155 << wrap("MED", "li")
5156 << wrap("STL", "li")
5157 << wrap("CGNS", "li")
5158 << wrap("GMF", "li");
5159 lab = tr("INFO_AVAILABLE_FORMATS") + ":" + wrap(items.join(""), "ul");
5162 app->infoPanel()->addLabel(lab, gb);
5164 gb = app->infoPanel()->addGroup(tr("INFO_GRP_CHECK_MESH"));
5165 lab = tr("INFO_DISPLAY") + "<br/>";
5166 items << wrap(tr("INFO_QUALITY_AREA"), "li")
5167 << wrap(tr("INFO_QUALITY_VOLUME"), "li")
5168 << wrap(tr("INFO_QUALITY_ASPECT_RATION"), "li")
5169 << wrap("...", "li");
5170 lab = lab + tr("INFO_QUALITY_INFO") + ":" + wrap(items.join(""), "ul");
5172 lab = lab + tr("INFO_CLIPPING");
5174 app->infoPanel()->addLabel(lab, gb);
5177 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
5178 PyGILState_STATE gstate = PyGILState_Ensure();
5179 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
5180 if ( !pluginsmanager ) {
5184 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
5189 PyGILState_Release(gstate);
5190 // end of SMESH plugins loading
5192 // Reset actions accelerator keys
5193 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
5195 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
5196 GetSMESHGen()->UpdateStudy();
5198 // get all view currently opened in the study and connect their signals to
5199 // the corresponding slots of the class.
5200 SUIT_Desktop* aDesk = study->application()->desktop();
5202 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
5203 SUIT_ViewWindow* wnd;
5204 foreach ( wnd, wndList )
5208 // remove actors whose objects are removed in GetSMESHGen()->UpdateStudy()
5209 SMESH::UpdateActorsAfterUpdateStudy(wnd);
5215 Py_XDECREF(pluginsmanager);
5219 bool SMESHGUI::deactivateModule( SUIT_Study* study )
5221 setMenuShown( false );
5222 setToolShown( false );
5224 EmitSignalCloseAllDialogs();
5226 // Unset actions accelerator keys
5227 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
5229 return SalomeApp_Module::deactivateModule( study );
5232 void SMESHGUI::studyClosed( SUIT_Study* s )
5236 SMESH::RemoveVisuData();
5237 SalomeApp_Module::studyClosed( s );
5240 void SMESHGUI::OnGUIEvent()
5242 const QObject* obj = sender();
5243 if ( !obj || !obj->inherits( "QAction" ) )
5245 int id = actionId((QAction*)obj);
5250 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
5252 if ( CORBA::is_nil( myComponentSMESH ) )
5254 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
5255 return aGUI.myComponentSMESH;
5257 return myComponentSMESH;
5260 QString SMESHGUI::engineIOR() const
5262 CORBA::ORB_var anORB = getApp()->orb();
5263 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
5264 return QString( anIOR.in() );
5267 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
5269 SalomeApp_Module::contextMenuPopup( client, menu, title );
5271 selectionMgr()->selectedObjects( lst );
5272 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
5273 Handle(SALOME_InteractiveObject) io = lst.First();
5274 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
5275 _PTR(Study) study = appStudy->studyDS();
5276 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
5278 QString aName = SMESH::fromUtf8( obj->GetName());
5279 while ( !aName.isEmpty() && aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
5280 aName.remove(( aName.length() - 1 ), 1 );
5286 LightApp_Selection* SMESHGUI::createSelection() const
5288 return new SMESHGUI_Selection();
5291 void SMESHGUI::windows( QMap<int, int>& aMap ) const
5293 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
5294 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
5295 aMap.insert( SalomeApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea);
5296 #ifndef DISABLE_PYCONSOLE
5297 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
5301 void SMESHGUI::viewManagers( QStringList& list ) const
5303 list.append( SVTK_Viewer::Type() );
5306 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
5308 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
5309 SMESH::UpdateSelectionProp( this );
5311 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
5312 for(int i = 0; i < aViews.count() ; i++){
5313 SUIT_ViewWindow *sf = aViews[i];
5316 EmitSignalActivatedViewManager();
5320 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
5322 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
5323 myClippingPlaneInfoMap.erase( theViewManager );
5326 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
5328 theActor->AddObserver( SMESH::DeleteActorEvent,
5329 myEventCallbackCommand.GetPointer(),
5333 void SMESHGUI::ProcessEvents( vtkObject* theObject,
5334 unsigned long theEvent,
5335 void* theClientData,
5336 void* /*theCallData*/ )
5338 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
5339 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
5340 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
5341 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5342 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5343 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5344 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5345 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5346 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5347 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5348 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5349 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5350 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5351 if( anActor == *anIter3 ) {
5352 anActorList.erase( anIter3 );
5363 void SMESHGUI::createPreferences()
5365 // General tab ------------------------------------------------------------------------
5366 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5368 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5369 setPreferenceProperty( autoUpdate, "columns", 2 );
5370 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5371 setPreferenceProperty( lim, "min", 0 );
5372 setPreferenceProperty( lim, "max", 100000000 );
5373 setPreferenceProperty( lim, "step", 1000 );
5374 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5375 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5377 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5378 setPreferenceProperty( dispgroup, "columns", 2 );
5380 addPreference( tr( "PREF_FITALL_ON_DISPLAYONLY" ), dispgroup, LightApp_Preferences::Bool, "SMESH", "fitall_on_displayonly" );
5382 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5384 modes.append( tr("MEN_WIRE") );
5385 modes.append( tr("MEN_SHADE") );
5386 modes.append( tr("MEN_NODES") );
5387 modes.append( tr("MEN_SHRINK") );
5388 QList<QVariant> indices;
5389 indices.append( 0 );
5390 indices.append( 1 );
5391 indices.append( 2 );
5392 indices.append( 3 );
5393 setPreferenceProperty( dispmode, "strings", modes );
5394 setPreferenceProperty( dispmode, "indexes", indices );
5396 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5397 setPreferenceProperty( arcgroup, "columns", 2 );
5398 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5399 QStringList quadraticModes;
5400 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5401 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5403 indices.append( 0 );
5404 indices.append( 1 );
5405 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5406 setPreferenceProperty( quadraticmode, "indexes", indices );
5408 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5409 "SMESH", "max_angle" );
5410 setPreferenceProperty( maxAngle, "min", 1 );
5411 setPreferenceProperty( maxAngle, "max", 90 );
5413 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5414 setPreferenceProperty( qaGroup, "columns", 2 );
5415 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5416 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5417 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5418 setPreferenceProperty( prec, "min", 0 );
5419 setPreferenceProperty( prec, "max", 100 );
5420 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5421 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5422 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5423 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5424 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5427 int cinc = addPreference(tr("PREF_CONTROLS_INCREMENT"), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_increment");
5428 setPreferenceProperty( cinc, "min", 0 );
5429 setPreferenceProperty( cinc, "max", 5 );
5432 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5433 setPreferenceProperty( exportgroup, "columns", 2 );
5434 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5435 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5436 addPreference( tr( "PREF_MED_SAVE_NUMS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "med_save_numbers" );
5437 int zTol = addPreference( tr( "PREF_ZTOLERANCE" ), exportgroup, LightApp_Preferences::DblSpin, "SMESH", "med_ztolerance" );
5438 setPreferenceProperty( zTol, "precision", 10 );
5439 setPreferenceProperty( zTol, "min", 0.0000000001 );
5440 setPreferenceProperty( zTol, "max", 1000000.0 );
5441 setPreferenceProperty( zTol, "step", 1. );
5442 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5444 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5445 setPreferenceProperty( computeGroup, "columns", 2 );
5446 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5448 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5449 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5450 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5452 indices.append( 0 );
5453 indices.append( 1 );
5454 indices.append( 2 );
5455 setPreferenceProperty( notifyMode, "strings", modes );
5456 setPreferenceProperty( notifyMode, "indexes", indices );
5458 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5459 setPreferenceProperty( infoGroup, "columns", 2 );
5460 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5462 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5463 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5465 indices.append( 0 );
5466 indices.append( 1 );
5467 setPreferenceProperty( elemInfo, "strings", modes );
5468 setPreferenceProperty( elemInfo, "indexes", indices );
5469 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5470 setPreferenceProperty( nodesLim, "min", 0 );
5471 setPreferenceProperty( nodesLim, "max", 10000000 );
5472 setPreferenceProperty( nodesLim, "step", 10000 );
5473 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5474 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5475 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5476 setPreferenceProperty( ctrlLim, "min", 0 );
5477 setPreferenceProperty( ctrlLim, "max", 10000000 );
5478 setPreferenceProperty( ctrlLim, "step", 1000 );
5479 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5480 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5481 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5482 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5483 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5485 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5486 setPreferenceProperty( segGroup, "columns", 2 );
5487 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5488 "SMESH", "segmentation" );
5489 setPreferenceProperty( segLen, "min", 1 );
5490 setPreferenceProperty( segLen, "max", 10000000 );
5491 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5492 "SMESH", "nb_segments_per_edge" );
5493 setPreferenceProperty( nbSeg, "min", 1 );
5494 setPreferenceProperty( nbSeg, "max", 10000000 );
5495 addPreference( tr( "PREF_USE_MESHGEMS_HYPOSET" ), segGroup, LightApp_Preferences::Bool, "SMESH", "use-meshgems-hypo-sets" );
5497 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5498 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5499 "SMESH", "forget_mesh_on_hyp_modif" );
5502 // Quantities with individual precision settings
5503 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5504 setPreferenceProperty( precGroup, "columns", 2 );
5506 const int nbQuantities = 6;
5507 int precs[nbQuantities], ii = 0;
5508 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5509 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5510 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5511 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5512 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5513 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5514 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5515 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5516 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5517 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5518 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5519 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5521 // Set property for precision value for spinboxes
5522 for ( ii = 0; ii < nbQuantities; ii++ ){
5523 setPreferenceProperty( precs[ii], "min", -14 );
5524 setPreferenceProperty( precs[ii], "max", 14 );
5525 setPreferenceProperty( precs[ii], "precision", 2 );
5528 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5529 setPreferenceProperty( previewGroup, "columns", 2 );
5530 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5531 setPreferenceProperty( chunkSize, "min", 1 );
5532 setPreferenceProperty( chunkSize, "max", 1000 );
5533 setPreferenceProperty( chunkSize, "step", 50 );
5535 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5536 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5538 // Mesh tab ------------------------------------------------------------------------
5539 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5540 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5541 setPreferenceProperty( nodeGroup, "columns", 3 );
5543 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5545 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5547 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5548 QList<QVariant> aMarkerTypeIndicesList;
5549 QList<QVariant> aMarkerTypeIconsList;
5550 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5551 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5552 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5553 aMarkerTypeIndicesList << i;
5554 aMarkerTypeIconsList << pixmap;
5556 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5557 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5559 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5561 QList<QVariant> aMarkerScaleIndicesList;
5562 QStringList aMarkerScaleValuesList;
5563 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5564 aMarkerScaleIndicesList << i;
5565 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5566 aMarkerScaleValuesList << QString::number( i );
5568 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5569 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5571 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5572 //setPreferenceProperty( elemGroup, "columns", 2 );
5574 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5575 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5576 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5577 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5578 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5579 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5580 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5581 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5582 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5585 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5586 setPreferenceProperty( grpGroup, "columns", 2 );
5588 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5589 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5591 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5592 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5593 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5594 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5595 int ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5596 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5597 int ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5598 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5599 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5600 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5601 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5602 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5603 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5604 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5606 setPreferenceProperty( size0d, "min", 1 );
5607 setPreferenceProperty( size0d, "max", 10 );
5609 // setPreferenceProperty( ballSize, "min", 1 );
5610 // setPreferenceProperty( ballSize, "max", 10 );
5612 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5613 setPreferenceProperty( ballDiameter, "max", 1e9 );
5614 setPreferenceProperty( ballDiameter, "step", 0.1 );
5616 setPreferenceProperty( ballScale, "min", 1e-2 );
5617 setPreferenceProperty( ballScale, "max", 1e7 );
5618 setPreferenceProperty( ballScale, "step", 0.5 );
5620 setPreferenceProperty( elemW, "min", 1 );
5621 setPreferenceProperty( elemW, "max", 5 );
5623 setPreferenceProperty( outW, "min", 1 );
5624 setPreferenceProperty( outW, "max", 5 );
5626 setPreferenceProperty( shrink, "min", 0 );
5627 setPreferenceProperty( shrink, "max", 100 );
5629 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5630 setPreferenceProperty( numGroup, "columns", 2 );
5632 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5633 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5635 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5636 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5638 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5639 setPreferenceProperty( orientGroup, "columns", 1 );
5641 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5642 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5644 setPreferenceProperty( orientScale, "min", 0.05 );
5645 setPreferenceProperty( orientScale, "max", 0.5 );
5646 setPreferenceProperty( orientScale, "step", 0.05 );
5648 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5650 // Selection tab ------------------------------------------------------------------------
5651 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5653 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5654 setPreferenceProperty( selGroup, "columns", 2 );
5656 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5657 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5659 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5660 setPreferenceProperty( preGroup, "columns", 2 );
5662 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5664 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5665 setPreferenceProperty( precSelGroup, "columns", 2 );
5667 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5668 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5669 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5671 int sinc = addPreference(tr("PREF_SELECTION_INCREMENT"), selTab, LightApp_Preferences::IntSpin, "SMESH", "selection_increment");
5672 setPreferenceProperty( sinc, "min", 0 );
5673 setPreferenceProperty( sinc, "max", 5 );
5675 // Scalar Bar tab ------------------------------------------------------------------------
5676 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5677 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5678 setPreferenceProperty( fontGr, "columns", 2 );
5680 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5681 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5683 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5684 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5686 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5687 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5689 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5690 setPreferenceProperty( numcol, "min", 2 );
5691 setPreferenceProperty( numcol, "max", 256 );
5693 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5694 setPreferenceProperty( numlab, "min", 2 );
5695 setPreferenceProperty( numlab, "max", 65 );
5697 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5698 setPreferenceProperty( orientGr, "columns", 2 );
5699 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5700 QStringList orients;
5701 orients.append( tr( "SMESH_VERTICAL" ) );
5702 orients.append( tr( "SMESH_HORIZONTAL" ) );
5703 indices.clear(); indices.append( 0 ); indices.append( 1 );
5704 setPreferenceProperty( orient, "strings", orients );
5705 setPreferenceProperty( orient, "indexes", indices );
5707 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5708 setPreferenceProperty( posVSizeGr, "columns", 2 );
5709 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5710 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5711 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5712 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5713 setPreferenceProperty( xv, "step", 0.1 );
5714 setPreferenceProperty( xv, "min", 0.0 );
5715 setPreferenceProperty( xv, "max", 1.0 );
5716 setPreferenceProperty( yv, "step", 0.1 );
5717 setPreferenceProperty( yv, "min", 0.0 );
5718 setPreferenceProperty( yv, "max", 1.0 );
5719 setPreferenceProperty( wv, "step", 0.1 );
5720 setPreferenceProperty( wv, "min", 0.0 );
5721 setPreferenceProperty( wv, "max", 1.0 );
5722 setPreferenceProperty( hv, "min", 0.0 );
5723 setPreferenceProperty( hv, "max", 1.0 );
5724 setPreferenceProperty( hv, "step", 0.1 );
5726 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5727 setPreferenceProperty( posHSizeGr, "columns", 2 );
5728 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5729 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5730 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5731 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5732 setPreferenceProperty( xv, "min", 0.0 );
5733 setPreferenceProperty( xv, "max", 1.0 );
5734 setPreferenceProperty( xv, "step", 0.1 );
5735 setPreferenceProperty( xh, "min", 0.0 );
5736 setPreferenceProperty( xh, "max", 1.0 );
5737 setPreferenceProperty( xh, "step", 0.1 );
5738 setPreferenceProperty( yh, "min", 0.0 );
5739 setPreferenceProperty( yh, "max", 1.0 );
5740 setPreferenceProperty( yh, "step", 0.1 );
5741 setPreferenceProperty( wh, "min", 0.0 );
5742 setPreferenceProperty( wh, "max", 1.0 );
5743 setPreferenceProperty( wh, "step", 0.1 );
5744 setPreferenceProperty( hh, "min", 0.0 );
5745 setPreferenceProperty( hh, "max", 1.0 );
5746 setPreferenceProperty( hh, "step", 0.1 );
5748 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5749 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5750 setPreferenceProperty( distributionGr, "columns", 3 );
5752 types.append( tr( "SMESH_MONOCOLOR" ) );
5753 types.append( tr( "SMESH_MULTICOLOR" ) );
5754 indices.clear(); indices.append( 0 ); indices.append( 1 );
5755 setPreferenceProperty( coloringType, "strings", types );
5756 setPreferenceProperty( coloringType, "indexes", indices );
5757 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5759 // Adaptation - begin
5760 #ifndef DISABLE_MG_ADAPT
5761 // Adaptation tab ------------------------------------------------------------------------
5762 int adaptTab = addPreference( tr( "ADAPT_PREF_TAB_GENERAL" ) );
5765 bloc = addPreference( tr( "ADAPT_PREF_MG_ADAPT" ), adaptTab );
5766 setPreferenceProperty( bloc, "columns", 1 );
5767 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_file_mesh_out" );
5768 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_publish_mesh_out" );
5769 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_size_map" );
5770 QStringList aListOfSizeMap;
5771 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL" );
5772 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND" );
5773 aListOfSizeMap << tr( "ADAPT_PREF_NONE" );;
5774 setPreferenceProperty( pref, "strings", aListOfSizeMap );
5775 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_time_step" );
5776 QStringList aListOfTimeStep;
5777 aListOfTimeStep << tr( "ADAPT_PREF_NONE" );
5778 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST" );
5779 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_C" );;
5780 setPreferenceProperty( pref, "strings", aListOfTimeStep );
5785 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5787 if ( sect=="SMESH" ) {
5788 double sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5789 double aTol = 1.00000009999999;
5790 std::string aWarning;
5791 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5793 if ( name == "selection_object_color" ||
5794 name == "selection_element_color" ||
5795 name == "highlight_color" ||
5796 name == "selection_precision_node" ||
5797 name == "selection_precision_element" ||
5798 name == "selection_precision_object" ||
5799 name == "selection_increment")
5801 SMESH::UpdateSelectionProp( this );
5803 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5805 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5806 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5807 if ( sbX1+sbW > aTol ) {
5808 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5811 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5812 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5815 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5817 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5818 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5819 if ( sbY1 + sbH > aTol ) {
5820 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5821 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5822 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5825 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5827 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5828 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5829 if ( sbX1 + sbW > aTol ) {
5830 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5833 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5834 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5837 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5839 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5840 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5841 if ( sbY1 + sbH > aTol ) {
5842 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5845 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5846 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5849 else if ( name == "segmentation" )
5851 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5852 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5854 else if ( name == "nb_segments_per_edge" )
5856 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5857 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5859 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5861 QString val = aResourceMgr->stringValue( "SMESH", name );
5862 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5864 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5866 SMESH::UpdateFontProp( this );
5868 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5870 SMESH::UpdateFontProp( this );
5873 if ( aWarning.size() != 0 ) {
5874 aWarning += "The default values are applied instead.";
5875 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5876 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5877 QObject::tr(aWarning.c_str()));
5882 //================================================================================
5884 * \brief Update something in accordance with update flags
5885 * \param theFlags - update flags
5887 * Update viewer or/and object browser etc. in accordance with update flags ( see
5888 * LightApp_UpdateFlags enumeration ).
5890 //================================================================================
5891 void SMESHGUI::update( const int flags )
5893 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5894 SMESH::UpdateView();
5896 SalomeApp_Module::update( flags );
5899 //================================================================================
5901 * \brief Set default selection mode
5903 * SLOT called when operation committed. Sets default selection mode
5905 //================================================================================
5906 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5908 SVTK_ViewWindow* vtkWnd =
5909 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5911 vtkWnd->SetSelectionMode( ActorSelection );
5914 //================================================================================
5916 * \brief Set default selection mode
5918 * SLOT called when operation aborted. Sets default selection mode
5920 //================================================================================
5921 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5923 SVTK_ViewWindow* vtkWnd =
5924 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5926 vtkWnd->SetSelectionMode( ActorSelection );
5929 //================================================================================
5931 * \brief Creates operation with given identifier
5932 * \param id - identifier of operation to be started
5933 * \return Pointer on created operation or NULL if operation is not created
5935 * Virtual method redefined from the base class creates operation with given id.
5936 * It is called called automatically from startOperation method of base class.
5938 //================================================================================
5939 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5941 LightApp_Operation* op = 0;
5942 // to do : create operation here
5945 case SMESHOp::OpSplitBiQuadratic:
5946 op = new SMESHGUI_SplitBiQuadOp();
5948 case SMESHOp::OpConvertMeshToQuadratic:
5949 op = new SMESHGUI_ConvToQuadOp();
5951 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
5952 op = new SMESHGUI_Make2DFrom3DOp();
5954 case SMESHOp::OpReorientFaces:
5955 op = new SMESHGUI_ReorientFacesOp();
5957 case SMESHOp::OpCreateMesh:
5958 op = new SMESHGUI_MeshOp( true, true );
5960 case SMESHOp::OpCreateSubMesh:
5961 op = new SMESHGUI_MeshOp( true, false );
5963 case SMESHOp::OpEditMeshOrSubMesh:
5964 case SMESHOp::OpEditMesh:
5965 case SMESHOp::OpEditSubMesh:
5966 op = new SMESHGUI_MeshOp( false );
5968 case SMESHOp::OpCompute:
5969 case SMESHOp::OpComputeSubMesh:
5970 op = new SMESHGUI_ComputeOp();
5972 case SMESHOp::OpShowErrors:
5973 op = new SMESHGUI_ShowErrorsOp();
5975 case SMESHOp::OpPreCompute:
5976 op = new SMESHGUI_PrecomputeOp();
5978 case SMESHOp::OpEvaluate:
5979 op = new SMESHGUI_EvaluateOp();
5981 case SMESHOp::OpMeshOrder:
5982 op = new SMESHGUI_MeshOrderOp();
5984 case SMESHOp::OpCreateGeometryGroup:
5985 op = new SMESHGUI_GroupOnShapeOp();
5987 case SMESHOp::OpFindElementByPoint:
5988 op = new SMESHGUI_FindElemByPointOp();
5990 case SMESHOp::OpMoveNode: // Make mesh pass through point
5991 op = new SMESHGUI_MakeNodeAtPointOp();
5993 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
5994 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
6001 op = SalomeApp_Module::createOperation( id );
6005 //================================================================================
6007 * \brief Stops current operations and starts a given one
6008 * \param id - The id of the operation to start
6010 //================================================================================
6012 void SMESHGUI::switchToOperation(int id)
6014 activeStudy()->abortAllOperations();
6015 startOperation( id );
6018 LightApp_Displayer* SMESHGUI::displayer()
6021 myDisplayer = new SMESHGUI_Displayer( getApp() );
6025 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
6028 int aTolerance = 64;
6029 int anIterations = 0;
6035 if( anIterations % aPeriod == 0 )
6038 if( aTolerance < 1 )
6042 aHue = (int)( 360.0 * rand() / RAND_MAX );
6045 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
6046 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
6047 for( ; it != itEnd; ++it )
6049 SALOMEDS::Color anAutoColor = *it;
6050 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
6053 aQColor.getHsv( &h, &s, &v );
6054 if( abs( h - aHue ) < aTolerance )
6066 aColor.setHsv( aHue, 255, 255 );
6068 SALOMEDS::Color aSColor;
6069 aSColor.R = aColor.redF();
6070 aSColor.G = aColor.greenF();
6071 aSColor.B = aColor.blueF();
6076 const char* gSeparator = "_"; // character used to separate parameter names
6077 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
6078 const char* gPathSep = "|"; // character used to separate paths
6081 * \brief Store visual parameters
6083 * This method is called just before the study document is saved.
6084 * Store visual parameters in AttributeParameter attribute(s)
6086 void SMESHGUI::storeVisualParameters (int savePoint)
6089 Kernel_Utils::Localizer loc;
6091 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6092 if (!appStudy || !appStudy->studyDS())
6094 _PTR(Study) studyDS = appStudy->studyDS();
6096 // componentName is used for encoding of entries when storing them in IParameters
6097 std::string componentName = myComponentSMESH->ComponentDataType();
6098 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
6099 //if (!aSComponent) return;
6102 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6103 componentName.c_str(),
6105 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6107 // store custom markers
6108 if( !myMarkerMap.empty() )
6110 VTK::MarkerMap::const_iterator anIter = myMarkerMap.begin();
6111 for( ; anIter != myMarkerMap.end(); anIter++ )
6113 int anId = anIter->first;
6114 VTK::MarkerData aMarkerData = anIter->second;
6115 std::string aMarkerFileName = aMarkerData.first;
6116 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
6117 if( aMarkerTexture.size() < 3 )
6118 continue; // should contain at least width, height and the first value
6120 QString aPropertyName( "texture" );
6121 aPropertyName += gSeparator;
6122 aPropertyName += QString::number( anId );
6124 QString aPropertyValue = aMarkerFileName.c_str();
6125 aPropertyValue += gPathSep;
6127 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
6128 ushort aWidth = *aTextureIter++;
6129 ushort aHeight = *aTextureIter++;
6130 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
6131 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
6132 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
6133 aPropertyValue += QString::number( *aTextureIter );
6135 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6139 // viewers counters are used for storing view_numbers in IParameters
6142 // main cycle to store parameters of displayed objects
6143 QList<SUIT_ViewManager*> lst;
6144 QList<SUIT_ViewManager*>::Iterator it;
6145 getApp()->viewManagers(lst);
6146 for (it = lst.begin(); it != lst.end(); it++)
6148 SUIT_ViewManager* vman = *it;
6149 QString vType = vman->getType();
6151 // saving VTK actors properties
6152 if (vType == SVTK_Viewer::Type())
6154 // store the clipping planes attached to the view manager
6155 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
6156 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
6157 if( anIter != myClippingPlaneInfoMap.end() )
6158 aClippingPlaneInfoList = anIter->second;
6160 if( !aClippingPlaneInfoList.empty() ) {
6161 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
6162 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
6164 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
6165 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
6167 QString aPropertyName( "ClippingPlane" );
6168 aPropertyName += gSeparator;
6169 aPropertyName += QString::number( vtkViewers );
6170 aPropertyName += gSeparator;
6171 aPropertyName += QString::number( anId );
6173 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
6174 aPropertyValue += gDigitsSep;
6175 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
6176 aPropertyValue += gDigitsSep;
6177 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6178 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
6179 aPropertyValue += gDigitsSep;
6180 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
6181 aPropertyValue += gDigitsSep;
6182 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
6183 aPropertyValue += gDigitsSep;
6184 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
6185 aPropertyValue += gDigitsSep;
6186 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
6187 aPropertyValue += gDigitsSep;
6188 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
6189 aPropertyValue += gDigitsSep;
6190 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
6192 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6193 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
6194 aPropertyValue += gDigitsSep;
6195 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
6196 aPropertyValue += gDigitsSep;
6197 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
6198 aPropertyValue += gDigitsSep;
6199 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
6202 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6206 QVector<SUIT_ViewWindow*> views = vman->getViews();
6207 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
6209 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
6211 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
6212 vtkActorCollection* allActors = aCopy.GetActors();
6213 allActors->InitTraversal();
6214 while (vtkActor* actor = allActors->GetNextActor())
6216 if (actor->GetVisibility()) // store only visible actors
6218 SMESH_Actor* aSmeshActor = 0;
6219 if (actor->IsA("SMESH_Actor"))
6220 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
6221 if (aSmeshActor && aSmeshActor->hasIO())
6223 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
6226 // entry is "encoded" = it does NOT contain component address,
6227 // since it is a subject to change on next component loading
6228 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
6230 std::string param, vtkParam = vType.toLatin1().data();
6231 vtkParam += gSeparator;
6232 vtkParam += QString::number(vtkViewers).toLatin1().data();
6233 vtkParam += gSeparator;
6236 param = vtkParam + "Visibility";
6237 ip->setParameter(entry, param, "On");
6240 param = vtkParam + "Representation";
6241 ip->setParameter(entry, param, QString::number
6242 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
6245 param = vtkParam + "IsShrunk";
6246 ip->setParameter(entry, param, QString::number
6247 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
6249 // Displayed entities
6250 unsigned int aMode = aSmeshActor->GetEntityMode();
6251 bool isE = aMode & SMESH_Actor::eEdges;
6252 bool isF = aMode & SMESH_Actor::eFaces;
6253 bool isV = aMode & SMESH_Actor::eVolumes;
6254 bool is0d = aMode & SMESH_Actor::e0DElements;
6255 bool isB = aMode & SMESH_Actor::eBallElem;
6257 QString modeStr ("e");
6258 modeStr += gDigitsSep; modeStr += QString::number(isE);
6259 modeStr += gDigitsSep; modeStr += "f";
6260 modeStr += gDigitsSep; modeStr += QString::number(isF);
6261 modeStr += gDigitsSep; modeStr += "v";
6262 modeStr += gDigitsSep; modeStr += QString::number(isV);
6263 modeStr += gDigitsSep; modeStr += "0d";
6264 modeStr += gDigitsSep; modeStr += QString::number(is0d);
6265 modeStr += gDigitsSep; modeStr += "b";
6266 modeStr += gDigitsSep; modeStr += QString::number(isB);
6268 param = vtkParam + "Entities";
6269 ip->setParameter(entry, param, modeStr.toLatin1().data());
6275 aSmeshActor->GetSufaceColor(r, g, b, delta);
6276 QStringList colorStr;
6277 colorStr << "surface";
6278 colorStr << QString::number(r);
6279 colorStr << QString::number(g);
6280 colorStr << QString::number(b);
6282 colorStr << "backsurface";
6283 colorStr << QString::number(delta);
6285 aSmeshActor->GetVolumeColor(r, g, b, delta);
6286 colorStr << "volume";
6287 colorStr << QString::number(r);
6288 colorStr << QString::number(g);
6289 colorStr << QString::number(b);
6290 colorStr << QString::number(delta);
6292 aSmeshActor->GetEdgeColor(r, g, b);
6294 colorStr << QString::number(r);
6295 colorStr << QString::number(g);
6296 colorStr << QString::number(b);
6298 aSmeshActor->GetNodeColor(r, g, b);
6300 colorStr << QString::number(r);
6301 colorStr << QString::number(g);
6302 colorStr << QString::number(b);
6304 aSmeshActor->GetOutlineColor(r, g, b);
6305 colorStr << "outline";
6306 colorStr << QString::number(r);
6307 colorStr << QString::number(g);
6308 colorStr << QString::number(b);
6310 aSmeshActor->Get0DColor(r, g, b);
6311 colorStr << "elem0d";
6312 colorStr << QString::number(r);
6313 colorStr << QString::number(g);
6314 colorStr << QString::number(b);
6316 aSmeshActor->GetBallColor(r, g, b);
6318 colorStr << QString::number(r);
6319 colorStr << QString::number(g);
6320 colorStr << QString::number(b);
6322 aSmeshActor->GetFacesOrientationColor(r, g, b);
6323 colorStr << "orientation";
6324 colorStr << QString::number(r);
6325 colorStr << QString::number(g);
6326 colorStr << QString::number(b);
6328 param = vtkParam + "Colors";
6329 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
6332 QStringList sizeStr;
6334 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
6335 sizeStr << "outline";
6336 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
6337 sizeStr << "elem0d";
6338 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
6340 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
6341 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
6342 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
6343 sizeStr << "shrink";
6344 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
6345 sizeStr << "orientation";
6346 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
6347 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
6349 param = vtkParam + "Sizes";
6350 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
6355 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
6356 if( aMarkerType == VTK::MT_USER ) {
6357 markerStr += "custom";
6358 markerStr += gDigitsSep;
6359 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
6363 markerStr += gDigitsSep;
6364 markerStr += QString::number( (int)aMarkerType );
6365 markerStr += gDigitsSep;
6366 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
6369 param = vtkParam + "PointMarker";
6370 ip->setParameter(entry, param, markerStr.toLatin1().data());
6373 param = vtkParam + "Opacity";
6374 ip->setParameter(entry, param,
6375 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
6378 param = vtkParam + "ClippingPlane";
6380 if( !aClippingPlaneInfoList.empty() ) {
6381 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
6382 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
6384 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
6385 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
6386 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6387 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6388 if( aSmeshActor == *anIter2 ) {
6389 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6390 QString::number( anId ).toLatin1().constData() );
6397 ip->setParameter( entry, param, "Off" );
6398 } // if (io->hasEntry())
6399 } // SMESH_Actor && hasIO
6401 } // while.. actors traversal
6405 } // if (SVTK view model)
6406 } // for (viewManagers)
6409 // data structures for clipping planes processing
6413 bool isOpenGLClipping;
6414 vtkIdType RelativeOrientation;
6417 int AbsoluteOrientation;
6418 double X, Y, Z, Dx, Dy, Dz;
6420 typedef std::list<TPlaneData> TPlaneDataList;
6421 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6423 typedef std::list<vtkActor*> TActorList;
6426 TActorList ActorList;
6427 SUIT_ViewManager* ViewManager;
6429 typedef std::list<TPlaneInfo> TPlaneInfoList;
6430 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6433 * \brief Restore visual parameters
6435 * This method is called after the study document is opened.
6436 * Restore visual parameters from AttributeParameter attribute(s)
6438 void SMESHGUI::restoreVisualParameters (int savePoint)
6441 Kernel_Utils::Localizer loc;
6443 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6444 if (!appStudy || !appStudy->studyDS())
6446 _PTR(Study) studyDS = appStudy->studyDS();
6448 // componentName is used for encoding of entries when storing them in IParameters
6449 std::string componentName = myComponentSMESH->ComponentDataType();
6452 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6453 componentName.c_str(),
6455 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6457 // restore custom markers and map of clipping planes
6458 TPlaneDataMap aPlaneDataMap;
6460 std::vector<std::string> properties = ip->getProperties();
6461 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6463 std::string property = *propIt;
6464 QString aPropertyName( property.c_str() );
6465 QString aPropertyValue( ip->getProperty( property ).c_str() );
6467 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6468 if( aPropertyNameList.isEmpty() )
6471 QString aPropertyType = aPropertyNameList[0];
6472 if( aPropertyType == "texture" )
6474 if( aPropertyNameList.size() != 2 )
6478 int anId = aPropertyNameList[1].toInt( &ok );
6479 if( !ok || anId < 1 )
6482 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6483 if( aPropertyValueList.size() != 2 )
6486 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6487 QString aMarkerTextureString = aPropertyValueList[1];
6488 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6489 if( aMarkerTextureStringList.size() != 3 )
6493 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6498 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6502 VTK::MarkerTexture aMarkerTexture;
6503 aMarkerTexture.push_back( aWidth );
6504 aMarkerTexture.push_back( aHeight );
6506 QString aMarkerTextureData = aMarkerTextureStringList[2];
6507 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6509 QChar aChar = aMarkerTextureData.at( i );
6510 if( aChar.isDigit() )
6511 aMarkerTexture.push_back( aChar.digitValue() );
6514 myMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6516 else if( aPropertyType == "ClippingPlane" )
6518 if( aPropertyNameList.size() != 3 )
6522 int aViewId = aPropertyNameList[1].toInt( &ok );
6523 if( !ok || aViewId < 0 )
6527 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6528 if( !ok || aClippingPlaneId < 0 )
6531 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6532 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6535 TPlaneData aPlaneData;
6536 aPlaneData.AbsoluteOrientation = false;
6537 aPlaneData.RelativeOrientation = 0;
6538 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6539 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6540 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6542 aPlaneData.Id = aClippingPlaneId;
6545 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6550 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6554 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6557 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6562 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6567 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6572 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6577 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6582 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6587 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6591 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6593 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6598 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6603 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6608 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6613 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6614 aPlaneDataList.push_back( aPlaneData );
6618 TPlaneInfoMap aPlaneInfoMap;
6620 std::vector<std::string> entries = ip->getEntries();
6622 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6624 // entry is a normal entry - it should be "decoded" (setting base address of component)
6625 QString entry (ip->decodeEntry(*entIt).c_str());
6627 // Check that the entry corresponds to a real object in the Study
6628 // as the object may be deleted or modified after the visual state is saved.
6629 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
6630 if (!so) continue; //Skip the not existent entry
6632 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6633 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6635 std::vector<std::string>::iterator namesIt = paramNames.begin();
6636 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6638 // actors are stored in a map after displaying of them for
6639 // quicker access in the future: map < viewID to actor >
6640 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6642 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6644 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6645 // '_' is used as separator and should not be used in viewer type or parameter names.
6646 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6647 if (lst.size() != 3)
6650 QString viewerTypStr = lst[0];
6651 QString viewIndexStr = lst[1];
6652 QString paramNameStr = lst[2];
6655 int viewIndex = viewIndexStr.toUInt(&ok);
6656 if (!ok) // bad conversion of view index to integer
6660 if (viewerTypStr == SVTK_Viewer::Type())
6662 SMESH_Actor* aSmeshActor = 0;
6663 if (vtkActors.IsBound(viewIndex))
6664 aSmeshActor = vtkActors.Find(viewIndex);
6666 QList<SUIT_ViewManager*> lst;
6667 getApp()->viewManagers(viewerTypStr, lst);
6669 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6670 SUIT_ViewManager* vman = NULL;
6671 if (viewIndex >= 0 && viewIndex < lst.count())
6672 vman = lst.at(viewIndex);
6674 if (paramNameStr == "Visibility")
6676 if (!aSmeshActor && displayer() && vman)
6678 SUIT_ViewModel* vmodel = vman->getViewModel();
6679 // SVTK view model can be casted to SALOME_View
6680 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6682 // store displayed actor in a temporary map for quicker
6683 // access later when restoring other parameters
6684 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6685 vtkRenderer* Renderer = vtkView->getRenderer();
6686 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6687 vtkActorCollection* theActors = aCopy.GetActors();
6688 theActors->InitTraversal();
6689 bool isFound = false;
6690 vtkActor *ac = theActors->GetNextActor();
6691 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6692 if (ac->IsA("SMESH_Actor")) {
6693 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6694 if (aGeomAc->hasIO()) {
6695 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6696 if (io->hasEntry() && strcmp(io->getEntry(), entry.toUtf8().data()) == 0) {
6698 vtkActors.Bind(viewIndex, aGeomAc);
6704 } // if (paramNameStr == "Visibility")
6707 // the rest properties "work" with SMESH_Actor
6710 QString val ((*valuesIt).c_str());
6713 if (paramNameStr == "Representation") {
6714 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6717 else if (paramNameStr == "IsShrunk") {
6719 if (!aSmeshActor->IsShrunk())
6720 aSmeshActor->SetShrink();
6723 if (aSmeshActor->IsShrunk())
6724 aSmeshActor->UnShrink();
6727 // Displayed entities
6728 else if (paramNameStr == "Entities") {
6729 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6730 int aEntityMode = SMESH_Actor::eAllEntity;
6731 for ( int i = 0; i < mode.count(); i+=2 ) {
6732 if ( i < mode.count()-1 ) {
6733 QString type = mode[i];
6734 bool val = mode[i+1].toInt();
6735 if ( type == "e" && !val )
6736 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6737 else if ( type == "f" && !val )
6738 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6739 else if ( type == "v" && !val )
6740 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6741 else if ( type == "0d" && !val )
6742 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6743 else if ( type == "b" && !val )
6744 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6747 aSmeshActor->SetEntityMode( aEntityMode );
6750 else if (paramNameStr == "Colors") {
6751 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6758 QColor outlineColor;
6759 QColor orientationColor;
6765 // below lines are required to get default values for delta coefficients
6766 // of backface color for faces and color of reversed volumes
6767 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6768 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6769 for ( int i = 0; i < colors.count(); i++ ) {
6770 QString type = colors[i];
6771 if ( type == "surface" ) {
6772 // face color is set by 3 values r:g:b, where
6773 // - r,g,b - is rgb color components
6774 if ( i+1 >= colors.count() ) break; // format error
6775 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6776 if ( i+2 >= colors.count() ) break; // format error
6777 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6778 if ( i+3 >= colors.count() ) break; // format error
6779 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6780 faceColor.setRgbF( r, g, b );
6783 else if ( type == "backsurface" ) {
6784 // backface color can be defined in several ways
6785 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6786 // - in latest versions, it is set as delta coefficient
6787 bool rgbOk = false, deltaOk;
6788 if ( i+1 >= colors.count() ) break; // format error
6789 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6790 int delta = colors[i+1].toInt( &deltaOk );
6792 if ( i+1 < colors.count() ) // index is shifted to 1
6793 g = colors[i+1].toDouble( &rgbOk );
6794 if ( rgbOk ) i++; // shift index
6795 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6796 b = colors[i+1].toDouble( &rgbOk );
6798 // - as currently there's no way to set directly backsurface color as it was before,
6799 // we ignore old dump where r,g,b triple was set
6800 // - also we check that delta parameter is set properly
6801 if ( !rgbOk && deltaOk )
6804 else if ( type == "volume" ) {
6805 // volume color is set by 4 values r:g:b:delta, where
6806 // - r,g,b - is a normal volume rgb color components
6807 // - delta - is a reversed volume color delta coefficient
6808 if ( i+1 >= colors.count() ) break; // format error
6809 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6810 if ( i+2 >= colors.count() ) break; // format error
6811 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6812 if ( i+3 >= colors.count() ) break; // format error
6813 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6814 if ( i+4 >= colors.count() ) break; // format error
6815 int delta = colors[i+4].toInt( &bOk );
6816 if ( !bOk ) break; // format error
6817 volumeColor.setRgbF( r, g, b );
6821 else if ( type == "edge" ) {
6822 // edge color is set by 3 values r:g:b, where
6823 // - r,g,b - is rgb color components
6824 if ( i+1 >= colors.count() ) break; // format error
6825 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6826 if ( i+2 >= colors.count() ) break; // format error
6827 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6828 if ( i+3 >= colors.count() ) break; // format error
6829 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6830 edgeColor.setRgbF( r, g, b );
6833 else if ( type == "node" ) {
6834 // node color is set by 3 values r:g:b, where
6835 // - r,g,b - is rgb color components
6836 if ( i+1 >= colors.count() ) break; // format error
6837 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6838 if ( i+2 >= colors.count() ) break; // format error
6839 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6840 if ( i+3 >= colors.count() ) break; // format error
6841 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6842 nodeColor.setRgbF( r, g, b );
6845 else if ( type == "elem0d" ) {
6846 // 0d element color is set by 3 values r:g:b, where
6847 // - r,g,b - is rgb color components
6848 if ( i+1 >= colors.count() ) break; // format error
6849 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6850 if ( i+2 >= colors.count() ) break; // format error
6851 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6852 if ( i+3 >= colors.count() ) break; // format error
6853 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6854 elem0dColor.setRgbF( r, g, b );
6857 else if ( type == "ball" ) {
6858 // ball 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 ballColor.setRgbF( r, g, b );
6869 else if ( type == "outline" ) {
6870 // outline color is set by 3 values r:g:b, where
6871 // - r,g,b - is rgb color components
6872 if ( i+1 >= colors.count() ) break; // format error
6873 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6874 if ( i+2 >= colors.count() ) break; // format error
6875 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6876 if ( i+3 >= colors.count() ) break; // format error
6877 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6878 outlineColor.setRgbF( r, g, b );
6881 else if ( type == "orientation" ) {
6882 // orientation color is set by 3 values r:g:b, where
6883 // - r,g,b - is rgb color components
6884 if ( i+1 >= colors.count() ) break; // format error
6885 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6886 if ( i+2 >= colors.count() ) break; // format error
6887 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6888 if ( i+3 >= colors.count() ) break; // format error
6889 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6890 orientationColor.setRgbF( r, g, b );
6895 if ( nodeColor.isValid() )
6896 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6898 if ( edgeColor.isValid() )
6899 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6901 if ( faceColor.isValid() )
6902 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6904 if ( volumeColor.isValid() )
6905 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6906 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6907 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6909 if ( elem0dColor.isValid() )
6910 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6912 if ( ballColor.isValid() )
6913 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6915 if ( outlineColor.isValid() )
6916 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6917 // orientation color
6918 if ( orientationColor.isValid() )
6919 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6922 else if (paramNameStr == "Sizes") {
6923 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6926 int outlineWidth = -1;
6927 int elem0dSize = -1;
6928 //int ballSize = -1;
6929 double ballDiameter = -1.0;
6930 double ballScale = -1.0;
6931 double shrinkSize = -1;
6932 double orientationSize = -1;
6933 bool orientation3d = false;
6934 for ( int i = 0; i < sizes.count(); i++ ) {
6935 QString type = sizes[i];
6936 if ( type == "line" ) {
6937 // line (wireframe) width is given as single integer value
6938 if ( i+1 >= sizes.count() ) break; // format error
6939 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6943 if ( type == "outline" ) {
6944 // outline width is given as single integer value
6945 if ( i+1 >= sizes.count() ) break; // format error
6946 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6950 else if ( type == "elem0d" ) {
6951 // 0d element size is given as single integer value
6952 if ( i+1 >= sizes.count() ) break; // format error
6953 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6957 else if ( type == "ball" ) {
6958 // balls are specified by two values: size:scale, where
6959 // - size - is a integer value specifying size
6960 // - scale - is a double value specifying scale factor
6961 if ( i+1 >= sizes.count() ) break; // format error
6962 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6963 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6964 if ( i+2 >= sizes.count() ) break; // format error
6965 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6971 else if ( type == "shrink" ) {
6972 // shrink factor is given as single floating point value
6973 if ( i+1 >= sizes.count() ) break; // format error
6974 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6978 else if ( type == "orientation" ) {
6979 // orientation vectors are specified by two values size:3d, where
6980 // - size - is a floating point value specifying scale factor
6981 // - 3d - is a boolean
6982 if ( i+1 >= sizes.count() ) break; // format error
6983 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6984 if ( i+2 >= sizes.count() ) break; // format error
6985 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6986 orientationSize = v1;
6987 orientation3d = (bool)v2;
6991 // line (wireframe) width
6992 if ( lineWidth > 0 )
6993 aSmeshActor->SetLineWidth( lineWidth );
6995 if ( outlineWidth > 0 )
6996 aSmeshActor->SetOutlineWidth( outlineWidth );
6997 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6998 aSmeshActor->SetOutlineWidth( lineWidth );
7000 if ( elem0dSize > 0 )
7001 aSmeshActor->Set0DSize( elem0dSize );
7003 /*if ( ballSize > 0 )
7004 aSmeshActor->SetBallSize( ballSize );*/
7006 if ( ballDiameter > 0 )
7007 aSmeshActor->SetBallSize( ballDiameter );
7009 if ( ballScale > 0.0 )
7010 aSmeshActor->SetBallScale( ballScale );
7012 if ( shrinkSize > 0 )
7013 aSmeshActor->SetShrinkFactor( shrinkSize );
7014 // orientation vectors
7015 if ( orientationSize > 0 ) {
7016 aSmeshActor->SetFacesOrientationScale( orientationSize );
7017 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
7021 else if (paramNameStr == "PointMarker") {
7022 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
7023 if( data.count() >= 2 ) {
7025 int aParam1 = data[1].toInt( &ok );
7027 if( data[0] == "std" && data.count() == 3 ) {
7028 int aParam2 = data[2].toInt( &ok );
7029 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
7031 else if( data[0] == "custom" ) {
7032 VTK::MarkerMap::const_iterator markerIt = myMarkerMap.find( aParam1 );
7033 if( markerIt != myMarkerMap.end() ) {
7034 VTK::MarkerData aMarkerData = markerIt->second;
7035 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
7042 else if (paramNameStr == "Opacity") {
7043 aSmeshActor->SetOpacity(val.toFloat());
7046 else if (paramNameStr.startsWith("ClippingPlane")) {
7047 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
7048 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
7049 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
7050 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
7051 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
7052 // new format - val looks like "Off" or "0" (plane id)
7053 // (note: in new format "Off" value is used only for consistency,
7054 // so it is processed together with values in old format)
7055 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
7056 if( anIsOldFormat ) {
7057 if (paramNameStr == "ClippingPlane1" || val == "Off")
7058 aSmeshActor->RemoveAllClippingPlanes();
7060 QList<SUIT_ViewManager*> lst;
7061 getApp()->viewManagers(viewerTypStr, lst);
7062 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
7063 if (viewIndex >= 0 && viewIndex < lst.count()) {
7064 SUIT_ViewManager* vman = lst.at(viewIndex);
7065 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
7067 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
7069 SMESH::TActorList anActorList;
7070 anActorList.push_back( aSmeshActor );
7071 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
7072 aPlane->myViewWindow = vtkView;
7073 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
7074 aPlane->PlaneMode = aMode;
7075 bool isOpenGLClipping = ( bool )vals[1].toInt();
7076 aPlane->IsOpenGLClipping = isOpenGLClipping;
7077 if ( aMode == SMESH::Absolute ) {
7078 aPlane->myAbsoluteOrientation = vals[2].toInt();
7079 aPlane->X = vals[3].toFloat();
7080 aPlane->Y = vals[4].toFloat();
7081 aPlane->Z = vals[5].toFloat();
7082 aPlane->Dx = vals[6].toFloat();
7083 aPlane->Dy = vals[7].toFloat();
7084 aPlane->Dz = vals[8].toFloat();
7086 else if ( aMode == SMESH::Relative ) {
7087 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
7088 aPlane->myDistance = vals[3].toFloat();
7089 aPlane->myAngle[0] = vals[4].toFloat();
7090 aPlane->myAngle[1] = vals[5].toFloat();
7094 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7095 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7096 aClippingPlaneInfo.Plane = aPlane;
7097 aClippingPlaneInfo.ActorList = anActorList;
7098 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7106 int aPlaneId = val.toInt( &ok );
7107 if( ok && aPlaneId >= 0 ) {
7108 bool anIsDefinedPlane = false;
7109 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
7110 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
7111 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7112 TPlaneInfo& aPlaneInfo = *anIter;
7113 if( aPlaneInfo.PlaneId == aPlaneId ) {
7114 aPlaneInfo.ActorList.push_back( aSmeshActor );
7115 anIsDefinedPlane = true;
7119 if( !anIsDefinedPlane ) {
7120 TPlaneInfo aPlaneInfo;
7121 aPlaneInfo.PlaneId = aPlaneId;
7122 aPlaneInfo.ActorList.push_back( aSmeshActor );
7123 aPlaneInfo.ViewManager = vman;
7125 // to make the list sorted by plane id
7126 anIter = aPlaneInfoList.begin();
7127 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7128 const TPlaneInfo& aPlaneInfoRef = *anIter;
7129 if( aPlaneInfoRef.PlaneId > aPlaneId )
7132 aPlaneInfoList.insert( anIter, aPlaneInfo );
7137 } // if (aSmeshActor)
7138 } // other parameters than Visibility
7140 } // for names/parameters iterator
7141 } // for entries iterator
7143 // take into account planes with empty list of actors referred to them
7144 QList<SUIT_ViewManager*> aVMList;
7145 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
7147 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
7148 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
7149 int aViewId = aPlaneDataIter->first;
7150 if( aViewId >= 0 && aViewId < aVMList.count() ) {
7151 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
7153 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
7155 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
7156 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
7157 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
7158 const TPlaneData& aPlaneData = *anIter2;
7159 int aPlaneId = aPlaneData.Id;
7161 bool anIsFound = false;
7162 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7163 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7164 const TPlaneInfo& aPlaneInfo = *anIter3;
7165 if( aPlaneInfo.PlaneId == aPlaneId ) {
7172 TPlaneInfo aPlaneInfo; // ActorList field is empty
7173 aPlaneInfo.PlaneId = aPlaneId;
7174 aPlaneInfo.ViewManager = aViewManager;
7176 // to make the list sorted by plane id
7177 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
7178 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
7179 const TPlaneInfo& aPlaneInfoRef = *anIter4;
7180 if( aPlaneInfoRef.PlaneId > aPlaneId )
7183 aPlaneInfoList.insert( anIter4, aPlaneInfo );
7189 // add clipping planes to actors according to the restored parameters
7190 // and update the clipping plane map
7191 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
7192 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
7193 int aViewId = anIter1->first;
7194 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
7196 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
7197 if( anIter2 == aPlaneDataMap.end() )
7199 const TPlaneDataList& aPlaneDataList = anIter2->second;
7201 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7202 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7203 const TPlaneInfo& aPlaneInfo = *anIter3;
7204 int aPlaneId = aPlaneInfo.PlaneId;
7205 const TActorList& anActorList = aPlaneInfo.ActorList;
7206 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
7210 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
7214 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
7216 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
7217 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
7218 const TPlaneData& aPlaneData = *anIter4;
7219 if( aPlaneData.Id == aPlaneId ) {
7220 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
7221 aPlane->myViewWindow = aViewWindow;
7222 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
7223 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
7224 if ( aPlane->PlaneMode == SMESH::Absolute ) {
7225 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
7226 aPlane->X = aPlaneData.X;
7227 aPlane->Y = aPlaneData.Y;
7228 aPlane->Z = aPlaneData.Z;
7229 aPlane->Dx = aPlaneData.Dx;
7230 aPlane->Dy = aPlaneData.Dy;
7231 aPlane->Dz = aPlaneData.Dz;
7233 else if ( aPlane->PlaneMode == SMESH::Relative ) {
7234 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
7235 aPlane->myDistance = aPlaneData.Distance;
7236 aPlane->myAngle[0] = aPlaneData.Angle[0];
7237 aPlane->myAngle[1] = aPlaneData.Angle[1];
7240 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7241 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7242 aClippingPlaneInfo.Plane = aPlane;
7243 aClippingPlaneInfo.ActorList = anActorList;
7244 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7255 // update all VTK views
7256 QList<SUIT_ViewManager*> lst;
7257 getApp()->viewManagers(lst);
7258 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
7259 SUIT_ViewModel* vmodel = (*it)->getViewModel();
7260 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
7261 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
7262 // set OpenGL clipping planes
7263 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
7264 vtkActorCollection* anAllActors = aCopy.GetActors();
7265 anAllActors->InitTraversal();
7266 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
7267 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
7268 anActor->SetOpenGLClippingPlane();
7270 vtkView->getRenderer()->ResetCameraClippingRange();
7277 \brief Adds preferences for dfont of VTK viewer
7279 \param pIf group identifier
7280 \param param parameter
7281 \return identifier of preferences
7283 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
7285 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
7287 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
7290 fam.append( tr( "SMESH_FONT_ARIAL" ) );
7291 fam.append( tr( "SMESH_FONT_COURIER" ) );
7292 fam.append( tr( "SMESH_FONT_TIMES" ) );
7294 setPreferenceProperty( tfont, "fonts", fam );
7296 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
7297 if ( needSize ) f = f | QtxFontEdit::Size;
7298 setPreferenceProperty( tfont, "features", f );
7304 \brief Actions after hypothesis edition
7305 Updates object browser after hypothesis edition
7307 void SMESHGUI::onHypothesisEdit( int result )
7310 SMESHGUI::Modified();
7311 updateObjBrowser( true );
7315 \brief Actions after choosing menu of control modes
7316 Updates control mode actions according to current selection
7318 void SMESHGUI::onUpdateControlActions()
7320 SALOME_ListIO selected;
7321 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
7322 aSel->selectedObjects( selected );
7324 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
7325 if ( selected.Extent() ) {
7326 if ( selected.First()->hasEntry() ) {
7327 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
7328 aControl = anActor->GetControlMode();
7329 SALOME_ListIteratorOfListIO it(selected);
7330 for ( it.Next(); it.More(); it.Next() ) {
7331 Handle(SALOME_InteractiveObject) anIO = it.Value();
7332 if ( anIO->hasEntry() ) {
7333 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
7334 if ( aControl != anActor->GetControlMode() ) {
7335 aControl = SMESH_Actor::eNone;
7345 int anAction = ActionToControl( aControl, true );
7347 action( anAction )->setChecked( true );
7349 QMenu* send = (QMenu*)sender();
7350 QList<QAction*> actions = send->actions();
7351 for ( int i = 0; i < actions.size(); i++ )
7352 actions[i]->setChecked( false );
7358 \brief Signal handler closing(SUIT_ViewWindow*) of a view
7359 \param pview view being closed
7361 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
7362 #ifndef DISABLE_PLOT2DVIEWER
7363 //Crear all Plot2d Viewers if need.
7364 SMESH::ClearPlot2Viewers(pview);
7366 EmitSignalCloseView();
7369 void SMESHGUI::message( const QString& msg )
7372 QStringList data = msg.split("/");
7373 if ( data.count() > 0 ) {
7374 if ( data.first() == "mesh_loading" ) {
7376 QString entry = data.count() > 1 ? data[1] : QString();
7377 if ( entry.isEmpty() )
7380 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
7382 _PTR(SObject) obj = study->FindObjectID( entry.toUtf8().constData() );
7385 name = SMESH::fromUtf8(obj->GetName());
7386 if ( name.isEmpty() )
7389 if ( data.last() == "stop" )
7390 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7392 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7393 QApplication::processEvents();
7399 \brief Connects or disconnects signals about activating and cloning view on the module slots
7400 \param pview view which is connected/disconnected
7402 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7406 SUIT_ViewManager* viewMgr = pview->getViewManager();
7408 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7409 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7411 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7412 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7417 \brief Return \c true if object can be renamed
7419 bool SMESHGUI::renameAllowed( const QString& entry) const {
7420 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7424 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7428 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7433 if(appStudy->isComponent(entry) || obj->isReference())
7436 // check type to prevent renaming of inappropriate objects
7437 int aType = SMESHGUI_Selection::type(qPrintable(entry));
7438 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7439 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7440 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7441 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7442 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7449 Rename object by entry.
7450 \param entry entry of the object
7451 \param name new name of the object
7452 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7454 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7456 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7460 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7465 _PTR(Study) aStudy = appStudy->studyDS();
7470 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7472 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7477 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7478 _PTR(GenericAttribute) anAttr;
7479 _PTR(AttributeName) aName;
7481 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7483 // check type to prevent renaming of inappropriate objects
7484 int aType = SMESHGUI_Selection::type( qPrintable(entry));
7485 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7486 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7487 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7488 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7489 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7490 if ( !name.isEmpty() ) {
7491 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qUtf8Printable(name) );
7493 // update name of group object and its actor
7494 Handle(SALOME_InteractiveObject) IObject =
7495 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7497 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7498 if( !aGroupObject->_is_nil() ) {
7499 aGroupObject->SetName( qUtf8Printable(name) );
7500 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7501 anActor->setName( qUtf8Printable(name) );
7511 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7513 static QList<QColor> colors;
7515 if ( colors.isEmpty() ) {
7517 for (int s = 0; s < 2 ; s++)
7519 for (int v = 100; v >= 40; v = v - 20)
7521 for (int h = 0; h < 359 ; h = h + 60)
7523 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7528 static int currentColor = randomize( colors.size() );
7530 SALOMEDS::Color color;
7531 color.R = (double)colors[currentColor].red() / 255.0;
7532 color.G = (double)colors[currentColor].green() / 255.0;
7533 color.B = (double)colors[currentColor].blue() / 255.0;
7535 currentColor = (currentColor+1) % colors.count();